]>
Commit | Line | Data |
---|---|---|
760966c1 AD |
1 | var hotkeys_enabled = true; |
2 | ||
a7565293 AD |
3 | var xmlhttp_rpc = Ajax.getTransport(); |
4 | ||
292a8a12 | 5 | function browser_has_opacity() { |
605f7d46 AD |
6 | return navigator.userAgent.match("Gecko") != null || |
7 | navigator.userAgent.match("Opera") != null; | |
292a8a12 AD |
8 | } |
9 | ||
7c620da8 AD |
10 | function is_opera() { |
11 | return navigator.userAgent.match("Opera"); | |
12 | } | |
13 | ||
55160955 | 14 | function exception_error(location, e, silent) { |
83f043bb AD |
15 | var msg; |
16 | ||
17 | if (e.fileName) { | |
18 | var base_fname = e.fileName.substring(e.fileName.lastIndexOf("/") + 1); | |
19 | ||
20 | msg = "Exception: " + e.name + ", " + e.message + | |
21 | "\nFunction: " + location + "()" + | |
22 | "\nLocation: " + base_fname + ":" + e.lineNumber; | |
ee1f45f4 | 23 | |
83f043bb AD |
24 | } else { |
25 | msg = "Exception: " + e + "\nFunction: " + location + "()"; | |
26 | } | |
27 | ||
ee1f45f4 AD |
28 | debug("<b>EXCEPTION: " + msg + "</b>"); |
29 | ||
55160955 AD |
30 | if (!silent) { |
31 | alert(msg); | |
32 | } | |
7719618b AD |
33 | } |
34 | ||
760966c1 AD |
35 | function disableHotkeys() { |
36 | hotkeys_enabled = false; | |
37 | } | |
38 | ||
39 | function enableHotkeys() { | |
40 | hotkeys_enabled = true; | |
41 | } | |
42 | ||
c0e5a40e AD |
43 | function xmlhttp_ready(obj) { |
44 | return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState; | |
45 | } | |
46 | ||
9cfc649a AD |
47 | function notify_callback() { |
48 | var container = document.getElementById('notify'); | |
49 | if (xmlhttp.readyState == 4) { | |
50 | container.innerHTML=xmlhttp.responseText; | |
51 | } | |
52 | } | |
53 | ||
54 | function rpc_notify_callback() { | |
55 | var container = document.getElementById('notify'); | |
56 | if (xmlhttp_rpc.readyState == 4) { | |
57 | container.innerHTML=xmlhttp_rpc.responseText; | |
58 | } | |
59 | } | |
60 | ||
7726fa02 AD |
61 | function param_escape(arg) { |
62 | if (typeof encodeURIComponent != 'undefined') | |
63 | return encodeURIComponent(arg); | |
64 | else | |
65 | return escape(arg); | |
66 | } | |
67 | ||
68 | function param_unescape(arg) { | |
69 | if (typeof decodeURIComponent != 'undefined') | |
70 | return decodeURIComponent(arg); | |
71 | else | |
72 | return unescape(arg); | |
73 | } | |
74 | ||
508a81e1 AD |
75 | function delay(gap) { |
76 | var then,now; | |
77 | then=new Date().getTime(); | |
78 | now=then; | |
79 | while((now-then)<gap) { | |
80 | now=new Date().getTime(); | |
81 | } | |
82 | } | |
7726fa02 | 83 | |
ce3bf408 AD |
84 | var notify_hide_timerid = false; |
85 | var notify_last_doc = false; | |
86 | ||
d05514a4 | 87 | var notify_effect = false; |
59a543f0 | 88 | |
ce3bf408 AD |
89 | function hide_notify() { |
90 | if (notify_last_doc) { | |
91 | var n = notify_last_doc.getElementById("notify"); | |
d05514a4 AD |
92 | n.style.display = "none"; |
93 | ||
94 | /* if (browser_has_opacity()) { | |
ce3bf408 | 95 | if (notify_opacity >= 0) { |
0655a1d5 | 96 | notify_opacity = notify_opacity - 0.1; |
ce3bf408 | 97 | n.style.opacity = notify_opacity; |
292a8a12 | 98 | notify_hide_timerid = window.setTimeout("hide_notify()", 20); |
ce3bf408 AD |
99 | } else { |
100 | n.style.display = "none"; | |
292a8a12 | 101 | n.style.opacity = 1; |
ce3bf408 AD |
102 | } |
103 | } else { | |
104 | n.style.display = "none"; | |
d05514a4 | 105 | } */ |
8dcfffd0 | 106 | } |
d05514a4 | 107 | } |
c05608c2 | 108 | |
0530ddd8 | 109 | function notify_real(msg, doc, no_hide, is_err) { |
7726fa02 | 110 | |
ce3bf408 AD |
111 | var n = doc.getElementById("notify"); |
112 | var nb = doc.getElementById("notify_body"); | |
7726fa02 | 113 | |
c05608c2 | 114 | if (!n || !nb) return; |
f0601b87 | 115 | |
0655a1d5 AD |
116 | if (notify_hide_timerid) { |
117 | window.clearTimeout(notify_hide_timerid); | |
118 | } | |
119 | ||
120 | notify_last_doc = doc; | |
121 | notify_opacity = 1; | |
122 | ||
8dcfffd0 | 123 | if (msg == "") { |
0655a1d5 AD |
124 | if (n.style.display == "block") { |
125 | notify_hide_timerid = window.setTimeout("hide_notify()", 0); | |
126 | } | |
127 | return; | |
7726fa02 | 128 | } else { |
0ceded7a | 129 | n.style.display = "block"; |
8dcfffd0 | 130 | } |
7726fa02 | 131 | |
0530ddd8 | 132 | if (is_err) { |
f407c086 AD |
133 | n.className = "notifyError"; |
134 | // n.style.backgroundColor = "#ffcccc"; | |
135 | // n.style.color = "black"; | |
136 | // n.style.borderColor = "#ff0000"; | |
0530ddd8 | 137 | } else { |
f407c086 AD |
138 | n.className = "notify"; |
139 | // n.style.backgroundColor = "#fff7d5"; | |
140 | // n.style.borderColor = "#d7c47a"; | |
141 | // n.style.color = "black"; | |
0530ddd8 AD |
142 | } |
143 | ||
106689b0 AD |
144 | // msg = "<img src='images/live_com_loading.gif'> " + msg; |
145 | ||
0ceded7a AD |
146 | nb.innerHTML = msg; |
147 | ||
4d4200a8 | 148 | if (!no_hide) { |
292a8a12 | 149 | notify_hide_timerid = window.setTimeout("hide_notify()", 3000); |
4d4200a8 | 150 | } |
ce3bf408 AD |
151 | } |
152 | ||
0530ddd8 | 153 | function p_notify(msg, no_hide, is_err) { |
9cb99906 | 154 | notify_real(msg, document, no_hide, is_err); |
ce3bf408 AD |
155 | } |
156 | ||
0530ddd8 AD |
157 | function notify(msg, no_hide, is_err) { |
158 | notify_real(msg, document, no_hide, is_err); | |
7726fa02 AD |
159 | } |
160 | ||
508a81e1 | 161 | function printLockingError() { |
f0601b87 | 162 | notify("Please wait until operation finishes");} |
508a81e1 | 163 | |
13ad9102 | 164 | function hotkey_handler(e) { |
760966c1 | 165 | |
ee1f45f4 | 166 | try { |
2e02b896 | 167 | |
ee1f45f4 AD |
168 | var keycode; |
169 | ||
170 | if (!hotkeys_enabled) return; | |
171 | ||
172 | if (window.event) { | |
173 | keycode = window.event.keyCode; | |
174 | } else if (e) { | |
175 | keycode = e.which; | |
176 | } | |
d437c8cf | 177 | |
ee1f45f4 | 178 | if (keycode == 82) { // r |
0feab655 | 179 | return scheduleFeedUpdate(true); |
ee1f45f4 | 180 | } |
0a383013 AD |
181 | |
182 | if (keycode == 83) { // r | |
0feab655 | 183 | return displayDlg("search", getActiveFeedId()); |
0a383013 AD |
184 | } |
185 | ||
ee1f45f4 AD |
186 | if (keycode == 85) { // u |
187 | if (getActiveFeedId()) { | |
0feab655 | 188 | return viewfeed(getActiveFeedId(), "ForceUpdate"); |
ee1f45f4 AD |
189 | } |
190 | } | |
191 | ||
192 | if (keycode == 65) { // a | |
0feab655 | 193 | return toggleDispRead(); |
ee1f45f4 AD |
194 | } |
195 | ||
0feab655 | 196 | var feedlist = document.getElementById('feedList'); |
ee1f45f4 AD |
197 | |
198 | if (keycode == 74) { // j | |
199 | var feed = getActiveFeedId(); | |
200 | var new_feed = getRelativeFeedId(feedlist, feed, 'prev'); | |
767e2486 | 201 | if (new_feed) viewfeed(new_feed, ''); |
ee1f45f4 AD |
202 | } |
203 | ||
204 | if (keycode == 75) { // k | |
205 | var feed = getActiveFeedId(); | |
206 | var new_feed = getRelativeFeedId(feedlist, feed, 'next'); | |
767e2486 | 207 | if (new_feed) viewfeed(new_feed, ''); |
7b433d8c | 208 | } |
9cfc649a | 209 | |
ee1f45f4 | 210 | if (keycode == 78 || keycode == 40) { // n, down |
0feab655 AD |
211 | if (typeof moveToPost != 'undefined') { |
212 | return moveToPost('next'); | |
e59a2f12 | 213 | } |
ee1f45f4 AD |
214 | } |
215 | ||
216 | if (keycode == 80 || keycode == 38) { // p, up | |
0feab655 AD |
217 | if (typeof moveToPost != 'undefined') { |
218 | return moveToPost('prev'); | |
e59a2f12 | 219 | } |
ee1f45f4 AD |
220 | } |
221 | ||
222 | if (typeof localHotkeyHandler != 'undefined') { | |
223 | try { | |
224 | localHotkeyHandler(keycode); | |
225 | } catch (e) { | |
226 | exception_error("hotkey_handler, local:", e); | |
227 | } | |
228 | } | |
229 | } catch (e) { | |
230 | exception_error("hotkey_handler", e); | |
231 | } | |
13ad9102 AD |
232 | } |
233 | ||
e828e31e | 234 | function cleanSelectedList(element) { |
f0601b87 AD |
235 | var content = document.getElementById(element); |
236 | ||
703b632e AD |
237 | if (!document.getElementById("feedCatHolder")) { |
238 | for (i = 0; i < content.childNodes.length; i++) { | |
239 | var child = content.childNodes[i]; | |
d0bb308e AD |
240 | try { |
241 | child.className = child.className.replace("Selected", ""); | |
242 | } catch (e) { | |
243 | // | |
244 | } | |
703b632e AD |
245 | } |
246 | } else { | |
247 | for (i = 0; i < content.childNodes.length; i++) { | |
248 | var child = content.childNodes[i]; | |
703b632e | 249 | if (child.id == "feedCatHolder") { |
9cb99906 | 250 | debug(child.id); |
c3f348c2 | 251 | var fcat = child.lastChild; |
703b632e | 252 | for (j = 0; j < fcat.childNodes.length; j++) { |
befc807f | 253 | var feed = fcat.childNodes[j]; |
703b632e AD |
254 | feed.className = feed.className.replace("Selected", ""); |
255 | } | |
256 | } | |
befc807f | 257 | } |
703b632e | 258 | } |
e828e31e AD |
259 | } |
260 | ||
261 | ||
262 | function cleanSelected(element) { | |
263 | var content = document.getElementById(element); | |
f0601b87 AD |
264 | |
265 | for (i = 0; i < content.rows.length; i++) { | |
266 | content.rows[i].className = content.rows[i].className.replace("Selected", ""); | |
267 | } | |
f0601b87 AD |
268 | } |
269 | ||
270 | function getVisibleUnreadHeadlines() { | |
271 | var content = document.getElementById("headlinesList"); | |
272 | ||
273 | var rows = new Array(); | |
274 | ||
275 | for (i = 0; i < content.rows.length; i++) { | |
276 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
277 | if (row_id.length > 0 && content.rows[i].className.match("Unread")) { | |
278 | rows.push(row_id); | |
279 | } | |
280 | } | |
281 | return rows; | |
282 | } | |
283 | ||
284 | function getVisibleHeadlineIds() { | |
285 | ||
286 | var content = document.getElementById("headlinesList"); | |
287 | ||
288 | var rows = new Array(); | |
289 | ||
290 | for (i = 0; i < content.rows.length; i++) { | |
291 | var row_id = content.rows[i].id.replace("RROW-", ""); | |
292 | if (row_id.length > 0) { | |
293 | rows.push(row_id); | |
294 | } | |
295 | } | |
296 | return rows; | |
297 | } | |
298 | ||
299 | function getFirstVisibleHeadlineId() { | |
300 | var rows = getVisibleHeadlineIds(); | |
301 | return rows[0]; | |
302 | } | |
303 | ||
304 | function getLastVisibleHeadlineId() { | |
305 | var rows = getVisibleHeadlineIds(); | |
306 | return rows[rows.length-1]; | |
307 | } | |
308 | ||
309 | function markHeadline(id) { | |
310 | var row = document.getElementById("RROW-" + id); | |
311 | if (row) { | |
35f3c923 AD |
312 | var is_active = false; |
313 | ||
314 | if (row.className.match("Active")) { | |
315 | is_active = true; | |
316 | } | |
317 | row.className = row.className.replace("Selected", ""); | |
318 | row.className = row.className.replace("Active", ""); | |
319 | row.className = row.className.replace("Insensitive", ""); | |
320 | ||
321 | if (is_active) { | |
322 | row.className = row.className = "Active"; | |
323 | } | |
324 | ||
72020095 AD |
325 | var check = document.getElementById("RCHK-" + id); |
326 | ||
327 | if (check) { | |
328 | check.checked = true; | |
329 | } | |
330 | ||
35f3c923 AD |
331 | row.className = row.className + "Selected"; |
332 | ||
f0601b87 AD |
333 | } |
334 | } | |
335 | ||
336 | function getFeedIds() { | |
337 | var content = document.getElementById("feedsList"); | |
338 | ||
339 | var rows = new Array(); | |
340 | ||
341 | for (i = 0; i < content.rows.length; i++) { | |
342 | var id = content.rows[i].id.replace("FEEDR-", ""); | |
343 | if (id.length > 0) { | |
344 | rows.push(id); | |
345 | } | |
346 | } | |
347 | ||
348 | return rows; | |
349 | } | |
13ad9102 | 350 | |
76b4eae1 AD |
351 | function setCookie(name, value, lifetime, path, domain, secure) { |
352 | ||
353 | var d = false; | |
354 | ||
355 | if (lifetime) { | |
356 | d = new Date(); | |
357 | d.setTime(lifetime * 1000); | |
358 | } | |
359 | ||
360 | int_setCookie(name, value, d, path, domain, secure); | |
361 | ||
362 | } | |
363 | ||
364 | function int_setCookie(name, value, expires, path, domain, secure) { | |
ac43eba1 AD |
365 | document.cookie= name + "=" + escape(value) + |
366 | ((expires) ? "; expires=" + expires.toGMTString() : "") + | |
367 | ((path) ? "; path=" + path : "") + | |
368 | ((domain) ? "; domain=" + domain : "") + | |
369 | ((secure) ? "; secure" : ""); | |
370 | } | |
371 | ||
76b4eae1 AD |
372 | function delCookie(name, path, domain) { |
373 | if (getCookie(name)) { | |
374 | document.cookie = name + "=" + | |
375 | ((path) ? ";path=" + path : "") + | |
376 | ((domain) ? ";domain=" + domain : "" ) + | |
377 | ";expires=Thu, 01-Jan-1970 00:00:01 GMT"; | |
378 | } | |
379 | } | |
380 | ||
381 | ||
ac43eba1 AD |
382 | function getCookie(name) { |
383 | ||
384 | var dc = document.cookie; | |
385 | var prefix = name + "="; | |
386 | var begin = dc.indexOf("; " + prefix); | |
387 | if (begin == -1) { | |
388 | begin = dc.indexOf(prefix); | |
389 | if (begin != 0) return null; | |
390 | } | |
391 | else { | |
392 | begin += 2; | |
393 | } | |
394 | var end = document.cookie.indexOf(";", begin); | |
395 | if (end == -1) { | |
396 | end = dc.length; | |
397 | } | |
398 | return unescape(dc.substring(begin + prefix.length, end)); | |
399 | } | |
400 | ||
1a66d16e AD |
401 | function disableContainerChildren(id, disable, doc) { |
402 | ||
403 | if (!doc) doc = document; | |
404 | ||
405 | var container = doc.getElementById(id); | |
ac43eba1 | 406 | |
4220b0bd AD |
407 | if (!container) { |
408 | //alert("disableContainerChildren: element " + id + " not found"); | |
409 | return; | |
410 | } | |
411 | ||
ac43eba1 AD |
412 | for (var i = 0; i < container.childNodes.length; i++) { |
413 | var child = container.childNodes[i]; | |
414 | ||
d5224f0d AD |
415 | try { |
416 | child.disabled = disable; | |
417 | } catch (E) { | |
418 | ||
419 | } | |
ac43eba1 AD |
420 | |
421 | if (disable) { | |
422 | if (child.className && child.className.match("button")) { | |
423 | child.className = "disabledButton"; | |
424 | } | |
425 | } else { | |
426 | if (child.className && child.className.match("disabledButton")) { | |
427 | child.className = "button"; | |
428 | } | |
d5224f0d | 429 | } |
ac43eba1 AD |
430 | } |
431 | ||
432 | } | |
7726fa02 | 433 | |
e828e31e AD |
434 | function gotoPreferences() { |
435 | document.location.href = "prefs.php"; | |
436 | } | |
437 | ||
438 | function gotoMain() { | |
439 | document.location.href = "tt-rss.php"; | |
440 | } | |
441 | ||
8158c57a AD |
442 | function gotoExportOpml() { |
443 | document.location.href = "opml.php?op=Export"; | |
444 | } | |
86741347 AD |
445 | |
446 | function getActiveFeedId() { | |
33d13e72 AD |
447 | // return getCookie("ttrss_vf_actfeed"); |
448 | try { | |
0feab655 AD |
449 | debug("gAFID: " + active_feed_id); |
450 | return active_feed_id; | |
33d13e72 AD |
451 | } catch (e) { |
452 | exception_error("getActiveFeedId", e); | |
453 | } | |
86741347 AD |
454 | } |
455 | ||
0a6c4846 | 456 | function activeFeedIsCat() { |
0feab655 | 457 | return active_feed_is_cat; |
0a6c4846 AD |
458 | } |
459 | ||
86741347 | 460 | function setActiveFeedId(id) { |
33d13e72 AD |
461 | // return setCookie("ttrss_vf_actfeed", id); |
462 | try { | |
5c365f60 | 463 | debug("sAFID(" + id + ")"); |
0feab655 | 464 | active_feed_id = id; |
33d13e72 AD |
465 | } catch (e) { |
466 | exception_error("setActiveFeedId", e); | |
467 | } | |
86741347 | 468 | } |
090e250b | 469 | |
ac378ad4 | 470 | function parse_counters(reply, scheduled_call) { |
1a6a9555 | 471 | try { |
ac378ad4 | 472 | |
9e397d0f AD |
473 | var feeds_found = 0; |
474 | ||
f54f515f AD |
475 | if (reply.firstChild && reply.firstChild.firstChild) { |
476 | debug("<b>wrong element passed to parse_counters, adjusting.</b>"); | |
477 | reply = reply.firstChild; | |
478 | } | |
479 | ||
1a6a9555 | 480 | for (var l = 0; l < reply.childNodes.length; l++) { |
9cbca41f AD |
481 | if (!reply.childNodes[l] || |
482 | typeof(reply.childNodes[l].getAttribute) == "undefined") { | |
6043fb7e AD |
483 | // where did this come from? |
484 | continue; | |
485 | } | |
486 | ||
1a6a9555 AD |
487 | var id = reply.childNodes[l].getAttribute("id"); |
488 | var t = reply.childNodes[l].getAttribute("type"); | |
489 | var ctr = reply.childNodes[l].getAttribute("counter"); | |
023fe037 AD |
490 | var error = reply.childNodes[l].getAttribute("error"); |
491 | var has_img = reply.childNodes[l].getAttribute("hi"); | |
fb1fb4ab | 492 | var updated = reply.childNodes[l].getAttribute("updated"); |
1a6a9555 AD |
493 | |
494 | if (id == "global-unread") { | |
0feab655 AD |
495 | global_unread = ctr; |
496 | updateTitle(); | |
1a6a9555 AD |
497 | continue; |
498 | } | |
7bf7e4d3 AD |
499 | |
500 | if (id == "subscribed-feeds") { | |
501 | feeds_found = ctr; | |
502 | continue; | |
503 | } | |
1a6a9555 AD |
504 | |
505 | if (t == "category") { | |
0feab655 | 506 | var catctr = document.getElementById("FCATCTR-" + id); |
1a6a9555 AD |
507 | if (catctr) { |
508 | catctr.innerHTML = "(" + ctr + " unread)"; | |
509 | } | |
510 | continue; | |
511 | } | |
512 | ||
0feab655 AD |
513 | var feedctr = document.getElementById("FEEDCTR-" + id); |
514 | var feedu = document.getElementById("FEEDU-" + id); | |
515 | var feedr = document.getElementById("FEEDR-" + id); | |
516 | var feed_img = document.getElementById("FIMG-" + id); | |
517 | var feedlink = document.getElementById("FEEDL-" + id); | |
518 | var feedupd = document.getElementById("FLUPD-" + id); | |
fb1fb4ab AD |
519 | |
520 | if (updated && feedlink) { | |
521 | if (error) { | |
522 | feedlink.title = "Error: " + error + " (" + updated + ")"; | |
523 | } else { | |
524 | feedlink.title = "Updated: " + updated; | |
525 | } | |
526 | } | |
023fe037 | 527 | |
78d5212c AD |
528 | if (updated && feedupd) { |
529 | if (error) { | |
530 | feedupd.innerHTML = updated + " (Error)"; | |
531 | } else { | |
532 | feedupd.innerHTML = updated; | |
533 | } | |
534 | } | |
535 | ||
1a6a9555 | 536 | if (feedctr && feedu && feedr) { |
e8ef3b97 AD |
537 | |
538 | if (feedu.innerHTML != ctr && id == getActiveFeedId() && scheduled_call) { | |
5b064721 | 539 | viewCurrentFeed(); |
e8ef3b97 | 540 | } |
1a6a9555 AD |
541 | |
542 | feedu.innerHTML = ctr; | |
023fe037 | 543 | |
426d3c57 AD |
544 | if (error) { |
545 | feedr.className = feedr.className.replace("feed", "error"); | |
546 | } else if (id > 0) { | |
547 | feedr.className = feedr.className.replace("error", "feed"); | |
023fe037 | 548 | } |
1a6a9555 AD |
549 | |
550 | if (ctr > 0) { | |
551 | feedctr.className = "odd"; | |
552 | if (!feedr.className.match("Unread")) { | |
553 | var is_selected = feedr.className.match("Selected"); | |
554 | ||
555 | feedr.className = feedr.className.replace("Selected", ""); | |
556 | feedr.className = feedr.className.replace("Unread", ""); | |
557 | ||
558 | feedr.className = feedr.className + "Unread"; | |
559 | ||
560 | if (is_selected) { | |
561 | feedr.className = feedr.className + "Selected"; | |
562 | } | |
563 | ||
564 | } | |
565 | } else { | |
566 | feedctr.className = "invisible"; | |
567 | feedr.className = feedr.className.replace("Unread", ""); | |
568 | } | |
569 | } | |
570 | } | |
9e397d0f | 571 | |
0feab655 | 572 | hideOrShowFeeds(document, getInitParam("hide_read_feeds") == 1); |
7553dd8b | 573 | |
0feab655 | 574 | var feeds_stored = number_of_feeds; |
9e397d0f AD |
575 | |
576 | debug("Feed counters, C: " + feeds_found + ", S:" + feeds_stored); | |
577 | ||
578 | if (feeds_stored != feeds_found) { | |
0feab655 | 579 | number_of_feeds = feeds_found; |
7bf7e4d3 AD |
580 | |
581 | if (feeds_stored != 0) { | |
9e397d0f | 582 | debug("Subscribed feed number changed, refreshing feedlist"); |
0e9dd1ba | 583 | setTimeout('updateFeedList(false, false)', 50); |
9e397d0f AD |
584 | } |
585 | } | |
586 | ||
1a6a9555 | 587 | } catch (e) { |
83f043bb | 588 | exception_error("parse_counters", e); |
1a6a9555 AD |
589 | } |
590 | } | |
591 | ||
4f3a84f4 | 592 | function all_counters_callback() { |
090e250b | 593 | if (xmlhttp_rpc.readyState == 4) { |
7719618b | 594 | try { |
3866b046 | 595 | if (!xmlhttp_rpc.responseXML || !xmlhttp_rpc.responseXML.firstChild) { |
b00ed196 | 596 | debug("[all_counters_callback] backend did not return valid XML"); |
7719618b AD |
597 | return; |
598 | } | |
894ebcf5 | 599 | |
6b4163cb | 600 | debug("in all_counters_callback : " + xmlhttp_rpc.responseXML); |
1cb7492d | 601 | |
7719618b | 602 | var reply = xmlhttp_rpc.responseXML.firstChild; |
280ee9a3 | 603 | |
f54f515f AD |
604 | var counters = reply.firstChild; |
605 | ||
606 | parse_counters(counters); | |
1cb7492d AD |
607 | |
608 | var runtime = counters.nextSibling; | |
609 | ||
610 | if (runtime) { | |
0feab655 | 611 | parse_runtime_info(runtime); |
1cb7492d | 612 | } |
c9268ed5 | 613 | |
cea51014 | 614 | if (getInitParam("feeds_sort_by_unread") == 1) { |
c9268ed5 AD |
615 | resort_feedlist(); |
616 | } | |
293fa942 AD |
617 | |
618 | hideOrShowFeeds(document, getInitParam("hide_read_feeds") == 1); | |
619 | ||
7719618b AD |
620 | } catch (e) { |
621 | exception_error("all_counters_callback", e); | |
090e250b AD |
622 | } |
623 | } | |
624 | } | |
625 | ||
c9268ed5 AD |
626 | function get_feed_entry_unread(doc, elem) { |
627 | ||
628 | var id = elem.id.replace("FEEDR-", ""); | |
629 | ||
630 | if (id <= 0) { | |
631 | return -1; | |
632 | } | |
633 | ||
634 | try { | |
635 | return parseInt(doc.getElementById("FEEDU-" + id).innerHTML); | |
636 | } catch (e) { | |
637 | return -1; | |
638 | } | |
639 | } | |
640 | ||
641 | function resort_category(doc, node) { | |
642 | debug("resort_category: " + node); | |
643 | ||
644 | if (node.hasChildNodes() && node.firstChild.nextSibling != false) { | |
645 | for (i = 0; i < node.childNodes.length; i++) { | |
646 | if (node.childNodes[i].nodeName != "LI") { continue; } | |
647 | ||
648 | if (get_feed_entry_unread(doc, node.childNodes[i]) < 0) { | |
649 | continue; | |
650 | } | |
651 | ||
652 | for (j = i+1; j < node.childNodes.length; j++) { | |
653 | if (node.childNodes[j].nodeName != "LI") { continue; } | |
654 | ||
655 | var tmp_val = get_feed_entry_unread(doc, node.childNodes[i]); | |
656 | var cur_val = get_feed_entry_unread(doc, node.childNodes[j]); | |
657 | ||
658 | if (cur_val > tmp_val) { | |
659 | tempnode_i = node.childNodes[i].cloneNode(true); | |
660 | tempnode_j = node.childNodes[j].cloneNode(true); | |
661 | node.replaceChild(tempnode_i, node.childNodes[j]); | |
662 | node.replaceChild(tempnode_j, node.childNodes[i]); | |
663 | } | |
664 | } | |
665 | ||
666 | } | |
667 | } | |
668 | ||
669 | } | |
670 | ||
671 | function resort_feedlist() { | |
672 | debug("resort_feedlist"); | |
673 | ||
0feab655 | 674 | var fd = document; |
c9268ed5 AD |
675 | |
676 | if (fd.getElementById("feedCatHolder")) { | |
677 | ||
678 | var feeds = fd.getElementById("feedList"); | |
679 | var child = feeds.firstChild; | |
680 | ||
681 | while (child) { | |
682 | ||
683 | if (child.id == "feedCatHolder") { | |
684 | resort_category(fd, child.firstChild); | |
685 | } | |
686 | ||
687 | child = child.nextSibling; | |
688 | } | |
689 | ||
690 | } else { | |
691 | resort_category(fd, fd.getElementById("feedList")); | |
692 | } | |
693 | } | |
694 | ||
4f3a84f4 | 695 | function update_all_counters(feed) { |
090e250b | 696 | if (xmlhttp_ready(xmlhttp_rpc)) { |
8143ae1f | 697 | var query = "backend.php?op=rpc&subop=getAllCounters"; |
e47cfe37 AD |
698 | |
699 | if (feed > 0) { | |
700 | query = query + "&aid=" + feed; | |
701 | } | |
702 | ||
090e250b | 703 | xmlhttp_rpc.open("GET", query, true); |
4f3a84f4 | 704 | xmlhttp_rpc.onreadystatechange=all_counters_callback; |
090e250b AD |
705 | xmlhttp_rpc.send(null); |
706 | } | |
707 | } | |
7dc66a61 AD |
708 | |
709 | function popupHelp(tid) { | |
710 | var w = window.open("backend.php?op=help&tid=" + tid, | |
711 | "Popup Help", | |
712 | "menubar=no,location=no,resizable=yes,scrollbars=yes,status=no"); | |
713 | } | |
b6644d29 AD |
714 | |
715 | /** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj | |
716 | * * @author Sundar Dorai-Raj | |
717 | * * Email: sdoraira@vt.edu | |
718 | * * This program is free software; you can redistribute it and/or | |
719 | * * modify it under the terms of the GNU General Public License | |
720 | * * as published by the Free Software Foundation; either version 2 | |
721 | * * of the License, or (at your option) any later version, | |
722 | * * provided that any use properly credits the author. | |
723 | * * This program is distributed in the hope that it will be useful, | |
724 | * * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
725 | * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
726 | * * GNU General Public License for more details at http://www.gnu.org * * */ | |
727 | ||
728 | var numbers=".0123456789"; | |
729 | function isNumeric(x) { | |
730 | // is x a String or a character? | |
731 | if(x.length>1) { | |
732 | // remove negative sign | |
733 | x=Math.abs(x)+""; | |
734 | for(j=0;j<x.length;j++) { | |
735 | // call isNumeric recursively for each character | |
736 | number=isNumeric(x.substring(j,j+1)); | |
737 | if(!number) return number; | |
738 | } | |
739 | return number; | |
740 | } | |
741 | else { | |
742 | // if x is number return true | |
743 | if(numbers.indexOf(x)>=0) return true; | |
744 | return false; | |
745 | } | |
746 | } | |
747 | ||
3745788e AD |
748 | |
749 | function hideOrShowFeeds(doc, hide) { | |
750 | ||
7553dd8b AD |
751 | debug("hideOrShowFeeds: " + doc + ", " + hide); |
752 | ||
0feab655 | 753 | var fd = document; |
293fa942 AD |
754 | |
755 | var list = fd.getElementById("feedList"); | |
756 | ||
757 | if (fd.getElementById("feedCatHolder")) { | |
758 | ||
759 | var feeds = fd.getElementById("feedList"); | |
760 | var child = feeds.firstChild; | |
761 | ||
762 | while (child) { | |
763 | ||
764 | if (child.id == "feedCatHolder") { | |
765 | hideOrShowFeedsCategory(fd, child.firstChild, hide, child.previousSibling); | |
766 | } | |
767 | ||
768 | child = child.nextSibling; | |
769 | } | |
770 | ||
771 | } else { | |
772 | hideOrShowFeedsCategory(fd, fd.getElementById("feedList"), hide); | |
773 | } | |
774 | } | |
775 | ||
776 | function hideOrShowFeedsCategory(doc, node, hide, cat_node) { | |
777 | ||
778 | // debug("hideOrShowFeedsCategory: " + node + " (" + hide + ")"); | |
3ed751d4 | 779 | |
293fa942 | 780 | var cat_unread = 0; |
3745788e | 781 | |
293fa942 AD |
782 | if (node.hasChildNodes() && node.firstChild.nextSibling != false) { |
783 | for (i = 0; i < node.childNodes.length; i++) { | |
784 | if (node.childNodes[i].nodeName != "LI") { continue; } | |
bbf4d0b2 | 785 | |
b31c2311 | 786 | if (node.childNodes[i].style != undefined) { |
293fa942 | 787 | |
b31c2311 AD |
788 | var has_unread = (node.childNodes[i].className != "feed"); |
789 | ||
790 | // debug(node.childNodes[i].id + " --> " + has_unread); | |
791 | ||
792 | if (hide && !has_unread) { | |
793 | node.childNodes[i].style.display = "none"; | |
794 | } | |
795 | ||
796 | if (!hide) { | |
797 | node.childNodes[i].style.display = "list-item"; | |
798 | } | |
799 | ||
800 | if (has_unread) { | |
7553dd8b | 801 | node.childNodes[i].style.display = "list-item"; |
b31c2311 AD |
802 | cat_unread++; |
803 | } | |
293fa942 | 804 | } |
3745788e | 805 | } |
b31c2311 | 806 | } |
3745788e | 807 | |
293fa942 | 808 | if (cat_unread == 0) { |
b31c2311 AD |
809 | if (cat_node.style == undefined) { |
810 | debug("ERROR: supplied cat_node " + cat_node + | |
811 | " has no styles. WTF?"); | |
812 | return; | |
813 | } | |
293fa942 AD |
814 | if (hide) { |
815 | cat_node.style.display = "none"; | |
816 | } else { | |
817 | cat_node.style.display = "list-item"; | |
818 | } | |
7553dd8b | 819 | } else { |
0ac2faea AD |
820 | try { |
821 | cat_node.style.display = "list-item"; | |
822 | } catch (e) { | |
823 | debug(e); | |
824 | } | |
293fa942 | 825 | } |
3745788e | 826 | |
293fa942 | 827 | // debug("unread for category: " + cat_unread); |
3745788e AD |
828 | } |
829 | ||
35f3c923 AD |
830 | function selectTableRow(r, do_select) { |
831 | r.className = r.className.replace("Selected", ""); | |
832 | ||
833 | if (do_select) { | |
834 | r.className = r.className + "Selected"; | |
835 | } | |
836 | } | |
837 | ||
6c12c809 AD |
838 | function selectTableRowById(elem_id, check_id, do_select) { |
839 | ||
840 | try { | |
841 | ||
842 | var row = document.getElementById(elem_id); | |
843 | ||
844 | if (row) { | |
845 | selectTableRow(row, do_select); | |
846 | } | |
847 | ||
848 | var check = document.getElementById(check_id); | |
849 | ||
850 | if (check) { | |
851 | check.checked = do_select; | |
852 | } | |
853 | } catch (e) { | |
854 | exception_error("selectTableRowById", e); | |
855 | } | |
856 | } | |
857 | ||
1572afe5 | 858 | function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select, |
649e0af9 | 859 | classcheck, reset_others) { |
3745788e | 860 | |
35f3c923 AD |
861 | var content = document.getElementById(content_id); |
862 | ||
863 | if (!content) { | |
864 | alert("[selectTableRows] Element " + content_id + " not found."); | |
865 | return; | |
866 | } | |
867 | ||
868 | for (i = 0; i < content.rows.length; i++) { | |
1572afe5 AD |
869 | if (!classcheck || content.rows[i].className.match(classcheck)) { |
870 | ||
871 | if (content.rows[i].id.match(prefix)) { | |
872 | selectTableRow(content.rows[i], do_select); | |
649e0af9 AD |
873 | |
874 | var row_id = content.rows[i].id.replace(prefix, ""); | |
875 | var check = document.getElementById(check_prefix + row_id); | |
3055bc41 | 876 | |
649e0af9 AD |
877 | if (check) { |
878 | check.checked = do_select; | |
879 | } | |
880 | } else if (reset_others) { | |
881 | selectTableRow(content.rows[i], false); | |
7d8d10c6 AD |
882 | |
883 | var row_id = content.rows[i].id.replace(prefix, ""); | |
884 | var check = document.getElementById(check_prefix + row_id); | |
885 | ||
886 | if (check) { | |
887 | check.checked = false; | |
888 | } | |
889 | ||
1572afe5 | 890 | } |
649e0af9 AD |
891 | } else if (reset_others) { |
892 | selectTableRow(content.rows[i], false); | |
7d8d10c6 AD |
893 | |
894 | var row_id = content.rows[i].id.replace(prefix, ""); | |
895 | var check = document.getElementById(check_prefix + row_id); | |
896 | ||
897 | if (check) { | |
898 | check.checked = false; | |
899 | } | |
900 | ||
3055bc41 | 901 | } |
35f3c923 | 902 | } |
295f9b42 | 903 | } |
91ff844a AD |
904 | |
905 | function getSelectedTableRowIds(content_id, prefix) { | |
906 | ||
907 | var content = document.getElementById(content_id); | |
908 | ||
909 | if (!content) { | |
910 | alert("[getSelectedTableRowIds] Element " + content_id + " not found."); | |
911 | return; | |
912 | } | |
913 | ||
914 | var sel_rows = new Array(); | |
915 | ||
916 | for (i = 0; i < content.rows.length; i++) { | |
1572afe5 AD |
917 | if (content.rows[i].id.match(prefix) && |
918 | content.rows[i].className.match("Selected")) { | |
919 | ||
91ff844a AD |
920 | var row_id = content.rows[i].id.replace(prefix + "-", ""); |
921 | sel_rows.push(row_id); | |
922 | } | |
923 | } | |
924 | ||
925 | return sel_rows; | |
926 | ||
927 | } | |
928 | ||
386cbf27 AD |
929 | function toggleSelectRowById(sender, id) { |
930 | var row = document.getElementById(id); | |
931 | ||
932 | if (sender.checked) { | |
933 | if (!row.className.match("Selected")) { | |
934 | row.className = row.className + "Selected"; | |
935 | } | |
936 | } else { | |
937 | if (row.className.match("Selected")) { | |
938 | row.className = row.className.replace("Selected", ""); | |
939 | } | |
940 | } | |
941 | } | |
942 | ||
b92e6209 AD |
943 | function toggleSelectListRow(sender) { |
944 | var parent_row = sender.parentNode; | |
945 | ||
946 | if (sender.checked) { | |
947 | if (!parent_row.className.match("Selected")) { | |
948 | parent_row.className = parent_row.className + "Selected"; | |
949 | } | |
950 | } else { | |
951 | if (parent_row.className.match("Selected")) { | |
952 | parent_row.className = parent_row.className.replace("Selected", ""); | |
953 | } | |
954 | } | |
955 | } | |
956 | ||
386cbf27 | 957 | |
1572afe5 AD |
958 | function toggleSelectRow(sender) { |
959 | var parent_row = sender.parentNode.parentNode; | |
960 | ||
961 | if (sender.checked) { | |
962 | if (!parent_row.className.match("Selected")) { | |
963 | parent_row.className = parent_row.className + "Selected"; | |
964 | } | |
965 | } else { | |
966 | if (parent_row.className.match("Selected")) { | |
967 | parent_row.className = parent_row.className.replace("Selected", ""); | |
968 | } | |
969 | } | |
970 | } | |
971 | ||
3866b046 AD |
972 | function openExternalUrl(url) { |
973 | var w = window.open(url); | |
974 | } | |
1572afe5 | 975 | |
1da76274 | 976 | function getRelativeFeedId(list, id, direction, unread_only) { |
7b433d8c AD |
977 | if (!id) { |
978 | if (direction == "next") { | |
979 | for (i = 0; i < list.childNodes.length; i++) { | |
980 | var child = list.childNodes[i]; | |
1da76274 | 981 | if (child.id && child.id == "feedCatHolder") { |
c3f348c2 | 982 | if (child.lastChild) { |
d05514a4 | 983 | var cr = getRelativeFeedId(child.firstChild, id, direction, unread_only); |
7b433d8c AD |
984 | if (cr) return cr; |
985 | } | |
1da76274 | 986 | } else if (child.id && child.id.match("FEEDR-")) { |
7b433d8c AD |
987 | return child.id.replace('FEEDR-', ''); |
988 | } | |
989 | } | |
990 | } | |
991 | ||
992 | // FIXME select last feed doesn't work when only unread feeds are visible | |
993 | ||
994 | if (direction == "prev") { | |
995 | for (i = list.childNodes.length-1; i >= 0; i--) { | |
996 | var child = list.childNodes[i]; | |
997 | if (child.id == "feedCatHolder") { | |
998 | if (child.firstChild) { | |
999 | var cr = getRelativeFeedId(child.firstChild, id, direction); | |
1000 | if (cr) return cr; | |
1001 | } | |
1002 | } else if (child.id.match("FEEDR-")) { | |
1003 | ||
e8bd0da9 | 1004 | if (getInitParam("hide_read_feeds") == 1) { |
7b433d8c AD |
1005 | if (child.className != "feed") { |
1006 | alert(child.className); | |
1007 | return child.id.replace('FEEDR-', ''); | |
1008 | } | |
1009 | } else { | |
1010 | return child.id.replace('FEEDR-', ''); | |
1011 | } | |
1012 | } | |
1013 | } | |
1014 | } | |
1015 | } else { | |
1016 | ||
d05514a4 | 1017 | var feed = list.ownerDocument.getElementById("FEEDR-" + id); |
7b433d8c | 1018 | |
e8bd0da9 | 1019 | if (getInitParam("hide_read_feeds") == 1) { |
1da76274 AD |
1020 | unread_only = true; |
1021 | } | |
1022 | ||
7b433d8c AD |
1023 | if (direction == "next") { |
1024 | ||
1da76274 | 1025 | var e = feed; |
7b433d8c | 1026 | |
1da76274 | 1027 | while (e) { |
7b433d8c | 1028 | |
1da76274 AD |
1029 | if (e.nextSibling) { |
1030 | ||
1031 | e = e.nextSibling; | |
1032 | ||
1033 | } else if (e.parentNode.parentNode.nextSibling) { | |
7b433d8c | 1034 | |
1da76274 | 1035 | var this_cat = e.parentNode.parentNode; |
7b433d8c | 1036 | |
1da76274 | 1037 | e = false; |
7b433d8c | 1038 | |
1da76274 AD |
1039 | if (this_cat && this_cat.nextSibling) { |
1040 | while (!e && this_cat.nextSibling) { | |
1041 | this_cat = this_cat.nextSibling; | |
1042 | if (this_cat.id == "feedCatHolder") { | |
1043 | e = this_cat.firstChild.firstChild; | |
7b433d8c AD |
1044 | } |
1045 | } | |
7b433d8c | 1046 | } |
1da76274 AD |
1047 | |
1048 | } else { | |
1049 | e = false; | |
1050 | } | |
1051 | ||
1052 | if (e) { | |
d05514a4 | 1053 | if (!unread_only || (unread_only && e.className != "feed" && |
cabffe9d | 1054 | e.className.match("feed"))) { |
1da76274 AD |
1055 | return e.id.replace("FEEDR-", ""); |
1056 | } | |
1057 | } | |
7b433d8c | 1058 | } |
1da76274 | 1059 | |
7b433d8c AD |
1060 | } else if (direction == "prev") { |
1061 | ||
1da76274 | 1062 | var e = feed; |
7b433d8c | 1063 | |
1da76274 | 1064 | while (e) { |
7b433d8c | 1065 | |
1da76274 AD |
1066 | if (e.previousSibling) { |
1067 | ||
1068 | e = e.previousSibling; | |
1069 | ||
1070 | } else if (e.parentNode.parentNode.previousSibling) { | |
7b433d8c | 1071 | |
1da76274 | 1072 | var this_cat = e.parentNode.parentNode; |
7b433d8c | 1073 | |
1da76274 AD |
1074 | e = false; |
1075 | ||
1076 | if (this_cat && this_cat.previousSibling) { | |
1077 | while (!e && this_cat.previousSibling) { | |
1078 | this_cat = this_cat.previousSibling; | |
1079 | if (this_cat.id == "feedCatHolder") { | |
1080 | e = this_cat.firstChild.lastChild; | |
7b433d8c AD |
1081 | } |
1082 | } | |
7b433d8c | 1083 | } |
1da76274 AD |
1084 | |
1085 | } else { | |
1086 | e = false; | |
1087 | } | |
1088 | ||
1089 | if (e) { | |
e686782e | 1090 | if (!unread_only || (unread_only && e.className != "feed" && |
cabffe9d | 1091 | e.className.match("feed"))) { |
1da76274 AD |
1092 | return e.id.replace("FEEDR-", ""); |
1093 | } | |
1094 | } | |
1095 | } | |
7b433d8c AD |
1096 | } |
1097 | } | |
1098 | } | |
36aab70f AD |
1099 | |
1100 | function showBlockElement(id) { | |
1101 | var elem = document.getElementById(id); | |
1102 | ||
1103 | if (elem) { | |
1104 | elem.style.display = "block"; | |
1105 | } else { | |
1106 | alert("[showBlockElement] can't find element with id " + id); | |
1107 | } | |
1108 | } | |
1109 | ||
a9b0bfd5 AD |
1110 | function hideParentElement(e) { |
1111 | e.parentNode.style.display = "none"; | |
1112 | } | |
1b0809ae AD |
1113 | |
1114 | function dropboxSelect(e, v) { | |
1115 | for (i = 0; i < e.length; i++) { | |
1116 | if (e[i].value == v) { | |
1117 | e.selectedIndex = i; | |
1118 | break; | |
1119 | } | |
1120 | } | |
1121 | } | |
0ee1d1a0 AD |
1122 | |
1123 | // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z | |
1124 | // bugfixed just a little bit :-) | |
1125 | function getURLParam(strParamName){ | |
1126 | var strReturn = ""; | |
1127 | var strHref = window.location.href; | |
1128 | ||
1129 | if (strHref.indexOf("#") == strHref.length-1) { | |
1130 | strHref = strHref.substring(0, strHref.length-1); | |
1131 | } | |
1132 | ||
1133 | if ( strHref.indexOf("?") > -1 ){ | |
1134 | var strQueryString = strHref.substr(strHref.indexOf("?")); | |
1135 | var aQueryString = strQueryString.split("&"); | |
1136 | for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){ | |
1137 | if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){ | |
1138 | var aParam = aQueryString[iParam].split("="); | |
1139 | strReturn = aParam[1]; | |
1140 | break; | |
1141 | } | |
1142 | } | |
1143 | } | |
1144 | return strReturn; | |
1145 | } | |
1146 | ||
cf1bc085 AD |
1147 | function leading_zero(p) { |
1148 | var s = String(p); | |
1149 | if (s.length == 1) s = "0" + s; | |
1150 | return s; | |
1151 | } | |
c38c2b69 | 1152 | |
86b682ce | 1153 | function closeInfoBox(cleanup) { |
e5d758e3 AD |
1154 | var box = document.getElementById('infoBox'); |
1155 | var shadow = document.getElementById('infoBoxShadow'); | |
1156 | ||
1157 | if (shadow) { | |
1158 | shadow.style.display = "none"; | |
1159 | } else if (box) { | |
1160 | box.style.display = "none"; | |
1161 | } | |
1162 | ||
86b682ce AD |
1163 | if (cleanup) box.innerHTML = " "; |
1164 | ||
e5d758e3 | 1165 | enableHotkeys(); |
c14b5566 | 1166 | |
90ac84df | 1167 | return false; |
e5d758e3 AD |
1168 | } |
1169 | ||
1170 | ||
7b5c6012 AD |
1171 | function displayDlg(id, param) { |
1172 | ||
1173 | if (!xmlhttp_ready(xmlhttp)) { | |
1174 | printLockingError(); | |
1175 | return | |
1176 | } | |
1177 | ||
1178 | notify(""); | |
1179 | ||
1180 | xmlhttp.open("GET", "backend.php?op=dlg&id=" + | |
1181 | param_escape(id) + "¶m=" + param_escape(param), true); | |
e5d758e3 | 1182 | xmlhttp.onreadystatechange=infobox_callback; |
7b5c6012 AD |
1183 | xmlhttp.send(null); |
1184 | ||
1185 | disableHotkeys(); | |
2371c520 | 1186 | |
90ac84df | 1187 | return false; |
7b5c6012 AD |
1188 | } |
1189 | ||
e5d758e3 | 1190 | function infobox_submit_callback() { |
7b5c6012 | 1191 | if (xmlhttp.readyState == 4) { |
e5d758e3 | 1192 | closeInfoBox(); |
7b5c6012 | 1193 | |
6e6504bc AD |
1194 | try { |
1195 | // called from prefs, reload tab | |
1196 | if (active_tab) { | |
1197 | selectTab(active_tab, false); | |
1198 | } | |
1199 | } catch (e) { } | |
79f3553b AD |
1200 | |
1201 | notify(xmlhttp.responseText); | |
1202 | ||
7b5c6012 AD |
1203 | } |
1204 | } | |
1205 | ||
e5d758e3 | 1206 | function infobox_callback() { |
7b5c6012 | 1207 | if (xmlhttp.readyState == 4) { |
e5d758e3 AD |
1208 | var box = document.getElementById('infoBox'); |
1209 | var shadow = document.getElementById('infoBoxShadow'); | |
1210 | if (box) { | |
1211 | box.innerHTML=xmlhttp.responseText; | |
1212 | if (shadow) { | |
1213 | shadow.style.display = "block"; | |
1214 | } else { | |
1215 | box.style.display = "block"; | |
1216 | } | |
1217 | } | |
9c483746 | 1218 | notify(""); |
e5d758e3 | 1219 | } |
7b5c6012 AD |
1220 | } |
1221 | ||
1222 | function qaddFilter() { | |
1223 | ||
1224 | if (!xmlhttp_ready(xmlhttp)) { | |
1225 | printLockingError(); | |
1226 | return | |
1227 | } | |
1228 | ||
c91c2249 AD |
1229 | var form = document.forms['filter_add_form']; |
1230 | var reg_exp = form.reg_exp.value; | |
1231 | ||
1232 | if (reg_exp == "") { | |
1233 | alert("Can't add filter: nothing to match on."); | |
1234 | return false; | |
1235 | } | |
1236 | ||
79f3553b | 1237 | var query = Form.serialize("filter_add_form"); |
7b5c6012 | 1238 | |
79f3553b AD |
1239 | xmlhttp.open("GET", "backend.php?" + query, true); |
1240 | xmlhttp.onreadystatechange=infobox_submit_callback; | |
1241 | xmlhttp.send(null); | |
7b5c6012 | 1242 | |
c14b5566 | 1243 | return true; |
7b5c6012 AD |
1244 | } |
1245 | ||
2371c520 AD |
1246 | function toggleSubmitNotEmpty(e, submit_id) { |
1247 | try { | |
1248 | document.getElementById(submit_id).disabled = (e.value == "") | |
1249 | } catch (e) { | |
1250 | exception_error("toggleSubmitNotEmpty", e); | |
1251 | } | |
1252 | } | |
1d7bf5a0 | 1253 | |
605f7d46 AD |
1254 | function isValidURL(s) { |
1255 | return s.match("http://") != null || s.match("https://") != null; | |
1256 | } | |
07eb9178 AD |
1257 | |
1258 | function qafAdd() { | |
1259 | ||
1260 | if (!xmlhttp_ready(xmlhttp)) { | |
1261 | printLockingError(); | |
1262 | return | |
1263 | } | |
1264 | ||
c91c2249 AD |
1265 | var form = document.forms['feed_add_form']; |
1266 | var feed_url = form.feed_url.value; | |
1267 | ||
1268 | if (feed_url == "") { | |
1269 | alert("Can't subscribe: no feed URL given."); | |
1270 | return false; | |
1271 | } | |
1272 | ||
a58d997c | 1273 | notify("Adding feed...", true); |
07eb9178 AD |
1274 | |
1275 | closeInfoBox(); | |
1276 | ||
0feab655 | 1277 | var feeds_doc = document; |
07eb9178 | 1278 | |
80e4dc34 | 1279 | // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait..."; |
07eb9178 AD |
1280 | |
1281 | var query = Form.serialize("feed_add_form"); | |
1282 | ||
1283 | xmlhttp.open("GET", "backend.php?" + query, true); | |
1284 | xmlhttp.onreadystatechange=dlg_frefresh_callback; | |
1285 | xmlhttp.send(null); | |
7bc4f251 AD |
1286 | |
1287 | return false; | |
07eb9178 AD |
1288 | } |
1289 | ||
6e6504bc | 1290 | function filterCR(e, f) |
86b682ce AD |
1291 | { |
1292 | var key; | |
1293 | ||
1294 | if(window.event) | |
1295 | key = window.event.keyCode; //IE | |
1296 | else | |
1297 | key = e.which; //firefox | |
1298 | ||
6e6504bc AD |
1299 | if (key == 13) { |
1300 | if (typeof f != 'undefined') { | |
1301 | f(); | |
1302 | return false; | |
1303 | } else { | |
1304 | return false; | |
1305 | } | |
1306 | } else { | |
1307 | return true; | |
1308 | } | |
86b682ce AD |
1309 | } |
1310 | ||
ac378ad4 | 1311 | function getMainContext() { |
6b4163cb | 1312 | return this.window; |
ac378ad4 AD |
1313 | } |
1314 | ||
33d13e72 | 1315 | function getFeedsContext() { |
6b4163cb | 1316 | return this.window; |
33d13e72 AD |
1317 | } |
1318 | ||
0bd411db | 1319 | function getContentContext() { |
6b4163cb | 1320 | return this.window; |
0bd411db AD |
1321 | } |
1322 | ||
ee1f45f4 | 1323 | function getHeadlinesContext() { |
6b4163cb | 1324 | return this.window; |
ee1f45f4 AD |
1325 | } |
1326 | ||
e8614131 AD |
1327 | var debug_last_class = "even"; |
1328 | ||
ac378ad4 | 1329 | function debug(msg) { |
ac378ad4 | 1330 | |
0feab655 AD |
1331 | if (debug_last_class == "even") { |
1332 | debug_last_class = "odd"; | |
e8614131 | 1333 | } else { |
0feab655 | 1334 | debug_last_class = "even"; |
e8614131 AD |
1335 | } |
1336 | ||
0feab655 | 1337 | var c = document.getElementById('debug_output'); |
ac378ad4 | 1338 | if (c && c.style.display == "block") { |
c9268ed5 | 1339 | while (c.lastChild != 'undefined' && c.childNodes.length > 100) { |
ac378ad4 AD |
1340 | c.removeChild(c.lastChild); |
1341 | } | |
1342 | ||
1343 | var d = new Date(); | |
1344 | var ts = leading_zero(d.getHours()) + ":" + leading_zero(d.getMinutes()) + | |
1345 | ":" + leading_zero(d.getSeconds()); | |
0feab655 | 1346 | c.innerHTML = "<li class=\"" + debug_last_class + "\"><span class=\"debugTS\">[" + ts + "]</span> " + |
e8614131 | 1347 | msg + "</li>" + c.innerHTML; |
ac378ad4 AD |
1348 | } |
1349 | } | |
1350 | ||
33d13e72 AD |
1351 | function getInitParam(key) { |
1352 | return getMainContext().init_params[key]; | |
1353 | } | |
3ac2b520 | 1354 | |
e8bd0da9 | 1355 | function storeInitParam(key, value, is_client) { |
33d13e72 | 1356 | try { |
e8bd0da9 | 1357 | if (!is_client) { |
1035fcec AD |
1358 | if (getMainContext().init_params[key] != value) { |
1359 | debug("storeInitParam: " + key + " => " + value); | |
0b7cb301 AD |
1360 | //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" + |
1361 | // param_escape(key) + "&value=" + param_escape(value)); | |
1362 | var f = getMainContext().document.getElementById("backReqBox"); | |
1363 | f.src = "backend.php?op=rpc&subop=storeParam&key=" + | |
1364 | param_escape(key) + "&value=" + param_escape(value); | |
1035fcec | 1365 | } |
e8bd0da9 | 1366 | } |
1035fcec | 1367 | getMainContext().init_params[key] = value; |
33d13e72 AD |
1368 | } catch (e) { |
1369 | exception_error("storeInitParam", e); | |
1370 | } | |
1371 | } | |
a7565293 | 1372 | |
1035fcec AD |
1373 | /* |
1374 | function storeInitParams(params, is_client) { | |
1375 | try { | |
1376 | var s = ""; | |
1377 | ||
1378 | for (k in params) { | |
1379 | if (getMainContext().init_params[k] != params[k]) { | |
1380 | s += k + "=" + params[k] + ";"; | |
1381 | getMainContext().init_params[k] = params[k]; | |
1382 | } | |
1383 | } | |
1384 | ||
1385 | debug("storeInitParams: " + s); | |
1386 | ||
1387 | if (!is_client) { | |
1388 | new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s); | |
1389 | } | |
1390 | } catch (e) { | |
1391 | exception_error("storeInitParams", e); | |
1392 | } | |
1393 | }*/ | |
1394 | ||
a7565293 AD |
1395 | function fatalError(code, message) { |
1396 | try { | |
1397 | var fe = document.getElementById("fatal_error"); | |
1398 | var fc = document.getElementById("fatal_error_msg"); | |
1399 | ||
1400 | fc.innerHTML = "Code " + code + ": " + message; | |
1401 | ||
1402 | fe.style.display = "block"; | |
1403 | ||
1404 | } catch (e) { | |
1405 | exception_error("fatalError", e); | |
1406 | } | |
1407 | } | |
1408 | ||
234e467c | 1409 | function getFeedName(id, is_cat) { |
64a2875d | 1410 | var d = getFeedsContext().document; |
234e467c AD |
1411 | |
1412 | var e; | |
1413 | ||
1414 | if (is_cat) { | |
1415 | e = d.getElementById("FCATN-" + id); | |
1416 | } else { | |
1417 | e = d.getElementById("FEEDN-" + id); | |
1418 | } | |
64a2875d AD |
1419 | if (e) { |
1420 | return e.innerHTML.stripTags(); | |
1421 | } else { | |
1422 | return null; | |
1423 | } | |
1424 | } | |
0bd411db AD |
1425 | |
1426 | function viewContentUrl(url) { | |
1427 | getContentContext().location = url; | |
1428 | } |