Files
UAS-SIG-WebGIS-Poverty-Mapping/status.html
T
2026-06-13 13:38:52 +07:00

89 lines
3.6 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>WebGIS Status Check</title>
<style>
body { font-family: Arial; margin: 20px; }
.status { padding: 10px; margin: 10px 0; border-radius: 5px; }
.ok { background: #d4edda; color: #155724; }
.error { background: #f8d7da; color: #721c24; }
pre { background: #f5f5f5; padding: 10px; overflow: auto; }
</style>
</head>
<body>
<h1>WebGIS Status Check</h1>
<p>If you can see this page, your web server is working! ✓</p>
<div id="status"></div>
<script>
async function checkStatus() {
const status = document.getElementById('status');
// Test 1: Check if we're using HTTP
const isHTTP = window.location.protocol === 'http:' || window.location.protocol === 'https:';
const protocol = document.createElement('div');
protocol.className = 'status ' + (isHTTP ? 'ok' : 'error');
protocol.innerHTML = '<b>Protocol:</b> ' + (isHTTP ? '✓ HTTP/HTTPS' : '✗ Using file:// - Fetch will not work!');
status.appendChild(protocol);
// Test 2: Check database connection
try {
const response = await fetch('test_api.php');
const data = await response.json();
const dbStatus = document.createElement('div');
dbStatus.className = 'status ok';
dbStatus.innerHTML = '<b>Database:</b> ✓ Connected<br>' +
'<b>Table:</b> ' + data.table + '<br>' +
'<b>Columns:</b> ' + data.column_count + '<br>' +
'<pre>' + JSON.stringify(data.columns, null, 2) + '</pre>';
status.appendChild(dbStatus);
} catch (e) {
const dbStatus = document.createElement('div');
dbStatus.className = 'status error';
dbStatus.innerHTML = '<b>Database:</b> ✗ Connection failed<br>' + e.message;
status.appendChild(dbStatus);
}
// Test 3: Check save API
try {
const fd = new FormData();
fd.append('tipe', 'worship');
fd.append('lat', 'test');
fd.append('lng', 'test');
const response = await fetch('save_point.php', { method: 'POST', body: fd });
const data = await response.text();
const saveStatus = document.createElement('div');
saveStatus.className = 'status ok';
saveStatus.innerHTML = '<b>Save API:</b> ✓ Responding<br>' +
'<pre>' + data.substring(0, 200) + '</pre>';
status.appendChild(saveStatus);
} catch (e) {
const saveStatus = document.createElement('div');
saveStatus.className = 'status error';
saveStatus.innerHTML = '<b>Save API:</b> ✗ Error<br>' + e.message;
status.appendChild(saveStatus);
}
// Test 4: Check get API
try {
const response = await fetch('get_point.php');
const data = await response.json();
const getStatus = document.createElement('div');
getStatus.className = 'status ok';
getStatus.innerHTML = '<b>Get API:</b> ✓ Responding<br>' +
'<b>Records:</b> ' + data.length;
status.appendChild(getStatus);
} catch (e) {
const getStatus = document.createElement('div');
getStatus.className = 'status error';
getStatus.innerHTML = '<b>Get API:</b> ✗ Error<br>' + e.message;
status.appendChild(getStatus);
}
}
window.addEventListener('load', checkStatus);
</script>
</body>
</html>