You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
HMG_QLine/web/index.html

71 lines
1.9 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta content="IE=Edge" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>HMG QLine</title>
<script>
// Auto-detect device IP using WebRTC - polling version
window.deviceIPResult = null;
window.deviceIPDetecting = false;
window.startIPDetection = function() {
if (window.deviceIPDetecting) return;
window.deviceIPDetecting = true;
window.deviceIPResult = null;
try {
const rtc = new RTCPeerConnection({iceServers: []});
let resolved = false;
rtc.createDataChannel('');
rtc.createOffer().then(offer => rtc.setLocalDescription(offer));
rtc.onicecandidate = function(evt) {
if (resolved) return;
if (!evt || !evt.candidate) return;
const candidate = evt.candidate.candidate;
const ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3})/;
const match = ipRegex.exec(candidate);
if (match) {
const ip = match[1];
// Ignore loopback and link-local
if (!ip.startsWith('127.') && !ip.startsWith('169.254.')) {
resolved = true;
rtc.close();
window.deviceIPResult = ip;
window.deviceIPDetecting = false;
}
}
};
// Timeout after 3 seconds
setTimeout(() => {
if (!resolved) {
resolved = true;
rtc.close();
window.deviceIPResult = 'TIMEOUT';
window.deviceIPDetecting = false;
}
}, 3000);
} catch (e) {
console.error('IP detection error:', e);
window.deviceIPResult = 'ERROR';
window.deviceIPDetecting = false;
}
};
</script>
</head>
<body>
<script src="flutter_bootstrap.js" async></script>
</body>
</html>