Produced by Araxis Merge on 10/24/2017 6:38:26 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | CHAMP_VA1.zip\CHAMP_VA1\node_modules\gulp-webserver\node_modules\tiny-lr\lib\public | livereload.js | Mon Oct 16 21:06:50 2017 UTC |
| 2 | CHAMP_VA1.zip\CHAMP_VA1\node_modules\gulp-webserver\node_modules\tiny-lr\lib\public | livereload.js | Mon Oct 23 19:48:12 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 2230 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /*! Copyri ght (c) 20 10-2012 An drey Taran tsovCopyri ght (c) 20 10-2012 An drey Taran tsov */ | |
| 2 | /*! https: //github.c om/liverel oad/livere load-js / http://liv ereload.co m */ | |
| 3 | (function( ) { | |
| 4 | var __cust omevents = {}, __pro tocol = {} , __connec tor = {}, __timer = {}, __opti ons = {}, __reloader = {}, __l ivereload = {}, __le ss = {}, _ _startup = {}; | |
| 5 | ||
| 6 | // custome vents | |
| 7 | var Custom Events; | |
| 8 | CustomEven ts = { | |
| 9 | bind: fu nction(ele ment, even tName, han dler) { | |
| 10 | if (el ement.addE ventListen er) { | |
| 11 | retu rn element .addEventL istener(ev entName, h andler, fa lse); | |
| 12 | } else if (eleme nt.attachE vent) { | |
| 13 | elem ent[eventN ame] = 1; | |
| 14 | retu rn element .attachEve nt('onprop ertychange ', functio n(event) { | |
| 15 | if (event.pr opertyName === event Name) { | |
| 16 | return han dler(); | |
| 17 | } | |
| 18 | }); | |
| 19 | } else { | |
| 20 | thro w new Erro r("Attempt to attach custom ev ent " + ev entName + " to somet hing which isn't a D OMElement" ); | |
| 21 | } | |
| 22 | }, | |
| 23 | fire: fu nction(ele ment, even tName) { | |
| 24 | var ev ent; | |
| 25 | if (el ement.addE ventListen er) { | |
| 26 | even t = docume nt.createE vent('HTML Events'); | |
| 27 | even t.initEven t(eventNam e, true, t rue); | |
| 28 | retu rn documen t.dispatch Event(even t); | |
| 29 | } else if (eleme nt.attachE vent) { | |
| 30 | if ( element[ev entName]) { | |
| 31 | re turn eleme nt[eventNa me]++; | |
| 32 | } | |
| 33 | } else { | |
| 34 | thro w new Erro r("Attempt to fire c ustom even t " + even tName + " on somethi ng which i sn't a DOM Element"); | |
| 35 | } | |
| 36 | } | |
| 37 | }; | |
| 38 | __customev ents.bind = CustomEv ents.bind; | |
| 39 | __customev ents.fire = CustomEv ents.fire; | |
| 40 | ||
| 41 | // protoco l | |
| 42 | var PROTOC OL_6, PROT OCOL_7, Pa rser, Prot ocolError; | |
| 43 | var __inde xOf = Arra y.prototyp e.indexOf || functio n(item) { | |
| 44 | for (var i = 0, l = this.len gth; i < l ; i++) { | |
| 45 | if (th is[i] === item) retu rn i; | |
| 46 | } | |
| 47 | return - 1; | |
| 48 | }; | |
| 49 | __protocol .PROTOCOL_ 6 = PROTOC OL_6 = 'ht tp://liver eload.com/ protocols/ official-6 '; | |
| 50 | __protocol .PROTOCOL_ 7 = PROTOC OL_7 = 'ht tp://liver eload.com/ protocols/ official-7 '; | |
| 51 | __protocol .ProtocolE rror = Pro tocolError = (functi on() { | |
| 52 | function ProtocolE rror(reaso n, data) { | |
| 53 | this.m essage = " LiveReload protocol error (" + reason + ") after r eceiving d ata: \"" + data + "\ "."; | |
| 54 | } | |
| 55 | return P rotocolErr or; | |
| 56 | })(); | |
| 57 | __protocol .Parser = Parser = ( function() { | |
| 58 | function Parser(ha ndlers) { | |
| 59 | this.h andlers = handlers; | |
| 60 | this.r eset(); | |
| 61 | } | |
| 62 | Parser.p rototype.r eset = fun ction() { | |
| 63 | return this.prot ocol = nul l; | |
| 64 | }; | |
| 65 | Parser.p rototype.p rocess = f unction(da ta) { | |
| 66 | var co mmand, mes sage, opti ons, _ref; | |
| 67 | try { | |
| 68 | if ( !(this.pro tocol != n ull)) { | |
| 69 | if (data.mat ch(/^!!ver :([\d.]+)$ /)) { | |
| 70 | this.proto col = 6; | |
| 71 | } else if (m essage = t his._parse Message(da ta, ['hell o'])) { | |
| 72 | if (!messa ge.protoco ls.length) { | |
| 73 | throw ne w Protocol Error("no protocols specified in handsha ke message "); | |
| 74 | } else if (__indexOf .call(mess age.protoc ols, PROTO COL_7) >= 0) { | |
| 75 | this.pro tocol = 7; | |
| 76 | } else if (__indexOf .call(mess age.protoc ols, PROTO COL_6) >= 0) { | |
| 77 | this.pro tocol = 6; | |
| 78 | } else { | |
| 79 | throw ne w Protocol Error("no supported protocols found"); | |
| 80 | } | |
| 81 | } | |
| 82 | re turn this. handlers.c onnected(t his.protoc ol); | |
| 83 | } el se if (thi s.protocol === 6) { | |
| 84 | me ssage = JS ON.parse(d ata); | |
| 85 | if (!message .length) { | |
| 86 | throw new ProtocolEr ror("proto col 6 mess ages must be arrays" ); | |
| 87 | } | |
| 88 | co mmand = me ssage[0], options = message[1] ; | |
| 89 | if (command !== 'refre sh') { | |
| 90 | throw new ProtocolEr ror("unkno wn protoco l 6 comman d"); | |
| 91 | } | |
| 92 | re turn this. handlers.m essage({ | |
| 93 | command: ' reload', | |
| 94 | path: opti ons.path, | |
| 95 | liveCSS: ( _ref = opt ions.apply _css_live) != null ? _ref : tr ue | |
| 96 | }) ; | |
| 97 | } el se { | |
| 98 | me ssage = th is._parseM essage(dat a, ['reloa d', 'alert ']); | |
| 99 | re turn this. handlers.m essage(mes sage); | |
| 100 | } | |
| 101 | } catc h (e) { | |
| 102 | if ( e instance of Protoco lError) { | |
| 103 | re turn this. handlers.e rror(e); | |
| 104 | } el se { | |
| 105 | th row e; | |
| 106 | } | |
| 107 | } | |
| 108 | }; | |
| 109 | Parser.p rototype._ parseMessa ge = funct ion(data, validComma nds) { | |
| 110 | var me ssage, _re f; | |
| 111 | try { | |
| 112 | mess age = JSON .parse(dat a); | |
| 113 | } catc h (e) { | |
| 114 | thro w new Prot ocolError( 'unparsabl e JSON', d ata); | |
| 115 | } | |
| 116 | if (!m essage.com mand) { | |
| 117 | thro w new Prot ocolError( 'missing " command" k ey', data) ; | |
| 118 | } | |
| 119 | if (_r ef = messa ge.command , __indexO f.call(val idCommands , _ref) < 0) { | |
| 120 | thro w new Prot ocolError( "invalid c ommand '" + message. command + "', only v alid comma nds are: " + (validC ommands.jo in(', ')) + ")", dat a); | |
| 121 | } | |
| 122 | return message; | |
| 123 | }; | |
| 124 | return P arser; | |
| 125 | })(); | |
| 126 | ||
| 127 | // connect or | |
| 128 | // Generat ed by Coff eeScript 1 .3.3 | |
| 129 | var Connec tor, PROTO COL_6, PRO TOCOL_7, P arser, Ver sion, _ref ; | |
| 130 | ||
| 131 | _ref = __p rotocol, P arser = _r ef.Parser, PROTOCOL_ 6 = _ref.P ROTOCOL_6, PROTOCOL_ 7 = _ref.P ROTOCOL_7; | |
| 132 | ||
| 133 | Version = '2.0.8'; | |
| 134 | ||
| 135 | __connecto r.Connecto r = Connec tor = (fun ction() { | |
| 136 | ||
| 137 | function Connector (options, WebSocket, Timer, ha ndlers) { | |
| 138 | var _t his = this ; | |
| 139 | this.o ptions = o ptions; | |
| 140 | this.W ebSocket = WebSocket ; | |
| 141 | this.T imer = Tim er; | |
| 142 | this.h andlers = handlers; | |
| 143 | this._ uri = "ws" + (this.o ptions.htt ps ? "s" : "") + ":/ /" + this. options.ho st + ":" + this.opti ons.port + "/liverel oad"; | |
| 144 | this._ nextDelay = this.opt ions.minde lay; | |
| 145 | this._ connection Desired = false; | |
| 146 | this.p rotocol = 0; | |
| 147 | this.p rotocolPar ser = new Parser({ | |
| 148 | conn ected: fun ction(prot ocol) { | |
| 149 | _t his.protoc ol = proto col; | |
| 150 | _t his._hands hakeTimeou t.stop(); | |
| 151 | _t his._nextD elay = _th is.options .mindelay; | |
| 152 | _t his._disco nnectionRe ason = 'br oken'; | |
| 153 | re turn _this .handlers. connected( protocol); | |
| 154 | }, | |
| 155 | erro r: functio n(e) { | |
| 156 | _t his.handle rs.error(e ); | |
| 157 | re turn _this ._closeOnE rror(); | |
| 158 | }, | |
| 159 | mess age: funct ion(messag e) { | |
| 160 | re turn _this .handlers. message(me ssage); | |
| 161 | } | |
| 162 | }); | |
| 163 | this._ handshakeT imeout = n ew Timer(f unction() { | |
| 164 | if ( !_this._is SocketConn ected()) { | |
| 165 | re turn; | |
| 166 | } | |
| 167 | _thi s._disconn ectionReas on = 'hand shake-time out'; | |
| 168 | retu rn _this.s ocket.clos e(); | |
| 169 | }); | |
| 170 | this._ reconnectT imer = new Timer(fun ction() { | |
| 171 | if ( !_this._co nnectionDe sired) { | |
| 172 | re turn; | |
| 173 | } | |
| 174 | retu rn _this.c onnect(); | |
| 175 | }); | |
| 176 | this.c onnect(); | |
| 177 | } | |
| 178 | ||
| 179 | Connecto r.prototyp e._isSocke tConnected = functio n() { | |
| 180 | return this.sock et && this .socket.re adyState = == this.We bSocket.OP EN; | |
| 181 | }; | |
| 182 | ||
| 183 | Connecto r.prototyp e.connect = function () { | |
| 184 | var _t his = this ; | |
| 185 | this._ connection Desired = true; | |
| 186 | if (th is._isSock etConnecte d()) { | |
| 187 | retu rn; | |
| 188 | } | |
| 189 | this._ reconnectT imer.stop( ); | |
| 190 | this._ disconnect ionReason = 'cannot- connect'; | |
| 191 | this.p rotocolPar ser.reset( ); | |
| 192 | this.h andlers.co nnecting() ; | |
| 193 | this.s ocket = ne w this.Web Socket(thi s._uri); | |
| 194 | this.s ocket.onop en = funct ion(e) { | |
| 195 | retu rn _this._ onopen(e); | |
| 196 | }; | |
| 197 | this.s ocket.oncl ose = func tion(e) { | |
| 198 | retu rn _this._ onclose(e) ; | |
| 199 | }; | |
| 200 | this.s ocket.onme ssage = fu nction(e) { | |
| 201 | retu rn _this._ onmessage( e); | |
| 202 | }; | |
| 203 | return this.sock et.onerror = functio n(e) { | |
| 204 | retu rn _this._ onerror(e) ; | |
| 205 | }; | |
| 206 | }; | |
| 207 | ||
| 208 | Connecto r.prototyp e.disconne ct = funct ion() { | |
| 209 | this._ connection Desired = false; | |
| 210 | this._ reconnectT imer.stop( ); | |
| 211 | if (!t his._isSoc ketConnect ed()) { | |
| 212 | retu rn; | |
| 213 | } | |
| 214 | this._ disconnect ionReason = 'manual' ; | |
| 215 | return this.sock et.close() ; | |
| 216 | }; | |
| 217 | ||
| 218 | Connecto r.prototyp e._schedul eReconnect ion = func tion() { | |
| 219 | if (!t his._conne ctionDesir ed) { | |
| 220 | retu rn; | |
| 221 | } | |
| 222 | if (!t his._recon nectTimer. running) { | |
| 223 | this ._reconnec tTimer.sta rt(this._n extDelay); | |
| 224 | retu rn this._n extDelay = Math.min( this.optio ns.maxdela y, this._n extDelay * 2); | |
| 225 | } | |
| 226 | }; | |
| 227 | ||
| 228 | Connecto r.prototyp e.sendComm and = func tion(comma nd) { | |
| 229 | if (th is.protoco l == null) { | |
| 230 | retu rn; | |
| 231 | } | |
| 232 | return this._sen dCommand(c ommand); | |
| 233 | }; | |
| 234 | ||
| 235 | Connecto r.prototyp e._sendCom mand = fun ction(comm and) { | |
| 236 | return this.sock et.send(JS ON.stringi fy(command )); | |
| 237 | }; | |
| 238 | ||
| 239 | Connecto r.prototyp e._closeOn Error = fu nction() { | |
| 240 | this._ handshakeT imeout.sto p(); | |
| 241 | this._ disconnect ionReason = 'error'; | |
| 242 | return this.sock et.close() ; | |
| 243 | }; | |
| 244 | ||
| 245 | Connecto r.prototyp e._onopen = function (e) { | |
| 246 | var he llo; | |
| 247 | this.h andlers.so cketConnec ted(); | |
| 248 | this._ disconnect ionReason = 'handsha ke-failed' ; | |
| 249 | hello = { | |
| 250 | comm and: 'hell o', | |
| 251 | prot ocols: [PR OTOCOL_6, PROTOCOL_7 ] | |
| 252 | }; | |
| 253 | hello. ver = Vers ion; | |
| 254 | if (th is.options .ext) { | |
| 255 | hell o.ext = th is.options .ext; | |
| 256 | } | |
| 257 | if (th is.options .extver) { | |
| 258 | hell o.extver = this.opti ons.extver ; | |
| 259 | } | |
| 260 | if (th is.options .snipver) { | |
| 261 | hell o.snipver = this.opt ions.snipv er; | |
| 262 | } | |
| 263 | this._ sendComman d(hello); | |
| 264 | return this._han dshakeTime out.start( this.optio ns.handsha ke_timeout ); | |
| 265 | }; | |
| 266 | ||
| 267 | Connecto r.prototyp e._onclose = functio n(e) { | |
| 268 | this.p rotocol = 0; | |
| 269 | this.h andlers.di sconnected (this._dis connection Reason, th is._nextDe lay); | |
| 270 | return this._sch eduleRecon nection(); | |
| 271 | }; | |
| 272 | ||
| 273 | Connecto r.prototyp e._onerror = functio n(e) {}; | |
| 274 | ||
| 275 | Connecto r.prototyp e._onmessa ge = funct ion(e) { | |
| 276 | return this.prot ocolParser .process(e .data); | |
| 277 | }; | |
| 278 | ||
| 279 | return C onnector; | |
| 280 | ||
| 281 | })(); | |
| 282 | ||
| 283 | // timer | |
| 284 | var Timer; | |
| 285 | var __bind = functio n(fn, me){ return fu nction(){ return fn. apply(me, arguments) ; }; }; | |
| 286 | __timer.Ti mer = Time r = (funct ion() { | |
| 287 | function Timer(fun c) { | |
| 288 | this.f unc = func ; | |
| 289 | this.r unning = f alse; | |
| 290 | this.i d = null; | |
| 291 | this._ handler = __bind(fun ction() { | |
| 292 | this .running = false; | |
| 293 | this .id = null ; | |
| 294 | retu rn this.fu nc(); | |
| 295 | }, thi s); | |
| 296 | } | |
| 297 | Timer.pr ototype.st art = func tion(timeo ut) { | |
| 298 | if (th is.running ) { | |
| 299 | clea rTimeout(t his.id); | |
| 300 | } | |
| 301 | this.i d = setTim eout(this. _handler, timeout); | |
| 302 | return this.runn ing = true ; | |
| 303 | }; | |
| 304 | Timer.pr ototype.st op = funct ion() { | |
| 305 | if (th is.running ) { | |
| 306 | clea rTimeout(t his.id); | |
| 307 | this .running = false; | |
| 308 | retu rn this.id = null; | |
| 309 | } | |
| 310 | }; | |
| 311 | return T imer; | |
| 312 | })(); | |
| 313 | Timer.star t = functi on(timeout , func) { | |
| 314 | return s etTimeout( func, time out); | |
| 315 | }; | |
| 316 | ||
| 317 | // options | |
| 318 | var Option s; | |
| 319 | __options. Options = Options = (function( ) { | |
| 320 | function Options() { | |
| 321 | this.h ttps = fal se; | |
| 322 | this.h ost = null ; | |
| 323 | this.port = PORT ; | |
| 324 | this.s nipver = n ull; | |
| 325 | this.e xt = null; | |
| 326 | this.e xtver = nu ll; | |
| 327 | this.m indelay = 1000; | |
| 328 | this.m axdelay = 60000; | |
| 329 | this.h andshake_t imeout = 5 000; | |
| 330 | this.a nimate = f alse; | |
| 331 | } | |
| 332 | Options. prototype. set = func tion(name, value) { | |
| 333 | switch (typeof t his[name]) { | |
| 334 | case 'undefine d': | |
| 335 | br eak; | |
| 336 | case 'number': | |
| 337 | re turn this[ name] = +v alue; | |
| 338 | defa ult: | |
| 339 | re turn this[ name] = va lue; | |
| 340 | } | |
| 341 | }; | |
| 342 | return O ptions; | |
| 343 | })(); | |
| 344 | Options.ex tract = fu nction(doc ument) { | |
| 345 | var elem ent, keyAn dValue, m, mm, optio ns, pair, src, _i, _ j, _len, _ len2, _ref , _ref2; | |
| 346 | _ref = d ocument.ge tElementsB yTagName(' script'); | |
| 347 | for (_i = 0, _len = _ref.len gth; _i < _len; _i++ ) { | |
| 348 | elemen t = _ref[_ i]; | |
| 349 | if ((s rc = eleme nt.src) && (m = src. match(/^[^ :]+:\/\/(. *)\/z?live reload\.js (?:\?(.*)) ?$/))) { | |
| 350 | opti ons = new Options(); | |
| 351 | opti ons.https = src.inde xOf("https ") === 0; | |
| 352 | if ( mm = m[1]. match(/^([ ^\/:]+)(?: :(\d+))?$/ )) { | |
| 353 | op tions.host = mm[1]; | |
| 354 | if (mm[2]) { | |
| 355 | options.po rt = parse Int(mm[2], 10); | |
| 356 | } | |
| 357 | } | |
| 358 | if ( m[2]) { | |
| 359 | _r ef2 = m[2] .split('&' ); | |
| 360 | fo r (_j = 0, _len2 = _ ref2.lengt h; _j < _l en2; _j++) { | |
| 361 | pair = _re f2[_j]; | |
| 362 | if ((keyAn dValue = p air.split( '=')).leng th > 1) { | |
| 363 | options. set(keyAnd Value[0].r eplace(/-/ g, '_'), k eyAndValue .slice(1). join('=')) ; | |
| 364 | } | |
| 365 | } | |
| 366 | } | |
| 367 | retu rn options ; | |
| 368 | } | |
| 369 | } | |
| 370 | return n ull; | |
| 371 | }; | |
| 372 | ||
| 373 | // reloade r | |
| 374 | // Generat ed by Coff eeScript 1 .3.1 | |
| 375 | (function( ) { | |
| 376 | var IMAG E_STYLES, Reloader, numberOfMa tchingSegm ents, path FromUrl, p athsMatch, pickBestM atch, spli tUrl; | |
| 377 | ||
| 378 | splitUrl = functio n(url) { | |
| 379 | var ha sh, index, params; | |
| 380 | if ((i ndex = url .indexOf(' #')) >= 0) { | |
| 381 | hash = url.sli ce(index); | |
| 382 | url = url.slic e(0, index ); | |
| 383 | } else { | |
| 384 | hash = ''; | |
| 385 | } | |
| 386 | if ((i ndex = url .indexOf(' ?')) >= 0) { | |
| 387 | para ms = url.s lice(index ); | |
| 388 | url = url.slic e(0, index ); | |
| 389 | } else { | |
| 390 | para ms = ''; | |
| 391 | } | |
| 392 | return { | |
| 393 | url: url, | |
| 394 | para ms: params , | |
| 395 | hash : hash | |
| 396 | }; | |
| 397 | }; | |
| 398 | ||
| 399 | pathFrom Url = func tion(url) { | |
| 400 | var pa th; | |
| 401 | url = splitUrl(u rl).url; | |
| 402 | if (ur l.indexOf( 'file://') === 0) { | |
| 403 | path = url.rep lace(/^fil e:\/\/(loc alhost)?/, ''); | |
| 404 | } else { | |
| 405 | path = url.rep lace(/^([^ :]+:)?\/\/ ([^:\/]+)( :\d*)?\//, '/'); | |
| 406 | } | |
| 407 | return decodeURI Component( path); | |
| 408 | }; | |
| 409 | ||
| 410 | pickBest Match = fu nction(pat h, objects , pathFunc ) { | |
| 411 | var be stMatch, o bject, sco re, _i, _l en; | |
| 412 | bestMa tch = { | |
| 413 | scor e: 0 | |
| 414 | }; | |
| 415 | for (_ i = 0, _le n = object s.length; _i < _len; _i++) { | |
| 416 | obje ct = objec ts[_i]; | |
| 417 | scor e = number OfMatching Segments(p ath, pathF unc(object )); | |
| 418 | if ( score > be stMatch.sc ore) { | |
| 419 | be stMatch = { | |
| 420 | object: ob ject, | |
| 421 | score: sco re | |
| 422 | }; | |
| 423 | } | |
| 424 | } | |
| 425 | if (be stMatch.sc ore > 0) { | |
| 426 | retu rn bestMat ch; | |
| 427 | } else { | |
| 428 | retu rn null; | |
| 429 | } | |
| 430 | }; | |
| 431 | ||
| 432 | numberOf MatchingSe gments = f unction(pa th1, path2 ) { | |
| 433 | var co mps1, comp s2, eqCoun t, len; | |
| 434 | ||
| 435 | // nor malize win dows paths | |
| 436 | path1 = path1.re place(/\\/ g,'\/'); | |
| 437 | path2 = path2.re place(/\\/ g,'\/'); | |
| 438 | ||
| 439 | path1 = path1.re place(/^\/ +/, '').to LowerCase( ); | |
| 440 | path2 = path2.re place(/^\/ +/, '').to LowerCase( ); | |
| 441 | if (pa th1 === pa th2) { | |
| 442 | retu rn 10000; | |
| 443 | } | |
| 444 | comps1 = path1.s plit('/'). reverse(); | |
| 445 | comps2 = path2.s plit('/'). reverse(); | |
| 446 | len = Math.min(c omps1.leng th, comps2 .length); | |
| 447 | eqCoun t = 0; | |
| 448 | while (eqCount < len && co mps1[eqCou nt] === co mps2[eqCou nt]) { | |
| 449 | ++eq Count; | |
| 450 | } | |
| 451 | return eqCount; | |
| 452 | }; | |
| 453 | ||
| 454 | pathsMat ch = funct ion(path1, path2) { | |
| 455 | return numberOfM atchingSeg ments(path 1, path2) > 0; | |
| 456 | }; | |
| 457 | ||
| 458 | IMAGE_ST YLES = [ | |
| 459 | { | |
| 460 | sele ctor: 'bac kground', | |
| 461 | styl eNames: [' background Image'] | |
| 462 | }, { | |
| 463 | sele ctor: 'bor der', | |
| 464 | styl eNames: [' borderImag e', 'webki tBorderIma ge', 'MozB orderImage '] | |
| 465 | } | |
| 466 | ]; | |
| 467 | ||
| 468 | __reload er.Reloade r = Reload er = (func tion() { | |
| 469 | ||
| 470 | Reload er.name = 'Reloader' ; | |
| 471 | ||
| 472 | functi on Reloade r(window, console, T imer) { | |
| 473 | this .window = window; | |
| 474 | this .console = console; | |
| 475 | this .Timer = T imer; | |
| 476 | this .document = this.win dow.docume nt; | |
| 477 | this .importCac heWaitPeri od = 200; | |
| 478 | this .plugins = []; | |
| 479 | } | |
| 480 | ||
| 481 | Reload er.prototy pe.addPlug in = funct ion(plugin ) { | |
| 482 | retu rn this.pl ugins.push (plugin); | |
| 483 | }; | |
| 484 | ||
| 485 | Reload er.prototy pe.analyze = functio n(callback ) { | |
| 486 | retu rn results ; | |
| 487 | }; | |
| 488 | ||
| 489 | Reload er.prototy pe.reload = function (path, opt ions) { | |
| 490 | var plugin, _b ase, _i, _ len, _ref; | |
| 491 | this .options = options; | |
| 492 | if ( (_base = t his.option s).stylesh eetReloadT imeout == null) { | |
| 493 | _b ase.styles heetReload Timeout = 15000; | |
| 494 | } | |
| 495 | _ref = this.pl ugins; | |
| 496 | for (_i = 0, _ len = _ref .length; _ i < _len; _i++) { | |
| 497 | pl ugin = _re f[_i]; | |
| 498 | if (plugin.r eload && p lugin.relo ad(path, o ptions)) { | |
| 499 | return; | |
| 500 | } | |
| 501 | } | |
| 502 | if ( options.li veCSS) { | |
| 503 | if (path.mat ch(/\.css$ /i)) { | |
| 504 | if (this.r eloadStyle sheet(path )) { | |
| 505 | return; | |
| 506 | } | |
| 507 | } | |
| 508 | } | |
| 509 | if ( options.li veImg) { | |
| 510 | if (path.mat ch(/\.(jpe ?g|png|gif |svg)$/i)) { | |
| 511 | this.reloa dImages(pa th); | |
| 512 | return; | |
| 513 | } | |
| 514 | } | |
| 515 | retu rn this.re loadPage() ; | |
| 516 | }; | |
| 517 | ||
| 518 | Reload er.prototy pe.reloadP age = func tion() { | |
| 519 | retu rn this.wi ndow.docum ent.locati on.reload( ); | |
| 520 | }; | |
| 521 | ||
| 522 | Reload er.prototy pe.reloadI mages = fu nction(pat h) { | |
| 523 | var expando, i mg, select or, styleN ames, styl eSheet, _i , _j, _k, _l, _len, _len1, _le n2, _len3, _ref, _re f1, _ref2, _ref3, _r esults; | |
| 524 | expa ndo = this .generateU niqueStrin g(); | |
| 525 | _ref = this.do cument.ima ges; | |
| 526 | for (_i = 0, _ len = _ref .length; _ i < _len; _i++) { | |
| 527 | im g = _ref[_ i]; | |
| 528 | if (pathsMat ch(path, p athFromUrl (img.src)) ) { | |
| 529 | img.src = this.gener ateCacheBu stUrl(img. src, expan do); | |
| 530 | } | |
| 531 | } | |
| 532 | if ( this.docum ent.queryS electorAll ) { | |
| 533 | fo r (_j = 0, _len1 = I MAGE_STYLE S.length; _j < _len1 ; _j++) { | |
| 534 | _ref1 = IM AGE_STYLES [_j], sele ctor = _re f1.selecto r, styleNa mes = _ref 1.styleNam es; | |
| 535 | _ref2 = th is.documen t.querySel ectorAll(" [style*=" + selector + "]"); | |
| 536 | for (_k = 0, _len2 = _ref2.len gth; _k < _len2; _k+ +) { | |
| 537 | img = _r ef2[_k]; | |
| 538 | this.rel oadStyleIm ages(img.s tyle, styl eNames, pa th, expand o); | |
| 539 | } | |
| 540 | } | |
| 541 | } | |
| 542 | if ( this.docum ent.styleS heets) { | |
| 543 | _r ef3 = this .document. styleSheet s; | |
| 544 | _r esults = [ ]; | |
| 545 | fo r (_l = 0, _len3 = _ ref3.lengt h; _l < _l en3; _l++) { | |
| 546 | styleSheet = _ref3[_ l]; | |
| 547 | _results.p ush(this.r eloadStyle sheetImage s(styleShe et, path, expando)); | |
| 548 | } | |
| 549 | re turn _resu lts; | |
| 550 | } | |
| 551 | }; | |
| 552 | ||
| 553 | Reload er.prototy pe.reloadS tylesheetI mages = fu nction(sty leSheet, p ath, expan do) { | |
| 554 | var rule, rule s, styleNa mes, _i, _ j, _len, _ len1; | |
| 555 | try { | |
| 556 | ru les = styl eSheet != null ? sty leSheet.cs sRules : v oid 0; | |
| 557 | } ca tch (e) { | |
| 558 | ||
| 559 | } | |
| 560 | if ( !rules) { | |
| 561 | re turn; | |
| 562 | } | |
| 563 | for (_i = 0, _ len = rule s.length; _i < _len; _i++) { | |
| 564 | ru le = rules [_i]; | |
| 565 | sw itch (rule .type) { | |
| 566 | case CSSRu le.IMPORT_ RULE: | |
| 567 | this.rel oadStylesh eetImages( rule.style Sheet, pat h, expando ); | |
| 568 | break; | |
| 569 | case CSSRu le.STYLE_R ULE: | |
| 570 | for (_j = 0, _len1 = IMAGE_S TYLES.leng th; _j < _ len1; _j++ ) { | |
| 571 | styleN ames = IMA GE_STYLES[ _j].styleN ames; | |
| 572 | this.r eloadStyle Images(rul e.style, s tyleNames, path, exp ando); | |
| 573 | } | |
| 574 | break; | |
| 575 | case CSSRu le.MEDIA_R ULE: | |
| 576 | this.rel oadStylesh eetImages( rule, path , expando) ; | |
| 577 | } | |
| 578 | } | |
| 579 | }; | |
| 580 | ||
| 581 | Reload er.prototy pe.reloadS tyleImages = functio n(style, s tyleNames, path, exp ando) { | |
| 582 | var newValue, styleName, value, _i , _len, | |
| 583 | _t his = this ; | |
| 584 | for (_i = 0, _ len = styl eNames.len gth; _i < _len; _i++ ) { | |
| 585 | st yleName = styleNames [_i]; | |
| 586 | va lue = styl e[styleNam e]; | |
| 587 | if (typeof v alue === ' string') { | |
| 588 | newValue = value.rep lace(/\bur l\s*\(([^) ]*)\)/, fu nction(mat ch, src) { | |
| 589 | if (path sMatch(pat h, pathFro mUrl(src)) ) { | |
| 590 | return "url(" + (_this.gen erateCache BustUrl(sr c, expando )) + ")"; | |
| 591 | } else { | |
| 592 | return match; | |
| 593 | } | |
| 594 | }); | |
| 595 | if (newVal ue !== val ue) { | |
| 596 | style[st yleName] = newValue; | |
| 597 | } | |
| 598 | } | |
| 599 | } | |
| 600 | }; | |
| 601 | ||
| 602 | Reload er.prototy pe.reloadS tylesheet = function (path) { | |
| 603 | var imported, link, link s, match, style, _i, _j, _k, _ l, _len, _ len1, _len 2, _len3, _ref, _ref 1, | |
| 604 | _t his = this ; | |
| 605 | link s = (funct ion() { | |
| 606 | va r _i, _len , _ref, _r esults; | |
| 607 | _r ef = this. document.g etElements ByTagName( 'link'); | |
| 608 | _r esults = [ ]; | |
| 609 | fo r (_i = 0, _len = _r ef.length; _i < _len ; _i++) { | |
| 610 | link = _re f[_i]; | |
| 611 | if (link.r el === 'st ylesheet' && !link._ _LiveReloa d_pendingR emoval) { | |
| 612 | _results .push(link ); | |
| 613 | } | |
| 614 | } | |
| 615 | re turn _resu lts; | |
| 616 | }).c all(this); | |
| 617 | impo rted = []; | |
| 618 | _ref = this.do cument.get ElementsBy TagName('s tyle'); | |
| 619 | for (_i = 0, _ len = _ref .length; _ i < _len; _i++) { | |
| 620 | st yle = _ref [_i]; | |
| 621 | if (style.sh eet) { | |
| 622 | this.colle ctImported Stylesheet s(style, s tyle.sheet , imported ); | |
| 623 | } | |
| 624 | } | |
| 625 | for (_j = 0, _ len1 = lin ks.length; _j < _len 1; _j++) { | |
| 626 | li nk = links [_j]; | |
| 627 | th is.collect ImportedSt ylesheets( link, link .sheet, im ported); | |
| 628 | } | |
| 629 | if ( this.windo w.StyleFix && this.d ocument.qu erySelecto rAll) { | |
| 630 | _r ef1 = this .document. querySelec torAll('st yle[data-h ref]'); | |
| 631 | fo r (_k = 0, _len2 = _ ref1.lengt h; _k < _l en2; _k++) { | |
| 632 | style = _r ef1[_k]; | |
| 633 | links.push (style); | |
| 634 | } | |
| 635 | } | |
| 636 | this .console.l og("LiveRe load found " + links .length + " LINKed s tylesheets , " + impo rted.lengt h + " @imp orted styl esheets"); | |
| 637 | matc h = pickBe stMatch(pa th, links. concat(imp orted), fu nction(l) { | |
| 638 | re turn pathF romUrl(_th is.linkHre f(l)); | |
| 639 | }); | |
| 640 | if ( match) { | |
| 641 | if (match.ob ject.rule) { | |
| 642 | this.conso le.log("Li veReload i s reloadin g imported styleshee t: " + mat ch.object. href); | |
| 643 | this.reatt achImporte dRule(matc h.object); | |
| 644 | } else { | |
| 645 | this.conso le.log("Li veReload i s reloadin g styleshe et: " + (t his.linkHr ef(match.o bject))); | |
| 646 | this.reatt achStylesh eetLink(ma tch.object ); | |
| 647 | } | |
| 648 | } el se { | |
| 649 | th is.console .log("Live Reload wil l reload a ll stylesh eets becau se path '" + path + "' did not match any specific one"); | |
| 650 | fo r (_l = 0, _len3 = l inks.lengt h; _l < _l en3; _l++) { | |
| 651 | link = lin ks[_l]; | |
| 652 | this.reatt achStylesh eetLink(li nk); | |
| 653 | } | |
| 654 | } | |
| 655 | retu rn true; | |
| 656 | }; | |
| 657 | ||
| 658 | Reload er.prototy pe.collect ImportedSt ylesheets = function (link, sty leSheet, r esult) { | |
| 659 | var index, rul e, rules, _i, _len; | |
| 660 | try { | |
| 661 | ru les = styl eSheet != null ? sty leSheet.cs sRules : v oid 0; | |
| 662 | } ca tch (e) { | |
| 663 | ||
| 664 | } | |
| 665 | if ( rules && r ules.lengt h) { | |
| 666 | fo r (index = _i = 0, _ len = rule s.length; _i < _len; index = + +_i) { | |
| 667 | rule = rul es[index]; | |
| 668 | switch (ru le.type) { | |
| 669 | case CSS Rule.CHARS ET_RULE: | |
| 670 | contin ue; | |
| 671 | case CSS Rule.IMPOR T_RULE: | |
| 672 | result .push({ | |
| 673 | link : link, | |
| 674 | rule : rule, | |
| 675 | inde x: index, | |
| 676 | href : rule.hre f | |
| 677 | }); | |
| 678 | this.c ollectImpo rtedStyles heets(link , rule.sty leSheet, r esult); | |
| 679 | break; | |
| 680 | default: | |
| 681 | break; | |
| 682 | } | |
| 683 | } | |
| 684 | } | |
| 685 | }; | |
| 686 | ||
| 687 | Reload er.prototy pe.waitUnt ilCssLoads = functio n(clone, f unc) { | |
| 688 | var callbackEx ecuted, ex ecuteCallb ack, poll, | |
| 689 | _t his = this ; | |
| 690 | call backExecut ed = false ; | |
| 691 | exec uteCallbac k = functi on() { | |
| 692 | if (callback Executed) { | |
| 693 | return; | |
| 694 | } | |
| 695 | ca llbackExec uted = tru e; | |
| 696 | re turn func( ); | |
| 697 | }; | |
| 698 | clon e.onload = function( ) { | |
| 699 | _t his.knownT oSupportCs sOnLoad = true; | |
| 700 | re turn execu teCallback (); | |
| 701 | }; | |
| 702 | if ( !this.know nToSupport CssOnLoad) { | |
| 703 | (p oll = func tion() { | |
| 704 | if (clone. sheet) { | |
| 705 | return e xecuteCall back(); | |
| 706 | } else { | |
| 707 | return _ this.Timer .start(50, poll); | |
| 708 | } | |
| 709 | }) (); | |
| 710 | } | |
| 711 | retu rn this.Ti mer.start( this.optio ns.stylesh eetReloadT imeout, ex ecuteCallb ack); | |
| 712 | }; | |
| 713 | ||
| 714 | Reload er.prototy pe.linkHre f = functi on(link) { | |
| 715 | retu rn link.hr ef || link .getAttrib ute('data- href'); | |
| 716 | }; | |
| 717 | ||
| 718 | Reload er.prototy pe.reattac hStyleshee tLink = fu nction(lin k) { | |
| 719 | var clone, par ent, | |
| 720 | _t his = this ; | |
| 721 | if ( link.__Liv eReload_pe ndingRemov al) { | |
| 722 | re turn; | |
| 723 | } | |
| 724 | link .__LiveRel oad_pendin gRemoval = true; | |
| 725 | if ( link.tagNa me === 'ST YLE') { | |
| 726 | cl one = this .document. createElem ent('link' ); | |
| 727 | cl one.rel = 'styleshee t'; | |
| 728 | cl one.media = link.med ia; | |
| 729 | cl one.disabl ed = link. disabled; | |
| 730 | } el se { | |
| 731 | cl one = link .cloneNode (false); | |
| 732 | } | |
| 733 | clon e.href = t his.genera teCacheBus tUrl(this. linkHref(l ink)); | |
| 734 | pare nt = link. parentNode ; | |
| 735 | if ( parent.las tChild === link) { | |
| 736 | pa rent.appen dChild(clo ne); | |
| 737 | } el se { | |
| 738 | pa rent.inser tBefore(cl one, link. nextSiblin g); | |
| 739 | } | |
| 740 | retu rn this.wa itUntilCss Loads(clon e, functio n() { | |
| 741 | va r addition alWaitingT ime; | |
| 742 | if (/AppleWe bKit/.test (navigator .userAgent )) { | |
| 743 | additional WaitingTim e = 5; | |
| 744 | } else { | |
| 745 | additional WaitingTim e = 200; | |
| 746 | } | |
| 747 | re turn _this .Timer.sta rt(additio nalWaiting Time, func tion() { | |
| 748 | var _ref; | |
| 749 | if (!link. parentNode ) { | |
| 750 | return; | |
| 751 | } | |
| 752 | link.paren tNode.remo veChild(li nk); | |
| 753 | clone.onre adystatech ange = nul l; | |
| 754 | return (_r ef = _this .window.St yleFix) != null ? _r ef.link(cl one) : voi d 0; | |
| 755 | }) ; | |
| 756 | }); | |
| 757 | }; | |
| 758 | ||
| 759 | Reload er.prototy pe.reattac hImportedR ule = func tion(_arg) { | |
| 760 | var href, inde x, link, m edia, newR ule, paren t, rule, t empLink, | |
| 761 | _t his = this ; | |
| 762 | rule = _arg.ru le, index = _arg.ind ex, link = _arg.link ; | |
| 763 | pare nt = rule. parentStyl eSheet; | |
| 764 | href = this.ge nerateCach eBustUrl(r ule.href); | |
| 765 | medi a = rule.m edia.lengt h ? [].joi n.call(rul e.media, ' , ') : ''; | |
| 766 | newR ule = "@im port url(\ "" + href + "\") " + media + " ;"; | |
| 767 | rule .__LiveRel oad_newHre f = href; | |
| 768 | temp Link = thi s.document .createEle ment("link "); | |
| 769 | temp Link.rel = 'styleshe et'; | |
| 770 | temp Link.href = href; | |
| 771 | temp Link.__Liv eReload_pe ndingRemov al = true; | |
| 772 | if ( link.paren tNode) { | |
| 773 | li nk.parentN ode.insert Before(tem pLink, lin k); | |
| 774 | } | |
| 775 | retu rn this.Ti mer.start( this.impor tCacheWait Period, fu nction() { | |
| 776 | if (tempLink .parentNod e) { | |
| 777 | tempLink.p arentNode. removeChil d(tempLink ); | |
| 778 | } | |
| 779 | if (rule.__L iveReload_ newHref != = href) { | |
| 780 | return; | |
| 781 | } | |
| 782 | pa rent.inser tRule(newR ule, index ); | |
| 783 | pa rent.delet eRule(inde x + 1); | |
| 784 | ru le = paren t.cssRules [index]; | |
| 785 | ru le.__LiveR eload_newH ref = href ; | |
| 786 | re turn _this .Timer.sta rt(_this.i mportCache WaitPeriod , function () { | |
| 787 | if (rule._ _LiveReloa d_newHref !== href) { | |
| 788 | return; | |
| 789 | } | |
| 790 | parent.ins ertRule(ne wRule, ind ex); | |
| 791 | return par ent.delete Rule(index + 1); | |
| 792 | }) ; | |
| 793 | }); | |
| 794 | }; | |
| 795 | ||
| 796 | Reload er.prototy pe.generat eUniqueStr ing = func tion() { | |
| 797 | retu rn 'livere load=' + D ate.now(); | |
| 798 | }; | |
| 799 | ||
| 800 | Reload er.prototy pe.generat eCacheBust Url = func tion(url, expando) { | |
| 801 | var hash, oldP arams, par ams, _ref; | |
| 802 | if ( expando == null) { | |
| 803 | ex pando = th is.generat eUniqueStr ing(); | |
| 804 | } | |
| 805 | _ref = splitUr l(url), ur l = _ref.u rl, hash = _ref.hash , oldParam s = _ref.p arams; | |
| 806 | if ( this.optio ns.overrid eURL) { | |
| 807 | if (url.inde xOf(this.o ptions.ser verURL) < 0) { | |
| 808 | url = this .options.s erverURL + this.opti ons.overri deURL + "? url=" + en codeURICom ponent(url ); | |
| 809 | } | |
| 810 | } | |
| 811 | para ms = oldPa rams.repla ce(/(\?|&) livereload =(\d+)/, f unction(ma tch, sep) { | |
| 812 | re turn "" + sep + expa ndo; | |
| 813 | }); | |
| 814 | if ( params === oldParams ) { | |
| 815 | if (oldParam s.length = == 0) { | |
| 816 | params = " ?" + expan do; | |
| 817 | } else { | |
| 818 | params = " " + oldPar ams + "&" + expando; | |
| 819 | } | |
| 820 | } | |
| 821 | retu rn url + p arams + ha sh; | |
| 822 | }; | |
| 823 | ||
| 824 | return Reloader; | |
| 825 | ||
| 826 | })(); | |
| 827 | ||
| 828 | }).call(th is); | |
| 829 | ||
| 830 | // liverel oad | |
| 831 | var Connec tor, LiveR eload, Opt ions, Relo ader, Time r; | |
| 832 | ||
| 833 | Connector = __connec tor.Connec tor; | |
| 834 | ||
| 835 | Timer = __ timer.Time r; | |
| 836 | ||
| 837 | Options = __options. Options; | |
| 838 | ||
| 839 | Reloader = __reloade r.Reloader ; | |
| 840 | ||
| 841 | __liverelo ad.LiveRel oad = Live Reload = ( function() { | |
| 842 | ||
| 843 | function LiveReloa d(window) { | |
| 844 | var _t his = this ; | |
| 845 | this.w indow = wi ndow; | |
| 846 | this.l isteners = {}; | |
| 847 | this.p lugins = [ ]; | |
| 848 | this.p luginIdent ifiers = { }; | |
| 849 | this.c onsole = t his.window .location. href.match (/LR-verbo se/) && th is.window. console && this.wind ow.console .log && th is.window. console.er ror ? this .window.co nsole : { | |
| 850 | log: function( ) {}, | |
| 851 | erro r: functio n() {} | |
| 852 | }; | |
| 853 | if (!( this.WebSo cket = thi s.window.W ebSocket | | this.win dow.MozWeb Socket)) { | |
| 854 | cons ole.error( "LiveReloa d disabled because t he browser does not seem to su pport web sockets"); | |
| 855 | retu rn; | |
| 856 | } | |
| 857 | if (!( this.optio ns = Optio ns.extract (this.wind ow.documen t))) { | |
| 858 | cons ole.error( "LiveReloa d disabled because i t could no t find its own <SCRI PT> tag"); | |
| 859 | retu rn; | |
| 860 | } | |
| 861 | this.r eloader = new Reload er(this.wi ndow, this .console, Timer); | |
| 862 | this.c onnector = new Conne ctor(this. options, t his.WebSoc ket, Timer , { | |
| 863 | conn ecting: fu nction() { }, | |
| 864 | sock etConnecte d: functio n() {}, | |
| 865 | conn ected: fun ction(prot ocol) { | |
| 866 | va r _base; | |
| 867 | if (typeof ( _base = _t his.listen ers).conne ct === "fu nction") { | |
| 868 | _base.conn ect(); | |
| 869 | } | |
| 870 | _t his.log("L iveReload is connect ed to " + _this.opti ons.host + ":" + _th is.options .port + " (protocol v" + proto col + ")." ); | |
| 871 | re turn _this .analyze() ; | |
| 872 | }, | |
| 873 | erro r: functio n(e) { | |
| 874 | if (e instan ceof Proto colError) { | |
| 875 | return con sole.log(" " + e.mess age + ".") ; | |
| 876 | } else { | |
| 877 | return con sole.log(" LiveReload internal error: " + e.message ); | |
| 878 | } | |
| 879 | }, | |
| 880 | disc onnected: function(r eason, nex tDelay) { | |
| 881 | va r _base; | |
| 882 | if (typeof ( _base = _t his.listen ers).disco nnect === "function" ) { | |
| 883 | _base.disc onnect(); | |
| 884 | } | |
| 885 | sw itch (reas on) { | |
| 886 | case 'cann ot-connect ': | |
| 887 | return _ this.log(" LiveReload cannot co nnect to " + _this.o ptions.hos t + ":" + _this.opti ons.port + ", will r etry in " + nextDela y + " sec. "); | |
| 888 | case 'brok en': | |
| 889 | return _ this.log(" LiveReload disconnec ted from " + _this.o ptions.hos t + ":" + _this.opti ons.port + ", reconn ecting in " + nextDe lay + " se c."); | |
| 890 | case 'hand shake-time out': | |
| 891 | return _ this.log(" LiveReload cannot co nnect to " + _this.o ptions.hos t + ":" + _this.opti ons.port + " (handsh ake timeou t), will r etry in " + nextDela y + " sec. "); | |
| 892 | case 'hand shake-fail ed': | |
| 893 | return _ this.log(" LiveReload cannot co nnect to " + _this.o ptions.hos t + ":" + _this.opti ons.port + " (handsh ake failed ), will re try in " + nextDelay + " sec." ); | |
| 894 | case 'manu al': | |
| 895 | break; | |
| 896 | case 'erro r': | |
| 897 | break; | |
| 898 | default: | |
| 899 | return _ this.log(" LiveReload disconnec ted from " + _this.o ptions.hos t + ":" + _this.opti ons.port + " (" + re ason + "), reconnect ing in " + nextDelay + " sec." ); | |
| 900 | } | |
| 901 | }, | |
| 902 | mess age: funct ion(messag e) { | |
| 903 | sw itch (mess age.comman d) { | |
| 904 | case 'relo ad': | |
| 905 | return _ this.perfo rmReload(m essage); | |
| 906 | case 'aler t': | |
| 907 | return _ this.perfo rmAlert(me ssage); | |
| 908 | } | |
| 909 | } | |
| 910 | }); | |
| 911 | } | |
| 912 | ||
| 913 | LiveRelo ad.prototy pe.on = fu nction(eve ntName, ha ndler) { | |
| 914 | return this.list eners[even tName] = h andler; | |
| 915 | }; | |
| 916 | ||
| 917 | LiveRelo ad.prototy pe.log = f unction(me ssage) { | |
| 918 | return this.cons ole.log("" + message ); | |
| 919 | }; | |
| 920 | ||
| 921 | LiveRelo ad.prototy pe.perform Reload = f unction(me ssage) { | |
| 922 | var _b ase, _ref, _ref2; | |
| 923 | this.l og("LiveRe load recei ved reload request f or " + mes sage.path + "."); | |
| 924 | this.r eloader.re load(messa ge.path, { | |
| 925 | live CSS: (_ref = message .liveCSS) != null ? _ref : tru e, | |
| 926 | live Img: (_ref 2 = messag e.liveImg) != null ? _ref2 : t rue, | |
| 927 | orig inalPath: message.or iginalPath || '', | |
| 928 | over rideURL: m essage.ove rrideURL | | '', | |
| 929 | serv erURL: "ht tp://" + t his.option s.host + " :" + this. options.po rt | |
| 930 | }); | |
| 931 | return typeof (_ base = thi s.listener s).reload === "funct ion" ? _ba se.reload( ) : void 0 ; | |
| 932 | }; | |
| 933 | ||
| 934 | LiveRelo ad.prototy pe.perform Alert = fu nction(mes sage) { | |
| 935 | return alert(mes sage.messa ge); | |
| 936 | }; | |
| 937 | ||
| 938 | LiveRelo ad.prototy pe.shutDow n = functi on() { | |
| 939 | var _b ase; | |
| 940 | this.c onnector.d isconnect( ); | |
| 941 | this.l og("LiveRe load disco nnected.") ; | |
| 942 | return typeof (_ base = thi s.listener s).shutdow n === "fun ction" ? _ base.shutd own() : vo id 0; | |
| 943 | }; | |
| 944 | ||
| 945 | LiveRelo ad.prototy pe.hasPlug in = funct ion(identi fier) { | |
| 946 | return !!this.pl uginIdenti fiers[iden tifier]; | |
| 947 | }; | |
| 948 | ||
| 949 | LiveRelo ad.prototy pe.addPlug in = funct ion(plugin Class) { | |
| 950 | var pl ugin; | |
| 951 | var _t his = this ; | |
| 952 | if (th is.hasPlug in(pluginC lass.ident ifier)) re turn; | |
| 953 | this.p luginIdent ifiers[plu ginClass.i dentifier] = true; | |
| 954 | plugin = new plu ginClass(t his.window , { | |
| 955 | _liv ereload: t his, | |
| 956 | _rel oader: thi s.reloader , | |
| 957 | _con nector: th is.connect or, | |
| 958 | cons ole: this. console, | |
| 959 | Time r: Timer, | |
| 960 | gene rateCacheB ustUrl: fu nction(url ) { | |
| 961 | re turn _this .reloader. generateCa cheBustUrl (url); | |
| 962 | } | |
| 963 | }); | |
| 964 | this.p lugins.pus h(plugin); | |
| 965 | this.r eloader.ad dPlugin(pl ugin); | |
| 966 | }; | |
| 967 | ||
| 968 | LiveRelo ad.prototy pe.analyze = functio n() { | |
| 969 | var pl ugin, plug inData, pl uginsData, _i, _len, _ref; | |
| 970 | if (!( this.conne ctor.proto col >= 7)) return; | |
| 971 | plugin sData = {} ; | |
| 972 | _ref = this.plug ins; | |
| 973 | for (_ i = 0, _le n = _ref.l ength; _i < _len; _i ++) { | |
| 974 | plug in = _ref[ _i]; | |
| 975 | plug insData[pl ugin.const ructor.ide ntifier] = pluginDat a = (typeo f plugin.a nalyze === "function " ? plugin .analyze() : void 0) || {}; | |
| 976 | plug inData.ver sion = plu gin.constr uctor.vers ion; | |
| 977 | } | |
| 978 | this.c onnector.s endCommand ({ | |
| 979 | comm and: 'info ', | |
| 980 | plug ins: plugi nsData, | |
| 981 | url: this.wind ow.locatio n.href | |
| 982 | }); | |
| 983 | }; | |
| 984 | ||
| 985 | LiveRelo ad.prototy pe.setUpCS STransitio ns = funct ion() { | |
| 986 | var cs sText, hea d, prefixe r, styleNo de; | |
| 987 | prefix er = funct ion(declar ation) { | |
| 988 | retu rn (['-web kit-', '-m oz-', '']. map(functi on(item) { | |
| 989 | re turn "" + item + dec laration; | |
| 990 | })). join(' '); | |
| 991 | }; | |
| 992 | head = document. getElement sByTagName ('head')[0 ]; | |
| 993 | styleN ode = docu ment.creat eElement(" style"); | |
| 994 | cssTex t = ".live reload-rel oaded * { " + (prefi xer('trans ition: all 280ms eas e-out;')) + " }"; | |
| 995 | if (st yleNode.st yleSheet) { | |
| 996 | styl eNode.styl eSheet.css Text = css Text; | |
| 997 | } else { | |
| 998 | styl eNode.appe ndChild(do cument.cre ateTextNod e(cssText) ); | |
| 999 | } | |
| 1000 | return head.appe ndChild(st yleNode); | |
| 1001 | }; | |
| 1002 | ||
| 1003 | return L iveReload; | |
| 1004 | ||
| 1005 | })(); | |
| 1006 | ||
| 1007 | // less | |
| 1008 | var LessPl ugin; | |
| 1009 | __less = L essPlugin = (functio n() { | |
| 1010 | LessPlug in.identif ier = 'les s'; | |
| 1011 | LessPlug in.version = '1.0'; | |
| 1012 | function LessPlugi n(window, host) { | |
| 1013 | this.w indow = wi ndow; | |
| 1014 | this.h ost = host ; | |
| 1015 | } | |
| 1016 | LessPlug in.prototy pe.reload = function (path, opt ions) { | |
| 1017 | if (th is.window. less && th is.window. less.refre sh) { | |
| 1018 | if ( path.match (/\.less$/ i)) { | |
| 1019 | re turn this. reloadLess (path); | |
| 1020 | } | |
| 1021 | if ( options.or iginalPath .match(/\. less$/i)) { | |
| 1022 | re turn this. reloadLess (options.o riginalPat h); | |
| 1023 | } | |
| 1024 | } | |
| 1025 | return false; | |
| 1026 | }; | |
| 1027 | LessPlug in.prototy pe.clearGe neratedSty les = func tion() { | |
| 1028 | var _i , _ref, st yle; | |
| 1029 | _ref = document. getElement sByTagName ('style'); | |
| 1030 | for (v ar _i = _r ef.length - 1; _i >= 0; _i--) { | |
| 1031 | styl e = _ref[_ i]; | |
| 1032 | if ( style.id & & style.id .match(/le ss\:/)) { | |
| 1033 | st yle.parent Node.remov eChild(sty le); | |
| 1034 | } | |
| 1035 | }; | |
| 1036 | } | |
| 1037 | LessPlug in.prototy pe.reloadL ess = func tion(path) { | |
| 1038 | var li nk, links, _i, _len; | |
| 1039 | this.c learGenera tedStyles( ); | |
| 1040 | links = (functio n() { | |
| 1041 | var _i, _len, _ref, _res ults; | |
| 1042 | _ref = documen t.getEleme ntsByTagNa me('link') ; | |
| 1043 | _res ults = []; | |
| 1044 | for (_i = 0, _ len = _ref .length; _ i < _len; _i++) { | |
| 1045 | li nk = _ref[ _i]; | |
| 1046 | if (link.hre f && link. rel === 's tylesheet/ less' || ( link.rel.m atch(/styl esheet/) & & link.typ e.match(/^ text\/(x-) ?less$/))) { | |
| 1047 | _results.p ush(link); | |
| 1048 | } | |
| 1049 | } | |
| 1050 | retu rn _result s; | |
| 1051 | })(); | |
| 1052 | if (li nks.length === 0) { | |
| 1053 | retu rn false; | |
| 1054 | } | |
| 1055 | for (_ i = 0, _le n = links. length; _i < _len; _ i++) { | |
| 1056 | link = links[_ i]; | |
| 1057 | link .href = th is.host.ge nerateCach eBustUrl(l ink.href); | |
| 1058 | } | |
| 1059 | this.h ost.consol e.log("Liv eReload is asking LE SS to reco mpile all stylesheet s"); | |
| 1060 | this.w indow.less .refresh(t rue); | |
| 1061 | return true; | |
| 1062 | }; | |
| 1063 | LessPlug in.prototy pe.analyze = functio n() { | |
| 1064 | return { | |
| 1065 | disa ble: !!(th is.window. less && th is.window. less.refre sh) | |
| 1066 | }; | |
| 1067 | }; | |
| 1068 | return L essPlugin; | |
| 1069 | })(); | |
| 1070 | ||
| 1071 | // startup | |
| 1072 | var Custom Events, Li veReload, k, parent = window; | |
| 1073 | CustomEven ts = __cus tomevents; | |
| 1074 | LiveReload = window. LiveReload = new (__ livereload .LiveReloa d)(window) ; | |
| 1075 | try { | |
| 1076 | while (p arent !== parent.par ent) { | |
| 1077 | parent = parent. parent; | |
| 1078 | if (pa rent.LiveR eload !== undefined) { | |
| 1079 | pare nt.LiveRel oad.shutDo wn(); | |
| 1080 | } | |
| 1081 | } | |
| 1082 | } catch (e ) { | |
| 1083 | // Mostl y a securi ty excepti on about s ame-origin problem | |
| 1084 | } | |
| 1085 | for (k in window) { | |
| 1086 | if (k.ma tch(/^Live ReloadPlug in/)) { | |
| 1087 | LiveRe load.addPl ugin(windo w[k]); | |
| 1088 | } | |
| 1089 | } | |
| 1090 | LiveReload .addPlugin (__less); | |
| 1091 | LiveReload .on('shutd own', func tion() { | |
| 1092 | return d elete wind ow.LiveRel oad; | |
| 1093 | }); | |
| 1094 | LiveReload .on('conne ct', funct ion() { | |
| 1095 | if (!!/t rue|1$/.te st(LiveRel oad.option s.animate) ) { | |
| 1096 | LiveRe load.setUp CSSTransit ions(); | |
| 1097 | } | |
| 1098 | return C ustomEvent s.fire(doc ument, 'Li veReloadCo nnect'); | |
| 1099 | }); | |
| 1100 | LiveReload .on('disco nnect', fu nction() { | |
| 1101 | return C ustomEvent s.fire(doc ument, 'Li veReloadDi sconnect') ; | |
| 1102 | }); | |
| 1103 | LiveReload .on('reloa d', functi on() { | |
| 1104 | var exis tingHtmlCl ass, html, reloadedC lass, _ref ; | |
| 1105 | html = d ocument.bo dy.parentN ode; | |
| 1106 | reloaded Class = ' livereload -reloaded' ; | |
| 1107 | existing HtmlClass = (_ref = html.getAt tribute('c lass')) != null ? _r ef : ''; | |
| 1108 | html.set Attribute( 'class', " " + (exist ingHtmlCla ss.replace (reloadedC lass, '')) + " " + r eloadedCla ss); | |
| 1109 | return s etTimeout( (function( ) { | |
| 1110 | return html.setA ttribute(' class', ex istingHtml Class.repl ace(reload edClass, ' ')); | |
| 1111 | }), 300) ; | |
| 1112 | }); | |
| 1113 | CustomEven ts.bind(do cument, 'L iveReloadS hutDown', function() { | |
| 1114 | return L iveReload. shutDown() ; | |
| 1115 | }); | |
| 1116 | })(); |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.