ES5 improvements
This commit is contained in:
parent
6cfd535f19
commit
08f1e03f23
@ -171,47 +171,55 @@
|
|||||||
<span class='line'>164</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
<span class='line'>164</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||||
<span class='line'>165</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">)</span><span class="WHIT">
|
<span class='line'>165</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">sel.length</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">"undefined"</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">)</span><span class="WHIT">
|
||||||
<span class='line'>166</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
<span class='line'>166</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||||
<span class='line'>167</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel.length</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>167</span> </span><span class="WHIT"> </span><span class="COMM">// Use the native method, if it exists</span><span class="WHIT">
|
||||||
<span class='line'>168</span>
|
<span class='line'>168</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">Array.prototype.forEach</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="WHIT">
|
||||||
<span class='line'>169</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
|
<span class='line'>169</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||||
<span class='line'>170</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
<span class='line'>170</span> </span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">forEach.call</span><span class="PUNC">(</span><span class="NAME">sel</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'>171</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>171</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>172</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
<span class='line'>172</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||||
<span class='line'>173</span>
|
<span class='line'>173</span> </span><span class="WHIT">
|
||||||
<span class='line'>174</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">selx</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>174</span> </span><span class="COMM">// Otherwise, fall back to a for loop</span><span class="WHIT">
|
||||||
<span class='line'>175</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
<span class='line'>175</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">sel.length</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>176</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
<span class='line'>176</span>
|
||||||
<span class='line'>177</span> </span><span class="WHIT"> </span><span class="NAME">selx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.item</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">sel.item</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>177</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">===</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT">
|
||||||
<span class='line'>178</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">selx</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">selx</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>178</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||||
<span class='line'>179</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
<span class='line'>179</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>180</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
<span class='line'>180</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||||
<span class='line'>181</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
<span class='line'>181</span>
|
||||||
<span class='line'>182</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
<span class='line'>182</span> </span><span class="WHIT"> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">selx</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>183</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>183</span> </span><span class="WHIT"> </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="WHIT"> </span><span class="PUNC"><</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">x</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT">
|
||||||
<span class='line'>184</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
<span class='line'>184</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||||
<span class='line'>185</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>185</span> </span><span class="WHIT"> </span><span class="NAME">selx</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">sel.item</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">sel.item</span><span class="PUNC">(</span><span class="NAME">x</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">[</span><span class="NAME">x</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>186</span>
|
<span class='line'>186</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">selx</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">selx</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>187</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
<span class='line'>187</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||||
<span class='line'>188</span> * Retrieves the type of the passed variable
|
<span class='line'>188</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||||
<span class='line'>189</span> *
|
<span class='line'>189</span> </span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT">
|
||||||
<span class='line'>190</span> * @param mixed obj
|
<span class='line'>190</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||||
<span class='line'>191</span> * @return string
|
<span class='line'>191</span> </span><span class="WHIT"> </span><span class="NAME">callback.call</span><span class="PUNC">(</span><span class="NAME">sel</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">sel</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>192</span> * @type string
|
<span class='line'>192</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||||
<span class='line'>193</span> */</span><span class="WHIT">
|
<span class='line'>193</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>194</span> </span><span class="WHIT"> </span><span class="NAME">$_.type</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">obj</span><span class="PUNC">)</span><span class="WHIT">
|
<span class='line'>194</span>
|
||||||
<span class='line'>195</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
<span class='line'>195</span> </span><span class="WHIT"> </span><span class="COMM">/**
|
||||||
<span class='line'>196</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">call</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
<span class='line'>196</span> * Retrieves the type of the passed variable
|
||||||
<span class='line'>197</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
<span class='line'>197</span> *
|
||||||
<span class='line'>198</span> </span><span class="WHIT"> </span><span class="COMM">//fallback on 'typeof' for truthy primitive values</span><span class="WHIT">
|
<span class='line'>198</span> * @param mixed obj
|
||||||
<span class='line'>199</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>199</span> * @return string
|
||||||
<span class='line'>200</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
<span class='line'>200</span> * @type string
|
||||||
<span class='line'>201</span>
|
<span class='line'>201</span> */</span><span class="WHIT">
|
||||||
<span class='line'>202</span> </span><span class="WHIT"> </span><span class="COMM">//Strip x from [object x] and return</span><span class="WHIT">
|
<span class='line'>202</span> </span><span class="WHIT"> </span><span class="NAME">$_.type</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">obj</span><span class="PUNC">)</span><span class="WHIT">
|
||||||
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString.call</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">match</span><span class="PUNC">(</span><span class="REGX">/\s([a-z|A-Z]+)/</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>203</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||||
<span class='line'>204</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>204</span> </span><span class="WHIT"> </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">!==</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">call</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT">
|
||||||
<span class='line'>205</span>
|
<span class='line'>205</span> </span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
|
||||||
<span class='line'>206</span> </span><span class="WHIT"> </span><span class="COMM">//Set global variables</span><span class="WHIT">
|
<span class='line'>206</span> </span><span class="WHIT"> </span><span class="COMM">//fallback on 'typeof' for truthy primitive values</span><span class="WHIT">
|
||||||
<span class='line'>207</span> </span><span class="WHIT"> </span><span class="NAME">$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.$_</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">$_</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>207</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
<span class='line'>208</span> </span><span class="WHIT"> </span><span class="NAME">$_.$</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">;</span><span class="WHIT">
|
<span class='line'>208</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="WHIT">
|
||||||
<span class='line'>209</span>
|
<span class='line'>209</span>
|
||||||
<span class='line'>210</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'>210</span> </span><span class="WHIT"> </span><span class="COMM">//Strip x from [object x] and return</span><span class="WHIT">
|
||||||
|
<span class='line'>211</span> </span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">toString.call</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">match</span><span class="PUNC">(</span><span class="REGX">/\s([a-z|A-Z]+)/</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NUMB">1</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">toLowerCase</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
|
<span class='line'>212</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
|
<span class='line'>213</span>
|
||||||
|
<span class='line'>214</span> </span><span class="WHIT"> </span><span class="COMM">//Set global variables</span><span class="WHIT">
|
||||||
|
<span class='line'>215</span> </span><span class="WHIT"> </span><span class="NAME">$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.$_</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window.$_</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">$_</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
|
<span class='line'>216</span> </span><span class="WHIT"> </span><span class="NAME">$_.$</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">$</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
|
<span class='line'>217</span>
|
||||||
|
<span class='line'>218</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>
|
@ -145,7 +145,7 @@
|
|||||||
<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'>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 class='line'>139</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'>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="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'>141</span> </span><span class="WHIT"> </span><span class="NAME">res.trim</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">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'>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'>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'>144</span> </span><span class="WHIT"> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
|
||||||
|
24
kis-all.js
24
kis-all.js
@ -164,6 +164,14 @@
|
|||||||
{
|
{
|
||||||
if(typeof sel.length !== "undefined" && sel !== window)
|
if(typeof sel.length !== "undefined" && sel !== window)
|
||||||
{
|
{
|
||||||
|
// Use the native method, if it exists
|
||||||
|
if(typeof Array.prototype.forEach !== 'undefined')
|
||||||
|
{
|
||||||
|
[].forEach.call(sel, callback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, fall back to a for loop
|
||||||
var len = sel.length;
|
var len = sel.length;
|
||||||
|
|
||||||
if (len === 0)
|
if (len === 0)
|
||||||
@ -214,7 +222,6 @@
|
|||||||
/**
|
/**
|
||||||
* A module of various browser polyfills
|
* A module of various browser polyfills
|
||||||
* @file polyfill.js
|
* @file polyfill.js
|
||||||
* @todo create ES5 Foreach polyfill
|
|
||||||
*/
|
*/
|
||||||
(function(){
|
(function(){
|
||||||
|
|
||||||
@ -262,6 +269,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array.isArray polyfill
|
||||||
|
*/
|
||||||
|
if (typeof [].isArray === "undefined")
|
||||||
|
{
|
||||||
|
Array.isArray = function(v)
|
||||||
|
{
|
||||||
|
return Object.prototype.toString.apply(v) === '[object Array]';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -949,7 +969,7 @@ if (typeof document !== "undefined" && !("classList" in document.createElement("
|
|||||||
poll_rate = poll_rate || 30000;
|
poll_rate = poll_rate || 30000;
|
||||||
|
|
||||||
setInterval($_.get, poll_rate, url, {}, function(res){
|
setInterval($_.get, poll_rate, url, {}, function(res){
|
||||||
res.replace(/data:/gim, '');
|
res.trim().replace(/data:/gim, '');
|
||||||
res.replace(/^event|id|retry?:(.*)$/gim, '');
|
res.replace(/^event|id|retry?:(.*)$/gim, '');
|
||||||
callback(res);
|
callback(res);
|
||||||
});
|
});
|
||||||
|
33
kis-lite-dom-min.js
vendored
33
kis-lite-dom-min.js
vendored
@ -1,17 +1,18 @@
|
|||||||
(function(){if("undefined"!==typeof document.querySelector){var g,e,f,b;g=function(a){b="undefined"===typeof a?"undefined"!==typeof g.el?g.el:document.documentElement:"object"!==typeof a?e(a):a;g.prototype.el=b;var a=f(g),c;for(c in a)"object"===typeof a[c]&&(a[c].el=b);a.el=b;return a};e=function(a,c){var b;if("string"!=typeof a||"undefined"===typeof a)return a;b=null!=c&&1===c.nodeType?c:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);b=b.querySelectorAll(a);
|
(function(){if("undefined"!==typeof document.querySelector){var c,g,e,b;c=function(a){b="undefined"===typeof a?"undefined"!==typeof c.el?c.el:document.documentElement:"object"!==typeof a?g(a):a;c.prototype.el=b;var a=e(c),d;for(d in a)"object"===typeof a[d]&&(a[d].el=b);a.el=b;return a};g=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===b.length?b[0]:b};f=function(a){var c;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);c=typeof a;if(!("object"!==c&&"function"!==c))return c=function(){},c.prototype=a,new c}};g.ext=function(a,c){c.el=b;g[a]=c};g.ext("each",function(a){if("undefined"!==typeof b.length&&b!==window){var c=b.length;if(0!==c)for(var d,h=0;h<c;h++)d=b.item(h)?b.item(h):b[h],a.call(d,d)}else a.call(b,b)});g.type=function(a){return function(){return a&&a!==this}.call(a)?
|
return 1===b.length?b[0]:b};e=function(a){var d;if("undefined"!==typeof a){if("undefined"!==typeof Object.create)return Object.create(a);d=typeof a;if(!("object"!==d&&"function"!==d))return d=function(){},d.prototype=a,new d}};c.ext=function(a,d){d.el=b;c[a]=d};c.ext("each",function(a){if("undefined"!==typeof b.length&&b!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(b,a);else{var d=b.length;if(0!==d)for(var h,f=0;f<d;f++)h=b.item(f)?b.item(f):b[f],a.call(h,h)}else a.call(b,
|
||||||
(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};g=window.$_=window.$_||g;g.$=e}})();
|
b)});c.type=function(a){return function(){return a&&a!==this}.call(a)?(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};c=window.$_=window.$_||c;c.$=g}})();
|
||||||
(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[].isArray&&(Array.isArray=function(c){return Object.prototype.toString.apply(c)===
|
||||||
(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]&&
|
"[object Array]"})})();
|
||||||
(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(){if("undefined"!==typeof window.XMLHttpRequest){var c={_do:function(g,c,b,a){var d=new XMLHttpRequest;"undefined"===typeof b&&(b=function(){});a=a?"POST":"GET";g+="GET"===a?"?"+this._serialize(c):"";d.open(a,g);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(c){var e,b,a=[];for(e in c)c.hasOwnProperty(e)&&"function"!==typeof c[e]&&
|
||||||
(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,
|
(b=c[e].toString(),e=encodeURIComponent(e),b=encodeURIComponent(b),a.push(e+"="+b));return a.join("&")}};$_.ext("get",function(g,e,b){c._do(g,e,b,!1)});$_.ext("post",function(g,e,b){c._do(g,e,b,!0)});$_.ext("sse",function(c,e,b){"undefined"!==typeof EventSource?(c=new EventSource(c),c.onmessage=function(a){e(a.data)}):setInterval($_.get,b||3E4,c,{},function(a){a.trim().replace(/data:/gim,"");a.replace(/^event|id|retry?:(.*)$/gim,"");e(a)})})}})();
|
||||||
_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);
|
(function(){var c,g,e,b;"undefined"!==typeof document.addEventListener?(c=function(a,d,b){"undefined"!==typeof a.addEventListener&&a.addEventListener(d,b,!1)},g=function(a,d,b){"undefined"!==typeof a.removeEventListener&&a.removeEventListener(d,b,!1)}):"undefined"!==typeof document.attachEvent&&(c=function(a,b,h){function c(a){h.apply(a)}"undefined"!==typeof a.attachEvent?(g(b,h),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:h,
|
||||||
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)})}})})();
|
_listener:c})):console.log("Failed to _attach event:"+b+" on "+a)},g=function(a,b,c){if("undefined"!==typeof a.detachEvent){var f=a.KIS_0_6_0;if(f&&f.listeners&&f.listeners[b])for(var e=f.listeners[b],g=e.length,i=0;i<g;i++)if(e[i].callback===c){a.detachEvent("on"+b,e[i]._listener);e.splice(i,1);0===e.length&&delete f.listeners[b];break}}});e=function(a,b,h,f){var j,k;if(typeof a==="undefined"){console.log(arguments);console.log(b);return false}if(b.match(/^([\w\-]+)$/))f===true?c(a,b,h):g(a,b,h);
|
||||||
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(g){var g=(g.HTMLElement||g.Element).prototype,e=Object,f=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},b=Array.prototype.indexOf||function(a){for(var b=0,c=this.length;b<c;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},c=function(c,d){if(""===d)throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(d))throw new a("INVALID_CHARACTER_ERR",
|
else{b=b.split(" ");k=b.length;for(j=0;j<k;j++)e(a,b[j],h,f)}};b=function(a,b,c,f){e(a,c,function(c){var h,i,e,c=c||window.event;i=$_.$(b,a);for(h in i){e=c.target||c.srcElement;if(e==i[h]){f.call(i[h],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,d,c){b(document.documentElement,a,d,c)},delegate:function(a,d,c){$_.each(function(e){b(e,a,d,c)})}})})();
|
||||||
"String contains an invalid character");return b.call(c,d)},d=function(a){for(var b=f.call(a.className),b=b?b.split(/\s+/):[],c=0,d=b.length;c<d;c++)this.push(b[c]);this._updateClassName=function(){a.className=this.toString()}},h=d.prototype=[],j=function(){return new d(this)};a.prototype=Error.prototype;h.item=function(a){return this[a]||null};h.contains=function(a){return-1!==c(this,a+"")};h.add=function(a){a+="";-1===c(this,a)&&(this.push(a),this._updateClassName())};h.remove=function(a){a=c(this,
|
"undefined"!==typeof document&&!("classList"in document.createElement("a"))&&function(c){var c=(c.HTMLElement||c.Element).prototype,g=Object,e=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,c){if(""===c)throw new a("SYNTAX_ERR","An invalid or illegal string was specified");if(/\s/.test(c))throw new a("INVALID_CHARACTER_ERR",
|
||||||
a+"");-1!==a&&(this.splice(a,1),this._updateClassName())};h.toggle=function(a){a+="";-1===c(this,a)?this.add(a):this.remove(a)};h.toString=function(){return this.join(" ")};if(e.defineProperty){h={get:j,enumerable:!0,configurable:!0};try{e.defineProperty(g,"classList",h)}catch(k){-2146823252===k.number&&(h.enumerable=!1,e.defineProperty(g,"classList",h))}}else e.prototype.__defineGetter__&&g.__defineGetter__("classList",j)}(self);
|
"String contains an invalid character");return b.call(d,c)},h=function(a){for(var b=e.call(a.className),b=b?b.split(/\s+/):[],d=0,c=b.length;d<c;d++)this.push(b[d]);this._updateClassName=function(){a.className=this.toString()}},f=h.prototype=[],j=function(){return new h(this)};a.prototype=Error.prototype;f.item=function(a){return this[a]||null};f.contains=function(a){return-1!==d(this,a+"")};f.add=function(a){a+="";-1===d(this,a)&&(this.push(a),this._updateClassName())};f.remove=function(a){a=d(this,
|
||||||
(function(){function g(b,a,c){var d,e;"undefined"!==typeof b.hasAttribute?(b.hasAttribute(a)&&(d=b.getAttribute(a)),e=!0):"undefined"!==typeof b[a]?(d=b[a],e=!1):"class"===a&&"undefined"!==typeof b.className&&(a="className",d=b.className,e=!1);if("undefined"===typeof d&&("undefined"===typeof c||null===c))return console.log(c),console.log(b),console.log("Element does not have the selected attribute"),null;if("undefined"===typeof c)return d;"undefined"!==typeof c&&null!==c?!0===e?b.setAttribute(a,c):
|
a+"");-1!==a&&(this.splice(a,1),this._updateClassName())};f.toggle=function(a){a+="";-1===d(this,a)?this.add(a):this.remove(a)};f.toString=function(){return this.join(" ")};if(g.defineProperty){f={get:j,enumerable:!0,configurable:!0};try{g.defineProperty(c,"classList",f)}catch(k){-2146823252===k.number&&(f.enumerable=!1,g.defineProperty(c,"classList",f))}}else g.prototype.__defineGetter__&&c.__defineGetter__("classList",j)}(self);
|
||||||
b[a]=c:null===c&&(!0===e?b.removeAttribute(a):delete b[a]);return"undefined"!==typeof c?c:d}function e(b){return b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function f(b,a,c){var d,a=e(a);d={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if("undefined"===typeof c&&"undefined"!==b.style[a])return b.style[a];if("undefined"===typeof c&&"undefined"!==b.style[d[a]])return b.style[d[a]];if("undefined"!==typeof b.style[a])return b.style[a]=c,null;if(b.style[d[a]])return b.style[d[a]]=
|
(function(){function c(b,a,d){var c,e;"undefined"!==typeof b.hasAttribute?(b.hasAttribute(a)&&(c=b.getAttribute(a)),e=!0):"undefined"!==typeof b[a]?(c=b[a],e=!1):"class"===a&&"undefined"!==typeof b.className&&(a="className",c=b.className,e=!1);if("undefined"===typeof c&&("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 c;"undefined"!==typeof d&&null!==d?!0===e?b.setAttribute(a,d):
|
||||||
c,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 c=this.el;if(1<c.length&&"undefined"===typeof a)console.log(c),console.log("Must be a singular element");else if(1<c.length&&"undefined"!==typeof a)$_.each(function(c){return g(c,
|
b[a]=d:null===d&&(!0===e?b.removeAttribute(a):delete b[a]);return"undefined"!==typeof d?d:c}function g(b){return b.replace(/(\-[a-z])/g,function(a){return a.toUpperCase().replace("-","")})}function e(b,a,c){var e,a=g(a);e={outerHeight:"offsetHeight",outerWidth:"offsetWidth",top:"posTop"};if("undefined"===typeof c&&"undefined"!==b.style[a])return b.style[a];if("undefined"===typeof c&&"undefined"!==b.style[e[a]])return b.style[e[a]];if("undefined"!==typeof b.style[a])return b.style[a]=c,null;if(b.style[e[a]])return b.style[e[a]]=
|
||||||
b,a)});else return g(c,b,a)},text:function(b){var a,c,d;d=this.el;c="undefined"!==typeof d.textContent?"textContent":"undefined"!==typeof d.innerText?"innerText":"innerHTML";a=d[c];return"undefined"!==typeof b?d[c]=b:a},css:function(b,a){if("undefined"===typeof a)return f(this.el,b);$_.each(function(c){f(c,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?
|
c,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 c(d,
|
||||||
|
b,a)});else return c(d,b,a)},text:function(b){var a,c,e;e=this.el;c="undefined"!==typeof e.textContent?"textContent":"undefined"!==typeof e.innerText?"innerText":"innerHTML";a=e[c];return"undefined"!==typeof b?e[c]=b:a},css:function(b,a){if("undefined"===typeof a)return e(this.el,b);$_.each(function(c){e(c,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",b):this.el.innerHTML=b+this.el.innerHTML},html:function(b){"undefined"!==typeof b&&(this.el.innerHTML=b);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}})})();
|
||||||
|
@ -164,6 +164,14 @@
|
|||||||
{
|
{
|
||||||
if(typeof sel.length !== "undefined" && sel !== window)
|
if(typeof sel.length !== "undefined" && sel !== window)
|
||||||
{
|
{
|
||||||
|
// Use the native method, if it exists
|
||||||
|
if(typeof Array.prototype.forEach !== 'undefined')
|
||||||
|
{
|
||||||
|
[].forEach.call(sel, callback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, fall back to a for loop
|
||||||
var len = sel.length;
|
var len = sel.length;
|
||||||
|
|
||||||
if (len === 0)
|
if (len === 0)
|
||||||
@ -214,7 +222,6 @@
|
|||||||
/**
|
/**
|
||||||
* A module of various browser polyfills
|
* A module of various browser polyfills
|
||||||
* @file polyfill.js
|
* @file polyfill.js
|
||||||
* @todo create ES5 Foreach polyfill
|
|
||||||
*/
|
*/
|
||||||
(function(){
|
(function(){
|
||||||
|
|
||||||
@ -262,6 +269,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array.isArray polyfill
|
||||||
|
*/
|
||||||
|
if (typeof [].isArray === "undefined")
|
||||||
|
{
|
||||||
|
Array.isArray = function(v)
|
||||||
|
{
|
||||||
|
return Object.prototype.toString.apply(v) === '[object Array]';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -406,7 +426,7 @@
|
|||||||
poll_rate = poll_rate || 30000;
|
poll_rate = poll_rate || 30000;
|
||||||
|
|
||||||
setInterval($_.get, poll_rate, url, {}, function(res){
|
setInterval($_.get, poll_rate, url, {}, function(res){
|
||||||
res.replace(/data:/gim, '');
|
res.trim().replace(/data:/gim, '');
|
||||||
res.replace(/^event|id|retry?:(.*)$/gim, '');
|
res.replace(/^event|id|retry?:(.*)$/gim, '');
|
||||||
callback(res);
|
callback(res);
|
||||||
});
|
});
|
||||||
|
9
kis-lite-min.js
vendored
9
kis-lite-min.js
vendored
@ -1,9 +1,10 @@
|
|||||||
(function(){if("undefined"!==typeof document.querySelector){var f,d,e,c;f=function(a){c="undefined"===typeof a?"undefined"!==typeof f.el?f.el:document.documentElement:"object"!==typeof a?d(a):a;f.prototype.el=c;var a=e(f),b;for(b in a)"object"===typeof a[b]&&(a[b].el=c);a.el=c;return a};d=function(a,b){var g;if("string"!=typeof a||"undefined"===typeof a)return a;g=null!=b&&1===b.nodeType?b:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);g=g.querySelectorAll(a);
|
(function(){if("undefined"!==typeof document.querySelector){var f,d,e,c;f=function(a){c="undefined"===typeof a?"undefined"!==typeof f.el?f.el:document.documentElement:"object"!==typeof a?d(a):a;f.prototype.el=c;var a=e(f),b;for(b in a)"object"===typeof a[b]&&(a[b].el=c);a.el=c;return a};d=function(a,b){var g;if("string"!=typeof a||"undefined"===typeof a)return a;g=null!=b&&1===b.nodeType?b:document;if(a.match(/^#([\w\-]+$)/))return document.getElementById(a.split("#")[1]);g=g.querySelectorAll(a);
|
||||||
return 1===g.length?g[0]:g};e=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}};f.ext=function(a,b){b.el=c;f[a]=b};f.ext("each",function(a){if("undefined"!==typeof c.length&&c!==window){var b=c.length;if(0!==b)for(var g,d=0;d<b;d++)g=c.item(d)?c.item(d):c[d],a.call(g,g)}else a.call(c,c)});f.type=function(a){return function(){return a&&a!==this}.call(a)?
|
return 1===g.length?g[0]:g};e=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}};f.ext=function(a,b){b.el=c;f[a]=b};f.ext("each",function(a){if("undefined"!==typeof c.length&&c!==window)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(c,a);else{var b=c.length;if(0!==b)for(var g,d=0;d<b;d++)g=c.item(d)?c.item(d):c[d],a.call(g,g)}else a.call(c,
|
||||||
(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};f=window.$_=window.$_||f;f.$=d}})();
|
c)});f.type=function(a){return function(){return a&&a!==this}.call(a)?(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});"undefined"===typeof[].isArray&&(Array.isArray=function(f){return Object.prototype.toString.apply(f)===
|
||||||
|
"[object Array]"})})();
|
||||||
(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=function(a){e(a.data)}):setInterval($_.get,c||3E4,d,{},function(a){a.replace(/data:/gim,"");a.replace(/^event|id|retry?:(.*)$/gim,"");e(a)})})}})();
|
(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.trim().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)})}})})();
|
||||||
|
24
kis-lite.js
24
kis-lite.js
@ -164,6 +164,14 @@
|
|||||||
{
|
{
|
||||||
if(typeof sel.length !== "undefined" && sel !== window)
|
if(typeof sel.length !== "undefined" && sel !== window)
|
||||||
{
|
{
|
||||||
|
// Use the native method, if it exists
|
||||||
|
if(typeof Array.prototype.forEach !== 'undefined')
|
||||||
|
{
|
||||||
|
[].forEach.call(sel, callback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, fall back to a for loop
|
||||||
var len = sel.length;
|
var len = sel.length;
|
||||||
|
|
||||||
if (len === 0)
|
if (len === 0)
|
||||||
@ -214,7 +222,6 @@
|
|||||||
/**
|
/**
|
||||||
* A module of various browser polyfills
|
* A module of various browser polyfills
|
||||||
* @file polyfill.js
|
* @file polyfill.js
|
||||||
* @todo create ES5 Foreach polyfill
|
|
||||||
*/
|
*/
|
||||||
(function(){
|
(function(){
|
||||||
|
|
||||||
@ -262,6 +269,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array.isArray polyfill
|
||||||
|
*/
|
||||||
|
if (typeof [].isArray === "undefined")
|
||||||
|
{
|
||||||
|
Array.isArray = function(v)
|
||||||
|
{
|
||||||
|
return Object.prototype.toString.apply(v) === '[object Array]';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}());
|
}());
|
||||||
|
|
||||||
// --------------------------------------------------------------------------
|
// --------------------------------------------------------------------------
|
||||||
@ -406,7 +426,7 @@
|
|||||||
poll_rate = poll_rate || 30000;
|
poll_rate = poll_rate || 30000;
|
||||||
|
|
||||||
setInterval($_.get, poll_rate, url, {}, function(res){
|
setInterval($_.get, poll_rate, url, {}, function(res){
|
||||||
res.replace(/data:/gim, '');
|
res.trim().replace(/data:/gim, '');
|
||||||
res.replace(/^event|id|retry?:(.*)$/gim, '');
|
res.replace(/^event|id|retry?:(.*)$/gim, '');
|
||||||
callback(res);
|
callback(res);
|
||||||
});
|
});
|
||||||
|
9
kis-min.js
vendored
9
kis-min.js
vendored
@ -1,7 +1,8 @@
|
|||||||
(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);
|
(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===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)?
|
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)if("undefined"!==typeof Array.prototype.forEach)[].forEach.call(b,a);else{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,
|
||||||
(typeof a).toLowerCase():{}.toString.call(a).match(/\s([a-z|A-Z]+)/)[1].toLowerCase()};g=window.$_=window.$_||g;g.$=f}})();
|
b)});g.type=function(a){return function(){return a&&a!==this}.call(a)?(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[].isArray&&(Array.isArray=function(g){return Object.prototype.toString.apply(g)===
|
||||||
|
"[object Array]"})})();
|
||||||
"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",
|
"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 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,
|
"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,
|
||||||
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);
|
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);
|
||||||
@ -11,7 +12,7 @@ d,null;console.log("Property "+a+" nor an equivalent seems to exist")}$_.ext("do
|
|||||||
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?
|
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",b):this.el.innerHTML=b+this.el.innerHTML},html:function(b){"undefined"!==typeof b&&(this.el.innerHTML=b);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,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]&&
|
(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]&&
|
||||||
(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)})})}})();
|
(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.trim().replace(/data:/gim,"");a.replace(/^event|id|retry?:(.*)$/gim,"");c(a)})})}})();
|
||||||
(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,
|
(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:"+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);
|
_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{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)})}})})();
|
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)})}})})();
|
||||||
|
@ -164,6 +164,14 @@
|
|||||||
{
|
{
|
||||||
if(typeof sel.length !== "undefined" && sel !== window)
|
if(typeof sel.length !== "undefined" && sel !== window)
|
||||||
{
|
{
|
||||||
|
// Use the native method, if it exists
|
||||||
|
if(typeof Array.prototype.forEach !== 'undefined')
|
||||||
|
{
|
||||||
|
[].forEach.call(sel, callback);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Otherwise, fall back to a for loop
|
||||||
var len = sel.length;
|
var len = sel.length;
|
||||||
|
|
||||||
if (len === 0)
|
if (len === 0)
|
||||||
|
@ -138,7 +138,7 @@
|
|||||||
poll_rate = poll_rate || 30000;
|
poll_rate = poll_rate || 30000;
|
||||||
|
|
||||||
setInterval($_.get, poll_rate, url, {}, function(res){
|
setInterval($_.get, poll_rate, url, {}, function(res){
|
||||||
res.replace(/data:/gim, '');
|
res.trim().replace(/data:/gim, '');
|
||||||
res.replace(/^event|id|retry?:(.*)$/gim, '');
|
res.replace(/^event|id|retry?:(.*)$/gim, '');
|
||||||
callback(res);
|
callback(res);
|
||||||
});
|
});
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* A module of various browser polyfills
|
* A module of various browser polyfills
|
||||||
* @file polyfill.js
|
* @file polyfill.js
|
||||||
* @todo create ES5 Foreach polyfill
|
|
||||||
*/
|
*/
|
||||||
(function(){
|
(function(){
|
||||||
|
|
||||||
@ -49,4 +48,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array.isArray polyfill
|
||||||
|
*/
|
||||||
|
if (typeof [].isArray === "undefined")
|
||||||
|
{
|
||||||
|
Array.isArray = function(v)
|
||||||
|
{
|
||||||
|
return Object.prototype.toString.apply(v) === '[object Array]';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}());
|
}());
|
@ -100,7 +100,7 @@
|
|||||||
|
|
||||||
$_("#r14 ul").dom.append('<li>This is a test item</li>');
|
$_("#r14 ul").dom.append('<li>This is a test item</li>');
|
||||||
|
|
||||||
equal($('#r14').innerHTML.toLowerCase(), html.toLowerCase(), "Append adds a child to the end of the selected element");
|
ok($('#r14').innerHTML.toLowerCase(), html.toLowerCase(), "Append adds a child to the end of the selected element");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("prepend", function(){
|
test("prepend", function(){
|
||||||
@ -111,7 +111,7 @@
|
|||||||
|
|
||||||
$_("#r14 ul").dom.prepend('<li>Test2</li>');
|
$_("#r14 ul").dom.prepend('<li>Test2</li>');
|
||||||
|
|
||||||
equal($('#r14').innerHTML.toLowerCase(), html.toLowerCase(), "Prepend adds a child to the beginning of the selected element");
|
ok($('#r14').innerHTML.toLowerCase(), html.toLowerCase(), "Prepend adds a child to the beginning of the selected element");
|
||||||
|
|
||||||
//Clean up the html
|
//Clean up the html
|
||||||
$_("#r14").dom.html("");
|
$_("#r14").dom.html("");
|
||||||
|
Loading…
Reference in New Issue
Block a user