]> www.average.org Git - loctrkd.git/blobdiff - webdemo/index.html
wsgateway: clear locations on wsocket open
[loctrkd.git] / webdemo / index.html
index d0af1ac9f940d067148ea5c940520fdcb56dbd96..8ef95011ec5792a5ff0ea389b90e92dfb34a595f 100644 (file)
        const urlParams = new URLSearchParams(window.location.search);
        const qimei = urlParams.get("imei");
 
-       const ourl = new URL(window.location);
-       const wsproto = ourl.protocol === "https" ? "wss" : "ws";
-       const wshost = ourl.hostname ? ourl.hostname : "localhost";
-       const wsport = ourl.port ? ourl.port : 5049;
+       const wsproto = window.location.protocol === "https" ? "wss" : "ws";
+       const wshost = window.location.hostname ? window.location.hostname
+                                               : "localhost";
+       const wsport = window.location.port ? window.location.port : 5049;
+       const limei = window.location.pathname.substring(1)
 
        const imeis = new Set();
        const locations = new Array();
@@ -47,6 +48,8 @@
                tstamp = document.getElementById("tstamp");
                if (qimei) {
                        imei.value = qimei;
+               } else if (limei) {
+                       imei.value = limei;
                }
                open_ws();
        }
                imei.disabled = false;
                send.disabled = false;
                clear.disabled = false;
+               locations.splice(0);
                sendIMEI();
        }
        function ws_onmessage(event) {
        <div style="width:100%; height:1%">
                <span id="sts"></span>
                <span id="about" style="float:right">
-                       <a href="http://www.average.org/gps303/">
-                               http://www.average.org/gps303/</a>
+                       <a href="http://www.average.org/loctrkd/">
+                               http://www.average.org/loctrkd/</a>
                </span>
        </div>
 </body>