mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 12:49:34 +00:00
fhemweb.js: some cosmetic changes while looking for a bug (Forum #64276)
git-svn-id: https://svn.fhem.de/fhem/trunk@12993 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
1ec0e6703c
commit
b7604f4402
@ -1,12 +1,14 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
// $Id$
|
||||||
|
|
||||||
var FW_serverGenerated;
|
var FW_serverGenerated;
|
||||||
var FW_serverFirstMsg = (new Date()).getTime()/1000;
|
var FW_serverFirstMsg = (new Date()).getTime()/1000;
|
||||||
var FW_serverLastMsg = FW_serverFirstMsg;
|
var FW_serverLastMsg = FW_serverFirstMsg;
|
||||||
var FW_isIE = (navigator.appVersion.indexOf("MSIE") > 0);
|
var FW_isIE = (navigator.appVersion.indexOf("MSIE") > 0);
|
||||||
var FW_isiOS = navigator.userAgent.match(/(iPad|iPhone|iPod)/);
|
var FW_isiOS = navigator.userAgent.match(/(iPad|iPhone|iPod)/);
|
||||||
var FW_scripts = {}, FW_links = {};
|
var FW_scripts = {}, FW_links = {};
|
||||||
var FW_docReady = false;
|
var FW_docReady = false, FW_longpollType;
|
||||||
var FW_root = "/fhem"; // root
|
var FW_root = "/fhem"; // root
|
||||||
var embedLoadRetry = 100;
|
var embedLoadRetry = 100;
|
||||||
|
|
||||||
@ -54,6 +56,7 @@ FW_jqueryReadyFn()
|
|||||||
{
|
{
|
||||||
FW_docReady = true;
|
FW_docReady = true;
|
||||||
FW_serverGenerated = $("body").attr("generated");
|
FW_serverGenerated = $("body").attr("generated");
|
||||||
|
FW_longpollType = $("body").attr("longpoll");
|
||||||
if($("body").attr("longpoll") != "0")
|
if($("body").attr("longpoll") != "0")
|
||||||
setTimeout("FW_longpoll()", 100);
|
setTimeout("FW_longpoll()", 100);
|
||||||
|
|
||||||
@ -676,7 +679,7 @@ FW_doUpdate(evt)
|
|||||||
var input="";
|
var input="";
|
||||||
|
|
||||||
if(evt.target instanceof WebSocket) {
|
if(evt.target instanceof WebSocket) {
|
||||||
if(evt.type == 'close') {
|
if(evt.type == 'close' && !FW_leaving) {
|
||||||
FW_errmsg(errstr, 4900);
|
FW_errmsg(errstr, 4900);
|
||||||
FW_pollConn.close();
|
FW_pollConn.close();
|
||||||
FW_pollConn = undefined;
|
FW_pollConn = undefined;
|
||||||
@ -771,7 +774,11 @@ FW_longpoll()
|
|||||||
FW_longpollOffset = 0;
|
FW_longpollOffset = 0;
|
||||||
if(FW_pollConn) {
|
if(FW_pollConn) {
|
||||||
FW_leaving = 1;
|
FW_leaving = 1;
|
||||||
FW_pollConn.abort();
|
if(FW_longpollType == "websocket")
|
||||||
|
FW_pollConn.close();
|
||||||
|
else
|
||||||
|
FW_pollConn.abort();
|
||||||
|
FW_pollConn = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
FW_leaving = 0;
|
FW_leaving = 0;
|
||||||
@ -831,7 +838,7 @@ FW_longpoll()
|
|||||||
"×tamp="+new Date().getTime();
|
"×tamp="+new Date().getTime();
|
||||||
query = addcsrf(query);
|
query = addcsrf(query);
|
||||||
|
|
||||||
if($("body").attr("longpoll") == "websocket") {
|
if(FW_longpollType == "websocket") {
|
||||||
FW_pollConn = new WebSocket((location+query).replace(/^http/i, "ws"));
|
FW_pollConn = new WebSocket((location+query).replace(/^http/i, "ws"));
|
||||||
FW_pollConn.onclose =
|
FW_pollConn.onclose =
|
||||||
FW_pollConn.onerror =
|
FW_pollConn.onerror =
|
||||||
@ -845,7 +852,8 @@ FW_longpoll()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log("Longpoll with filter "+filter);
|
log("Inform-channel opened ("+(FW_longpollType == 1 ? "HTTP":FW_longpollType )
|
||||||
|
+") with filter "+filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*************** LONGPOLL END **************/
|
/*************** LONGPOLL END **************/
|
||||||
|
Loading…
Reference in New Issue
Block a user