]> git.wh0rd.org - tt-rss.git/blame - functions.js
prefs: reorganize toolbar buttons
[tt-rss.git] / functions.js
CommitLineData
760966c1 1var hotkeys_enabled = true;
730dbf19 2var notify_silent = false;
99509451 3var last_progress_point = 0;
6cc1fab3 4var async_counters_work = false;
61992f57 5
b07b61da
AD
6/* add method to remove element from array */
7
8Array.prototype.remove = function(s) {
9 for (var i=0; i < this.length; i++) {
10 if (s == this[i]) this.splice(i, 1);
11 }
12}
13
7c620da8 14function is_opera() {
ee8768db 15 return window.opera;
583c58b8
AD
16}
17
273d1e29 18function exception_error(location, e, ext_info) {
e8a429e3 19 var msg = format_exception_error(location, e);
e8a429e3 20
91743a49
AD
21 if (!ext_info) ext_info = "N/A";
22
e8a429e3
AD
23 disableHotkeys();
24
273d1e29 25 try {
e8a429e3 26
acac8448 27 var ebc = $("xebContent");
273d1e29
AD
28
29 if (ebc) {
30
31 Element.show("dialog_overlay");
32 Element.show("errorBoxShadow");
33
34 if (ext_info) {
35 if (ext_info.responseText) {
36 ext_info = ext_info.responseText;
37 }
e8a429e3 38 }
273d1e29
AD
39
40 ebc.innerHTML =
41 "<div><b>Error message:</b></div>" +
42 "<pre>" + msg + "</pre>" +
43 "<div><b>Additional information:</b></div>" +
44 "<textarea readonly=\"1\">" + ext_info + "</textarea>";
45
46 } else {
47 alert(msg);
e8a429e3
AD
48 }
49
273d1e29 50 } catch (e) {
e8a429e3 51 alert(msg);
e8a429e3 52
e8a429e3 53 }
273d1e29 54
e8a429e3
AD
55}
56
57function format_exception_error(location, e) {
83f043bb
AD
58 var msg;
59
60 if (e.fileName) {
61 var base_fname = e.fileName.substring(e.fileName.lastIndexOf("/") + 1);
62
63 msg = "Exception: " + e.name + ", " + e.message +
64 "\nFunction: " + location + "()" +
65 "\nLocation: " + base_fname + ":" + e.lineNumber;
f74cfded
AD
66
67 } else if (e.description) {
68 msg = "Exception: " + e.description + "\nFunction: " + location + "()";
83f043bb
AD
69 } else {
70 msg = "Exception: " + e + "\nFunction: " + location + "()";
71 }
72
ee1f45f4
AD
73 debug("<b>EXCEPTION: " + msg + "</b>");
74
e8a429e3 75 return msg;
7719618b
AD
76}
77
e8a429e3 78
760966c1
AD
79function disableHotkeys() {
80 hotkeys_enabled = false;
81}
82
83function enableHotkeys() {
84 hotkeys_enabled = true;
85}
86
d395a942
AD
87function open_article_callback(transport) {
88 try {
298f3f78 89
d395a942 90 if (transport.responseXML) {
06925d9e 91
d395a942
AD
92 var link = transport.responseXML.getElementsByTagName("link")[0];
93 var id = transport.responseXML.getElementsByTagName("id")[0];
298f3f78 94
06925d9e
AD
95 debug("open_article_callback, received link: " + link);
96
04e91733 97 if (link && id) {
06925d9e 98
04e91733
AD
99 var wname = "ttrss_article_" + id.firstChild.nodeValue;
100
101 debug("link url: " + link.firstChild.nodeValue + ", wname " + wname);
102
103 var w = window.open(link.firstChild.nodeValue, wname);
4298481d
AD
104
105 if (!w) { notify_error("Failed to load article in new window"); }
e2ccbfab 106
d395a942
AD
107 if (id) {
108 id = id.firstChild.nodeValue;
acac8448 109 if (!$("headlinesList")) {
d395a942 110 window.setTimeout("toggleUnread(" + id + ", 0)", 100);
e2ccbfab 111 }
298f3f78 112 }
06925d9e
AD
113 } else {
114 notify_error("Can't open article: received invalid article link");
298f3f78 115 }
06925d9e
AD
116 } else {
117 notify_error("Can't open article: received invalid XML");
01a87dff 118 }
01a87dff 119
d395a942
AD
120 } catch (e) {
121 exception_error("open_article_callback", e);
9cfc649a
AD
122 }
123}
124
7726fa02
AD
125function param_escape(arg) {
126 if (typeof encodeURIComponent != 'undefined')
127 return encodeURIComponent(arg);
128 else
129 return escape(arg);
130}
131
132function param_unescape(arg) {
133 if (typeof decodeURIComponent != 'undefined')
134 return decodeURIComponent(arg);
135 else
136 return unescape(arg);
137}
138
508a81e1
AD
139function delay(gap) {
140 var then,now;
141 then=new Date().getTime();
142 now=then;
143 while((now-then)<gap) {
144 now=new Date().getTime();
145 }
146}
7726fa02 147
ce3bf408 148var notify_hide_timerid = false;
59a543f0 149
ce3bf408 150function hide_notify() {
acac8448 151 var n = $("notify");
42c32916 152 if (n) {
d05514a4 153 n.style.display = "none";
8dcfffd0 154 }
d05514a4 155}
c05608c2 156
730dbf19
AD
157function notify_silent_next() {
158 notify_silent = true;
159}
160
42c32916 161function notify_real(msg, no_hide, n_type) {
7726fa02 162
730dbf19
AD
163 if (notify_silent) {
164 notify_silent = false;
165 return;
166 }
167
acac8448
AD
168 var n = $("notify");
169 var nb = $("notify_body");
7726fa02 170
c05608c2 171 if (!n || !nb) return;
f0601b87 172
0655a1d5
AD
173 if (notify_hide_timerid) {
174 window.clearTimeout(notify_hide_timerid);
175 }
176
8dcfffd0 177 if (msg == "") {
0655a1d5
AD
178 if (n.style.display == "block") {
179 notify_hide_timerid = window.setTimeout("hide_notify()", 0);
180 }
181 return;
7726fa02 182 } else {
0ceded7a 183 n.style.display = "block";
8dcfffd0 184 }
7726fa02 185
42c32916
AD
186 /* types:
187
188 1 - generic
189 2 - progress
190 3 - error
191 4 - info
192
193 */
194
f3977cf5
AD
195 if (typeof __ != 'undefined') {
196 msg = __(msg);
197 }
198
42c32916
AD
199 if (n_type == 1) {
200 n.className = "notify";
201 } else if (n_type == 2) {
202 n.className = "notifyProgress";
203 msg = "<img src='images/indicator_white.gif'> " + msg;
204 } else if (n_type == 3) {
f407c086 205 n.className = "notifyError";
e780d1d2 206 msg = "<img src='images/sign_excl.gif'> " + msg;
42c32916
AD
207 } else if (n_type == 4) {
208 n.className = "notifyInfo";
e780d1d2 209 msg = "<img src='images/sign_info.gif'> " + msg;
0530ddd8
AD
210 }
211
106689b0
AD
212// msg = "<img src='images/live_com_loading.gif'> " + msg;
213
0ceded7a
AD
214 nb.innerHTML = msg;
215
4d4200a8 216 if (!no_hide) {
292a8a12 217 notify_hide_timerid = window.setTimeout("hide_notify()", 3000);
4d4200a8 218 }
ce3bf408
AD
219}
220
42c32916
AD
221function notify(msg, no_hide) {
222 notify_real(msg, no_hide, 1);
ce3bf408
AD
223}
224
42c32916
AD
225function notify_progress(msg, no_hide) {
226 notify_real(msg, no_hide, 2);
227}
228
229function notify_error(msg, no_hide) {
230 notify_real(msg, no_hide, 3);
231
232}
233
234function notify_info(msg, no_hide) {
235 notify_real(msg, no_hide, 4);
7726fa02
AD
236}
237
508a81e1 238function printLockingError() {
42c32916
AD
239 notify_info("Please wait until operation finishes.");
240}
508a81e1 241
e828e31e 242function cleanSelected(element) {
acac8448 243 var content = $(element);
f0601b87
AD
244
245 for (i = 0; i < content.rows.length; i++) {
246 content.rows[i].className = content.rows[i].className.replace("Selected", "");
247 }
f0601b87
AD
248}
249
250function getVisibleUnreadHeadlines() {
acac8448 251 var content = $("headlinesList");
f0601b87
AD
252
253 var rows = new Array();
254
3a40e8a2
AD
255 if (!content) return rows;
256
f0601b87
AD
257 for (i = 0; i < content.rows.length; i++) {
258 var row_id = content.rows[i].id.replace("RROW-", "");
259 if (row_id.length > 0 && content.rows[i].className.match("Unread")) {
260 rows.push(row_id);
261 }
262 }
263 return rows;
264}
265
266function getVisibleHeadlineIds() {
267
acac8448 268 var content = $("headlinesList");
f0601b87
AD
269
270 var rows = new Array();
271
3a40e8a2
AD
272 if (!content) return rows;
273
f0601b87
AD
274 for (i = 0; i < content.rows.length; i++) {
275 var row_id = content.rows[i].id.replace("RROW-", "");
276 if (row_id.length > 0) {
277 rows.push(row_id);
278 }
279 }
280 return rows;
281}
282
283function getFirstVisibleHeadlineId() {
5ad9d132
AD
284 if (isCdmMode()) {
285 var rows = cdmGetVisibleArticles();
286 return rows[0];
287 } else {
288 var rows = getVisibleHeadlineIds();
289 return rows[0];
290 }
f0601b87
AD
291}
292
293function getLastVisibleHeadlineId() {
5ad9d132
AD
294 if (isCdmMode()) {
295 var rows = cdmGetVisibleArticles();
296 return rows[rows.length-1];
297 } else {
298 var rows = getVisibleHeadlineIds();
299 return rows[rows.length-1];
300 }
f0601b87
AD
301}
302
303function markHeadline(id) {
acac8448 304 var row = $("RROW-" + id);
f0601b87 305 if (row) {
35f3c923
AD
306 var is_active = false;
307
308 if (row.className.match("Active")) {
309 is_active = true;
310 }
311 row.className = row.className.replace("Selected", "");
312 row.className = row.className.replace("Active", "");
313 row.className = row.className.replace("Insensitive", "");
314
315 if (is_active) {
316 row.className = row.className = "Active";
317 }
318
acac8448 319 var check = $("RCHK-" + id);
72020095
AD
320
321 if (check) {
322 check.checked = true;
323 }
324
35f3c923
AD
325 row.className = row.className + "Selected";
326
f0601b87
AD
327 }
328}
329
330function getFeedIds() {
acac8448 331 var content = $("feedsList");
f0601b87
AD
332
333 var rows = new Array();
334
335 for (i = 0; i < content.rows.length; i++) {
336 var id = content.rows[i].id.replace("FEEDR-", "");
337 if (id.length > 0) {
338 rows.push(id);
339 }
340 }
341
342 return rows;
343}
13ad9102 344
76b4eae1
AD
345function setCookie(name, value, lifetime, path, domain, secure) {
346
347 var d = false;
348
349 if (lifetime) {
350 d = new Date();
be0801a1 351 d.setTime(d.getTime() + (lifetime * 1000));
76b4eae1 352 }
cdbb6dc6
AD
353
354 debug("setCookie: " + name + " => " + value + ": " + d);
76b4eae1
AD
355
356 int_setCookie(name, value, d, path, domain, secure);
357
358}
359
360function int_setCookie(name, value, expires, path, domain, secure) {
ac43eba1
AD
361 document.cookie= name + "=" + escape(value) +
362 ((expires) ? "; expires=" + expires.toGMTString() : "") +
363 ((path) ? "; path=" + path : "") +
364 ((domain) ? "; domain=" + domain : "") +
365 ((secure) ? "; secure" : "");
366}
367
76b4eae1
AD
368function delCookie(name, path, domain) {
369 if (getCookie(name)) {
370 document.cookie = name + "=" +
371 ((path) ? ";path=" + path : "") +
372 ((domain) ? ";domain=" + domain : "" ) +
373 ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
374 }
375}
376
377
ac43eba1
AD
378function getCookie(name) {
379
380 var dc = document.cookie;
381 var prefix = name + "=";
382 var begin = dc.indexOf("; " + prefix);
383 if (begin == -1) {
384 begin = dc.indexOf(prefix);
385 if (begin != 0) return null;
386 }
387 else {
388 begin += 2;
389 }
390 var end = document.cookie.indexOf(";", begin);
391 if (end == -1) {
392 end = dc.length;
393 }
394 return unescape(dc.substring(begin + prefix.length, end));
395}
396
1a66d16e
AD
397function disableContainerChildren(id, disable, doc) {
398
399 if (!doc) doc = document;
400
acac8448 401 var container = $(id);
ac43eba1 402
4220b0bd
AD
403 if (!container) {
404 //alert("disableContainerChildren: element " + id + " not found");
405 return;
406 }
407
ac43eba1
AD
408 for (var i = 0; i < container.childNodes.length; i++) {
409 var child = container.childNodes[i];
410
d5224f0d
AD
411 try {
412 child.disabled = disable;
413 } catch (E) {
414
415 }
ac43eba1
AD
416
417 if (disable) {
418 if (child.className && child.className.match("button")) {
419 child.className = "disabledButton";
420 }
421 } else {
422 if (child.className && child.className.match("disabledButton")) {
423 child.className = "button";
424 }
d5224f0d 425 }
ac43eba1
AD
426 }
427
428}
7726fa02 429
e828e31e
AD
430function gotoPreferences() {
431 document.location.href = "prefs.php";
432}
433
434function gotoMain() {
435 document.location.href = "tt-rss.php";
436}
437
8158c57a
AD
438function gotoExportOpml() {
439 document.location.href = "opml.php?op=Export";
440}
86741347 441
ac378ad4 442function parse_counters(reply, scheduled_call) {
1a6a9555 443 try {
ac378ad4 444
9e397d0f
AD
445 var feeds_found = 0;
446
85bd574b 447 var elems = reply.getElementsByTagName("counter");
f54f515f 448
85bd574b 449 for (var l = 0; l < elems.length; l++) {
6043fb7e 450
85bd574b
AD
451 var id = elems[l].getAttribute("id");
452 var t = elems[l].getAttribute("type");
453 var ctr = elems[l].getAttribute("counter");
454 var error = elems[l].getAttribute("error");
455 var has_img = elems[l].getAttribute("hi");
456 var updated = elems[l].getAttribute("updated");
4ffa126e 457 var title = elems[l].getAttribute("title");
bdb7369b
AD
458 var xmsg = elems[l].getAttribute("xmsg");
459
1a6a9555 460 if (id == "global-unread") {
0cd6bb46 461
65c0779b
AD
462 if (ctr > global_unread) {
463 offlineDownloadStart(1);
0cd6bb46
AD
464 }
465
0feab655
AD
466 global_unread = ctr;
467 updateTitle();
1a6a9555
AD
468 continue;
469 }
7bf7e4d3
AD
470
471 if (id == "subscribed-feeds") {
472 feeds_found = ctr;
473 continue;
474 }
1a6a9555
AD
475
476 if (t == "category") {
acac8448 477 var catctr = $("FCATCTR-" + id);
1a6a9555 478 if (catctr) {
67dabe1a
AD
479 catctr.innerHTML = "(" + ctr + ")";
480 if (ctr > 0) {
481 catctr.className = "catCtrHasUnread";
482 } else {
483 catctr.className = "catCtrNoUnread";
484 }
1a6a9555
AD
485 }
486 continue;
487 }
488
acac8448
AD
489 var feedctr = $("FEEDCTR-" + id);
490 var feedu = $("FEEDU-" + id);
491 var feedr = $("FEEDR-" + id);
492 var feed_img = $("FIMG-" + id);
493 var feedlink = $("FEEDL-" + id);
494 var feedupd = $("FLUPD-" + id);
fb1fb4ab
AD
495
496 if (updated && feedlink) {
497 if (error) {
498 feedlink.title = "Error: " + error + " (" + updated + ")";
499 } else {
500 feedlink.title = "Updated: " + updated;
501 }
502 }
023fe037 503
bdb7369b
AD
504 if (feedupd) {
505 if (!updated) updated = "";
506
78d5212c 507 if (error) {
bdb7369b
AD
508 if (xmsg) {
509 feedupd.innerHTML = updated + " " + xmsg + " (Error)";
510 } else {
511 feedupd.innerHTML = updated + " (Error)";
512 }
78d5212c 513 } else {
bdb7369b
AD
514 if (xmsg) {
515 feedupd.innerHTML = updated + " " + xmsg;
516 } else {
517 feedupd.innerHTML = updated;
518 }
78d5212c
AD
519 }
520 }
521
f74cfded 522 if (has_img && feed_img) {
f780548a
AD
523 if (!feed_img.src.match(id + ".ico")) {
524 feed_img.src = getInitParam("icons_location") + "/" + id + ".ico";
525 }
527c3bf0
AD
526 }
527
4ffa126e
AD
528 if (feedlink && title) {
529 feedlink.innerHTML = title;
530 }
531
1a6a9555 532 if (feedctr && feedu && feedr) {
e8ef3b97 533
0ac73f91
AD
534 if (parseInt(ctr) > 0 &&
535 parseInt(feedu.innerHTML) < parseInt(ctr) &&
536 id == getActiveFeedId() && scheduled_call) {
537
37e93d6c 538 displayNewContentPrompt(id);
e8ef3b97 539 }
8e9141ed
AD
540
541 var row_needs_hl = (ctr > 0 && ctr > parseInt(feedu.innerHTML));
542
1a6a9555 543 feedu.innerHTML = ctr;
023fe037 544
426d3c57
AD
545 if (error) {
546 feedr.className = feedr.className.replace("feed", "error");
547 } else if (id > 0) {
548 feedr.className = feedr.className.replace("error", "feed");
023fe037 549 }
1a6a9555
AD
550
551 if (ctr > 0) {
d7e83df7 552 feedctr.className = "feedCtrHasUnread";
1a6a9555
AD
553 if (!feedr.className.match("Unread")) {
554 var is_selected = feedr.className.match("Selected");
555
556 feedr.className = feedr.className.replace("Selected", "");
557 feedr.className = feedr.className.replace("Unread", "");
558
559 feedr.className = feedr.className + "Unread";
560
561 if (is_selected) {
562 feedr.className = feedr.className + "Selected";
8e9141ed
AD
563 }
564
565 }
566
567 if (row_needs_hl) {
1341ea0d
AD
568 new Effect.Highlight(feedr, {duration: 1, startcolor: "#fff7d5",
569 queue: { position:'end', scope: 'EFQ-' + id, limit: 1 } } );
d9d0db0f
AD
570
571 cache_invalidate("F:" + id);
1a6a9555
AD
572 }
573 } else {
d7e83df7 574 feedctr.className = "feedCtrNoUnread";
1a6a9555
AD
575 feedr.className = feedr.className.replace("Unread", "");
576 }
577 }
578 }
9e397d0f 579
60ea2377 580 hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
7553dd8b 581
0feab655 582 var feeds_stored = number_of_feeds;
9e397d0f
AD
583
584 debug("Feed counters, C: " + feeds_found + ", S:" + feeds_stored);
585
586 if (feeds_stored != feeds_found) {
0feab655 587 number_of_feeds = feeds_found;
7bf7e4d3 588
2fe69e22 589 if (feeds_stored != 0 && feeds_found != 0) {
9e397d0f 590 debug("Subscribed feed number changed, refreshing feedlist");
0e9dd1ba 591 setTimeout('updateFeedList(false, false)', 50);
9e397d0f 592 }
4f7743a9 593 } else {
acac8448 594/* var fl = $("feeds-frame").innerHTML;
3e2937fc
AD
595 if (fl) {
596 cache_invalidate("FEEDLIST");
597 cache_inject("FEEDLIST", fl, getInitParam("num_feeds"));
87b16a0a 598 } */
9e397d0f
AD
599 }
600
1a6a9555 601 } catch (e) {
83f043bb 602 exception_error("parse_counters", e);
1a6a9555
AD
603 }
604}
605
288487e4 606function parse_counters_reply(transport, scheduled_call) {
5854573a 607
288487e4 608 if (!transport.responseXML) {
42c32916 609 notify_error("Backend did not return valid XML", true);
5854573a
AD
610 return;
611 }
612
288487e4 613 var reply = transport.responseXML.firstChild;
5854573a
AD
614
615 if (!reply) {
42c32916 616 notify_error("Backend did not return expected XML object", true);
5854573a
AD
617 updateTitle("");
618 return;
619 }
5854573a 620
2184738a 621 if (!transport_error_check(transport)) return;
5854573a 622
36e05046 623 var counters = reply.getElementsByTagName("counters")[0];
5854573a 624
3ac2f3c7 625 parse_counters(counters, scheduled_call);
5854573a 626
36e05046 627 var runtime_info = reply.getElementsByTagName("runtime-info")[0];
5854573a
AD
628
629 parse_runtime_info(runtime_info);
630
61a20560
AD
631 if (feedsSortByUnread()) {
632 resort_feedlist();
633 }
5854573a 634
60ea2377 635 hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
5854573a
AD
636
637}
638
6cc1fab3 639function all_counters_callback2(transport, async_call) {
1341ea0d 640 try {
6cc1fab3 641 if (async_call) async_counters_work = true;
c8a9fe5b
AD
642
643 if (offline_mode) return;
6cc1fab3 644
1341ea0d
AD
645 debug("<b>all_counters_callback2 IN: " + transport + "</b>");
646 parse_counters_reply(transport);
647 debug("<b>all_counters_callback2 OUT: " + transport + "</b>");
648
649 } catch (e) {
273d1e29 650 exception_error("all_counters_callback2", e, transport);
1341ea0d
AD
651 }
652}
653
8e9dd206
AD
654function get_feed_unread(id) {
655 try {
acac8448 656 return parseInt($("FEEDU-" + id).innerHTML);
8e9dd206 657 } catch (e) {
8e9dd206
AD
658 return -1;
659 }
660}
661
ec37f4f1
AD
662function get_cat_unread(id) {
663 try {
acac8448 664 var ctr = $("FCATCTR-" + id).innerHTML;
ec37f4f1
AD
665 ctr = ctr.replace("(", "");
666 ctr = ctr.replace(")", "");
667 return parseInt(ctr);
668 } catch (e) {
ec37f4f1
AD
669 return -1;
670 }
671}
672
60ea2377 673function get_feed_entry_unread(elem) {
c9268ed5
AD
674
675 var id = elem.id.replace("FEEDR-", "");
676
677 if (id <= 0) {
678 return -1;
679 }
680
681 try {
acac8448 682 return parseInt($("FEEDU-" + id).innerHTML);
c9268ed5
AD
683 } catch (e) {
684 return -1;
685 }
686}
687
61a20560
AD
688function get_feed_entry_name(elem) {
689 var id = elem.id.replace("FEEDR-", "");
690 return getFeedName(id);
691}
692
693
95d0edcc 694function resort_category(node, cat_mode) {
c9268ed5 695
d6586c1d 696 try {
61a20560 697
95d0edcc 698 debug("resort_category: " + node + " CM=" + cat_mode);
d6586c1d
AD
699
700 var by_unread = feedsSortByUnread();
701
702 var list = node.getElementsByTagName("LI");
703
704 for (i = 0; i < list.length; i++) {
705
706 for (j = i+1; j < list.length; j++) {
707
708 var tmp_val = get_feed_entry_unread(list[i]);
709 var cur_val = get_feed_entry_unread(list[j]);
710
711 var tmp_name = get_feed_entry_name(list[i]);
712 var cur_name = get_feed_entry_name(list[j]);
95d0edcc
AD
713
714 var valid_pair = cat_mode || (list[i].id.match(/FEEDR-[0-9]/) &&
715 list[j].id.match(/FEEDR-[0-9]/));
716
717 if (valid_pair && ((by_unread && (cur_val > tmp_val)) || (!by_unread && (cur_name < tmp_name)))) {
d6586c1d
AD
718 tempnode_i = list[i].cloneNode(true);
719 tempnode_j = list[j].cloneNode(true);
720 node.replaceChild(tempnode_i, list[j]);
721 node.replaceChild(tempnode_j, list[i]);
c9268ed5
AD
722 }
723 }
c9268ed5 724 }
d6586c1d
AD
725
726 } catch (e) {
727 exception_error("resort_category", e);
c9268ed5
AD
728 }
729
730}
731
732function resort_feedlist() {
733 debug("resort_feedlist");
734
acac8448 735 if ($("FCATLIST--1")) {
c9268ed5 736
60ea2377 737 var lists = document.getElementsByTagName("UL");
c9268ed5 738
60ea2377
AD
739 for (var i = 0; i < lists.length; i++) {
740 if (lists[i].id && lists[i].id.match("FCATLIST-")) {
95d0edcc 741 resort_category(lists[i], true);
c9268ed5 742 }
c9268ed5
AD
743 }
744
745 } else {
95d0edcc 746 resort_category($("feedList"), false);
c9268ed5
AD
747 }
748}
749
b6644d29
AD
750/** * @(#)isNumeric.js * * Copyright (c) 2000 by Sundar Dorai-Raj
751 * * @author Sundar Dorai-Raj
752 * * Email: sdoraira@vt.edu
753 * * This program is free software; you can redistribute it and/or
754 * * modify it under the terms of the GNU General Public License
755 * * as published by the Free Software Foundation; either version 2
756 * * of the License, or (at your option) any later version,
757 * * provided that any use properly credits the author.
758 * * This program is distributed in the hope that it will be useful,
759 * * but WITHOUT ANY WARRANTY; without even the implied warranty of
760 * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
761 * * GNU General Public License for more details at http://www.gnu.org * * */
762
763 var numbers=".0123456789";
764 function isNumeric(x) {
765 // is x a String or a character?
766 if(x.length>1) {
767 // remove negative sign
768 x=Math.abs(x)+"";
769 for(j=0;j<x.length;j++) {
770 // call isNumeric recursively for each character
771 number=isNumeric(x.substring(j,j+1));
772 if(!number) return number;
773 }
774 return number;
775 }
776 else {
777 // if x is number return true
778 if(numbers.indexOf(x)>=0) return true;
779 return false;
780 }
781 }
782
3745788e 783
60ea2377 784function hideOrShowFeeds(hide) {
3745788e 785
60ea2377 786 try {
293fa942 787
60ea2377 788 debug("hideOrShowFeeds: " + hide);
293fa942 789
acac8448 790 if ($("FCATLIST--1")) {
293fa942 791
60ea2377 792 var lists = document.getElementsByTagName("UL");
293fa942 793
60ea2377
AD
794 for (var i = 0; i < lists.length; i++) {
795 if (lists[i].id && lists[i].id.match("FCATLIST-")) {
293fa942 796
60ea2377
AD
797 var id = lists[i].id.replace("FCATLIST-", "");
798 hideOrShowFeedsCategory(id, hide);
293fa942 799 }
293fa942
AD
800 }
801
802 } else {
60ea2377 803 hideOrShowFeedsCategory(null, hide);
293fa942 804 }
293fa942 805
60ea2377
AD
806 } catch (e) {
807 exception_error("hideOrShowFeeds", e);
4724a093 808 }
60ea2377 809}
4724a093 810
60ea2377 811function hideOrShowFeedsCategory(id, hide) {
2c2b019b 812
60ea2377
AD
813 try {
814
815 var node = null;
816 var cat_node = null;
bbf4d0b2 817
60ea2377 818 if (id) {
acac8448
AD
819 node = $("FCATLIST-" + id);
820 cat_node = $("FCAT-" + id);
60ea2377 821 } else {
acac8448 822 node = $("feedList"); // no categories
60ea2377 823 }
293fa942 824
60ea2377 825 // debug("hideOrShowFeedsCategory: " + node + " (" + hide + ")");
b31c2311 826
60ea2377 827 var cat_unread = 0;
b31c2311 828
60ea2377
AD
829 if (!node) {
830 debug("hideOrShowFeeds: passed node is null, aborting");
831 return;
832 }
b31c2311 833
60ea2377
AD
834 // debug("cat: " + node.id);
835
836 if (node.hasChildNodes() && node.firstChild.nextSibling != false) {
837 for (i = 0; i < node.childNodes.length; i++) {
838 if (node.childNodes[i].nodeName != "LI") { continue; }
b31c2311 839
60ea2377
AD
840 if (node.childNodes[i].style != undefined) {
841
842 var has_unread = (node.childNodes[i].className != "feed" &&
843 node.childNodes[i].className != "label" &&
844 !(!getInitParam("hide_read_shows_special") &&
845 node.childNodes[i].className == "virt") &&
846 node.childNodes[i].className != "error" &&
847 node.childNodes[i].className != "tag");
848
849 // debug(node.childNodes[i].id + " --> " + has_unread);
850
851 if (hide && !has_unread) {
852 //node.childNodes[i].style.display = "none";
853 var id = node.childNodes[i].id;
854 Effect.Fade(node.childNodes[i], {duration : 0.3,
855 queue: { position: 'end', scope: 'FFADE-' + id, limit: 1 }});
856 }
857
858 if (!hide) {
859 node.childNodes[i].style.display = "list-item";
860 //Effect.Appear(node.childNodes[i], {duration : 0.3});
861 }
862
863 if (has_unread) {
864 node.childNodes[i].style.display = "list-item";
865 cat_unread++;
866 //Effect.Appear(node.childNodes[i], {duration : 0.3});
867 //Effect.Highlight(node.childNodes[i]);
868 }
b31c2311 869 }
293fa942 870 }
60ea2377
AD
871 }
872
873 // debug("end cat: " + node.id + " unread " + cat_unread);
f4ce1f83
AD
874
875 if (cat_node) {
876
877 if (cat_unread == 0) {
878 if (cat_node.style == undefined) {
879 debug("ERROR: supplied cat_node " + cat_node +
880 " has no styles. WTF?");
881 return;
882 }
883 if (hide) {
884 //cat_node.style.display = "none";
885 Effect.Fade(cat_node, {duration : 0.3,
886 queue: { position: 'end', scope: 'CFADE-' + node.id, limit: 1 }});
887 } else {
888 cat_node.style.display = "list-item";
889 }
60ea2377 890 } else {
f4ce1f83
AD
891 try {
892 cat_node.style.display = "list-item";
893 } catch (e) {
894 debug(e);
895 }
60ea2377 896 }
0ac2faea 897 }
3745788e 898
293fa942 899// debug("unread for category: " + cat_unread);
60ea2377
AD
900
901 } catch (e) {
902 exception_error("hideOrShowFeedsCategory", e);
903 }
3745788e
AD
904}
905
35f3c923
AD
906function selectTableRow(r, do_select) {
907 r.className = r.className.replace("Selected", "");
908
909 if (do_select) {
910 r.className = r.className + "Selected";
911 }
912}
913
6c12c809
AD
914function selectTableRowById(elem_id, check_id, do_select) {
915
916 try {
917
acac8448 918 var row = $(elem_id);
6c12c809
AD
919
920 if (row) {
921 selectTableRow(row, do_select);
922 }
923
acac8448 924 var check = $(check_id);
6c12c809
AD
925
926 if (check) {
927 check.checked = do_select;
928 }
929 } catch (e) {
930 exception_error("selectTableRowById", e);
931 }
932}
933
1572afe5 934function selectTableRowsByIdPrefix(content_id, prefix, check_prefix, do_select,
649e0af9 935 classcheck, reset_others) {
3745788e 936
acac8448 937 var content = $(content_id);
35f3c923
AD
938
939 if (!content) {
940 alert("[selectTableRows] Element " + content_id + " not found.");
941 return;
942 }
943
944 for (i = 0; i < content.rows.length; i++) {
7a822893
AD
945 if (Element.visible(content.rows[i])) {
946 if (!classcheck || content.rows[i].className.match(classcheck)) {
947
948 if (content.rows[i].id.match(prefix)) {
949 selectTableRow(content.rows[i], do_select);
950
951 var row_id = content.rows[i].id.replace(prefix, "");
acac8448 952 var check = $(check_prefix + row_id);
7a822893
AD
953
954 if (check) {
955 check.checked = do_select;
956 }
957 } else if (reset_others) {
958 selectTableRow(content.rows[i], false);
959
960 var row_id = content.rows[i].id.replace(prefix, "");
acac8448 961 var check = $(check_prefix + row_id);
7a822893
AD
962
963 if (check) {
964 check.checked = false;
965 }
1572afe5 966
649e0af9
AD
967 }
968 } else if (reset_others) {
969 selectTableRow(content.rows[i], false);
7a822893 970
7d8d10c6 971 var row_id = content.rows[i].id.replace(prefix, "");
acac8448 972 var check = $(check_prefix + row_id);
7a822893 973
7d8d10c6
AD
974 if (check) {
975 check.checked = false;
976 }
7a822893 977
7d8d10c6 978 }
3055bc41 979 }
35f3c923 980 }
295f9b42 981}
91ff844a
AD
982
983function getSelectedTableRowIds(content_id, prefix) {
984
acac8448 985 var content = $(content_id);
91ff844a
AD
986
987 if (!content) {
988 alert("[getSelectedTableRowIds] Element " + content_id + " not found.");
989 return;
990 }
991
992 var sel_rows = new Array();
993
994 for (i = 0; i < content.rows.length; i++) {
1572afe5
AD
995 if (content.rows[i].id.match(prefix) &&
996 content.rows[i].className.match("Selected")) {
997
91ff844a
AD
998 var row_id = content.rows[i].id.replace(prefix + "-", "");
999 sel_rows.push(row_id);
1000 }
1001 }
1002
1003 return sel_rows;
1004
1005}
1006
386cbf27 1007function toggleSelectRowById(sender, id) {
acac8448 1008 var row = $(id);
386cbf27
AD
1009
1010 if (sender.checked) {
1011 if (!row.className.match("Selected")) {
1012 row.className = row.className + "Selected";
1013 }
1014 } else {
1015 if (row.className.match("Selected")) {
1016 row.className = row.className.replace("Selected", "");
1017 }
1018 }
1019}
1020
b92e6209
AD
1021function toggleSelectListRow(sender) {
1022 var parent_row = sender.parentNode;
1023
1024 if (sender.checked) {
1025 if (!parent_row.className.match("Selected")) {
1026 parent_row.className = parent_row.className + "Selected";
1027 }
1028 } else {
1029 if (parent_row.className.match("Selected")) {
1030 parent_row.className = parent_row.className.replace("Selected", "");
1031 }
1032 }
1033}
1034
67343d9f
AD
1035function tSR(sender) {
1036 return toggleSelectRow(sender);
1037}
386cbf27 1038
1572afe5
AD
1039function toggleSelectRow(sender) {
1040 var parent_row = sender.parentNode.parentNode;
1041
1042 if (sender.checked) {
1043 if (!parent_row.className.match("Selected")) {
1044 parent_row.className = parent_row.className + "Selected";
1045 }
1046 } else {
1047 if (parent_row.className.match("Selected")) {
1048 parent_row.className = parent_row.className.replace("Selected", "");
1049 }
1050 }
1051}
1052
f46192bb
AD
1053function getNextUnreadCat(id) {
1054 try {
acac8448 1055 var rows = $("feedList").getElementsByTagName("LI");
f46192bb
AD
1056 var feeds = new Array();
1057
1058 var unread_only = true;
1059 var is_cat = true;
1060
1061 for (var i = 0; i < rows.length; i++) {
1062 if (rows[i].id.match("FCAT-")) {
1063 if (rows[i].id == "FCAT-" + id && is_cat || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) {
1064
1065 var cat_id = parseInt(rows[i].id.replace("FCAT-", ""));
1066
1067 if (cat_id >= 0) {
1068 if (!unread_only || get_cat_unread(cat_id) > 0) {
1069 feeds.push(cat_id);
1070 }
1071 }
1072 }
1073 }
1074 }
1075
1076 var idx = feeds.indexOf(id);
1077 if (idx != -1 && idx < feeds.length) {
1078 return feeds[idx+1];
1079 } else {
1080 return feeds.shift();
1081 }
1082
1083 } catch (e) {
1084 exception_error("getNextUnreadCat", e);
1085 }
1086}
ec37f4f1
AD
1087
1088function getRelativeFeedId2(id, is_cat, direction, unread_only) {
1089 try {
1090
1091// alert(id + " IC: " + is_cat + " D: " + direction + " U: " + unread_only);
1092
acac8448 1093 var rows = $("feedList").getElementsByTagName("LI");
ec37f4f1
AD
1094 var feeds = new Array();
1095
1096 for (var i = 0; i < rows.length; i++) {
1097 if (rows[i].id.match("FEEDR-")) {
1098
1099 if (rows[i].id == "FEEDR-" + id && !is_cat || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) {
1100
1101 if (!unread_only ||
1102 (rows[i].className.match("Unread") || rows[i].id == "FEEDR-" + id)) {
1103 feeds.push(rows[i].id.replace("FEEDR-", ""));
1104 }
1105 }
1106 }
1107
1108 if (rows[i].id.match("FCAT-")) {
1109 if (rows[i].id == "FCAT-" + id && is_cat || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) {
1110
1111 var cat_id = parseInt(rows[i].id.replace("FCAT-", ""));
1112
1113 if (cat_id >= 0) {
1114 if (!unread_only || get_cat_unread(cat_id) > 0) {
1115 feeds.push("CAT:"+cat_id);
1116 }
1117 }
1118 }
1119 }
1120 }
1121
1122// alert(feeds.toString());
1123
1124 if (!id) {
1125 if (direction == "next") {
1126 return feeds.shift();
1127 } else {
1128 return feeds.pop();
1129 }
1130 } else {
1131 if (direction == "next") {
1132 if (is_cat) id = "CAT:" + id;
1133 var idx = feeds.indexOf(id);
1134 if (idx != -1 && idx < feeds.length) {
1135 return feeds[idx+1];
1136 } else {
1137 return getRelativeFeedId2(false, is_cat, direction, unread_only);
1138 }
1139 } else {
1140 if (is_cat) id = "CAT:" + id;
1141 var idx = feeds.indexOf(id);
1142 if (idx > 0) {
1143 return feeds[idx-1];
1144 } else {
1145 return getRelativeFeedId2(false, is_cat, direction, unread_only);
1146 }
1147 }
1148
1149 }
1150
1151 } catch (e) {
1152 exception_error("getRelativeFeedId2", e);
1153 }
1154}
1155
1156
1da76274 1157function getRelativeFeedId(list, id, direction, unread_only) {
731b05f4
AD
1158 var rows = list.getElementsByTagName("LI");
1159 var feeds = new Array();
1160
1161 for (var i = 0; i < rows.length; i++) {
1162 if (rows[i].id.match("FEEDR-")) {
1163
8809f484 1164 if (rows[i].id == "FEEDR-" + id || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) {
731b05f4
AD
1165
1166 if (!unread_only ||
1167 (rows[i].className.match("Unread") || rows[i].id == "FEEDR-" + id)) {
1168 feeds.push(rows[i].id.replace("FEEDR-", ""));
1169 }
1170 }
1171 }
1172 }
1173
7b433d8c 1174 if (!id) {
731b05f4
AD
1175 if (direction == "next") {
1176 return feeds.shift();
1177 } else {
1178 return feeds.pop();
1179 }
1180 } else {
1181 if (direction == "next") {
1182 var idx = feeds.indexOf(id);
1183 if (idx != -1 && idx < feeds.length) {
1184 return feeds[idx+1];
07a67863
AD
1185 } else {
1186 return getRelativeFeedId(list, false, direction, unread_only);
731b05f4
AD
1187 }
1188 } else {
1189 var idx = feeds.indexOf(id);
1190 if (idx > 0) {
1191 return feeds[idx-1];
07a67863
AD
1192 } else {
1193 return getRelativeFeedId(list, false, direction, unread_only);
731b05f4
AD
1194 }
1195 }
1196
1197 }
7b433d8c 1198}
36aab70f 1199
f27de515 1200function showBlockElement(id, h_id) {
acac8448 1201 var elem = $(id);
36aab70f
AD
1202
1203 if (elem) {
1204 elem.style.display = "block";
f27de515
AD
1205
1206 if (h_id) {
acac8448 1207 elem = $(h_id);
f27de515
AD
1208 if (elem) {
1209 elem.style.display = "none";
1210 }
1211 }
36aab70f
AD
1212 } else {
1213 alert("[showBlockElement] can't find element with id " + id);
1214 }
1215}
1216
b9073cd9
AD
1217function appearBlockElement_afh(effect) {
1218
1219}
1220
1221function checkboxToggleElement(elem, id) {
1222 if (elem.checked) {
ecace165 1223 Effect.Appear(id, {duration : 0.5});
b9073cd9 1224 } else {
ecace165 1225 Effect.Fade(id, {duration : 0.5});
b9073cd9
AD
1226 }
1227}
1228
1229function appearBlockElement(id, h_id) {
1230
1231 try {
a04c8e8d
AD
1232 if (h_id) {
1233 Effect.Fade(h_id);
1234 }
b9073cd9
AD
1235 Effect.SlideDown(id, {duration : 1.0, afterFinish: appearBlockElement_afh});
1236 } catch (e) {
1237 exception_error("appearBlockElement", e);
1238 }
1239
1240}
1241
a9b0bfd5
AD
1242function hideParentElement(e) {
1243 e.parentNode.style.display = "none";
1244}
1b0809ae
AD
1245
1246function dropboxSelect(e, v) {
1247 for (i = 0; i < e.length; i++) {
1248 if (e[i].value == v) {
1249 e.selectedIndex = i;
1250 break;
1251 }
1252 }
1253}
0ee1d1a0
AD
1254
1255// originally stolen from http://www.11tmr.com/11tmr.nsf/d6plinks/MWHE-695L9Z
1256// bugfixed just a little bit :-)
1257function getURLParam(strParamName){
1258 var strReturn = "";
1259 var strHref = window.location.href;
1260
1261 if (strHref.indexOf("#") == strHref.length-1) {
1262 strHref = strHref.substring(0, strHref.length-1);
1263 }
1264
1265 if ( strHref.indexOf("?") > -1 ){
1266 var strQueryString = strHref.substr(strHref.indexOf("?"));
1267 var aQueryString = strQueryString.split("&");
1268 for ( var iParam = 0; iParam < aQueryString.length; iParam++ ){
1269 if (aQueryString[iParam].indexOf(strParamName + "=") > -1 ){
1270 var aParam = aQueryString[iParam].split("=");
1271 strReturn = aParam[1];
1272 break;
1273 }
1274 }
1275 }
1276 return strReturn;
1277}
1278
cf1bc085
AD
1279function leading_zero(p) {
1280 var s = String(p);
1281 if (s.length == 1) s = "0" + s;
1282 return s;
1283}
c38c2b69 1284
e8a429e3 1285function closeErrorBox() {
5ede560f 1286
273d1e29 1287 if (Element.visible("errorBoxShadow")) {
e8a429e3 1288 Element.hide("dialog_overlay");
273d1e29 1289 Element.hide("errorBoxShadow");
e5d758e3 1290
e8a429e3 1291 enableHotkeys();
e5d758e3
AD
1292 }
1293
e8a429e3
AD
1294 return false;
1295}
86b682ce 1296
e8a429e3
AD
1297function closeInfoBox(cleanup) {
1298
588e4dc3
AD
1299 try {
1300 enableHotkeys();
e8a429e3 1301
588e4dc3
AD
1302 if (Element.visible("infoBoxShadow")) {
1303 Element.hide("dialog_overlay");
1304 Element.hide("infoBoxShadow");
e8a429e3 1305
588e4dc3
AD
1306 if (cleanup) $("infoBoxShadow").innerHTML = "&nbsp;";
1307 }
1308 } catch (e) {
1309 exception_error("closeInfoBox", e);
e8a429e3 1310 }
588e4dc3 1311
90ac84df 1312 return false;
e5d758e3
AD
1313}
1314
1315
7b5c6012
AD
1316function displayDlg(id, param) {
1317
35a03bdd 1318 notify_progress("Loading, please wait...", true);
7b5c6012 1319
7b5c6012 1320 disableHotkeys();
2371c520 1321
b4e75b2a 1322 var query = "?op=dlg&id=" +
288487e4
AD
1323 param_escape(id) + "&param=" + param_escape(param);
1324
b4e75b2a
AD
1325 new Ajax.Request("backend.php", {
1326 parameters: query,
288487e4
AD
1327 onComplete: function (transport) {
1328 infobox_callback2(transport);
1329 } });
1330
90ac84df 1331 return false;
7b5c6012
AD
1332}
1333
288487e4
AD
1334function infobox_submit_callback2(transport) {
1335 closeInfoBox();
79f3553b 1336
288487e4
AD
1337 try {
1338 // called from prefs, reload tab
438f2ce9 1339 if (typeof active_tab != 'undefined' && active_tab) {
288487e4 1340 selectTab(active_tab, false);
5e6f933a 1341 }
288487e4 1342 } catch (e) { }
79f3553b 1343
288487e4
AD
1344 if (transport.responseText) {
1345 notify_info(transport.responseText);
1346 }
7b5c6012
AD
1347}
1348
d395a942
AD
1349function infobox_callback2(transport) {
1350 try {
5ede560f 1351
d395a942 1352 debug("infobox_callback2");
5ede560f 1353
acac8448 1354 var box = $('infoBox');
de85cac2 1355
d395a942 1356 if (box) {
1dc47c41 1357
de85cac2
AD
1358 if (!getInitParam("infobox_disable_overlay")) {
1359 Element.show("dialog_overlay");
aa8716da 1360 }
de85cac2
AD
1361
1362 box.innerHTML=transport.responseText;
1363 Element.show("infoBoxShadow");
1364 //Effect.SlideDown("infoBoxShadow", {duration : 1.0});
1365
1366
d395a942 1367 }
05fcdf52 1368
d395a942 1369 /* FIXME this needs to be moved out somewhere */
05fcdf52 1370
acac8448 1371 if ($("tags_choices")) {
d395a942
AD
1372 new Ajax.Autocompleter('tags_str', 'tags_choices',
1373 "backend.php?op=rpc&subop=completeTags",
1374 { tokens: ',', paramName: "search" });
442d77f1 1375 }
d395a942 1376
6068d33b
AD
1377 disableHotkeys();
1378
d395a942
AD
1379 notify("");
1380 } catch (e) {
1381 exception_error("infobox_callback2", e);
442d77f1
AD
1382 }
1383}
1384
18ab3d7a 1385function createFilter() {
7b5c6012 1386
438f2ce9 1387 try {
6068d33b 1388
438f2ce9
AD
1389 var form = document.forms['filter_add_form'];
1390 var reg_exp = form.reg_exp.value;
1391
1392 if (reg_exp == "") {
1393 alert(__("Can't add filter: nothing to match on."));
1394 return false;
1395 }
288487e4 1396
438f2ce9
AD
1397 var query = Form.serialize("filter_add_form");
1398
1399 // we can be called from some other tab in Prefs
1400 if (typeof active_tab != 'undefined' && active_tab) {
1401 active_tab = "filterConfig";
1402 }
1403
1404 new Ajax.Request("backend.php?" + query, {
1405 onComplete: function (transport) {
1406 infobox_submit_callback2(transport);
1407 } });
1408
1409 return true;
1410
1411 } catch (e) {
1412 exception_error("createFilter", e);
1413 }
7b5c6012
AD
1414}
1415
2371c520
AD
1416function toggleSubmitNotEmpty(e, submit_id) {
1417 try {
acac8448 1418 $(submit_id).disabled = (e.value == "")
2371c520
AD
1419 } catch (e) {
1420 exception_error("toggleSubmitNotEmpty", e);
1421 }
1422}
1d7bf5a0 1423
605f7d46 1424function isValidURL(s) {
0d32b41e 1425 return s.match("http://") != null || s.match("https://") != null || s.match("feed://") != null;
605f7d46 1426}
07eb9178 1427
18ab3d7a 1428function subscribeToFeed() {
07eb9178 1429
c91c2249
AD
1430 var form = document.forms['feed_add_form'];
1431 var feed_url = form.feed_url.value;
1432
1433 if (feed_url == "") {
89cb787e 1434 alert(__("Can't subscribe: no feed URL given."));
c91c2249
AD
1435 return false;
1436 }
1437
1ba6daf7 1438 notify_progress(__("Subscribing to feed..."), true);
07eb9178
AD
1439
1440 closeInfoBox();
1441
0feab655 1442 var feeds_doc = document;
07eb9178 1443
80e4dc34 1444// feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
07eb9178
AD
1445
1446 var query = Form.serialize("feed_add_form");
1447
f27de515
AD
1448 debug("subscribe q: " + query);
1449
288487e4
AD
1450 new Ajax.Request("backend.php", {
1451 parameters: query,
1452 onComplete: function(transport) {
1453 dlg_frefresh_callback(transport);
1454 } });
7bc4f251
AD
1455
1456 return false;
07eb9178
AD
1457}
1458
6e6504bc 1459function filterCR(e, f)
86b682ce
AD
1460{
1461 var key;
1462
1463 if(window.event)
1464 key = window.event.keyCode; //IE
1465 else
1466 key = e.which; //firefox
1467
6e6504bc
AD
1468 if (key == 13) {
1469 if (typeof f != 'undefined') {
1470 f();
1471 return false;
1472 } else {
1473 return false;
1474 }
1475 } else {
1476 return true;
1477 }
86b682ce
AD
1478}
1479
e8614131
AD
1480var debug_last_class = "even";
1481
ac378ad4 1482function debug(msg) {
ac378ad4 1483
0feab655
AD
1484 if (debug_last_class == "even") {
1485 debug_last_class = "odd";
e8614131 1486 } else {
0feab655 1487 debug_last_class = "even";
e8614131
AD
1488 }
1489
acac8448 1490 var c = $('debug_output');
8836613c 1491 if (c && Element.visible(c)) {
c9268ed5 1492 while (c.lastChild != 'undefined' && c.childNodes.length > 100) {
ac378ad4
AD
1493 c.removeChild(c.lastChild);
1494 }
1495
1496 var d = new Date();
1497 var ts = leading_zero(d.getHours()) + ":" + leading_zero(d.getMinutes()) +
1498 ":" + leading_zero(d.getSeconds());
0feab655 1499 c.innerHTML = "<li class=\"" + debug_last_class + "\"><span class=\"debugTS\">[" + ts + "]</span> " +
e8614131 1500 msg + "</li>" + c.innerHTML;
ac378ad4
AD
1501 }
1502}
1503
33d13e72 1504function getInitParam(key) {
40496720 1505 return init_params[key];
33d13e72 1506}
3ac2b520 1507
be0801a1 1508function storeInitParam(key, value) {
40496720 1509 debug("<b>storeInitParam is OBSOLETE: " + key + " => " + value + "</b>");
5158ced9 1510 init_params[key] = value;
be0801a1
AD
1511}
1512
273d1e29 1513function fatalError(code, msg, ext_info) {
a7565293 1514 try {
a7565293 1515
91743a49
AD
1516 if (!ext_info) ext_info = "N/A";
1517
b4c27af7 1518 if (code == 6) {
206d4967 1519 window.location.href = "tt-rss.php";
b4c27af7
AD
1520 } else if (code == 5) {
1521 window.location.href = "update.php";
1522 } else {
4724a093 1523
273d1e29 1524 if (msg == "") msg = "Unknown error";
42c32916 1525
acac8448 1526 var ebc = $("xebContent");
4724a093 1527
273d1e29
AD
1528 if (ebc) {
1529
1530 Element.show("dialog_overlay");
1531 Element.show("errorBoxShadow");
1532 Element.hide("xebBtn");
1533
1534 if (ext_info) {
1535 if (ext_info.responseText) {
1536 ext_info = ext_info.responseText;
1537 }
1538 }
1539
1540 ebc.innerHTML =
1541 "<div><b>Error message:</b></div>" +
1542 "<pre>" + msg + "</pre>" +
1543 "<div><b>Additional information:</b></div>" +
1544 "<textarea readonly=\"1\">" + ext_info + "</textarea>";
1545 }
4724a093 1546 }
a7565293
AD
1547
1548 } catch (e) {
1549 exception_error("fatalError", e);
1550 }
1551}
1552
234e467c 1553function getFeedName(id, is_cat) {
234e467c
AD
1554 var e;
1555
1556 if (is_cat) {
acac8448 1557 e = $("FCATN-" + id);
234e467c 1558 } else {
acac8448 1559 e = $("FEEDN-" + id);
234e467c 1560 }
64a2875d
AD
1561 if (e) {
1562 return e.innerHTML.stripTags();
1563 } else {
1564 return null;
1565 }
1566}
0bd411db 1567
d0da85c2
AD
1568function filterDlgCheckType(sender) {
1569
1570 try {
1571
1572 var ftype = sender[sender.selectedIndex].value;
1573
1574 var form = document.forms["filter_add_form"];
1575
1576 if (!form) {
1577 form = document.forms["filter_edit_form"];
1578 }
1579
1580 if (!form) {
1581 debug("filterDlgCheckType: can't find form!");
1582 return;
1583 }
1584
1585 // if selected filter type is 5 (Date) enable the modifier dropbox
1586 if (ftype == 5) {
1587 Element.show("filter_dlg_date_mod_box");
1588 Element.show("filter_dlg_date_chk_box");
1589 } else {
1590 Element.hide("filter_dlg_date_mod_box");
1591 Element.hide("filter_dlg_date_chk_box");
1592
1593 }
1594
1595 } catch (e) {
1596 exception_error("filterDlgCheckType", e);
1597 }
1598
1599}
1600
350f0ad1
AD
1601function filterDlgCheckAction(sender) {
1602
1603 try {
1604
1605 var action = sender[sender.selectedIndex].value;
1606
1607 var form = document.forms["filter_add_form"];
1608
1609 if (!form) {
1610 form = document.forms["filter_edit_form"];
1611 }
1612
1613 if (!form) {
1614 debug("filterDlgCheckAction: can't find form!");
1615 return;
1616 }
1617
acac8448 1618 var action_param = $("filter_dlg_param_box");
350f0ad1
AD
1619
1620 if (!action_param) {
143a4973 1621 debug("filterDlgCheckAction: can't find action param box!");
350f0ad1
AD
1622 return;
1623 }
1624
1625 // if selected action supports parameters, enable params field
ceb30ba4 1626 if (action == 4 || action == 6 || action == 7) {
143a4973 1627 Element.show(action_param);
ceb30ba4
AD
1628 if (action != 7) {
1629 Element.show(form.action_param);
1630 Element.hide(form.action_param_label);
1631 } else {
1632 Element.show(form.action_param_label);
1633 Element.hide(form.action_param);
1634 }
350f0ad1 1635 } else {
143a4973 1636 Element.hide(action_param);
350f0ad1
AD
1637 }
1638
1639 } catch (e) {
438f2ce9 1640 exception_error("filterDlgCheckAction", e);
350f0ad1
AD
1641 }
1642
1643}
ef16ae37 1644
d0da85c2
AD
1645function filterDlgCheckDate() {
1646 try {
1647 var form = document.forms["filter_add_form"];
1648
1649 if (!form) {
1650 form = document.forms["filter_edit_form"];
1651 }
1652
1653 if (!form) {
1654 debug("filterDlgCheckAction: can't find form!");
1655 return;
1656 }
1657
1658 var reg_exp = form.reg_exp.value;
1659
b4e75b2a 1660 var query = "?op=rpc&subop=checkDate&date=" + reg_exp;
d0da85c2 1661
b4e75b2a
AD
1662 new Ajax.Request("backend.php", {
1663 parameters: query,
d0da85c2
AD
1664 onComplete: function(transport) {
1665
1666 var form = document.forms["filter_add_form"];
1667
1668 if (!form) {
1669 form = document.forms["filter_edit_form"];
1670 }
1671
1672 if (transport.responseXML) {
1673 var result = transport.responseXML.getElementsByTagName("result")[0];
1674
1675 if (result && result.firstChild) {
1676 if (result.firstChild.nodeValue == "1") {
1677
1678 new Effect.Highlight(form.reg_exp, {startcolor : '#00ff00'});
1679
1680 return;
1681 }
1682 }
1683 }
1684
1685 new Effect.Highlight(form.reg_exp, {startcolor : '#ff0000'});
1686
1687 } });
1688
1689
1690 } catch (e) {
1691 exception_error("filterDlgCheckDate", e);
1692 }
1693}
1694
ef16ae37
AD
1695function explainError(code) {
1696 return displayDlg("explainError", code);
1697}
01a87dff 1698
e097e8be 1699// this only searches loaded headlines list, not in CDM
aa0fa9df 1700function getRelativePostIds(id, limit) {
e097e8be 1701
aa0fa9df
AD
1702 if (!limit) limit = 3;
1703
1704 debug("getRelativePostIds: " + id + " limit=" + limit);
e097e8be
AD
1705
1706 var ids = new Array();
acac8448 1707 var container = $("headlinesList");
e097e8be
AD
1708
1709 if (container) {
1710 var rows = container.rows;
1711
1712 for (var i = 0; i < rows.length; i++) {
1713 var r_id = rows[i].id.replace("RROW-", "");
1714
1715 if (r_id == id) {
aa0fa9df
AD
1716 for (var k = 1; k <= limit; k++) {
1717 var nid = false;
1718
1719 if (i > k-1) var nid = rows[i-k].id.replace("RROW-", "");
1720 if (nid) ids.push(nid);
1721
1722 if (i < rows.length-k) nid = rows[i+k].id.replace("RROW-", "");
1723 if (nid) ids.push(nid);
1724 }
e097e8be
AD
1725
1726 return ids;
1727 }
1728 }
1729 }
1730
1731 return false;
1732}
298f3f78
AD
1733
1734function openArticleInNewWindow(id) {
1735 try {
298f3f78
AD
1736 debug("openArticleInNewWindow: " + id);
1737
b4e75b2a 1738 var query = "?op=rpc&subop=getArticleLink&id=" + id;
04e91733
AD
1739 var wname = "ttrss_article_" + id;
1740
1741 debug(query + " " + wname);
1742
1743 var w = window.open("", wname);
298f3f78 1744
04e91733 1745 if (!w) notify_error("Failed to open window for the article");
298f3f78 1746
b4e75b2a
AD
1747 new Ajax.Request("backend.php", {
1748 parameters: query,
d395a942
AD
1749 onComplete: function(transport) {
1750 open_article_callback(transport);
1751 } });
1752
298f3f78
AD
1753
1754 } catch (e) {
1755 exception_error("openArticleInNewWindow", e);
1756 }
1757}
e4914b62 1758
537625c6
AD
1759/* http://textsnippets.com/posts/show/835 */
1760
1761Position.GetWindowSize = function(w) {
1762 w = w ? w : window;
1763 var width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
1764 var height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
1765 return [width, height]
1766}
1767
1768/* http://textsnippets.com/posts/show/836 */
1769
1770Position.Center = function(element, parent) {
1771 var w, h, pw, ph;
1772 var d = Element.getDimensions(element);
1773 w = d.width;
1774 h = d.height;
1775 Position.prepare();
1776 if (!parent) {
1777 var ws = Position.GetWindowSize();
1778 pw = ws[0];
1779 ph = ws[1];
1780 } else {
1781 pw = parent.offsetWidth;
1782 ph = parent.offsetHeight;
1783 }
1784 element.style.top = (ph/2) - (h/2) - Position.deltaY + "px";
1785 element.style.left = (pw/2) - (w/2) - Position.deltaX + "px";
1786}
1787
768858f1 1788
288487e4
AD
1789function labeltest_callback(transport) {
1790 try {
acac8448 1791 var container = $('label_test_result');
288487e4
AD
1792
1793 container.innerHTML = transport.responseText;
768858f1
AD
1794 if (!Element.visible(container)) {
1795 Effect.SlideDown(container, { duration : 0.5 });
1796 }
288487e4 1797
6f151277 1798 notify("");
288487e4
AD
1799 } catch (e) {
1800 exception_error("labeltest_callback", e);
6f151277
AD
1801 }
1802}
1803
1804function labelTest() {
1805
288487e4 1806 try {
acac8448 1807 var container = $('label_test_result');
288487e4
AD
1808
1809 var form = document.forms['label_edit_form'];
1810
1811 var sql_exp = form.sql_exp.value;
1812 var description = form.description.value;
1813
1814 notify_progress("Loading, please wait...");
1815
b4e75b2a 1816 var query = "?op=pref-labels&subop=test&expr=" +
288487e4
AD
1817 param_escape(sql_exp) + "&descr=" + param_escape(description);
1818
b4e75b2a
AD
1819 new Ajax.Request("backend.php", {
1820 parameters: query,
288487e4
AD
1821 onComplete: function (transport) {
1822 labeltest_callback(transport);
1823 } });
1824
1825 return false;
6f151277 1826
288487e4
AD
1827 } catch (e) {
1828 exception_error("labelTest", e);
1829 }
6f151277
AD
1830}
1831
c32cd48a 1832function isCdmMode() {
acac8448 1833 return !$("headlinesList");
c32cd48a
AD
1834}
1835
1836function getSelectedArticleIds2() {
1837 var rows = new Array();
1838 var cdm_mode = isCdmMode();
1839
1840 if (cdm_mode) {
1841 rows = cdmGetSelectedArticles();
1842 } else {
1843 rows = getSelectedTableRowIds("headlinesList", "RROW", "RCHK");
1844 }
1845
1846 var ids = new Array();
1847
1848 for (var i = 0; i < rows.length; i++) {
acac8448 1849 var chk = $("RCHK-" + rows[i]);
c32cd48a
AD
1850 if (chk && chk.checked) {
1851 ids.push(rows[i]);
1852 }
1853 }
1854
1855 return ids;
1856}
c4a36709 1857
f6d40ed2 1858function displayHelpInfobox(topic_id) {
c4a36709 1859
f6d40ed2
AD
1860 var url = "backend.php?op=help&tid=" + param_escape(topic_id);
1861
1862 var w = window.open(url, "ttrss_help",
1863 "status=0,toolbar=0,location=0,width=450,height=500,scrollbars=1,menubar=0");
1864
f6d40ed2 1865}
e635d56a 1866
477402d8 1867function focus_element(id) {
61992f57 1868 try {
acac8448 1869 var e = $(id);
477402d8 1870 if (e) e.focus();
61992f57 1871 } catch (e) {
438f2ce9 1872 exception_error("focus_element", e);
61992f57 1873 }
477402d8 1874 return false;
61992f57 1875}
e635d56a 1876
99509451 1877function loading_set_progress(p) {
730dbf19 1878 try {
fca95d5f
AD
1879 if (p < last_progress_point || !Element.visible("overlay")) return;
1880
1881 debug("<b>loading_set_progress : " + p + " (" + last_progress_point + ")</b>");
99509451 1882
acac8448 1883 var o = $("l_progress_i");
99509451 1884
673c9946
AD
1885// o.style.width = (p * 2) + "px";
1886
99509451
AD
1887 new Effect.Scale(o, p, {
1888 scaleY : false,
1889 scaleFrom : last_progress_point,
1890 scaleMode: { originalWidth : 200 },
673c9946 1891 queue: { position: 'end', scope: 'LSP-Q', limit: 3 } });
99509451
AD
1892
1893 last_progress_point = p;
730dbf19
AD
1894
1895 } catch (e) {
1896 exception_error("loading_set_progress", e);
1897 }
1898}
08827aaf
AD
1899
1900function remove_splash() {
1901 if (Element.visible("overlay")) {
1902 debug("about to remove splash, OMG!");
1903 Element.hide("overlay");
1904 debug("removed splash!");
1905 }
1906}
071ec48f
AD
1907
1908function addLabelExample() {
1909 try {
1910 var form = document.forms["label_edit_form"];
1911
1912 var text = form.sql_exp;
1913 var op = form.label_fields[form.label_fields.selectedIndex];
1914 var p = form.label_fields_param;
1915
1916 if (op) {
1917 op = op.value;
1918
1919 var tmp = "";
1920
1921 if (text.value != "") {
1922 if (text.value.substring(text.value.length-3, 3).toUpperCase() != "AND") {
1923 tmp = " AND ";
1924 } else {
1925 tmp = " ";
1926 }
1927 }
1928
1929 if (op == "unread") {
1930 tmp = tmp + "unread = true";
1931 }
1932
1933 if (op == "updated") {
1934 tmp = tmp + "last_read is null and unread = false";
1935 }
1936
1937 if (op == "kw_title") {
8c96d4b1
AD
1938 if (p.value == "") {
1939 alert("This action requires a parameter.");
1940 return false;
1941 }
071ec48f
AD
1942 tmp = tmp + "ttrss_entries.title like '%"+p.value+"%'";
1943 }
8c96d4b1 1944
071ec48f 1945 if (op == "kw_content") {
8c96d4b1
AD
1946 if (p.value == "") {
1947 alert("This action requires a parameter.");
1948 return false;
1949 }
1950
071ec48f
AD
1951 tmp = tmp + "ttrss_entries.content like '%"+p.value+"%'";
1952 }
1953
1954 if (op == "scoreE") {
8c96d4b1
AD
1955 if (isNaN(parseInt(p.value))) {
1956 alert("This action expects numeric parameter.");
1957 return false;
1958 }
071ec48f
AD
1959 tmp = tmp + "score = " + p.value;
1960 }
1961
1962 if (op == "scoreG") {
8c96d4b1
AD
1963 if (isNaN(parseInt(p.value))) {
1964 alert("This action expects numeric parameter.");
1965 return false;
1966 }
071ec48f
AD
1967 tmp = tmp + "score > " + p.value;
1968 }
1969
1970 if (op == "scoreL") {
8c96d4b1
AD
1971 if (isNaN(parseInt(p.value))) {
1972 alert("This action expects numeric parameter.");
1973 return false;
1974 }
071ec48f
AD
1975 tmp = tmp + "score < " + p.value;
1976 }
1977
1978 if (op == "newerD") {
e176b01a 1979 if (isNaN(parseInt(p.value))) {
071ec48f
AD
1980 alert("This action expects numeric parameter.");
1981 return false;
1982 }
1983 tmp = tmp + "updated > NOW() - INTERVAL '"+parseInt(p.value)+" days'";
1984 }
1985
1986 if (op == "newerH") {
e176b01a 1987 if (isNaN(parseInt(p.value))) {
071ec48f
AD
1988 alert("This action expects numeric parameter.");
1989 return false;
1990 }
1991
1992 tmp = tmp + "updated > NOW() - INTERVAL '"+parseInt(p.value)+" hours'";
1993 }
1994
1995 text.value = text.value + tmp;
1996
1997 p.value = "";
1998
1999 }
2000
2001 } catch (e) {
2002 exception_error("addLabelExample", e);
2003 }
2004
2005 return false;
2006}
2007
2008function labelFieldsCheck(elem) {
2009 try {
2010 var op = elem[elem.selectedIndex].value;
2011
2012 var p = document.forms["label_edit_form"].label_fields_param;
2013
2014 if (op == "kw_title" || op == "kw_content" || op == "scoreL" ||
2015 op == "scoreG" || op == "scoreE" || op == "newerD" ||
2016 op == "newerH" ) {
2017 Element.show(p);
2018 } else {
2019 Element.hide(p);
2020 }
2021
2022 } catch (e) {
2023 exception_error("labelFieldsCheck", e);
2024
2025 }
2026}
c2913898
AD
2027
2028function getSelectedFeedsFromBrowser() {
2029
acac8448
AD
2030 var list = $("browseFeedList");
2031 if (!list) list = $("browseBigFeedList");
c2913898
AD
2032
2033 var selected = new Array();
2034
2035 for (i = 0; i < list.childNodes.length; i++) {
2036 var child = list.childNodes[i];
2037 if (child.id && child.id.match("FBROW-")) {
2038 var id = child.id.replace("FBROW-", "");
2039
acac8448 2040 var cb = $("FBCHK-" + id);
c2913898
AD
2041
2042 if (cb.checked) {
2043 selected.push(id);
2044 }
2045 }
2046 }
2047
2048 return selected;
2049}
2050
2bab8824
AD
2051function updateFeedBrowser() {
2052 try {
2053
082ae95b 2054 var options = Form.serialize("feed_browser");
2bab8824 2055
082ae95b 2056 var query = "?op=rpc&subop=feedBrowser&" + options;
2bab8824 2057
f4280bdd
AD
2058 //notify_progress("Loading, please wait...", true);
2059
2060 Element.show('feed_browser_spinner');
2bab8824 2061
b4e75b2a
AD
2062 new Ajax.Request("backend.php", {
2063 parameters: query,
2bab8824
AD
2064 onComplete: function(transport) {
2065 notify('');
2066
f4280bdd
AD
2067 Element.hide('feed_browser_spinner');
2068
acac8448 2069 var c = $("browseFeedList");
2bab8824
AD
2070 var r = transport.responseXML.getElementsByTagName("content")[0];
2071 var nr = transport.responseXML.getElementsByTagName("num-results")[0];
acac8448 2072 var sb = $("feed_browser_subscribe");
2bab8824
AD
2073
2074 if (c && r) {
2075 c.innerHTML = r.firstChild.nodeValue;
2076 }
2077
2078 if (nr && sb) {
2079 if (nr.getAttribute("value") > 0) {
2080 sb.disabled = false;
2081 } else {
2082 sb.disabled = true;
2083 }
2084 }
2085
2086 } });
2087
2bab8824
AD
2088 } catch (e) {
2089 exception_error("updateFeedBrowser", e);
2090 }
082ae95b 2091
2bab8824
AD
2092}
2093
350468d0
AD
2094function browseFeeds(limit) {
2095
2096 try {
2097
b4e75b2a 2098 var query = "?op=pref-feeds&subop=browse";
350468d0
AD
2099
2100 notify_progress("Loading, please wait...", true);
2101
b4e75b2a
AD
2102 new Ajax.Request("backend.php", {
2103 parameters: query,
350468d0
AD
2104 onComplete: function(transport) {
2105 infobox_callback2(transport);
2106 } });
2107
2108 return false;
2109 } catch (e) {
2110 exception_error("browseFeeds", e);
2111 }
2112}
2113
2184738a
AD
2114function transport_error_check(transport) {
2115 try {
2116 if (transport.responseXML) {
2117 var error = transport.responseXML.getElementsByTagName("error")[0];
2118
2119 if (error) {
2120 var code = error.getAttribute("error-code");
2121 var msg = error.getAttribute("error-msg");
2122 if (code != 0) {
2123 fatalError(code, msg);
2124 return false;
2125 }
2126 }
2127 }
2128 } catch (e) {
2129 exception_error("check_for_error_xml", e);
2130 }
2131 return true;
2132}
2bab8824 2133
261b88b3
AD
2134function strip_tags(s) {
2135 return s.replace(/<\/?[^>]+(>|$)/g, "");
2136}
2137
2138function truncate_string(s, length) {
2139 if (!length) length = 30;
2140 var tmp = s.substring(0, length);
2141 if (s.length > length) tmp += "&hellip;";
2142 return tmp;
2143}
ab553f9a
AD
2144
2145/*
95f67d2e 2146function switchToFlash(e) {
9324c2c2
AD
2147 try {
2148 var targ = e;
2149 if (!e) var e = window.event;
2150 if (e.target) targ = e.target;
2151 else if (e.srcElement) targ = e.srcElement;
2152 if (targ.nodeType == 3) // defeat Safari bug
2153 targ = targ.parentNode;
2154
2155 //targ is the link that was clicked
2156 var audioTag=targ;
2157 do {
2158 audioTag=audioTag.previousSibling;
2159 } while(audioTag && audioTag.nodeType != 1)
2160
2161 var flashPlayer = audioTag.getElementsByTagName('span')[0];
2162 targ.parentNode.insertBefore(flashPlayer,targ);
2163 targ.parentNode.removeChild(targ);
2164 audioTag.parentNode.removeChild(audioTag);
2165
2166 return false;
2167 } catch (e) {
2168 exception_error("switchToFlash", e);
2169 }
95f67d2e 2170}
ab553f9a 2171
95f67d2e
AD
2172function html5AudioOrFlash(type) {
2173 var audioTag = document.createElement('audio');
8086c222
AD
2174 if(! audioTag.canPlayType || audioTag.canPlayType(type) == "no" ||
2175 audioTag.canPlayType(type) == ""){
95f67d2e
AD
2176 if($('switchToFlashLink')){
2177 switchToFlash($('switchToFlashLink'));
2178 }
2179 }
ab553f9a 2180} */
78935092
AD
2181
2182function hotkey_prefix_timeout() {
2183 try {
2184
2185 var date = new Date();
2186 var ts = Math.round(date.getTime() / 1000);
2187
2188 if (hotkey_prefix_pressed && ts - hotkey_prefix_pressed >= 5) {
2189 debug("hotkey_prefix seems to be stuck, aborting");
2190 hotkey_prefix_pressed = false;
2191 hotkey_prefix = false;
2192 Element.hide('cmdline');
2193 }
2194
2195 setTimeout("hotkey_prefix_timeout()", 1000);
2196
2197 } catch (e) {
2198 exception_error("hotkey_prefix_timeout", e);
2199 }
2200}
2201
37e93d6c
AD
2202function hideAuxDlg() {
2203 try {
2204 Element.hide('auxDlg');
2205 } catch (e) {
2206 exception_error("hideAuxDlg", e);
2207 }
2208}
2209
2210function displayNewContentPrompt(id) {
2211 try {
85e5c67d
AD
2212
2213 var msg = "<a href='#' onclick='viewfeed("+id+")'>" +
2214 __("New articles available (Click to show)") + "</a>";
78935092 2215
37e93d6c
AD
2216 msg = msg.replace("%s", getFeedName(id));
2217
2218 $('auxDlg').innerHTML = msg;
2219
2220 Element.show('auxDlg');
2221
2222 } catch (e) {
2223 exception_error("displayNewContentPrompt", e);
2224 }
2225}