changeset 22 | 3a4f0cd0794e |
parent 21 | 74edc873234f |
child 39 | 38dbcda3cf20 |
21:74edc873234f | 22:3a4f0cd0794e |
---|---|
47 } |
47 } |
48 } |
48 } |
49 |
49 |
50 function ajaxGet(uri, f) |
50 function ajaxGet(uri, f) |
51 { |
51 { |
52 if ( ajax_panicked ) |
|
53 return false; |
|
54 |
|
52 if (window.XMLHttpRequest) |
55 if (window.XMLHttpRequest) |
53 { |
56 { |
54 ajax = new XMLHttpRequest(); |
57 ajax = new XMLHttpRequest(); |
55 } |
58 } |
56 else |
59 else |
70 ajax.send(null); |
73 ajax.send(null); |
71 } |
74 } |
72 |
75 |
73 function ajaxPost(uri, parms, f) |
76 function ajaxPost(uri, parms, f) |
74 { |
77 { |
78 if ( ajax_panicked ) |
|
79 return false; |
|
80 |
|
75 if (window.XMLHttpRequest) |
81 if (window.XMLHttpRequest) |
76 { |
82 { |
77 ajax = new XMLHttpRequest(); |
83 ajax = new XMLHttpRequest(); |
78 } |
84 } |
79 else |
85 else |
95 if ( !is_Safari ) |
101 if ( !is_Safari ) |
96 { |
102 { |
97 ajax.setRequestHeader("Content-length", parms.length); |
103 ajax.setRequestHeader("Content-length", parms.length); |
98 } |
104 } |
99 ajax.setRequestHeader("Connection", "close"); |
105 ajax.setRequestHeader("Connection", "close"); |
106 ajax.onerror = function() |
|
107 { |
|
108 ajax_panic(); |
|
109 } |
|
100 ajax.send(parms); |
110 ajax.send(parms); |
101 } |
111 } |
102 |
112 |
103 function setAjaxLoading() |
113 function setAjaxLoading() |
104 { |
114 { |
202 { |
212 { |
203 first_load = false; |
213 first_load = false; |
204 jump_current_track(); |
214 jump_current_track(); |
205 } |
215 } |
206 } |
216 } |
217 else if ( ajax.readyState == 4 && ajax.status != 200 ) |
|
218 { |
|
219 ajax_panic(); |
|
220 console.debug(ajax); |
|
221 } |
|
207 }); |
222 }); |
223 } |
|
224 |
|
225 var ajax_panicked = false; |
|
226 |
|
227 function ajax_panic() |
|
228 { |
|
229 // set error flag |
|
230 ajax_panicked = true; |
|
231 |
|
232 // scroll to the top |
|
233 window.scroll(0, 0); |
|
234 |
|
235 // stop events |
|
236 pulsar_reset(); |
|
237 window.clearInterval(pl_refresh_id); |
|
238 if ( ct_counter ) |
|
239 window.clearInterval(ct_counter); |
|
240 if ( pulsar_interval_id ) |
|
241 window.clearInterval(pulsar_interval_id); |
|
242 |
|
243 // show error message |
|
244 var floater = document.createElement('div'); |
|
245 floater.style.backgroundColor = '#ffffff'; |
|
246 floater.style.opacity = 0.7; |
|
247 floater.style.filter = 'alpha(opacity=70)'; |
|
248 floater.style.textAlign = 'center'; |
|
249 floater.style.paddingTop = '120px'; |
|
250 floater.style.position = 'fixed'; |
|
251 floater.style.zIndex = '999'; |
|
252 floater.style.width = '100%'; |
|
253 floater.style.height = '100%'; |
|
254 floater.style.top = '0px'; |
|
255 floater.style.left = '0px'; |
|
256 floater.style.color = '#000000'; |
|
257 floater.innerHTML = 'There was a problem with a refresh request to the server. Please reload the page.'; |
|
258 var body = document.getElementsByTagName('body')[0]; |
|
259 body.appendChild(floater); |
|
208 } |
260 } |
209 |
261 |
210 function player_action(action) |
262 function player_action(action) |
211 { |
263 { |
212 var act2 = action; |
264 var act2 = action; |
324 str = '0' + str; |
376 str = '0' + str; |
325 } |
377 } |
326 return str; |
378 return str; |
327 } |
379 } |
328 |
380 |
329 setInterval(refresh_playlist, 10000); |
381 var pl_refresh_id = setInterval(refresh_playlist, 10000); |
330 |
382 |
331 window.onload = function(e) |
383 window.onload = function(e) |
332 { |
384 { |
333 runOnloadHooks(e); |
385 runOnloadHooks(e); |
334 } |
386 } |
412 } |
464 } |
413 pulsar_current = nc; |
465 pulsar_current = nc; |
414 } |
466 } |
415 |
467 |
416 addOnloadHook(pulsar_reset); |
468 addOnloadHook(pulsar_reset); |
417 setInterval(pulsar_advance, 50); |
469 var pulsar_interval_id = setInterval(pulsar_advance, 50); |
418 |
470 |
419 function updateTitle(artist, album, track) |
471 function updateTitle(artist, album, track) |
420 { |
472 { |
421 var sep = ''; |
473 var sep = ''; |
422 var str = ''; |
474 var str = ''; |