Replace sse event labels
This commit is contained in:
parent
5381e70fe7
commit
6cfd535f19
@ -136,13 +136,20 @@
|
|||||||
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="NAME">source</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">EventSource</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>129</span> </span><span class="WHIT"> </span><span class="NAME">source</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">EventSource</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>130</span> </span><span class="WHIT">
|
<span class='line'>130</span> </span><span class="WHIT">
|
||||||
<span class='line'>131</span> </span><span class="COMM">// Apply the callback</span><span class="WHIT">
|
<span class='line'>131</span> </span><span class="COMM">// Apply the callback</span><span class="WHIT">
|
||||||
<span class='line'>132</span> </span><span class="WHIT"> </span><span class="NAME">source.onmessage</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>132</span> </span><span class="WHIT"> </span><span class="NAME">source.onmessage</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">event</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||||
<span class='line'>133</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
<span class='line'>133</span> </span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">event.data</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>134</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="COMM">// Ajax polling fallback</span><span class="WHIT">
|
<span class='line'>134</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>135</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
<span class='line'>135</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||||
<span class='line'>136</span> </span><span class="WHIT"> </span><span class="NAME">poll_rate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">poll_rate</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">30000</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>136</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="COMM">// Ajax polling fallback</span><span class="WHIT">
|
||||||
<span class='line'>137</span> </span><span class="WHIT"> </span><span class="NAME">setInterval</span><span class="PUNC">(</span><span class="NAME">$_.get</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">poll_rate</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>137</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||||
<span class='line'>138</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
<span class='line'>138</span> </span><span class="WHIT"> </span><span class="NAME">poll_rate</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">poll_rate</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">30000</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>139</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>139</span> </span><span class="WHIT">
|
||||||
<span class='line'>140</span> </span><span class="WHIT">
|
<span class='line'>140</span> </span><span class="NAME">setInterval</span><span class="PUNC">(</span><span class="NAME">$_.get</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">poll_rate</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">res</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
|
||||||
<span class='line'>141</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>
|
<span class='line'>141</span> </span><span class="WHIT"> </span><span class="NAME">res.replace</span><span class="PUNC">(</span><span class="REGX">/data:/gim</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
|
<span class='line'>142</span> </span><span class="WHIT"> </span><span class="NAME">res.replace</span><span class="PUNC">(</span><span class="REGX">/^event|id|retry?:(.*)$/gim</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
|
<span class='line'>143</span> </span><span class="WHIT"> </span><span class="NAME">callback</span><span class="PUNC">(</span><span class="NAME">res</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
|
<span class='line'>144</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
|
<span class='line'>145</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||||
|
<span class='line'>146</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
|
<span class='line'>147</span> </span><span class="WHIT">
|
||||||
|
<span class='line'>148</span> </span><span class="PUNC">}</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span></pre></body></html>
|
11
kis-all.js
11
kis-all.js
@ -940,12 +940,19 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
|
|||||||
source = new EventSource(url);
|
source = new EventSource(url);
|
||||||
|
|
||||||
// Apply the callback
|
// Apply the callback
|
||||||
source.onmessage = callback;
|
source.onmessage = function(event){
|
||||||
|
callback(event.data);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else // Ajax polling fallback
|
else // Ajax polling fallback
|
||||||
{
|
{
|
||||||
poll_rate = poll_rate || 30000;
|
poll_rate = poll_rate || 30000;
|
||||||
setInterval($_.get, poll_rate, url, {}, callback);
|
|
||||||
|
setInterval($_.get, poll_rate, url, {}, function(res){
|
||||||
|
res.replace(/data:/gim, '');
|
||||||
|
res.replace(/^event|id|retry?:(.*)$/gim, '');
|
||||||
|
callback(res);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
2
kis-lite-dom-min.js
vendored
2
kis-lite-dom-min.js
vendored
@ -3,7 +3,7 @@ return 1===b.length?b[0]:b};f=function(a){var c;if("undefined"!==typeof a){if("u
|
|||||||
(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};g=window.$_=window.$_||g;g.$=e}})();
|
(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};g=window.$_=window.$_||g;g.$=e}})();
|
||||||
(function(){"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=false},Event.prototype.stopPropagation=function(){window.event.cancelBubble=true})})();
|
(function(){"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=false},Event.prototype.stopPropagation=function(){window.event.cancelBubble=true})})();
|
||||||
(function(){if("undefined"!==typeof window.XMLHttpRequest){var g={_do:function(e,f,b,a){var c=new XMLHttpRequest;"undefined"===typeof b&&(b=function(){});a=a?"POST":"GET";e+="GET"===a?"?"+this._serialize(f):"";c.open(a,e);c.onreadystatechange=function(){4===c.readyState&&b(c.responseText)};"POST"===a?(c.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),c.send(this._serialize(f))):c.send(null)},_serialize:function(e){var f,b,a=[];for(f in e)e.hasOwnProperty(f)&&"function"!==typeof e[f]&&
|
(function(){if("undefined"!==typeof window.XMLHttpRequest){var g={_do:function(e,f,b,a){var c=new XMLHttpRequest;"undefined"===typeof b&&(b=function(){});a=a?"POST":"GET";e+="GET"===a?"?"+this._serialize(f):"";c.open(a,e);c.onreadystatechange=function(){4===c.readyState&&b(c.responseText)};"POST"===a?(c.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),c.send(this._serialize(f))):c.send(null)},_serialize:function(e){var f,b,a=[];for(f in e)e.hasOwnProperty(f)&&"function"!==typeof e[f]&&
|
||||||
(b=e[f].toString(),f=encodeURIComponent(f),b=encodeURIComponent(b),a.push(f+"="+b));return a.join("&")}};$_.ext("get",function(e,f,b){g._do(e,f,b,!1)});$_.ext("post",function(e,f,b){g._do(e,f,b,!0)});$_.ext("sse",function(e,f,b){"undefined"!==typeof EventSource?(e=new EventSource(e),e.onmessage=f):setInterval($_.get,b||3E4,e,{},f)})}})();
|
(b=e[f].toString(),f=encodeURIComponent(f),b=encodeURIComponent(b),a.push(f+"="+b));return a.join("&")}};$_.ext("get",function(e,f,b){g._do(e,f,b,!1)});$_.ext("post",function(e,f,b){g._do(e,f,b,!0)});$_.ext("sse",function(e,f,b){"undefined"!==typeof EventSource?(e=new EventSource(e),e.onmessage=function(a){f(a.data)}):setInterval($_.get,b||3E4,e,{},function(a){a.replace(/data:/gim,"");a.replace(/^event|id|retry?:(.*)$/gim,"");f(a)})})}})();
|
||||||
(function(){var g,e,f,b;"undefined"!==typeof document.addEventListener?(g=function(a,c,b){"undefined"!==typeof a.addEventListener&&a.addEventListener(c,b,!1)},e=function(a,c,b){"undefined"!==typeof a.removeEventListener&&a.removeEventListener(c,b,!1)}):"undefined"!==typeof document.attachEvent&&(g=function(a,c,b){function h(a){b.apply(a)}"undefined"!==typeof a.attachEvent?(e(c,b),a.attachEvent("on"+c,h),a=a.KIS_0_6_0=a.KIS_0_6_0||{},a.listeners=a.listeners||{},a.listeners[c]=a.listeners[c]||[],a.listeners[c].push({callback:b,
|
(function(){var g,e,f,b;"undefined"!==typeof document.addEventListener?(g=function(a,c,b){"undefined"!==typeof a.addEventListener&&a.addEventListener(c,b,!1)},e=function(a,c,b){"undefined"!==typeof a.removeEventListener&&a.removeEventListener(c,b,!1)}):"undefined"!==typeof document.attachEvent&&(g=function(a,c,b){function h(a){b.apply(a)}"undefined"!==typeof a.attachEvent?(e(c,b),a.attachEvent("on"+c,h),a=a.KIS_0_6_0=a.KIS_0_6_0||{},a.listeners=a.listeners||{},a.listeners[c]=a.listeners[c]||[],a.listeners[c].push({callback:b,
|
||||||
_listener:h})):console.log("Failed to _attach event:"+c+" on "+a)},e=function(a,b,d){if("undefined"!==typeof a.detachEvent){var h=a.KIS_0_6_0;if(h&&h.listeners&&h.listeners[b])for(var e=h.listeners[b],f=e.length,i=0;i<f;i++)if(e[i].callback===d){a.detachEvent("on"+b,e[i]._listener);e.splice(i,1);0===e.length&&delete h.listeners[b];break}}});f=function(a,b,d,h){var j,k;if(typeof a==="undefined"){console.log(arguments);console.log(b);return false}if(b.match(/^([\w\-]+)$/))h===true?g(a,b,d):e(a,b,d);
|
_listener:h})):console.log("Failed to _attach event:"+c+" on "+a)},e=function(a,b,d){if("undefined"!==typeof a.detachEvent){var h=a.KIS_0_6_0;if(h&&h.listeners&&h.listeners[b])for(var e=h.listeners[b],f=e.length,i=0;i<f;i++)if(e[i].callback===d){a.detachEvent("on"+b,e[i]._listener);e.splice(i,1);0===e.length&&delete h.listeners[b];break}}});f=function(a,b,d,h){var j,k;if(typeof a==="undefined"){console.log(arguments);console.log(b);return false}if(b.match(/^([\w\-]+)$/))h===true?g(a,b,d):e(a,b,d);
|
||||||
else{b=b.split(" ");k=b.length;for(j=0;j<k;j++)f(a,b[j],d,h)}};b=function(a,b,d,e){f(a,d,function(d){var f,i,g,d=d||window.event;i=$_.$(b,a);for(f in i){g=d.target||d.srcElement;if(g==i[f]){e.call(i[f],d);d.stopPropagation()}}},true)};$_.ext("event",{add:function(a,b){$_.each(function(d){f(d,a,b,true)})},remove:function(a,b){$_.each(function(d){f(d,a,b,false)})},live:function(a,c,d){b(document.documentElement,a,c,d)},delegate:function(a,c,d){$_.each(function(e){b(e,a,c,d)})}})})();
|
else{b=b.split(" ");k=b.length;for(j=0;j<k;j++)f(a,b[j],d,h)}};b=function(a,b,d,e){f(a,d,function(d){var f,i,g,d=d||window.event;i=$_.$(b,a);for(f in i){g=d.target||d.srcElement;if(g==i[f]){e.call(i[f],d);d.stopPropagation()}}},true)};$_.ext("event",{add:function(a,b){$_.each(function(d){f(d,a,b,true)})},remove:function(a,b){$_.each(function(d){f(d,a,b,false)})},live:function(a,c,d){b(document.documentElement,a,c,d)},delegate:function(a,c,d){$_.each(function(e){b(e,a,c,d)})}})})();
|
||||||
|
@ -397,12 +397,19 @@
|
|||||||
source = new EventSource(url);
|
source = new EventSource(url);
|
||||||
|
|
||||||
// Apply the callback
|
// Apply the callback
|
||||||
source.onmessage = callback;
|
source.onmessage = function(event){
|
||||||
|
callback(event.data);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else // Ajax polling fallback
|
else // Ajax polling fallback
|
||||||
{
|
{
|
||||||
poll_rate = poll_rate || 30000;
|
poll_rate = poll_rate || 30000;
|
||||||
setInterval($_.get, poll_rate, url, {}, callback);
|
|
||||||
|
setInterval($_.get, poll_rate, url, {}, function(res){
|
||||||
|
res.replace(/data:/gim, '');
|
||||||
|
res.replace(/^event|id|retry?:(.*)$/gim, '');
|
||||||
|
callback(res);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
2
kis-lite-min.js
vendored
2
kis-lite-min.js
vendored
@ -3,7 +3,7 @@ return 1===g.length?g[0]:g};e=function(a){var b;if("undefined"!==typeof a){if("u
|
|||||||
(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};f=window.$_=window.$_||f;f.$=d}})();
|
(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};f=window.$_=window.$_||f;f.$=d}})();
|
||||||
(function(){"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=false},Event.prototype.stopPropagation=function(){window.event.cancelBubble=true})})();
|
(function(){"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=false},Event.prototype.stopPropagation=function(){window.event.cancelBubble=true})})();
|
||||||
(function(){if("undefined"!==typeof window.XMLHttpRequest){var f={_do:function(d,e,c,a){var b=new XMLHttpRequest;"undefined"===typeof c&&(c=function(){});a=a?"POST":"GET";d+="GET"===a?"?"+this._serialize(e):"";b.open(a,d);b.onreadystatechange=function(){4===b.readyState&&c(b.responseText)};"POST"===a?(b.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),b.send(this._serialize(e))):b.send(null)},_serialize:function(d){var e,c,a=[];for(e in d)d.hasOwnProperty(e)&&"function"!==typeof d[e]&&
|
(function(){if("undefined"!==typeof window.XMLHttpRequest){var f={_do:function(d,e,c,a){var b=new XMLHttpRequest;"undefined"===typeof c&&(c=function(){});a=a?"POST":"GET";d+="GET"===a?"?"+this._serialize(e):"";b.open(a,d);b.onreadystatechange=function(){4===b.readyState&&c(b.responseText)};"POST"===a?(b.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),b.send(this._serialize(e))):b.send(null)},_serialize:function(d){var e,c,a=[];for(e in d)d.hasOwnProperty(e)&&"function"!==typeof d[e]&&
|
||||||
(c=d[e].toString(),e=encodeURIComponent(e),c=encodeURIComponent(c),a.push(e+"="+c));return a.join("&")}};$_.ext("get",function(d,e,c){f._do(d,e,c,!1)});$_.ext("post",function(d,e,c){f._do(d,e,c,!0)});$_.ext("sse",function(d,e,c){"undefined"!==typeof EventSource?(d=new EventSource(d),d.onmessage=e):setInterval($_.get,c||3E4,d,{},e)})}})();
|
(c=d[e].toString(),e=encodeURIComponent(e),c=encodeURIComponent(c),a.push(e+"="+c));return a.join("&")}};$_.ext("get",function(d,e,c){f._do(d,e,c,!1)});$_.ext("post",function(d,e,c){f._do(d,e,c,!0)});$_.ext("sse",function(d,e,c){"undefined"!==typeof EventSource?(d=new EventSource(d),d.onmessage=function(a){e(a.data)}):setInterval($_.get,c||3E4,d,{},function(a){a.replace(/data:/gim,"");a.replace(/^event|id|retry?:(.*)$/gim,"");e(a)})})}})();
|
||||||
(function(){var f,d,e,c;"undefined"!==typeof document.addEventListener?(f=function(a,b,g){"undefined"!==typeof a.addEventListener&&a.addEventListener(b,g,!1)},d=function(a,b,g){"undefined"!==typeof a.removeEventListener&&a.removeEventListener(b,g,!1)}):"undefined"!==typeof document.attachEvent&&(f=function(a,b,g){function c(a){g.apply(a)}"undefined"!==typeof a.attachEvent?(d(b,g),a.attachEvent("on"+b,c),a=a.KIS_0_6_0=a.KIS_0_6_0||{},a.listeners=a.listeners||{},a.listeners[b]=a.listeners[b]||[],a.listeners[b].push({callback:g,
|
(function(){var f,d,e,c;"undefined"!==typeof document.addEventListener?(f=function(a,b,g){"undefined"!==typeof a.addEventListener&&a.addEventListener(b,g,!1)},d=function(a,b,g){"undefined"!==typeof a.removeEventListener&&a.removeEventListener(b,g,!1)}):"undefined"!==typeof document.attachEvent&&(f=function(a,b,g){function c(a){g.apply(a)}"undefined"!==typeof a.attachEvent?(d(b,g),a.attachEvent("on"+b,c),a=a.KIS_0_6_0=a.KIS_0_6_0||{},a.listeners=a.listeners||{},a.listeners[b]=a.listeners[b]||[],a.listeners[b].push({callback:g,
|
||||||
_listener:c})):console.log("Failed to _attach event:"+b+" on "+a)},d=function(a,b,c){if("undefined"!==typeof a.detachEvent){var d=a.KIS_0_6_0;if(d&&d.listeners&&d.listeners[b])for(var e=d.listeners[b],f=e.length,h=0;h<f;h++)if(e[h].callback===c){a.detachEvent("on"+b,e[h]._listener);e.splice(h,1);0===e.length&&delete d.listeners[b];break}}});e=function(a,b,c,j){var i,k;if(typeof a==="undefined"){console.log(arguments);console.log(b);return false}if(b.match(/^([\w\-]+)$/))j===true?f(a,b,c):d(a,b,c);
|
_listener:c})):console.log("Failed to _attach event:"+b+" on "+a)},d=function(a,b,c){if("undefined"!==typeof a.detachEvent){var d=a.KIS_0_6_0;if(d&&d.listeners&&d.listeners[b])for(var e=d.listeners[b],f=e.length,h=0;h<f;h++)if(e[h].callback===c){a.detachEvent("on"+b,e[h]._listener);e.splice(h,1);0===e.length&&delete d.listeners[b];break}}});e=function(a,b,c,j){var i,k;if(typeof a==="undefined"){console.log(arguments);console.log(b);return false}if(b.match(/^([\w\-]+)$/))j===true?f(a,b,c):d(a,b,c);
|
||||||
else{b=b.split(" ");k=b.length;for(i=0;i<k;i++)e(a,b[i],c,j)}};c=function(a,b,c,d){e(a,c,function(c){var e,g,f,c=c||window.event;g=$_.$(b,a);for(e in g){f=c.target||c.srcElement;if(f==g[e]){d.call(g[e],c);c.stopPropagation()}}},true)};$_.ext("event",{add:function(a,b){$_.each(function(c){e(c,a,b,true)})},remove:function(a,b){$_.each(function(c){e(c,a,b,false)})},live:function(a,b,d){c(document.documentElement,a,b,d)},delegate:function(a,b,d){$_.each(function(e){c(e,a,b,d)})}})})();
|
else{b=b.split(" ");k=b.length;for(i=0;i<k;i++)e(a,b[i],c,j)}};c=function(a,b,c,d){e(a,c,function(c){var e,g,f,c=c||window.event;g=$_.$(b,a);for(e in g){f=c.target||c.srcElement;if(f==g[e]){d.call(g[e],c);c.stopPropagation()}}},true)};$_.ext("event",{add:function(a,b){$_.each(function(c){e(c,a,b,true)})},remove:function(a,b){$_.each(function(c){e(c,a,b,false)})},live:function(a,b,d){c(document.documentElement,a,b,d)},delegate:function(a,b,d){$_.each(function(e){c(e,a,b,d)})}})})();
|
||||||
|
11
kis-lite.js
11
kis-lite.js
@ -397,12 +397,19 @@
|
|||||||
source = new EventSource(url);
|
source = new EventSource(url);
|
||||||
|
|
||||||
// Apply the callback
|
// Apply the callback
|
||||||
source.onmessage = callback;
|
source.onmessage = function(event){
|
||||||
|
callback(event.data);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else // Ajax polling fallback
|
else // Ajax polling fallback
|
||||||
{
|
{
|
||||||
poll_rate = poll_rate || 30000;
|
poll_rate = poll_rate || 30000;
|
||||||
setInterval($_.get, poll_rate, url, {}, callback);
|
|
||||||
|
setInterval($_.get, poll_rate, url, {}, function(res){
|
||||||
|
res.replace(/data:/gim, '');
|
||||||
|
res.replace(/^event|id|retry?:(.*)$/gim, '');
|
||||||
|
callback(res);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
44
kis-min.js
vendored
44
kis-min.js
vendored
@ -1,24 +1,24 @@
|
|||||||
(function(){if("undefined"!==typeof document.querySelector){var g,f,c,a;g=function(b){a="undefined"===typeof b?"undefined"!==typeof g.el?g.el:document.documentElement:"object"!==typeof b?f(b):b;g.prototype.el=a;var b=c(g),d;for(d in b)"object"===typeof b[d]&&(b[d].el=a);b.el=a;return b};f=function(b,d){var a;if("string"!=typeof b||"undefined"===typeof b)return b;a=null!=d&&1===d.nodeType?d:document;if(b.match(/^#([\w\-]+$)/))return document.getElementById(b.split("#")[1]);a=a.querySelectorAll(b);
|
(function(){if("undefined"!==typeof document.querySelector){var g,f,c,b;g=function(a){b="undefined"===typeof a?"undefined"!==typeof g.el?g.el:document.documentElement:"object"!==typeof a?f(a):a;g.prototype.el=b;var a=c(g),d;for(d in a)"object"===typeof a[d]&&(a[d].el=b);a.el=b;return a};f=function(a,d){var b;if("string"!=typeof a||"undefined"===typeof a)return a;b=null!=d&&1===d.nodeType?d:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);b=b.querySelectorAll(a);
|
||||||
return 1===a.length?a[0]:a};c=function(b){var a;if("undefined"!==typeof b){if("undefined"!==typeof Object.create)return Object.create(b);a=typeof b;if(!("object"!==a&&"function"!==a))return a=function(){},a.prototype=b,new a}};g.ext=function(b,d){d.el=a;g[b]=d};g.ext("each",function(b){if("undefined"!==typeof a.length&&a!==window){var d=a.length;if(0!==d)for(var e,c=0;c<d;c++)e=a.item(c)?a.item(c):a[c],b.call(e,e)}else b.call(a,a)});g.type=function(b){return function(){return b&&b!==this}.call(b)?
|
return 1===b.length?b[0]:b};c=function(a){var b;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);b=typeof a;if(!("object"!==b&&"function"!==b))return b=function(){},b.prototype=a,new b}};g.ext=function(a,d){d.el=b;g[a]=d};g.ext("each",function(a){if("undefined"!==typeof b.length&&b!==window){var d=b.length;if(0!==d)for(var e,c=0;c<d;c++)e=b.item(c)?b.item(c):b[c],a.call(e,e)}else a.call(b,b)});g.type=function(a){return function(){return a&&a!==this}.call(a)?
|
||||||
(typeof b).toLowerCase():{}.toString.call(b).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};g=window.$_=window.$_||g;g.$=f}})();
|
(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};g=window.$_=window.$_||g;g.$=f}})();
|
||||||
(function(){"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=false},Event.prototype.stopPropagation=function(){window.event.cancelBubble=true})})();
|
(function(){"undefined"===typeof window.console&&(window.console={log:function(){}});"undefined"===typeof String.prototype.trim&&(String.prototype.trim=function(){return this.replace(/^[\s\uFEFF]+|[\s\uFEFF]+$/g,"")});"undefined"===typeof Event.preventDefault&&"undefined"!==typeof window.event&&(Event.prototype.preventDefault=function(){window.event.returnValue=false},Event.prototype.stopPropagation=function(){window.event.cancelBubble=true})})();
|
||||||
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(g){var g=(g.HTMLElement||g.Element).prototype,f=Object,c=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},a=Array.prototype.indexOf||function(b){for(var a=0,d=this.length;a<d;a++)if(a in this&&this[a]===b)return a;return-1},b=function(b,a){this.name=b;this.code=DOMException[b];this.message=a},d=function(d,e){if(""===e)throw new b("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new b("INVALID_CHARACTER_ERR",
|
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(g){var g=(g.HTMLElement||g.Element).prototype,f=Object,c=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},b=Array.prototype.indexOf||function(a){for(var b=0,d=this.length;b<d;b++)if(b in this&&this[b]===a)return b;return-1},a=function(a,b){this.name=a;this.code=DOMException[a];this.message=b},d=function(d,e){if(""===e)throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(e))throw new a("INVALID_CHARACTER_ERR",
|
||||||
"String contains an invalid character");return a.call(d,e)},e=function(b){for(var a=c.call(b.className),a=a?a.split(/\s+/):[],d=0,e=a.length;d<e;d++)this.push(a[d]);this._updateClassName=function(){b.className=this.toString()}},h=e.prototype=[],i=function(){return new e(this)};b.prototype=Error.prototype;h.item=function(b){return this[b]||null};h.contains=function(b){return-1!==d(this,b+"")};h.add=function(b){b+="";-1===d(this,b)&&(this.push(b),this._updateClassName())};h.remove=function(b){b=d(this,
|
"String contains an invalid character");return b.call(d,e)},e=function(a){for(var b=c.call(a.className),b=b?b.split(/\s+/):[],d=0,e=b.length;d<e;d++)this.push(b[d]);this._updateClassName=function(){a.className=this.toString()}},h=e.prototype=[],i=function(){return new e(this)};a.prototype=Error.prototype;h.item=function(a){return this[a]||null};h.contains=function(a){return-1!==d(this,a+"")};h.add=function(a){a+="";-1===d(this,a)&&(this.push(a),this._updateClassName())};h.remove=function(a){a=d(this,
|
||||||
b+"");-1!==b&&(this.splice(b,1),this._updateClassName())};h.toggle=function(b){b+="";-1===d(this,b)?this.add(b):this.remove(b)};h.toString=function(){return this.join(" ")};if(f.defineProperty){h={get:i,enumerable:!0,configurable:!0};try{f.defineProperty(g,"classList",h)}catch(j){-2146823252===j.number&&(h.enumerable=!1,f.defineProperty(g,"classList",h))}}else f.prototype.__defineGetter__&&g.__defineGetter__("classList",i)}(self);
|
a+"");-1!==a&&(this.splice(a,1),this._updateClassName())};h.toggle=function(a){a+="";-1===d(this,a)?this.add(a):this.remove(a)};h.toString=function(){return this.join(" ")};if(f.defineProperty){h={get:i,enumerable:!0,configurable:!0};try{f.defineProperty(g,"classList",h)}catch(j){-2146823252===j.number&&(h.enumerable=!1,f.defineProperty(g,"classList",h))}}else f.prototype.__defineGetter__&&g.__defineGetter__("classList",i)}(self);
|
||||||
(function(){function g(a,b,d){var e,c;"undefined"!==typeof a.hasAttribute?(a.hasAttribute(b)&&(e=a.getAttribute(b)),c=!0):"undefined"!==typeof a[b]?(e=a[b],c=!1):"class"===b&&"undefined"!==typeof a.className&&(b="className",e=a.className,c=!1);if("undefined"===typeof e&&("undefined"===typeof d||null===d))return console.log(d),console.log(a),console.log("Element does not have the selected attribute"),null;if("undefined"===typeof d)return e;"undefined"!==typeof d&&null!==d?!0===c?a.setAttribute(b,d):
|
(function(){function g(b,a,d){var e,c;"undefined"!==typeof b.hasAttribute?(b.hasAttribute(a)&&(e=b.getAttribute(a)),c=!0):"undefined"!==typeof b[a]?(e=b[a],c=!1):"class"===a&&"undefined"!==typeof b.className&&(a="className",e=b.className,c=!1);if("undefined"===typeof e&&("undefined"===typeof d||null===d))return console.log(d),console.log(b),console.log("Element does not have the selected attribute"),null;if("undefined"===typeof d)return e;"undefined"!==typeof d&&null!==d?!0===c?b.setAttribute(a,d):
|
||||||
a[b]=d:null===d&&(!0===c?a.removeAttribute(b):delete a[b]);return"undefined"!==typeof d?d:e}function f(a){return a.replace(/(\-[a-z])/g,function(b){return b.toUpperCase().replace("-","")})}function c(a,b,d){var e,b=f(b);e={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if("undefined"===typeof d&&"undefined"!==a.style[b])return a.style[b];if("undefined"===typeof d&&"undefined"!==a.style[e[b]])return a.style[e[b]];if("undefined"!==typeof a.style[b])return a.style[b]=d,null;if(a.style[e[b]])return a.style[e[b]]=
|
b[a]=d:null===d&&(!0===c?b.removeAttribute(a):delete b[a]);return"undefined"!==typeof d?d:e}function f(b){return b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function c(b,a,d){var e,a=f(a);e={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if("undefined"===typeof d&&"undefined"!==b.style[a])return b.style[a];if("undefined"===typeof d&&"undefined"!==b.style[e[a]])return b.style[e[a]];if("undefined"!==typeof b.style[a])return b.style[a]=d,null;if(b.style[e[a]])return b.style[e[a]]=
|
||||||
d,null;console.log("Property "+b+" nor an equivalent seems to exist")}$_.ext("dom",{addClass:function(a){$_.each(function(b){b.classList.add(a)})},removeClass:function(a){$_.each(function(b){b.classList.remove(a)})},hide:function(){this.css("display","none")},show:function(a){"undefined"===typeof a&&(a="block");this.css("display",a)},attr:function(a,b){var d=this.el;if(1<d.length&&"undefined"===typeof b)console.log(d),console.log("Must be a singular element");else if(1<d.length&&"undefined"!==typeof b)$_.each(function(d){return g(d,
|
d,null;console.log("Property "+a+" nor an equivalent seems to exist")}$_.ext("dom",{addClass:function(b){$_.each(function(a){a.classList.add(b)})},removeClass:function(b){$_.each(function(a){a.classList.remove(b)})},hide:function(){this.css("display","none")},show:function(b){"undefined"===typeof b&&(b="block");this.css("display",b)},attr:function(b,a){var d=this.el;if(1<d.length&&"undefined"===typeof a)console.log(d),console.log("Must be a singular element");else if(1<d.length&&"undefined"!==typeof a)$_.each(function(d){return g(d,
|
||||||
a,b)});else return g(d,a,b)},text:function(a){var b,d,c;c=this.el;d="undefined"!==typeof c.textContent?"textContent":"undefined"!==typeof c.innerText?"innerText":"innerHTML";b=c[d];return"undefined"!==typeof a?c[d]=a:b},css:function(a,b){if("undefined"===typeof b)return c(this.el,a);$_.each(function(d){c(d,a,b)})},append:function(a){"undefined"!==typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("beforeend",a):this.el.innerHTML+=a},prepend:function(a){"undefined"!==typeof document.insertAdjacentHTML?
|
b,a)});else return g(d,b,a)},text:function(b){var a,d,c;c=this.el;d="undefined"!==typeof c.textContent?"textContent":"undefined"!==typeof c.innerText?"innerText":"innerHTML";a=c[d];return"undefined"!==typeof b?c[d]=b:a},css:function(b,a){if("undefined"===typeof a)return c(this.el,b);$_.each(function(d){c(d,b,a)})},append:function(b){"undefined"!==typeof document.insertAdjacentHTML?this.el.insertAdjacentHTML("beforeend",b):this.el.innerHTML+=b},prepend:function(b){"undefined"!==typeof document.insertAdjacentHTML?
|
||||||
this.el.insertAdjacentHTML("afterbegin",a):this.el.innerHTML=a+this.el.innerHTML},html:function(a){"undefined"!==typeof a&&(this.el.innerHTML=a);return this.el.innerHTML}})})();
|
this.el.insertAdjacentHTML("afterbegin",b):this.el.innerHTML=b+this.el.innerHTML},html:function(b){"undefined"!==typeof b&&(this.el.innerHTML=b);return this.el.innerHTML}})})();
|
||||||
(function(){if("undefined"!==typeof window.XMLHttpRequest){var g={_do:function(f,c,a,b){var d=new XMLHttpRequest;"undefined"===typeof a&&(a=function(){});b=b?"POST":"GET";f+="GET"===b?"?"+this._serialize(c):"";d.open(b,f);d.onreadystatechange=function(){4===d.readyState&&a(d.responseText)};"POST"===b?(d.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),d.send(this._serialize(c))):d.send(null)},_serialize:function(f){var c,a,b=[];for(c in f)f.hasOwnProperty(c)&&"function"!==typeof f[c]&&
|
(function(){if("undefined"!==typeof window.XMLHttpRequest){var g={_do:function(f,c,b,a){var d=new XMLHttpRequest;"undefined"===typeof b&&(b=function(){});a=a?"POST":"GET";f+="GET"===a?"?"+this._serialize(c):"";d.open(a,f);d.onreadystatechange=function(){4===d.readyState&&b(d.responseText)};"POST"===a?(d.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),d.send(this._serialize(c))):d.send(null)},_serialize:function(f){var c,b,a=[];for(c in f)f.hasOwnProperty(c)&&"function"!==typeof f[c]&&
|
||||||
(a=f[c].toString(),c=encodeURIComponent(c),a=encodeURIComponent(a),b.push(c+"="+a));return b.join("&")}};$_.ext("get",function(f,c,a){g._do(f,c,a,!1)});$_.ext("post",function(f,c,a){g._do(f,c,a,!0)});$_.ext("sse",function(f,c,a){"undefined"!==typeof EventSource?(f=new EventSource(f),f.onmessage=c):setInterval($_.get,a||3E4,f,{},c)})}})();
|
(b=f[c].toString(),c=encodeURIComponent(c),b=encodeURIComponent(b),a.push(c+"="+b));return a.join("&")}};$_.ext("get",function(f,c,b){g._do(f,c,b,!1)});$_.ext("post",function(f,c,b){g._do(f,c,b,!0)});$_.ext("sse",function(f,c,b){"undefined"!==typeof EventSource?(f=new EventSource(f),f.onmessage=function(a){c(a.data)}):setInterval($_.get,b||3E4,f,{},function(a){a.replace(/data:/gim,"");a.replace(/^event|id|retry?:(.*)$/gim,"");c(a)})})}})();
|
||||||
(function(){var g,f,c,a;"undefined"!==typeof document.addEventListener?(g=function(b,a,c){"undefined"!==typeof b.addEventListener&&b.addEventListener(a,c,!1)},f=function(b,a,c){"undefined"!==typeof b.removeEventListener&&b.removeEventListener(a,c,!1)}):"undefined"!==typeof document.attachEvent&&(g=function(b,a,c){function h(b){c.apply(b)}"undefined"!==typeof b.attachEvent?(f(a,c),b.attachEvent("on"+a,h),b=b.KIS_0_6_0=b.KIS_0_6_0||{},b.listeners=b.listeners||{},b.listeners[a]=b.listeners[a]||[],b.listeners[a].push({callback:c,
|
(function(){var g,f,c,b;"undefined"!==typeof document.addEventListener?(g=function(a,b,c){"undefined"!==typeof a.addEventListener&&a.addEventListener(b,c,!1)},f=function(a,b,c){"undefined"!==typeof a.removeEventListener&&a.removeEventListener(b,c,!1)}):"undefined"!==typeof document.attachEvent&&(g=function(a,b,c){function h(a){c.apply(a)}"undefined"!==typeof a.attachEvent?(f(b,c),a.attachEvent("on"+b,h),a=a.KIS_0_6_0=a.KIS_0_6_0||{},a.listeners=a.listeners||{},a.listeners[b]=a.listeners[b]||[],a.listeners[b].push({callback:c,
|
||||||
_listener:h})):console.log("Failed to _attach event:"+a+" on "+b)},f=function(b,a,c){if("undefined"!==typeof b.detachEvent){var h=b.KIS_0_6_0;if(h&&h.listeners&&h.listeners[a])for(var f=h.listeners[a],g=f.length,k=0;k<g;k++)if(f[k].callback===c){b.detachEvent("on"+a,f[k]._listener);f.splice(k,1);0===f.length&&delete h.listeners[a];break}}});c=function(b,a,e,h){var i,j;if(typeof b==="undefined"){console.log(arguments);console.log(a);return false}if(a.match(/^([\w\-]+)$/))h===true?g(b,a,e):f(b,a,e);
|
_listener:h})):console.log("Failed to _attach event:"+b+" on "+a)},f=function(a,b,c){if("undefined"!==typeof a.detachEvent){var h=a.KIS_0_6_0;if(h&&h.listeners&&h.listeners[b])for(var f=h.listeners[b],g=f.length,k=0;k<g;k++)if(f[k].callback===c){a.detachEvent("on"+b,f[k]._listener);f.splice(k,1);0===f.length&&delete h.listeners[b];break}}});c=function(a,b,e,h){var i,j;if(typeof a==="undefined"){console.log(arguments);console.log(b);return false}if(b.match(/^([\w\-]+)$/))h===true?g(a,b,e):f(a,b,e);
|
||||||
else{a=a.split(" ");j=a.length;for(i=0;i<j;i++)c(b,a[i],e,h)}};a=function(b,a,e,f){c(b,e,function(c){var e,g,l,c=c||window.event;g=$_.$(a,b);for(e in g){l=c.target||c.srcElement;if(l==g[e]){f.call(g[e],c);c.stopPropagation()}}},true)};$_.ext("event",{add:function(b,a){$_.each(function(e){c(e,b,a,true)})},remove:function(a,d){$_.each(function(e){c(e,a,d,false)})},live:function(b,d,c){a(document.documentElement,b,d,c)},delegate:function(b,c,e){$_.each(function(f){a(f,b,c,e)})}})})();
|
else{b=b.split(" ");j=b.length;for(i=0;i<j;i++)c(a,b[i],e,h)}};b=function(a,b,e,f){c(a,e,function(c){var e,g,l,c=c||window.event;g=$_.$(b,a);for(e in g){l=c.target||c.srcElement;if(l==g[e]){f.call(g[e],c);c.stopPropagation()}}},true)};$_.ext("event",{add:function(a,b){$_.each(function(e){c(e,a,b,true)})},remove:function(a,b){$_.each(function(e){c(e,a,b,false)})},live:function(a,c,e){b(document.documentElement,a,c,e)},delegate:function(a,c,e){$_.each(function(f){b(f,a,c,e)})}})})();
|
||||||
(function(){var g=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.msIndexedDB,f={};"undefined"!==typeof g&&(f={current_db:null,connect:function(c,a,b){var d={},d=g.open(c,a||1);"undefined"!==typeof b&&(d.onupgradeneeded=b);d.onerror=function(){console.log("IndexedDB disallowed.")};d.onsuccess=function(){f.current_db=d.result}},create_store:function(c,a,b){var d={};"undefined"!==typeof a&&(d.keyPath=a);"undefined"!==typeof b&&(d.autoIncrement=!!b);return g.createObjectStore(c,
|
(function(){var g=window.indexedDB||window.webkitIndexedDB||window.mozIndexedDB||window.msIndexedDB,f={};"undefined"!==typeof g&&(f={current_db:null,connect:function(c,b,a){var d={},d=g.open(c,b||1);"undefined"!==typeof a&&(d.onupgradeneeded=a);d.onerror=function(){console.log("IndexedDB disallowed.")};d.onsuccess=function(){f.current_db=d.result}},create_store:function(c,b,a){var d={};"undefined"!==typeof b&&(d.keyPath=b);"undefined"!==typeof a&&(d.autoIncrement=!!a);return g.createObjectStore(c,
|
||||||
d)},delete_store:function(){g.deleteObjectStore().onerror=g.onerror}},$_.ext("indexedDB",f))})();
|
d)},delete_store:function(){g.deleteObjectStore().onerror=g.onerror}},$_.ext("indexedDB",f))})();
|
||||||
(function(){if("undefined"===typeof localStorage||"undefined"===typeof JSON)return null;var g=localStorage,f=sessionStorage;$_.ext("store",{get:function(c,a){var b=a?f.getItem(c):g.getItem(c);return JSON.parse(b)},set:function(c,a,b){a=JSON.stringify(a);b?f.setItem(c,a):g.setItem(c,a)},remove:function(c,a){a?f.removeItem(c):g.removeItem(c)},getAll:function(c){var a,b={},d,e;e=c?g:f;a=e.length;for(c=0;c<a;c++)d=e.key(c),b[d]=e.getItem(d);return b},clear:function(c){c?f.clear():g.clear()}})})();
|
(function(){if("undefined"===typeof localStorage||"undefined"===typeof JSON)return null;var g=localStorage,f=sessionStorage;$_.ext("store",{get:function(c,b){var a=b?f.getItem(c):g.getItem(c);return JSON.parse(a)},set:function(c,b,a){b=JSON.stringify(b);a?f.setItem(c,b):g.setItem(c,b)},remove:function(c,b){b?f.removeItem(c):g.removeItem(c)},getAll:function(c){var b,a={},d,e;e=c?g:f;b=e.length;for(c=0;c<b;c++)d=e.key(c),a[d]=e.getItem(d);return a},clear:function(c){c?f.clear():g.clear()}})})();
|
||||||
(function(){var g=function(c){var a=[],b=0,d={},e,a=f.object_keys(c);a.sort(function(a,b){var c=parseFloat(b),d=parseFloat(a),e=c+""===b,f=d+""===a;return e&&f?c>d?1:c<d?-1:0:e&&!f?1:!e&&f?-1:b>a?1:b<a?-1:0});b=a.length;for(e=0;e<b;e++)d[a[e]]=c[a[e]];return d},f={object_keys:function(c){var a=[],b;for(b in c)c.hasOwnProperty(b)&&a.push(b);return a},object_values:function(c){var a=[],b;for(b in c)a.push(c[b]);return a},array_combine:function(c,a){var b={},d,e=0;"array"!==$_.type(c)&&(c=this.object_values(c));
|
(function(){var g=function(c){var b=[],a=0,d={},e,b=f.object_keys(c);b.sort(function(a,b){var c=parseFloat(b),d=parseFloat(a),e=c+""===b,f=d+""===a;return e&&f?c>d?1:c<d?-1:0:e&&!f?1:!e&&f?-1:b>a?1:b<a?-1:0});a=b.length;for(e=0;e<a;e++)d[b[e]]=c[b[e]];return d},f={object_keys:function(c){var b=[],a;for(a in c)c.hasOwnProperty(a)&&b.push(a);return b},object_values:function(c){var b=[],a;for(a in c)b.push(c[a]);return b},array_combine:function(c,b){var a={},d,e=0;"array"!==$_.type(c)&&(c=this.object_values(c));
|
||||||
"array"!==$_.type(a)&&(a=this.object_values(a));d=c.length;if(d!==a.length)return console.log("Object combine requires two arrays of the same size"),!1;for(e=0;e<d;e++)b[c[e]]=a[e];return b},object_merge:function(){var c=Array.prototype.slice.call(arguments),a=c.length,b={},d,e=0,f,g,j;d=!0;for(f=0;f<a;f++)if("array"!==$_.type(c[f])){d=!1;break}if(d){b=[];for(f=0;f<a;f++)b=b.contact(c[f]);return b}for(j=f=0;f<a;f++)if(d=c[f],"array"==$_.type(d)){g=0;for(e=d.length;g<e;g++)b[j++]=d[g]}else for(g in d)d.hasOwnProperty(g)&&
|
"array"!==$_.type(b)&&(b=this.object_values(b));d=c.length;if(d!==b.length)return console.log("Object combine requires two arrays of the same size"),!1;for(e=0;e<d;e++)a[c[e]]=b[e];return a},object_merge:function(){var c=Array.prototype.slice.call(arguments),b=c.length,a={},d,e=0,f,g,j;d=!0;for(f=0;f<b;f++)if("array"!==$_.type(c[f])){d=!1;break}if(d){a=[];for(f=0;f<b;f++)a=a.contact(c[f]);return a}for(j=f=0;f<b;f++)if(d=c[f],"array"==$_.type(d)){g=0;for(e=d.length;g<e;g++)a[j++]=d[g]}else for(g in d)d.hasOwnProperty(g)&&
|
||||||
(parseInt(g,10)+""===g?b[j++]=d[g]:b[g]=d[g]);return b},str_trans:function(c,a,b){var d=[],e=[],f=!1,i=0,j=0,k="",l="",o="",m="",n;if("object"===typeof a){a=g(a);for(n in a)a.hasOwnProperty(n)&&(d.push(n),e.push(a[n]));a=d;b=e}j=c.length;i=a.length;k="string"===typeof b;l="string"===typeof a;for(d=0;d<j;d++){f=!1;if(l){c.charAt(d-1);o=c.charAt(d);c.charAt(d+1);for(e=0;e<i;e++)if(o==a.charAt(e)){f=!0;break}}else for(e=0;e<i;e++)if(c.substr(d,a[e].length)==a[e]){f=!0;d=d+a[e].length-1;break}m=f?m+(k?
|
(parseInt(g,10)+""===g?a[j++]=d[g]:a[g]=d[g]);return a},str_trans:function(c,b,a){var d=[],e=[],f=!1,i=0,j=0,k="",l="",o="",m="",n;if("object"===typeof b){b=g(b);for(n in b)b.hasOwnProperty(n)&&(d.push(n),e.push(b[n]));b=d;a=e}j=c.length;i=b.length;k="string"===typeof a;l="string"===typeof b;for(d=0;d<j;d++){f=!1;if(l){c.charAt(d-1);o=c.charAt(d);c.charAt(d+1);for(e=0;e<i;e++)if(o==b.charAt(e)){f=!0;break}}else for(e=0;e<i;e++)if(c.substr(d,b[e].length)==b[e]){f=!0;d=d+b[e].length-1;break}m=f?m+(k?
|
||||||
b.charAt(e):b[e]):m+c.charAt(d)}return m}};$_.ext("util",f)})();
|
a.charAt(e):a[e]):m+c.charAt(d)}return m}};$_.ext("util",f)})();
|
||||||
|
@ -129,12 +129,19 @@
|
|||||||
source = new EventSource(url);
|
source = new EventSource(url);
|
||||||
|
|
||||||
// Apply the callback
|
// Apply the callback
|
||||||
source.onmessage = callback;
|
source.onmessage = function(event){
|
||||||
|
callback(event.data);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else // Ajax polling fallback
|
else // Ajax polling fallback
|
||||||
{
|
{
|
||||||
poll_rate = poll_rate || 30000;
|
poll_rate = poll_rate || 30000;
|
||||||
setInterval($_.get, poll_rate, url, {}, callback);
|
|
||||||
|
setInterval($_.get, poll_rate, url, {}, function(res){
|
||||||
|
res.replace(/data:/gim, '');
|
||||||
|
res.replace(/^event|id|retry?:(.*)$/gim, '');
|
||||||
|
callback(res);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user