From fc91b4ce602bbf08cbe8162df2086205f21c471f Mon Sep 17 00:00:00 2001 From: demmm Date: Wed, 17 Jun 2020 16:52:59 +0200 Subject: [PATCH] [localeq] use js to get the hasInternet status switching between Map.qml & Offline.qml now happens properly --- src/modules/localeq/localeq.qml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/modules/localeq/localeq.qml b/src/modules/localeq/localeq.qml index 0abdebfc9..ffd87f5b5 100644 --- a/src/modules/localeq/localeq.qml +++ b/src/modules/localeq/localeq.qml @@ -34,6 +34,32 @@ Page { //Needs to come from .conf/geoip property var hasInternet: true + function getInt(format) { + var requestURL = "https://example.org/"; + var xhr = new XMLHttpRequest; + + xhr.onreadystatechange = function() { + if (xhr.readyState === XMLHttpRequest.DONE) { + + if (xhr.status !== 200) { + console.log("Disconnected!!"); + var connected = false + hasInternet = connected + return; + } + + else { + console.log("Connected!!"); + } + } + } + xhr.open("GET", requestURL, true); + xhr.send(); + } + Component.onCompleted: { + getInt(); + } + Loader { id: image anchors.horizontalCenter: parent.horizontalCenter