]>
Commit | Line | Data |
---|---|---|
1 | var hotkeys_enabled = true; | |
2 | ||
3 | var xmlhttp_rpc = Ajax.getTransport(); | |
4 | ||
5 | function browser_has_opacity() { | |
6 | return navigator.userAgent.match("Gecko") != null || | |
7 | navigator.userAgent.match("Opera") != null; | |
8 | } | |
9 | ||
10 | function is_opera() { | |
11 | return navigator.userAgent.match("Opera"); | |
12 | } | |
13 | ||
14 | function exception_error(location, e, silent) { | |
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; | |
23 | ||
24 | } else { | |
25 | msg = "Exception: " + e + "\nFunction: " + location + "()"; | |
26 | } | |
27 | ||
28 | debug("<b>EXCEPTION: " + msg + "</b>"); | |
29 | ||
30 | if (!silent) { | |
31 | alert(msg); | |
32 | } | |
33 | } | |
34 | ||
35 | function disableHotkeys() { | |
36 | hotkeys_enabled = false; | |
37 | } | |
38 | ||
39 | function enableHotkeys() { | |
40 | hotkeys_enabled = true; | |
41 | } | |
42 | ||
43 | function xmlhttp_ready(obj) { | |
44 | return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState; | |
45 | } | |
46 | ||
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 | ||
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 | ||
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 | } | |
83 | ||
84 | var notify_hide_timerid = false; | |
85 | var notify_last_doc = false; | |
86 | ||
87 | var notify_effect = false; | |
88 | ||
89 | function hide_notify() { | |
90 | if (notify_last_doc) { | |
91 | var n = notify_last_doc.getElementById("notify"); | |
92 | n.style.display = "none"; | |
93 | ||
94 | /* if (browser_has_opacity()) { | |
95 | if (notify_opacity >= 0) { | |
96 | notify_opacity = notify_opacity - 0.1; | |
97 | n.style.opacity = notify_opacity; | |
98 | notify_hide_timerid = window.setTimeout("hide_notify()", 20); | |
99 | } else { | |
100 | n.style.display = "none"; | |
101 | n.style.opacity = 1; | |
102 | } | |
103 | } else { | |
104 | n.style.display = "none"; | |
105 | } */ | |
106 | } | |
107 | } | |
108 | ||
109 | function notify_real(msg, doc, no_hide, is_err) { | |
110 | ||
111 | var n = doc.getElementById("notify"); | |
112 | var nb = doc.getElementById("notify_body"); | |
113 | ||
114 | if (!n || !nb) return; | |
115 | ||
116 | if (notify_hide_timerid) { | |
117 | window.clearTimeout(notify_hide_timerid); | |
118 | } | |
119 | ||
120 | notify_last_doc = doc; | |
121 | notify_opacity = 1; | |
122 | ||
123 | if (msg == "") { | |
124 | if (n.style.display == "block") { | |
125 | notify_hide_timerid = window.setTimeout("hide_notify()", 0); | |
126 | } | |
127 | return; | |
128 | } else { | |
129 | n.style.display = "block"; | |
130 | } | |
131 | ||
132 | if (is_err) { | |
133 | n.className = "notifyError"; | |
134 | // n.style.backgroundColor = "#ffcccc"; | |
135 | // n.style.color = "black"; | |
136 | // n.style.borderColor = "#ff0000"; | |
137 | } else { | |
138 | n.className = "notify"; | |
139 | // n.style.backgroundColor = "#fff7d5"; | |
140 | // n.style.borderColor = "#d7c47a"; | |
141 | // n.style.color = "black"; | |
142 | } | |
143 | ||
144 | // msg = "<img src='images/live_com_loading.gif'> " + msg; | |
145 | ||
146 | nb.innerHTML = msg; | |
147 | ||
148 | if (!no_hide) { | |
149 | notify_hide_timerid = window.setTimeout("hide_notify()", 3000); | |
150 | } | |
151 | } | |
152 | ||
153 | function p_notify(msg, no_hide, is_err) { | |
154 | notify_real(msg, document, no_hide, is_err); | |
155 | } | |
156 | ||
157 | function notify(msg, no_hide, is_err) { | |
158 | notify_real(msg, document, no_hide, is_err); | |
159 | } | |
160 | ||
161 | function printLockingError() { | |
162 | notify("Please wait until operation finishes");} | |
163 | ||
164 | function hotkey_handler(e) { | |
165 | ||
166 | try { | |
167 | ||
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 | } | |
177 | ||
178 | if (keycode == 82) { // r | |
179 | return scheduleFeedUpdate(true); | |
180 | } | |
181 | ||
182 | if (keycode == 83) { // r | |
183 | return displayDlg("search", getActiveFeedId()); | |
184 | } | |
185 | ||
186 | if (keycode == 85) { // u | |
187 | if (getActiveFeedId()) { | |
188 | return viewfeed(getActiveFeedId(), "ForceUpdate"); | |
189 | } | |
190 | } | |
191 | ||
192 | if (keycode == 65) { // a | |
193 | return toggleDispRead(); | |
194 | } | |
195 | ||
196 | var feedlist = document.getElementById('feedList'); | |
197 | ||
198 | if (keycode == 74) { // j | |
199 | var feed = getActiveFeedId(); | |
200 | var new_feed = getRelativeFeedId(feedlist, feed, 'prev'); | |
201 | if (new_feed) viewfeed(new_feed, ''); | |
202 | } | |
203 | ||
204 | if (keycode == 75) { // k | |
205 | var feed = getActiveFeedId(); | |
206 | var new_feed = getRelativeFeedId(feedlist, feed, 'next'); | |
207 | if (new_feed) viewfeed(new_feed, ''); | |
208 | } | |
209 | ||
210 | if (keycode == 78 || keycode == 40) { // n, down | |
211 | if (typeof moveToPost != 'undefined') { | |
212 | return moveToPost('next'); | |
213 | } | |
214 | } | |
215 | ||
216 | if (keycode == 80 || keycode == 38) { // p, up | |
217 | if (typeof moveToPost != 'undefined') { | |
218 | return moveToPost('prev'); | |
219 | } | |
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 | } | |
232 | } | |
233 | ||
234 | function cleanSelectedList(element) { | |
235 | var content = document.getElementById(element); | |
236 | ||
237 | if (!document.getElementById("feedCatHolder")) { | |
238 | for (i = 0; i < content.childNodes.length; i++) { | |
239 | var child = content.childNodes[i]; | |
240 | try { | |
241 | child.className = child.className.replace("Selected", ""); | |
242 | } catch (e) { | |
243 | // | |
244 | } | |
245 | } | |
246 | } else { | |
247 | for (i = 0; i < content.childNodes.length; i++) { | |
248 | var child = content.childNodes[i]; | |
249 | if (child.id == "feedCatHolder") { | |
250 | debug(child.id); | |
251 | var fcat = child.lastChild; | |
252 | for (j = 0; j < fcat.childNodes.length; j++) { | |
253 | var feed = fcat.childNodes[j]; | |
254 | feed.className = feed.className.replace("Selected", ""); | |
255 | } | |
256 | } | |
257 | } | |
258 | } | |
259 | } | |
260 | ||
261 | ||
262 | function cleanSelected(element) { | |
263 | var content = document.getElementById(element); | |
264 | ||
265 | for (i = 0; i < content.rows.length; i++) { | |
266 | content.rows[i].className = content.rows[i].className.replace("Selected", ""); | |
267 | } | |
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) { | |
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 | ||
325 | var check = document.getElementById("RCHK-" + id); | |
326 | ||
327 | if (check) { | |
328 | check.checked = true; | |
329 | } | |
330 | ||
331 | row.className = row.className + "Selected"; | |
332 | ||
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 | } | |
350 | ||
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) { | |
365 | document.cookie= name + "=" + escape(value) + | |
366 | ((expires) ? "; expires=" + expires.toGMTString() : "") + | |
367 | ((path) ? "; path=" + path : "") + | |
368 | ((domain) ? "; domain=" + domain : "") + | |
369 | ((secure) ? "; secure" : ""); | |
370 | } | |
371 | ||
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 | ||
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 | ||
401 | function disableContainerChildren(id, disable, doc) { | |
402 | ||
403 | if (!doc) doc = document; | |
404 | ||
405 | var container = doc.getElementById(id); | |
406 | ||
407 | if (!container) { | |
408 | //alert("disableContainerChildren: element " + id + " not found"); | |
409 | return; | |
410 | } | |
411 | ||
412 | for (var i = 0; i < container.childNodes.length; i++) { | |
413 | var child = container.childNodes[i]; | |
414 | ||
415 | try { | |
416 | child.disabled = disable; | |
417 | } catch (E) { | |
418 | ||
419 | } | |
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 | } | |
429 | } | |
430 | } | |
431 | ||
432 | } | |
433 | ||
434 | function gotoPreferences() { | |
435 | document.location.href = "prefs.php"; | |
436 | } | |
437 | ||
438 | function gotoMain() { | |
439 | document.location.href = "tt-rss.php"; | |
440 | } | |
441 | ||
442 | function gotoExportOpml() { | |
443 | document.location.href = "opml.php?op=Export"; | |
444 | } | |
445 | ||
446 | function getActiveFeedId() { | |
447 | // return getCookie("ttrss_vf_actfeed"); | |
448 | try { | |
449 | debug("gAFID: " + active_feed_id); | |
450 | return active_feed_id; | |
451 | } catch (e) { | |
452 | exception_error("getActiveFeedId", e); | |
453 | } | |
454 | } | |
455 | ||
456 | function activeFeedIsCat() { | |
457 | return active_feed_is_cat; | |
458 | } | |
459 | ||
460 | function setActiveFeedId(id) { | |
461 | // return setCookie("ttrss_vf_actfeed", id); | |
462 | try { | |
463 | debug("sAFID(" + id + ")"); | |
464 | active_feed_id = id; | |
465 | } catch (e) { | |
466 | exception_error("setActiveFeedId", e); | |
467 | } | |
468 | } | |
469 | ||
470 | function parse_counters(reply, scheduled_call) { | |
471 | try { | |
472 | ||
473 | var feeds_found = 0; | |
474 | ||
475 | if (reply.firstChild && reply.firstChild.firstChild) { | |
476 | debug("<b>wrong element passed to parse_counters, adjusting.</b>"); | |
477 | reply = reply.firstChild; | |
478 | } | |
479 | ||
480 | for (var l = 0; l < reply.childNodes.length; l++) { | |
481 | if (!reply.childNodes[l] || | |
482 | typeof(reply.childNodes[l].getAttribute) == "undefined") { | |
483 | // where did this come from? | |
484 | continue; | |
485 | } | |
486 | ||
487 | var id = reply.childNodes[l].getAttribute("id"); | |
488 | var t = reply.childNodes[l].getAttribute("type"); | |
489 | var ctr = reply.childNodes[l].getAttribute("counter"); | |
490 | var error = reply.childNodes[l].getAttribute("error"); | |
491 | var has_img = reply.childNodes[l].getAttribute("hi"); | |
492 | var updated = reply.childNodes[l].getAttribute("updated"); | |
493 | ||
494 | if (id == "global-unread") { | |
495 | global_unread = ctr; | |
496 | updateTitle(); | |
497 | continue; | |
498 | } | |
499 | ||
500 | if (id == "subscribed-feeds") { | |
501 | feeds_found = ctr; | |
502 | continue; | |
503 | } | |
504 | ||
505 | if (t == "category") { | |
506 | var catctr = document.getElementById("FCATCTR-" + id); | |
507 | if (catctr) { | |
508 | catctr.innerHTML = "(" + ctr + " unread)"; | |
509 | } | |
510 | continue; | |
511 | } | |
512 | ||
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); | |
519 | ||
520 | if (updated && feedlink) { | |
521 | if (error) { | |
522 | feedlink.title = "Error: " + error + " (" + updated + ")"; | |
523 | } else { | |
524 | feedlink.title = "Updated: " + updated; | |
525 | } | |
526 | } | |
527 | ||
528 | if (updated && feedupd) { | |
529 | if (error) { | |
530 | feedupd.innerHTML = updated + " (Error)"; | |
531 | } else { | |
532 | feedupd.innerHTML = updated; | |
533 | } | |
534 | } | |
535 | ||
536 | if (feedctr && feedu && feedr) { | |
537 | ||
538 | if (feedu.innerHTML != ctr && id == getActiveFeedId() && scheduled_call) { | |
539 | viewCurrentFeed(); | |
540 | } | |
541 | ||
542 | feedu.innerHTML = ctr; | |
543 | ||
544 | if (error) { | |
545 | feedr.className = feedr.className.replace("feed", "error"); | |
546 | } else if (id > 0) { | |
547 | feedr.className = feedr.className.replace("error", "feed"); | |
548 | } | |
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 | } | |
571 | ||
572 | hideOrShowFeeds(document, getInitParam("hide_read_feeds") == 1); | |
573 | ||
574 | var feeds_stored = number_of_feeds; | |
575 | ||
576 | debug("Feed counters, C: " + feeds_found + ", S:" + feeds_stored); | |
577 | ||
578 | if (feeds_stored != feeds_found) { | |
579 | number_of_feeds = feeds_found; | |
580 | ||
581 | if (feeds_stored != 0) { | |
582 | debug("Subscribed feed number changed, refreshing feedlist"); | |
583 | setTimeout('updateFeedList(false, false)', 50); | |
584 | } | |
585 | } | |
586 | ||
587 | } catch (e) { | |
588 | exception_error("parse_counters", e); | |
589 | } | |
590 | } | |
591 | ||
592 | function all_counters_callback() { | |
593 | if (xmlhttp_rpc.readyState == 4) { | |
594 | try { | |
595 | if (!xmlhttp_rpc.responseXML || !xmlhttp_rpc.responseXML.firstChild) { | |
596 | debug("[all_counters_callback] backend did not return valid XML"); | |
597 | return; | |
598 | } | |
599 | ||
600 | debug("in all_counters_callback : " + xmlhttp_rpc.responseXML); | |
601 | ||
602 | var reply = xmlhttp_rpc.responseXML.firstChild; | |
603 | ||
604 | var counters = reply.firstChild; | |
605 | ||
606 | parse_counters(counters); | |
607 | ||
608 | var runtime = counters.nextSibling; | |
609 | ||
610 | if (runtime) { | |
611 | parse_runtime_info(runtime); | |
612 | } | |
613 | ||
614 | if (getInitParam("feeds_sort_by_unread") == 1) { | |
615 | resort_feedlist(); | |
616 | } | |
617 | ||
618 | hideOrShowFeeds(document, getInitParam("hide_read_feeds") == 1); | |
619 | ||
620 | } catch (e) { | |
621 | exception_error("all_counters_callback", e); | |
622 | } | |
623 | } | |
624 | } | |
625 | ||
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 | ||
674 | var fd = document; | |
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 | ||
695 | function update_all_counters(feed) { | |
696 | if (xmlhttp_ready(xmlhttp_rpc)) { | |
697 | var query = "backend.php?op=rpc&subop=getAllCounters"; | |
698 | ||
699 | if (feed > 0) { | |
700 | query = query + "&aid=" + feed; | |
701 | } | |
702 | ||
703 | xmlhttp_rpc.open("GET", query, true); | |
704 | xmlhttp_rpc.onreadystatechange=all_counters_callback; | |
705 | xmlhttp_rpc.send(null); | |
706 | } | |
707 | } | |
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 | } | |
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 | ||
748 | ||
749 | function hideOrShowFeeds(doc, hide) { | |
750 | ||
751 | debug("hideOrShowFeeds: " + doc + ", " + hide); | |
752 | ||
753 | var fd = document; | |
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 + ")"); | |
779 | ||
780 | var cat_unread = 0; | |
781 | ||
782 | if (!node) { | |
783 | debug("hideOrShowFeeds: passed node is null, aborting"); | |
784 | return; | |
785 | } | |
786 | ||
787 | if (node.hasChildNodes() && node.firstChild.nextSibling != false) { | |
788 | for (i = 0; i < node.childNodes.length; i++) { | |
789 | if (node.childNodes[i].nodeName != "LI") { continue; } | |
790 | ||
791 | if (node.childNodes[i].style != undefined) { | |
792 | ||
793 | var has_unread = (node.childNodes[i].className != "feed"); | |
794 | ||
795 | // debug(node.childNodes[i].id + " --> " + has_unread); | |
796 | ||
797 | if (hide && !has_unread) { | |
798 | node.childNodes[i].style.display = "none"; | |
799 | } | |
800 | ||
801 | if (!hide) { | |
802 | node.childNodes[i].style.display = "list-item"; | |
803 | } | |
804 | ||
805 | if (has_unread) { | |
806 | node.childNodes[i].style.display = "list-item"; | |
807 | cat_unread++; | |
808 | } | |
809 | } | |
810 | } | |
811 | } | |
812 | ||
813 | if (cat_unread == 0) { | |
814 | if (cat_node.style == undefined) { | |
815 | debug("ERROR: supplied cat_node " + cat_node + | |
816 | " has no styles. WTF?"); | |
817 | return; | |
818 | } | |
819 | if (hide) { | |
820 | cat_node.style.display = "none"; | |
821 | } else { | |
822 | cat_node.style.display = "list-item"; | |
823 | } | |
824 | } else { | |
825 | try { | |
826 | cat_node.style.display = "list-item"; | |
827 | } catch (e) { | |
828 | debug(e); | |
829 | } | |
830 | } | |
831 | ||
832 | // debug("unread for category: " + cat_unread); | |
833 | } | |
834 | ||
835 | function selectTableRow(r, do_select) { | |
836 | r.className = r.className.replace("Selected", ""); | |
837 | ||
838 | if (do_select) { | |
839 | r.className = r.className + "Selected"; | |
840 | } | |
841 | } | |
842 | ||
843 | function selectTableRowById(elem_id, check_id, do_select) { | |
844 | ||
845 | try { | |
846 | ||
847 | var row = document.getElementById(elem_id); | |
848 | ||
849 | if (row) { | |
850 | selectTableRow(row, do_select); | |
851 | } | |
852 | ||
853 | var check = document.getElementById(check_id); | |
854 | ||
855 | if (check) { | |
856 | check.checked = do_select; | |
857 | } | |
858 | } catch (e) { | |
859 | exception_error("selectTableRowById", e); | |
860 | } | |
861 | } | |
862 | ||
863 | function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select, | |
864 | classcheck, reset_others) { | |
865 | ||
866 | var content = document.getElementById(content_id); | |
867 | ||
868 | if (!content) { | |
869 | alert("[selectTableRows] Element " + content_id + " not found."); | |
870 | return; | |
871 | } | |
872 | ||
873 | for (i = 0; i < content.rows.length; i++) { | |
874 | if (!classcheck || content.rows[i].className.match(classcheck)) { | |
875 | ||
876 | if (content.rows[i].id.match(prefix)) { | |
877 | selectTableRow(content.rows[i], do_select); | |
878 | ||
879 | var row_id = content.rows[i].id.replace(prefix, ""); | |
880 | var check = document.getElementById(check_prefix + row_id); | |
881 | ||
882 | if (check) { | |
883 | check.checked = do_select; | |
884 | } | |
885 | } else if (reset_others) { | |
886 | selectTableRow(content.rows[i], false); | |
887 | ||
888 | var row_id = content.rows[i].id.replace(prefix, ""); | |
889 | var check = document.getElementById(check_prefix + row_id); | |
890 | ||
891 | if (check) { | |
892 | check.checked = false; | |
893 | } | |
894 | ||
895 | } | |
896 | } else if (reset_others) { | |
897 | selectTableRow(content.rows[i], false); | |
898 | ||
899 | var row_id = content.rows[i].id.replace(prefix, ""); | |
900 | var check = document.getElementById(check_prefix + row_id); | |
901 | ||
902 | if (check) { | |
903 | check.checked = false; | |
904 | } | |
905 | ||
906 | } | |
907 | } | |
908 | } | |
909 | ||
910 | function getSelectedTableRowIds(content_id, prefix) { | |
911 | ||
912 | var content = document.getElementById(content_id); | |
913 | ||
914 | if (!content) { | |
915 | alert("[getSelectedTableRowIds] Element " + content_id + " not found."); | |
916 | return; | |
917 | } | |
918 | ||
919 | var sel_rows = new Array(); | |
920 | ||
921 | for (i = 0; i < content.rows.length; i++) { | |
922 | if (content.rows[i].id.match(prefix) && | |
923 | content.rows[i].className.match("Selected")) { | |
924 | ||
925 | var row_id = content.rows[i].id.replace(prefix + "-", ""); | |
926 | sel_rows.push(row_id); | |
927 | } | |
928 | } | |
929 | ||
930 | return sel_rows; | |
931 | ||
932 | } | |
933 | ||
934 | function toggleSelectRowById(sender, id) { | |
935 | var row = document.getElementById(id); | |
936 | ||
937 | if (sender.checked) { | |
938 | if (!row.className.match("Selected")) { | |
939 | row.className = row.className + "Selected"; | |
940 | } | |
941 | } else { | |
942 | if (row.className.match("Selected")) { | |
943 | row.className = row.className.replace("Selected", ""); | |
944 | } | |
945 | } | |
946 | } | |
947 | ||
948 | function toggleSelectListRow(sender) { | |
949 | var parent_row = sender.parentNode; | |
950 | ||
951 | if (sender.checked) { | |
952 | if (!parent_row.className.match("Selected")) { | |
953 | parent_row.className = parent_row.className + "Selected"; | |
954 | } | |
955 | } else { | |
956 | if (parent_row.className.match("Selected")) { | |
957 | parent_row.className = parent_row.className.replace("Selected", ""); | |
958 | } | |
959 | } | |
960 | } | |
961 | ||
962 | ||
963 | function toggleSelectRow(sender) { | |
964 | var parent_row = sender.parentNode.parentNode; | |
965 | ||
966 | if (sender.checked) { | |
967 | if (!parent_row.className.match("Selected")) { | |
968 | parent_row.className = parent_row.className + "Selected"; | |
969 | } | |
970 | } else { | |
971 | if (parent_row.className.match("Selected")) { | |
972 | parent_row.className = parent_row.className.replace("Selected", ""); | |
973 | } | |
974 | } | |
975 | } | |
976 | ||
977 | function openExternalUrl(url) { | |
978 | var w = window.open(url); | |
979 | } | |
980 | ||
981 | function getRelativeFeedId(list, id, direction, unread_only) { | |
982 | if (!id) { | |
983 | if (direction == "next") { | |
984 | for (i = 0; i < list.childNodes.length; i++) { | |
985 | var child = list.childNodes[i]; | |
986 | if (child.id && child.id == "feedCatHolder") { | |
987 | if (child.lastChild) { | |
988 | var cr = getRelativeFeedId(child.firstChild, id, direction, unread_only); | |
989 | if (cr) return cr; | |
990 | } | |
991 | } else if (child.id && child.id.match("FEEDR-")) { | |
992 | return child.id.replace('FEEDR-', ''); | |
993 | } | |
994 | } | |
995 | } | |
996 | ||
997 | // FIXME select last feed doesn't work when only unread feeds are visible | |
998 | ||
999 | if (direction == "prev") { | |
1000 | for (i = list.childNodes.length-1; i >= 0; i--) { | |
1001 | var child = list.childNodes[i]; | |
1002 | if (child.id == "feedCatHolder") { | |
1003 | if (child.firstChild) { | |
1004 | var cr = getRelativeFeedId(child.firstChild, id, direction); | |
1005 | if (cr) return cr; | |
1006 | } | |
1007 | } else if (child.id.match("FEEDR-")) { | |
1008 | ||
1009 | if (getInitParam("hide_read_feeds") == 1) { | |
1010 | if (child.className != "feed") { | |
1011 | alert(child.className); | |
1012 | return child.id.replace('FEEDR-', ''); | |
1013 | } | |
1014 | } else { | |
1015 | return child.id.replace('FEEDR-', ''); | |
1016 | } | |
1017 | } | |
1018 | } | |
1019 | } | |
1020 | } else { | |
1021 | ||
1022 | var feed = list.ownerDocument.getElementById("FEEDR-" + id); | |
1023 | ||
1024 | if (getInitParam("hide_read_feeds") == 1) { | |
1025 | unread_only = true; | |
1026 | } | |
1027 | ||
1028 | if (direction == "next") { | |
1029 | ||
1030 | var e = feed; | |
1031 | ||
1032 | while (e) { | |
1033 | ||
1034 | if (e.nextSibling) { | |
1035 | ||
1036 | e = e.nextSibling; | |
1037 | ||
1038 | } else if (e.parentNode.parentNode.nextSibling) { | |
1039 | ||
1040 | var this_cat = e.parentNode.parentNode; | |
1041 | ||
1042 | e = false; | |
1043 | ||
1044 | if (this_cat && this_cat.nextSibling) { | |
1045 | while (!e && this_cat.nextSibling) { | |
1046 | this_cat = this_cat.nextSibling; | |
1047 | if (this_cat.id == "feedCatHolder") { | |
1048 | e = this_cat.firstChild.firstChild; | |
1049 | } | |
1050 | } | |
1051 | } | |
1052 | ||
1053 | } else { | |
1054 | e = false; | |
1055 | } | |
1056 | ||
1057 | if (e) { | |
1058 | if (!unread_only || (unread_only && e.className != "feed" && | |
1059 | e.className.match("feed"))) { | |
1060 | return e.id.replace("FEEDR-", ""); | |
1061 | } | |
1062 | } | |
1063 | } | |
1064 | ||
1065 | } else if (direction == "prev") { | |
1066 | ||
1067 | var e = feed; | |
1068 | ||
1069 | while (e) { | |
1070 | ||
1071 | if (e.previousSibling) { | |
1072 | ||
1073 | e = e.previousSibling; | |
1074 | ||
1075 | } else if (e.parentNode.parentNode.previousSibling) { | |
1076 | ||
1077 | var this_cat = e.parentNode.parentNode; | |
1078 | ||
1079 | e = false; | |
1080 | ||
1081 | if (this_cat && this_cat.previousSibling) { | |
1082 | while (!e && this_cat.previousSibling) { | |
1083 | this_cat = this_cat.previousSibling; | |
1084 | if (this_cat.id == "feedCatHolder") { | |
1085 | e = this_cat.firstChild.lastChild; | |
1086 | } | |
1087 | } | |
1088 | } | |
1089 | ||
1090 | } else { | |
1091 | e = false; | |
1092 | } | |
1093 | ||
1094 | if (e) { | |
1095 | if (!unread_only || (unread_only && e.className != "feed" && | |
1096 | e.className.match("feed"))) { | |
1097 | return e.id.replace("FEEDR-", ""); | |
1098 | } | |
1099 | } | |
1100 | } | |
1101 | } | |
1102 | } | |
1103 | } | |
1104 | ||
1105 | function showBlockElement(id) { | |
1106 | var elem = document.getElementById(id); | |
1107 | ||
1108 | if (elem) { | |
1109 | elem.style.display = "block"; | |
1110 | } else { | |
1111 | alert("[showBlockElement] can't find element with id " + id); | |
1112 | } | |
1113 | } | |
1114 | ||
1115 | function hideParentElement(e) { | |
1116 | e.parentNode.style.display = "none"; | |
1117 | } | |
1118 | ||
1119 | function dropboxSelect(e, v) { | |
1120 | for (i = 0; i < e.length; i++) { | |
1121 | if (e[i].value == v) { | |
1122 | e.selectedIndex = i; | |
1123 | break; | |
1124 | } | |
1125 | } | |
1126 | } | |
1127 | ||
1128 | // originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z | |
1129 | // bugfixed just a little bit :-) | |
1130 | function getURLParam(strParamName){ | |
1131 | var strReturn = ""; | |
1132 | var strHref = window.location.href; | |
1133 | ||
1134 | if (strHref.indexOf("#") == strHref.length-1) { | |
1135 | strHref = strHref.substring(0, strHref.length-1); | |
1136 | } | |
1137 | ||
1138 | if ( strHref.indexOf("?") > -1 ){ | |
1139 | var strQueryString = strHref.substr(strHref.indexOf("?")); | |
1140 | var aQueryString = strQueryString.split("&"); | |
1141 | for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){ | |
1142 | if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){ | |
1143 | var aParam = aQueryString[iParam].split("="); | |
1144 | strReturn = aParam[1]; | |
1145 | break; | |
1146 | } | |
1147 | } | |
1148 | } | |
1149 | return strReturn; | |
1150 | } | |
1151 | ||
1152 | function leading_zero(p) { | |
1153 | var s = String(p); | |
1154 | if (s.length == 1) s = "0" + s; | |
1155 | return s; | |
1156 | } | |
1157 | ||
1158 | function closeInfoBox(cleanup) { | |
1159 | var box = document.getElementById('infoBox'); | |
1160 | var shadow = document.getElementById('infoBoxShadow'); | |
1161 | ||
1162 | if (shadow) { | |
1163 | shadow.style.display = "none"; | |
1164 | } else if (box) { | |
1165 | box.style.display = "none"; | |
1166 | } | |
1167 | ||
1168 | if (cleanup) box.innerHTML = " "; | |
1169 | ||
1170 | enableHotkeys(); | |
1171 | ||
1172 | return false; | |
1173 | } | |
1174 | ||
1175 | ||
1176 | function displayDlg(id, param) { | |
1177 | ||
1178 | if (!xmlhttp_ready(xmlhttp)) { | |
1179 | printLockingError(); | |
1180 | return | |
1181 | } | |
1182 | ||
1183 | notify(""); | |
1184 | ||
1185 | xmlhttp.open("GET", "backend.php?op=dlg&id=" + | |
1186 | param_escape(id) + "¶m=" + param_escape(param), true); | |
1187 | xmlhttp.onreadystatechange=infobox_callback; | |
1188 | xmlhttp.send(null); | |
1189 | ||
1190 | disableHotkeys(); | |
1191 | ||
1192 | return false; | |
1193 | } | |
1194 | ||
1195 | function infobox_submit_callback() { | |
1196 | if (xmlhttp.readyState == 4) { | |
1197 | closeInfoBox(); | |
1198 | ||
1199 | try { | |
1200 | // called from prefs, reload tab | |
1201 | if (active_tab) { | |
1202 | selectTab(active_tab, false); | |
1203 | } | |
1204 | } catch (e) { } | |
1205 | ||
1206 | notify(xmlhttp.responseText); | |
1207 | ||
1208 | } | |
1209 | } | |
1210 | ||
1211 | function infobox_callback() { | |
1212 | if (xmlhttp.readyState == 4) { | |
1213 | var box = document.getElementById('infoBox'); | |
1214 | var shadow = document.getElementById('infoBoxShadow'); | |
1215 | if (box) { | |
1216 | box.innerHTML=xmlhttp.responseText; | |
1217 | if (shadow) { | |
1218 | shadow.style.display = "block"; | |
1219 | } else { | |
1220 | box.style.display = "block"; | |
1221 | } | |
1222 | } | |
1223 | notify(""); | |
1224 | } | |
1225 | } | |
1226 | ||
1227 | function qaddFilter() { | |
1228 | ||
1229 | if (!xmlhttp_ready(xmlhttp)) { | |
1230 | printLockingError(); | |
1231 | return | |
1232 | } | |
1233 | ||
1234 | var form = document.forms['filter_add_form']; | |
1235 | var reg_exp = form.reg_exp.value; | |
1236 | ||
1237 | if (reg_exp == "") { | |
1238 | alert("Can't add filter: nothing to match on."); | |
1239 | return false; | |
1240 | } | |
1241 | ||
1242 | var query = Form.serialize("filter_add_form"); | |
1243 | ||
1244 | xmlhttp.open("GET", "backend.php?" + query, true); | |
1245 | xmlhttp.onreadystatechange=infobox_submit_callback; | |
1246 | xmlhttp.send(null); | |
1247 | ||
1248 | return true; | |
1249 | } | |
1250 | ||
1251 | function toggleSubmitNotEmpty(e, submit_id) { | |
1252 | try { | |
1253 | document.getElementById(submit_id).disabled = (e.value == "") | |
1254 | } catch (e) { | |
1255 | exception_error("toggleSubmitNotEmpty", e); | |
1256 | } | |
1257 | } | |
1258 | ||
1259 | function isValidURL(s) { | |
1260 | return s.match("http://") != null || s.match("https://") != null; | |
1261 | } | |
1262 | ||
1263 | function qafAdd() { | |
1264 | ||
1265 | if (!xmlhttp_ready(xmlhttp)) { | |
1266 | printLockingError(); | |
1267 | return | |
1268 | } | |
1269 | ||
1270 | var form = document.forms['feed_add_form']; | |
1271 | var feed_url = form.feed_url.value; | |
1272 | ||
1273 | if (feed_url == "") { | |
1274 | alert("Can't subscribe: no feed URL given."); | |
1275 | return false; | |
1276 | } | |
1277 | ||
1278 | notify("Adding feed...", true); | |
1279 | ||
1280 | closeInfoBox(); | |
1281 | ||
1282 | var feeds_doc = document; | |
1283 | ||
1284 | // feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait..."; | |
1285 | ||
1286 | var query = Form.serialize("feed_add_form"); | |
1287 | ||
1288 | xmlhttp.open("GET", "backend.php?" + query, true); | |
1289 | xmlhttp.onreadystatechange=dlg_frefresh_callback; | |
1290 | xmlhttp.send(null); | |
1291 | ||
1292 | return false; | |
1293 | } | |
1294 | ||
1295 | function filterCR(e, f) | |
1296 | { | |
1297 | var key; | |
1298 | ||
1299 | if(window.event) | |
1300 | key = window.event.keyCode; //IE | |
1301 | else | |
1302 | key = e.which; //firefox | |
1303 | ||
1304 | if (key == 13) { | |
1305 | if (typeof f != 'undefined') { | |
1306 | f(); | |
1307 | return false; | |
1308 | } else { | |
1309 | return false; | |
1310 | } | |
1311 | } else { | |
1312 | return true; | |
1313 | } | |
1314 | } | |
1315 | ||
1316 | function getMainContext() { | |
1317 | return this.window; | |
1318 | } | |
1319 | ||
1320 | function getFeedsContext() { | |
1321 | return this.window; | |
1322 | } | |
1323 | ||
1324 | function getContentContext() { | |
1325 | return this.window; | |
1326 | } | |
1327 | ||
1328 | function getHeadlinesContext() { | |
1329 | return this.window; | |
1330 | } | |
1331 | ||
1332 | var debug_last_class = "even"; | |
1333 | ||
1334 | function debug(msg) { | |
1335 | ||
1336 | if (debug_last_class == "even") { | |
1337 | debug_last_class = "odd"; | |
1338 | } else { | |
1339 | debug_last_class = "even"; | |
1340 | } | |
1341 | ||
1342 | var c = document.getElementById('debug_output'); | |
1343 | if (c && c.style.display == "block") { | |
1344 | while (c.lastChild != 'undefined' && c.childNodes.length > 100) { | |
1345 | c.removeChild(c.lastChild); | |
1346 | } | |
1347 | ||
1348 | var d = new Date(); | |
1349 | var ts = leading_zero(d.getHours()) + ":" + leading_zero(d.getMinutes()) + | |
1350 | ":" + leading_zero(d.getSeconds()); | |
1351 | c.innerHTML = "<li class=\"" + debug_last_class + "\"><span class=\"debugTS\">[" + ts + "]</span> " + | |
1352 | msg + "</li>" + c.innerHTML; | |
1353 | } | |
1354 | } | |
1355 | ||
1356 | function getInitParam(key) { | |
1357 | return getMainContext().init_params[key]; | |
1358 | } | |
1359 | ||
1360 | function storeInitParam(key, value, is_client) { | |
1361 | try { | |
1362 | if (!is_client) { | |
1363 | if (getMainContext().init_params[key] != value) { | |
1364 | debug("storeInitParam: " + key + " => " + value); | |
1365 | //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" + | |
1366 | // param_escape(key) + "&value=" + param_escape(value)); | |
1367 | var f = getMainContext().document.getElementById("backReqBox"); | |
1368 | f.src = "backend.php?op=rpc&subop=storeParam&key=" + | |
1369 | param_escape(key) + "&value=" + param_escape(value); | |
1370 | } | |
1371 | } | |
1372 | getMainContext().init_params[key] = value; | |
1373 | } catch (e) { | |
1374 | exception_error("storeInitParam", e); | |
1375 | } | |
1376 | } | |
1377 | ||
1378 | /* | |
1379 | function storeInitParams(params, is_client) { | |
1380 | try { | |
1381 | var s = ""; | |
1382 | ||
1383 | for (k in params) { | |
1384 | if (getMainContext().init_params[k] != params[k]) { | |
1385 | s += k + "=" + params[k] + ";"; | |
1386 | getMainContext().init_params[k] = params[k]; | |
1387 | } | |
1388 | } | |
1389 | ||
1390 | debug("storeInitParams: " + s); | |
1391 | ||
1392 | if (!is_client) { | |
1393 | new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s); | |
1394 | } | |
1395 | } catch (e) { | |
1396 | exception_error("storeInitParams", e); | |
1397 | } | |
1398 | }*/ | |
1399 | ||
1400 | function fatalError(code, message) { | |
1401 | try { | |
1402 | ||
1403 | if (code != 6) { | |
1404 | ||
1405 | var fe = document.getElementById("fatal_error"); | |
1406 | var fc = document.getElementById("fatal_error_msg"); | |
1407 | ||
1408 | fc.innerHTML = "Code " + code + ": " + message; | |
1409 | ||
1410 | fe.style.display = "block"; | |
1411 | } else { | |
1412 | window.location.href = "login.php?rt=none"; | |
1413 | } | |
1414 | ||
1415 | } catch (e) { | |
1416 | exception_error("fatalError", e); | |
1417 | } | |
1418 | } | |
1419 | ||
1420 | function getFeedName(id, is_cat) { | |
1421 | var d = getFeedsContext().document; | |
1422 | ||
1423 | var e; | |
1424 | ||
1425 | if (is_cat) { | |
1426 | e = d.getElementById("FCATN-" + id); | |
1427 | } else { | |
1428 | e = d.getElementById("FEEDN-" + id); | |
1429 | } | |
1430 | if (e) { | |
1431 | return e.innerHTML.stripTags(); | |
1432 | } else { | |
1433 | return null; | |
1434 | } | |
1435 | } | |
1436 | ||
1437 | function viewContentUrl(url) { | |
1438 | getContentContext().location = url; | |
1439 | } |