]> git.wh0rd.org - tt-rss.git/blame - prefs.js
prefs: code cleanup
[tt-rss.git] / prefs.js
CommitLineData
007bda35
AD
1var xmlhttp = false;
2
91ff844a 3var active_feed_cat = false;
f5a50b25 4var active_tab = false;
c6232e43 5var feed_to_expand = false;
f5a50b25 6
a58069db 7var xmlhttp = Ajax.getTransport();
007bda35 8
a7565293
AD
9var init_params = new Array();
10
e513a74a 11var caller_subop = false;
7a09510c 12var sanity_check_done = false;
746dcf42 13var hotkey_prefix = false;
7a09510c 14
288487e4
AD
15function infobox_callback() {
16 if (xmlhttp.readyState == 4) {
17 infobox_callback2(xmlhttp);
18 }
19}
20
21function infobox_submit_callback() {
22 if (xmlhttp.readyState == 4) {
23 infobox_submit_callback2(xmlhttp);
24 }
25}
26
27
e4f4b46f 28function replace_pubkey_callback() {
c6232e43
AD
29 if (xmlhttp.readyState == 4) {
30 try {
e4f4b46f
AD
31 var link = document.getElementById("pubGenAddress");
32
33 if (xmlhttp.responseXML) {
34
945c243e
AD
35 var new_link = xmlhttp.responseXML.getElementsByTagName("link")[0];
36
37 if (new_link) {
38 link.href = new_link.firstChild.nodeValue;
e635d56a 39 //link.innerHTML = new_link.firstChild.nodeValue;
945c243e 40
3076c7b8
AD
41 new Effect.Highlight(link);
42
e635d56a 43 notify_info("Published feed URL changed.");
945c243e 44 } else {
e635d56a 45 notify_error("Could not change feed URL.");
945c243e 46 }
e4f4b46f
AD
47
48 } else {
e635d56a 49 notify_error("Could not change feed URL.");
e4f4b46f 50 }
c6232e43 51 } catch (e) {
e4f4b46f 52 exception_error("replace_pubkey_callback", e);
c6232e43
AD
53 }
54 }
945c243e 55}
c6232e43 56
e4f4b46f 57function expand_feed_callback() {
bc0ed820
AD
58 if (xmlhttp.readyState == 4) {
59 try {
e4f4b46f 60 var container = document.getElementById("BRDET-" + feed_to_expand);
bc0ed820 61 container.innerHTML=xmlhttp.responseText;
34a01a20 62// container.style.display = "block";
051c4d56 63 Effect.Appear(container, {duration : 0.5});
602ed7f2 64 notify('');
bc0ed820 65 } catch (e) {
e4f4b46f 66 exception_error("expand_feed_callback", e);
bc0ed820
AD
67 }
68 }
69}
70
007bda35 71function feedlist_callback() {
007bda35 72 if (xmlhttp.readyState == 4) {
47c6c988
AD
73 try {
74 var container = document.getElementById('prefContent');
75 container.innerHTML=xmlhttp.responseText;
a7f22b70 76 selectTab("feedConfig", true);
e513a74a
AD
77
78 if (caller_subop) {
79 var tuple = caller_subop.split(":");
80 if (tuple[0] == 'editFeed') {
81 window.setTimeout('editFeed('+tuple[1]+')', 100);
82 }
83
84 caller_subop = false;
85 }
23943c9b
AD
86 if (typeof correctPNG != 'undefined') {
87 correctPNG();
88 }
7f74a9da 89 notify("");
08827aaf
AD
90 remove_splash();
91
47c6c988
AD
92 } catch (e) {
93 exception_error("feedlist_callback", e);
961513a3 94 }
007bda35
AD
95 }
96}
97
442d77f1
AD
98/* stub for subscription dialog */
99
288487e4 100function dlg_frefresh_callback(transport) {
442d77f1 101
288487e4
AD
102 try {
103 var container = document.getElementById('prefContent');
104 container.innerHTML=transport.responseText;
105 selectTab("feedConfig", true);
442d77f1 106
288487e4
AD
107 if (caller_subop) {
108 var tuple = caller_subop.split(":");
109 if (tuple[0] == 'editFeed') {
110 window.setTimeout('editFeed('+tuple[1]+')', 100);
111 }
442d77f1 112
288487e4 113 caller_subop = false;
442d77f1 114 }
288487e4
AD
115 if (typeof correctPNG != 'undefined') {
116 correctPNG();
117 }
118 notify("");
119 } catch (e) {
120 exception_error("feedlist_callback", e);
442d77f1 121 }
288487e4 122
442d77f1
AD
123}
124
a0d53889 125function filterlist_callback() {
f5a50b25 126 var container = document.getElementById('prefContent');
a0d53889
AD
127 if (xmlhttp.readyState == 4) {
128 container.innerHTML=xmlhttp.responseText;
23943c9b
AD
129 if (typeof correctPNG != 'undefined') {
130 correctPNG();
131 }
7f74a9da 132 notify("");
08827aaf 133 remove_splash();
a0d53889
AD
134 }
135}
136
48f0adb0 137function labellist_callback() {
ceb30ba4
AD
138
139 try {
140
141 var container = document.getElementById('prefContent');
142 if (xmlhttp.readyState == 4) {
143 closeInfoBox();
144 container.innerHTML=xmlhttp.responseText;
145
146 if (document.getElementById("prefLabelList")) {
147 var elems = document.getElementById("prefLabelList").getElementsByTagName("SPAN");
148
149 for (var i = 0; i < elems.length; i++) {
150 if (elems[i].id && elems[i].id.match("LILT-")) {
151
152 var id = elems[i].id.replace("LILT-", "");
153 new Ajax.InPlaceEditor(elems[i],
9c5e85fe
AD
154 'backend.php?op=pref-labels&subop=save&id=' + id,
155 {cols: 20, rows: 1});
ceb30ba4
AD
156 }
157 }
48f0adb0 158 }
ceb30ba4
AD
159
160 if (typeof correctPNG != 'undefined') {
161 correctPNG();
48f0adb0 162 }
ceb30ba4
AD
163 notify("");
164 remove_splash();
48f0adb0 165 }
ceb30ba4
AD
166
167 } catch (e) {
168 exception_error("labellist_callback", e);
48f0adb0
AD
169 }
170}
4255b24c 171
c6232e43
AD
172function feed_browser_callback() {
173 var container = document.getElementById('prefContent');
174 if (xmlhttp.readyState == 4) {
175 container.innerHTML=xmlhttp.responseText;
7f74a9da 176 notify("");
08827aaf 177 remove_splash();
c6232e43
AD
178 }
179}
180
e6cb77a0
AD
181function userlist_callback() {
182 var container = document.getElementById('prefContent');
183 if (xmlhttp.readyState == 4) {
184 container.innerHTML=xmlhttp.responseText;
7f74a9da 185 notify("");
08827aaf 186 remove_splash();
e6cb77a0
AD
187 }
188}
189
4255b24c
AD
190function prefslist_callback() {
191 var container = document.getElementById('prefContent');
192 if (xmlhttp.readyState == 4) {
4255b24c 193 container.innerHTML=xmlhttp.responseText;
7f74a9da 194 notify("");
08827aaf 195 remove_splash();
4255b24c
AD
196 }
197}
198
b1895692
AD
199function gethelp_callback() {
200 var container = document.getElementById('prefHelpBox');
201 if (xmlhttp.readyState == 4) {
202
203 container.innerHTML = xmlhttp.responseText;
204 container.style.display = "block";
205
206 }
207}
4255b24c 208
0e091d38 209function notify_callback() {
0e091d38 210 if (xmlhttp.readyState == 4) {
42c32916
AD
211 notify_info(xmlhttp.responseText);
212 }
0e091d38
AD
213}
214
b652c1b7
AD
215function prefs_reset_callback() {
216 if (xmlhttp.readyState == 4) {
217 notify_info(xmlhttp.responseText);
218 selectTab();
219 }
220}
221
d95bd220
AD
222
223function changepass_callback() {
42395d28
AD
224 try {
225 if (xmlhttp.readyState == 4) {
226
227 if (xmlhttp.responseText.indexOf("ERROR: ") == 0) {
228 notify_error(xmlhttp.responseText.replace("ERROR: ", ""));
229 } else {
230 notify_info(xmlhttp.responseText);
231 var warn = document.getElementById("default_pass_warning");
232 if (warn) warn.style.display = "none";
233 }
234
235 document.forms['change_pass_form'].reset();
d95bd220 236
42395d28
AD
237 }
238 } catch (e) {
239 exception_error("changepass_callback", e);
240 }
d95bd220
AD
241}
242
8f708155
AD
243function init_cat_inline_editor() {
244 try {
11f083e7 245
8f708155
AD
246 if (document.getElementById("prefFeedCatList")) {
247 var elems = document.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
11f083e7 248
8f708155
AD
249 for (var i = 0; i < elems.length; i++) {
250 if (elems[i].id && elems[i].id.match("FCATT-")) {
251 var cat_id = elems[i].id.replace("FCATT-", "");
11f083e7 252 new Ajax.InPlaceEditor(elems[i],
8f708155 253 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id);
11f083e7
AD
254 }
255 }
8f708155
AD
256 }
257
258 } catch (e) {
259 exception_error("init_cat_inline_editor", e);
260 }
261}
262
263function infobox_feed_cat_callback() {
264 if (xmlhttp.readyState == 4) {
265 try {
266
267 infobox_callback();
268 init_cat_inline_editor();
11f083e7
AD
269
270 } catch (e) {
271 exception_error("infobox_feed_cat_callback", e);
272 }
273 }
274}
275
b83c7545 276function updateFeedList(sort_key) {
007bda35 277
c0e5a40e 278 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
279 printLockingError();
280 return
281 }
282
f932bc9f
AD
283 var feed_search = document.getElementById("feed_search");
284 var search = "";
285 if (feed_search) { search = feed_search.value; }
286
400b60d8
AD
287 var slat = document.getElementById("show_last_article_times");
288
289 var slat_checked = false;
290 if (slat) {
291 slat_checked = slat.checked;
292 }
293
b83c7545 294 xmlhttp.open("GET", "backend.php?op=pref-feeds" +
f932bc9f 295 "&sort=" + param_escape(sort_key) +
400b60d8 296 "&slat=" + param_escape(slat_checked) +
f932bc9f 297 "&search=" + param_escape(search), true);
007bda35
AD
298 xmlhttp.onreadystatechange=feedlist_callback;
299 xmlhttp.send(null);
300
301}
302
79ec0f2f 303function updateUsersList(sort_key) {
e6cb77a0
AD
304
305 if (!xmlhttp_ready(xmlhttp)) {
306 printLockingError();
307 return
308 }
309
a5bd7bf0
AD
310 var user_search = document.getElementById("user_search");
311 var search = "";
312 if (user_search) { search = user_search.value; }
313
79ec0f2f 314 xmlhttp.open("GET", "backend.php?op=pref-users&sort="
a5bd7bf0
AD
315 + param_escape(sort_key) +
316 "&search=" + param_escape(search), true);
e6cb77a0
AD
317 xmlhttp.onreadystatechange=userlist_callback;
318 xmlhttp.send(null);
319
320}
321
48f0adb0
AD
322function addLabel() {
323
ceb30ba4
AD
324 try {
325
48f0adb0
AD
326 if (!xmlhttp_ready(xmlhttp)) {
327 printLockingError();
328 return
329 }
330
ceb30ba4 331 var caption = prompt(__("Please enter label caption:"), "");
48f0adb0 332
4264f0b5
AD
333 if (caption == null) {
334 return false;
335 }
336
ceb30ba4 337 if (caption == "") {
89cb787e 338 alert(__("Can't create label: missing caption."));
f156fd00 339 return false;
de435974
AD
340 }
341
6068d33b
AD
342 // we can be called from some other tab
343 active_tab = "labelConfig";
344
ceb30ba4
AD
345 var query = "caption=" + param_escape(caption);
346
f156fd00
AD
347 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true);
348 xmlhttp.onreadystatechange=infobox_submit_callback;
349 xmlhttp.send(null);
ceb30ba4
AD
350
351 } catch (e) {
352 exception_error("addLabel", e);
353 }
de435974 354}
48f0adb0 355
71ad3959
AD
356function addFeed() {
357
c0e5a40e 358 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
359 printLockingError();
360 return
361 }
362
331900c6
AD
363 var link = document.getElementById("fadd_link");
364
83fe4d6d 365 if (link.value.length == 0) {
f3977cf5 366 alert(__("Error: No feed URL given."));
605f7d46 367 } else if (!isValidURL(link.value)) {
f3977cf5 368 alert(__("Error: Invalid feed URL."));
331900c6 369 } else {
42c32916 370 notify_progress("Adding feed...");
331900c6 371
e513a74a 372 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
331900c6
AD
373 param_escape(link.value), true);
374 xmlhttp.onreadystatechange=feedlist_callback;
375 xmlhttp.send(null);
376
377 link.value = "";
378
379 }
380
381}
382
91ff844a
AD
383function addFeedCat() {
384
385 if (!xmlhttp_ready(xmlhttp)) {
386 printLockingError();
387 return
388 }
389
390 var cat = document.getElementById("fadd_cat");
391
392 if (cat.value.length == 0) {
f3977cf5 393 alert(__("Can't add category: no name specified."));
91ff844a 394 } else {
42c32916 395 notify_progress("Adding feed category...");
91ff844a 396
9c483746 397 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
91ff844a 398 param_escape(cat.value), true);
8f708155 399 xmlhttp.onreadystatechange=infobox_feed_cat_callback;
91ff844a
AD
400 xmlhttp.send(null);
401
402 link.value = "";
403
404 }
405
406}
e6cb77a0
AD
407function addUser() {
408
409 if (!xmlhttp_ready(xmlhttp)) {
410 printLockingError();
411 return
412 }
413
414 var sqlexp = document.getElementById("uadd_box");
415
416 if (sqlexp.value.length == 0) {
89cb787e 417 alert(__("Can't add user: no login specified."));
e6cb77a0 418 } else {
42c32916 419 notify_progress("Adding user...");
e6cb77a0
AD
420
421 xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
422 param_escape(sqlexp.value), true);
423
424 xmlhttp.onreadystatechange=userlist_callback;
425 xmlhttp.send(null);
426
427 sqlexp.value = "";
428 }
429
430}
431
e6cb77a0
AD
432function editUser(id) {
433
434 if (!xmlhttp_ready(xmlhttp)) {
435 printLockingError();
436 return
437 }
438
6068d33b
AD
439 disableHotkeys();
440
9e31e1b9
AD
441 notify_progress("Loading, please wait...");
442
3c5783b7
AD
443 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
444 selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true);
e6cb77a0
AD
445
446 xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
447 param_escape(id), true);
3c5783b7 448 xmlhttp.onreadystatechange=infobox_callback;
e6cb77a0
AD
449 xmlhttp.send(null);
450
451}
452
a0d53889
AD
453function editFilter(id) {
454
455 if (!xmlhttp_ready(xmlhttp)) {
456 printLockingError();
457 return
458 }
459
6068d33b
AD
460 disableHotkeys();
461
9e31e1b9
AD
462 notify_progress("Loading, please wait...");
463
38bb1ceb 464// document.getElementById("create_filter_btn").disabled = true;
4220b0bd 465
07164479
AD
466 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
467 selectTableRowById('FILRR-'+id, 'FICHK-'+id, true);
a0d53889 468
07164479
AD
469 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id), true);
470 xmlhttp.onreadystatechange=infobox_callback;
a0d53889 471 xmlhttp.send(null);
a0d53889
AD
472}
473
331900c6
AD
474function editFeed(feed) {
475
508a81e1
AD
476// notify("Editing feed...");
477
c0e5a40e 478 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
479 printLockingError();
480 return
481 }
331900c6 482
6068d33b
AD
483 disableHotkeys();
484
9e31e1b9
AD
485 notify_progress("Loading, please wait...");
486
38bb1ceb 487/* document.getElementById("subscribe_to_feed_btn").disabled = true;
a349077c
AD
488
489 try {
490 document.getElementById("top25_feeds_btn").disabled = true;
491 } catch (e) {
492 // this button is not always available, no-op if not found
38bb1ceb 493 } */
a349077c 494
673d54ca 495 // clean selection from all rows & select row being edited
0ea4fb50 496 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
6c12c809 497 selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
0ea4fb50
AD
498
499 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
3c5783b7 500 param_escape(feed), true);
0ea4fb50
AD
501
502 xmlhttp.onreadystatechange=infobox_callback;
331900c6
AD
503 xmlhttp.send(null);
504
505}
506
91ff844a 507function editFeedCat(cat) {
48f0adb0 508
91ff844a
AD
509 if (!xmlhttp_ready(xmlhttp)) {
510 printLockingError();
511 return
48f0adb0
AD
512 }
513
6068d33b
AD
514 disableHotkeys();
515
9e31e1b9
AD
516 notify_progress("Loading, please wait...");
517
91ff844a 518 active_feed_cat = cat;
e6cb77a0 519
9c483746 520 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
91ff844a 521 param_escape(cat), true);
9c483746 522 xmlhttp.onreadystatechange=infobox_callback;
91ff844a 523 xmlhttp.send(null);
e6cb77a0 524
e6cb77a0
AD
525}
526
91ff844a
AD
527function getSelectedLabels() {
528 return getSelectedTableRowIds("prefLabelList", "LILRR");
529}
48f0adb0 530
91ff844a
AD
531function getSelectedUsers() {
532 return getSelectedTableRowIds("prefUserList", "UMRR");
a0d53889
AD
533}
534
83fe4d6d 535function getSelectedFeeds() {
91ff844a
AD
536 return getSelectedTableRowIds("prefFeedList", "FEEDR");
537}
331900c6 538
91ff844a
AD
539function getSelectedFilters() {
540 return getSelectedTableRowIds("prefFilterList", "FILRR");
541}
331900c6 542
91ff844a
AD
543function getSelectedFeedCats() {
544 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
83fe4d6d
AD
545}
546
c0ae0fdb
AD
547function getSelectedFeedsFromBrowser() {
548
549 var list = document.getElementById("browseFeedList");
550 if (!list) list = document.getElementById("browseBigFeedList");
551
552 var selected = new Array();
553
554 for (i = 0; i < list.childNodes.length; i++) {
555 var child = list.childNodes[i];
556 if (child.id && child.id.match("FBROW-")) {
557 var id = child.id.replace("FBROW-", "");
558
559 var cb = document.getElementById("FBCHK-" + id);
560
561 if (cb.checked) {
562 selected.push(id);
563 }
564 }
565 }
566
567 return selected;
568}
569
48f0adb0
AD
570function removeSelectedLabels() {
571
572 if (!xmlhttp_ready(xmlhttp)) {
573 printLockingError();
574 return
575 }
576
577 var sel_rows = getSelectedLabels();
578
579 if (sel_rows.length > 0) {
580
f56e3080 581 var ok = confirm(__("Remove selected labels?"));
48f0adb0 582
69668465 583 if (ok) {
42c32916 584 notify_progress("Removing selected labels...");
69668465
AD
585
586 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
587 param_escape(sel_rows.toString()), true);
588 xmlhttp.onreadystatechange=labellist_callback;
589 xmlhttp.send(null);
590 }
48f0adb0 591 } else {
89cb787e 592 alert(__("No labels are selected."));
48f0adb0 593 }
90ac84df
AD
594
595 return false;
48f0adb0
AD
596}
597
e6cb77a0
AD
598function removeSelectedUsers() {
599
600 if (!xmlhttp_ready(xmlhttp)) {
601 printLockingError();
602 return
603 }
604
605 var sel_rows = getSelectedUsers();
606
607 if (sel_rows.length > 0) {
608
f56e3080 609 var ok = confirm(__("Remove selected users?"));
e6cb77a0 610
69668465 611 if (ok) {
42c32916 612 notify_progress("Removing selected users...");
69668465
AD
613
614 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
615 param_escape(sel_rows.toString()), true);
616 xmlhttp.onreadystatechange=userlist_callback;
617 xmlhttp.send(null);
618 }
e6cb77a0
AD
619
620 } else {
89cb787e 621 alert(__("No users are selected."));
e6cb77a0 622 }
90ac84df
AD
623
624 return false;
e6cb77a0
AD
625}
626
48f0adb0
AD
627function removeSelectedFilters() {
628
629 if (!xmlhttp_ready(xmlhttp)) {
630 printLockingError();
631 return
632 }
633
634 var sel_rows = getSelectedFilters();
635
636 if (sel_rows.length > 0) {
637
f56e3080 638 var ok = confirm(__("Remove selected filters?"));
48f0adb0 639
69668465 640 if (ok) {
42c32916 641 notify_progress("Removing selected filters...");
69668465
AD
642
643 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
644 param_escape(sel_rows.toString()), true);
645 xmlhttp.onreadystatechange=filterlist_callback;
646 xmlhttp.send(null);
647 }
48f0adb0 648 } else {
89cb787e 649 alert(__("No filters are selected."));
48f0adb0 650 }
90ac84df
AD
651
652 return false;
48f0adb0
AD
653}
654
655
83fe4d6d
AD
656function removeSelectedFeeds() {
657
c0e5a40e 658 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
659 printLockingError();
660 return
661 }
662
83fe4d6d
AD
663 var sel_rows = getSelectedFeeds();
664
331900c6
AD
665 if (sel_rows.length > 0) {
666
f56e3080 667 var ok = confirm(__("Unsubscribe from selected feeds?"));
331900c6 668
69668465
AD
669 if (ok) {
670
42c32916 671 notify_progress("Unsubscribing from selected feeds...");
69668465
AD
672
673 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
674 param_escape(sel_rows.toString()), true);
675 xmlhttp.onreadystatechange=feedlist_callback;
676 xmlhttp.send(null);
677 }
71ad3959 678
71ad3959 679 } else {
331900c6 680
89cb787e 681 alert(__("No feeds are selected."));
331900c6 682
71ad3959 683 }
90ac84df
AD
684
685 return false;
71ad3959 686}
007bda35 687
c4a36709
AD
688function clearSelectedFeeds() {
689
690 if (!xmlhttp_ready(xmlhttp)) {
691 printLockingError();
692 return
693 }
694
695 var sel_rows = getSelectedFeeds();
696
697 if (sel_rows.length > 1) {
698 alert(__("Please select only one feed."));
699 return;
700 }
701
702 if (sel_rows.length > 0) {
703
704 var ok = confirm(__("Erase all non-starred articles in selected feed?"));
705
706 if (ok) {
707 notify_progress("Clearing selected feed...");
708 clearFeedArticles(sel_rows[0]);
709 }
710
711 } else {
712
713 alert(__("No feeds are selected."));
714
715 }
716
717 return false;
718}
719
e88a65f4
AD
720function purgeSelectedFeeds() {
721
722 if (!xmlhttp_ready(xmlhttp)) {
723 printLockingError();
724 return
725 }
726
727 var sel_rows = getSelectedFeeds();
728
729 if (sel_rows.length > 0) {
730
731 var pr = prompt(__("How many days of articles to keep (0 - use default)?"), "0");
732
733 if (pr != undefined) {
734 notify_progress("Purging selected feed...");
735
736 var query = "backend.php?op=rpc&subop=purge&ids="+
737 param_escape(sel_rows.toString()) + "&days=" + pr;
738
739 debug(query);
740
741 new Ajax.Request(query, {
742 onComplete: function(transport) {
743 notify('');
744 } });
745 }
746
747 } else {
748
749 alert(__("No feeds are selected."));
750
751 }
752
753 return false;
754}
755
91ff844a
AD
756function removeSelectedFeedCats() {
757
758 if (!xmlhttp_ready(xmlhttp)) {
759 printLockingError();
760 return
761 }
762
763 var sel_rows = getSelectedFeedCats();
764
765 if (sel_rows.length > 0) {
766
f56e3080 767 var ok = confirm(__("Remove selected categories?"));
91ff844a 768
69668465 769 if (ok) {
42c32916 770 notify_progress("Removing selected categories...");
69668465 771
9c483746 772 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
69668465 773 param_escape(sel_rows.toString()), true);
8f708155 774 xmlhttp.onreadystatechange=infobox_feed_cat_callback;
69668465
AD
775 xmlhttp.send(null);
776 }
91ff844a
AD
777
778 } else {
779
89cb787e 780 alert(__("No categories are selected."));
91ff844a
AD
781
782 }
783
90ac84df 784 return false;
91ff844a
AD
785}
786
508a81e1
AD
787function feedEditCancel() {
788
c0e5a40e 789 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
790 printLockingError();
791 return
792 }
793
a349077c 794 try {
57f734c8 795 document.getElementById("subscribe_to_feed_btn").disabled = false;
a349077c
AD
796 document.getElementById("top25_feeds_btn").disabled = false;
797 } catch (e) {
798 // this button is not always available, no-op if not found
799 }
800
327a3bbe
AD
801 closeInfoBox();
802
673d54ca 803 selectPrefRows('feed', false); // cleanup feed selection
508a81e1 804
90ac84df 805 return false;
508a81e1
AD
806}
807
91ff844a
AD
808function feedCatEditCancel() {
809
810 if (!xmlhttp_ready(xmlhttp)) {
811 printLockingError();
812 return
813 }
814
815 active_feed_cat = false;
816
3381c755
AD
817 try {
818 document.getElementById("subscribe_to_feed_btn").disabled = false;
819 document.getElementById("top25_feeds_btn").disabled = false;
820 } catch (e) {
821 // this button is not always available, no-op if not found
822 }
91ff844a 823
9c483746
AD
824 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
825 xmlhttp.onreadystatechange=infobox_callback;
91ff844a
AD
826 xmlhttp.send(null);
827
90ac84df 828 return false;
91ff844a
AD
829}
830
603c27f8
AD
831function feedEditSave() {
832
47c6c988 833 try {
47c6c988
AD
834
835 if (!xmlhttp_ready(xmlhttp)) {
836 printLockingError();
837 return
838 }
ad815c71 839
14f69488 840 // FIXME: add parameter validation
e3c99f3b 841
14f69488 842 var query = Form.serialize("edit_feed_form");
b0da3a7b 843
42c32916 844 notify_progress("Saving feed...");
673d54ca 845
47c6c988
AD
846 xmlhttp.open("POST", "backend.php", true);
847 xmlhttp.onreadystatechange=feedlist_callback;
848 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
14f69488
AD
849 xmlhttp.send(query);
850
59a543f0
AD
851 closeInfoBox();
852
c14b5566
AD
853 return false;
854
47c6c988
AD
855 } catch (e) {
856 exception_error("feedEditSave", e);
b0da3a7b 857 }
508a81e1
AD
858}
859
e6cb77a0
AD
860function userEditCancel() {
861
862 if (!xmlhttp_ready(xmlhttp)) {
863 printLockingError();
864 return
865 }
866
3c5783b7 867 selectPrefRows('user', false); // cleanup feed selection
3c5783b7 868 closeInfoBox();
90ac84df
AD
869
870 return false;
e6cb77a0 871}
48f0adb0 872
a0d53889
AD
873function filterEditCancel() {
874
875 if (!xmlhttp_ready(xmlhttp)) {
876 printLockingError();
877 return
878 }
4220b0bd 879
57f734c8
AD
880 try {
881 document.getElementById("create_filter_btn").disabled = false;
882 selectPrefRows('filter', false); // cleanup feed selection
883 } catch (e) { }
884
07164479 885 closeInfoBox();
90ac84df
AD
886
887 return false;
a0d53889
AD
888}
889
e6cb77a0
AD
890function userEditSave() {
891
e6cb77a0
AD
892 if (!xmlhttp_ready(xmlhttp)) {
893 printLockingError();
894 return
895 }
896
3c5783b7 897 var login = document.forms["user_edit_form"].login.value;
e6cb77a0
AD
898
899 if (login.length == 0) {
89cb787e 900 alert(__("Login field cannot be blank."));
e6cb77a0
AD
901 return;
902 }
3c5783b7 903
42c32916 904 notify_progress("Saving user...");
4220b0bd
AD
905
906 closeInfoBox();
907
3c5783b7
AD
908 var query = Form.serialize("user_edit_form");
909
910 xmlhttp.open("GET", "backend.php?" + query, true);
dbd9e2f1 911 xmlhttp.onreadystatechange=userlist_callback;
e6cb77a0 912 xmlhttp.send(null);
90ac84df
AD
913
914 return false;
e6cb77a0
AD
915}
916
917
a0d53889
AD
918function filterEditSave() {
919
a0d53889
AD
920 if (!xmlhttp_ready(xmlhttp)) {
921 printLockingError();
922 return
923 }
924
9ee3ac59 925/* if (!is_opera()) {
7c620da8
AD
926 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
927
928 if (reg_exp.length == 0) {
929 alert("Filter expression field cannot be blank.");
930 return;
931 }
9ee3ac59 932 } */
a0d53889 933
42c32916 934 notify_progress("Saving filter...");
a0d53889 935
7e939457 936 var query = Form.serialize("filter_edit_form");
dbd9e2f1 937
07164479
AD
938 closeInfoBox();
939
4220b0bd
AD
940 document.getElementById("create_filter_btn").disabled = false;
941
7e939457 942 xmlhttp.open("GET", "backend.php?" + query, true);
a0d53889 943 xmlhttp.onreadystatechange=filterlist_callback;
7e939457 944 xmlhttp.send(null);
a0d53889 945
90ac84df 946 return false;
a0d53889
AD
947}
948
a0d53889 949
e6cb77a0
AD
950function editSelectedUser() {
951 var rows = getSelectedUsers();
952
953 if (rows.length == 0) {
f3977cf5 954 alert(__("No users are selected."));
e6cb77a0
AD
955 return;
956 }
957
958 if (rows.length > 1) {
f3977cf5 959 alert(__("Please select only one user."));
e6cb77a0
AD
960 return;
961 }
962
dbd9e2f1
AD
963 notify("");
964
e6cb77a0
AD
965 editUser(rows[0]);
966}
967
968function resetSelectedUserPass() {
969 var rows = getSelectedUsers();
970
971 if (rows.length == 0) {
f3977cf5 972 alert(__("No users are selected."));
e6cb77a0
AD
973 return;
974 }
975
976 if (rows.length > 1) {
f3977cf5 977 alert(__("Please select only one user."));
e6cb77a0
AD
978 return;
979 }
980
f3977cf5 981 var ok = confirm(__("Reset password of selected user?"));
e6cb77a0 982
69668465 983 if (ok) {
42c32916 984 notify_progress("Resetting password for selected user...");
69668465
AD
985
986 var id = rows[0];
987
988 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
989 param_escape(id), true);
990 xmlhttp.onreadystatechange=userlist_callback;
991 xmlhttp.send(null);
992 }
e6cb77a0
AD
993}
994
717f5e64 995function selectedUserDetails() {
e6cb77a0 996
1a7572cb
AD
997 if (!xmlhttp_ready(xmlhttp)) {
998 printLockingError();
999 return
1000 }
1001
717f5e64
AD
1002 var rows = getSelectedUsers();
1003
1004 if (rows.length == 0) {
f3977cf5 1005 alert(__("No users are selected."));
717f5e64
AD
1006 return;
1007 }
1008
1009 if (rows.length > 1) {
f3977cf5 1010 alert(__("Please select only one user."));
717f5e64
AD
1011 return;
1012 }
1013
0077a65c 1014 notify_progress("Loading, please wait...");
717f5e64 1015
0077a65c 1016 var id = rows[0];
dbd9e2f1 1017
5a437c88 1018 xmlhttp.open("GET", "backend.php?op=pref-users&subop=user-details&id=" + id, true);
c6c3a07f
AD
1019 xmlhttp.onreadystatechange=infobox_callback;
1020 xmlhttp.send(null);
1021
1022}
1023
1024function selectedFeedDetails() {
1025
1026 if (!xmlhttp_ready(xmlhttp)) {
1027 printLockingError();
1028 return
1029 }
1030
1031 var rows = getSelectedFeeds();
1032
1033 if (rows.length == 0) {
f3977cf5 1034 alert(__("No feeds are selected."));
c6c3a07f
AD
1035 return;
1036 }
1037
01b3e191 1038 if (rows.length > 1) {
f3977cf5 1039 alert(__("Please select only one feed."));
01b3e191
AD
1040 return;
1041 }
c6c3a07f 1042
df268d47 1043// var id = rows[0];
c6c3a07f 1044
dbd9e2f1
AD
1045 notify("");
1046
df268d47
AD
1047 xmlhttp.open("GET", "backend.php?op=feed-details&id=" +
1048 param_escape(rows.toString()), true);
c6c3a07f 1049 xmlhttp.onreadystatechange=infobox_callback;
1a7572cb 1050 xmlhttp.send(null);
717f5e64
AD
1051
1052}
a0d53889
AD
1053
1054function editSelectedFilter() {
1055 var rows = getSelectedFilters();
1056
1057 if (rows.length == 0) {
f3977cf5 1058 alert(__("No filters are selected."));
a0d53889
AD
1059 return;
1060 }
1061
1062 if (rows.length > 1) {
f3977cf5 1063 alert(__("Please select only one filter."));
a0d53889
AD
1064 return;
1065 }
1066
dbd9e2f1
AD
1067 notify("");
1068
a0d53889
AD
1069 editFilter(rows[0]);
1070
1071}
1072
1073
508a81e1
AD
1074function editSelectedFeed() {
1075 var rows = getSelectedFeeds();
1076
1077 if (rows.length == 0) {
f3977cf5 1078 alert(__("No feeds are selected."));
508a81e1
AD
1079 return;
1080 }
1081
1082 if (rows.length > 1) {
f3977cf5 1083 alert(__("Please select one feed."));
508a81e1
AD
1084 return;
1085 }
1086
dbd9e2f1
AD
1087 notify("");
1088
508a81e1 1089 editFeed(rows[0]);
91ff844a
AD
1090
1091}
1092
758e1c4a
AD
1093function editSelectedFeeds() {
1094
1095 if (!xmlhttp_ready(xmlhttp)) {
1096 printLockingError();
1097 return
1098 }
1099
1100 var rows = getSelectedFeeds();
1101
1102 if (rows.length == 0) {
1103 alert(__("No feeds are selected."));
1104 return;
1105 }
1106
1107 notify("");
1108
1109 disableHotkeys();
1110
1111 notify_progress("Loading, please wait...");
1112
1113 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeeds&ids=" +
1114 param_escape(rows.toString()), true);
1115
1116 xmlhttp.onreadystatechange=infobox_callback;
1117 xmlhttp.send(null);
1118
1119}
1120
91ff844a
AD
1121function editSelectedFeedCat() {
1122 var rows = getSelectedFeedCats();
1123
1124 if (rows.length == 0) {
f3977cf5 1125 alert(__("No categories are selected."));
91ff844a
AD
1126 return;
1127 }
1128
1129 if (rows.length > 1) {
f3977cf5 1130 alert(__("Please select only one category."));
91ff844a
AD
1131 return;
1132 }
1133
1134 notify("");
1135
1136 editFeedCat(rows[0]);
508a81e1
AD
1137
1138}
1139
eec498c3 1140function piggie(enable) {
13ad9102 1141 if (enable) {
d437c8cf 1142 debug("I LOVEDED IT!");
1cac3c31 1143 var piggie = document.getElementById("piggie");
33377ef3 1144
537625c6
AD
1145 Element.show(piggie);
1146 Position.Center(piggie);
1147 Effect.Puff(piggie);
1148
508a81e1 1149 }
508a81e1
AD
1150}
1151
9f311df6
AD
1152function validateOpmlImport() {
1153
1154 var opml_file = document.getElementById("opml_file");
1155
1156 if (opml_file.value.length == 0) {
f3977cf5 1157 alert(__("No OPML file to upload."));
9f311df6
AD
1158 return false;
1159 } else {
1160 return true;
1161 }
1162}
1163
0e317f9d 1164function updateFilterList(sort_key) {
a0d53889
AD
1165
1166 if (!xmlhttp_ready(xmlhttp)) {
1167 printLockingError();
1168 return
1169 }
1170
9c87d75c
AD
1171 var filter_search = document.getElementById("filter_search");
1172 var search = "";
1173 if (filter_search) { search = filter_search.value; }
1174
e161a2cc 1175 xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" +
9c87d75c
AD
1176 param_escape(sort_key) +
1177 "&search=" + param_escape(search), true);
a0d53889
AD
1178 xmlhttp.onreadystatechange=filterlist_callback;
1179 xmlhttp.send(null);
1180
1181}
1182
e161a2cc 1183function updateLabelList(sort_key) {
48f0adb0
AD
1184
1185 if (!xmlhttp_ready(xmlhttp)) {
1186 printLockingError();
1187 return
1188 }
1189
112d2aec
AD
1190 var label_search = document.getElementById("label_search");
1191 var search = "";
1192 if (label_search) { search = label_search.value; }
1193
e161a2cc 1194 xmlhttp.open("GET", "backend.php?op=pref-labels&sort=" +
112d2aec
AD
1195 param_escape(sort_key) +
1196 "&search=" + param_escape(search), true);
48f0adb0
AD
1197 xmlhttp.onreadystatechange=labellist_callback;
1198 xmlhttp.send(null);
48f0adb0
AD
1199}
1200
4255b24c
AD
1201function updatePrefsList() {
1202
1203 if (!xmlhttp_ready(xmlhttp)) {
1204 printLockingError();
1205 return
1206 }
1207
4255b24c
AD
1208 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1209 xmlhttp.onreadystatechange=prefslist_callback;
1210 xmlhttp.send(null);
1211
1212}
1213
e513a74a 1214function selectTab(id, noupdate, subop) {
a7f22b70
AD
1215
1216// alert(id);
48f0adb0 1217
b2caf812 1218 if (!id) id = active_tab;
7f74a9da 1219
b2caf812 1220 try {
59a543f0 1221
b2caf812
AD
1222 if (!xmlhttp_ready(xmlhttp)) {
1223 printLockingError();
1224 return
a7f22b70 1225 }
f5a50b25 1226
a422968f
AD
1227 try {
1228 var c = document.getElementById('prefContent');
1229 c.scrollTop = 0;
1230 } catch (e) { };
1231
b2caf812 1232 if (!noupdate) {
f5a50b25 1233
b2caf812
AD
1234 debug("selectTab: " + id + "(NU: " + noupdate + ")");
1235
9e31e1b9 1236 notify_progress("Loading, please wait...");
b2caf812
AD
1237
1238 // close active infobox if needed
1239 closeInfoBox();
1240
1241 // clean up all current selections, just in case
1242 active_feed_cat = false;
d15f8675
AD
1243
1244// Effect.Fade("prefContent", {duration: 1, to: 0.01,
1245// queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1246
b2caf812
AD
1247 if (id == "feedConfig") {
1248 updateFeedList();
1249 } else if (id == "filterConfig") {
1250 updateFilterList();
1251 } else if (id == "labelConfig") {
1252 updateLabelList();
1253 } else if (id == "genConfig") {
1254 updatePrefsList();
1255 } else if (id == "userConfig") {
1256 updateUsersList();
1257 } else if (id == "feedBrowser") {
1258 updateBigFeedBrowser();
1259 }
f5a50b25 1260 }
6068d33b
AD
1261
1262 /* clean selection from all tabs */
b2caf812 1263
6068d33b
AD
1264 var tabs_holder = document.getElementById("prefTabs");
1265 var tab = tabs_holder.firstChild;
1266
1267 while (tab) {
1268 if (tab.className && tab.className.match("prefsTabSelected")) {
b2caf812
AD
1269 tab.className = "prefsTab";
1270 }
6068d33b 1271 tab = tab.nextSibling;
f5a50b25 1272 }
6068d33b
AD
1273
1274 /* mark new tab as selected */
1275
b2caf812
AD
1276 tab = document.getElementById(id + "Tab");
1277
1278 if (tab) {
1279 if (!tab.className.match("Selected")) {
1280 tab.className = tab.className + "Selected";
1281 }
1282 }
1283
b2caf812 1284 active_tab = id;
f5a50b25 1285
b2caf812
AD
1286 } catch (e) {
1287 exception_error("selectTab", e);
a7565293 1288 }
a7565293
AD
1289}
1290
1291function backend_sanity_check_callback() {
f5a50b25 1292
a7565293
AD
1293 if (xmlhttp.readyState == 4) {
1294
1295 try {
7a09510c
AD
1296
1297 if (sanity_check_done) {
81352b54
AD
1298 fatalError(11, "Sanity check request received twice. This can indicate "+
1299 "presence of Firebug or some other disrupting extension. "+
1300 "Please disable it and try again.");
7a09510c
AD
1301 return;
1302 }
1303
a7565293
AD
1304 if (!xmlhttp.responseXML) {
1305 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText);
1306 return;
1307 }
1308
1309 var reply = xmlhttp.responseXML.firstChild.firstChild;
1310
1311 if (!reply) {
1312 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText);
1313 return;
1314 }
1315
1316 var error_code = reply.getAttribute("error-code");
1317
1318 if (error_code && error_code != 0) {
1319 return fatalError(error_code, reply.getAttribute("error-msg"));
1320 }
1321
1322 debug("sanity check ok");
1323
1324 var params = reply.nextSibling;
1325
1326 if (params) {
1327 debug('reading init-params...');
1328 var param = params.firstChild;
1329
1330 while (param) {
1331 var k = param.getAttribute("key");
1332 var v = param.getAttribute("value");
1333 debug(k + " => " + v);
1334 init_params[k] = v;
1335 param = param.nextSibling;
1336 }
1337 }
1338
7a09510c
AD
1339 sanity_check_done = true;
1340
a7565293
AD
1341 init_second_stage();
1342
1343 } catch (e) {
1344 exception_error("backend_sanity_check_callback", e);
1345 }
1346 }
1347}
1348
1349function init_second_stage() {
1350
b2caf812
AD
1351 try {
1352 active_tab = getInitParam("prefs_active_tab");
fe8d2059 1353 if (!active_tab || active_tab == '0') active_tab = "genConfig";
4da47970 1354
d437c8cf
AD
1355 document.onkeydown = pref_hotkey_handler;
1356
e513a74a
AD
1357 var tab = getURLParam('tab');
1358
1359 caller_subop = getURLParam('subop');
1360
1361 if (tab) {
1362 active_tab = tab;
1363 }
1364
b2caf812
AD
1365 if (navigator.userAgent.match("Opera")) {
1366 setTimeout("selectTab()", 500);
1367 } else {
1368 selectTab(active_tab);
1369 }
1370 notify("");
08827aaf
AD
1371
1372 loading_set_progress(60);
1373
b2caf812
AD
1374 } catch (e) {
1375 exception_error("init_second_stage", e);
1376 }
a0d53889
AD
1377}
1378
007bda35 1379function init() {
e2ec66a8 1380
7719618b
AD
1381 try {
1382
97dcd654
AD
1383 if (arguments.callee.done) return;
1384 arguments.callee.done = true;
1385
a7565293 1386 if (getURLParam('debug')) {
8836613c 1387 Element.show("debug_output");
a7565293
AD
1388 debug('debug mode activated');
1389 }
1390
7719618b
AD
1391 // IE kludge
1392 if (!xmlhttp) {
1393 document.getElementById("prefContent").innerHTML =
1394 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1395 "to function properly. Your browser doesn't seem to support it.";
1396 return;
1397 }
4da47970 1398
08827aaf
AD
1399 loading_set_progress(30);
1400
a7565293
AD
1401 xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1402 xmlhttp.onreadystatechange=backend_sanity_check_callback;
1403 xmlhttp.send(null);
1404
7719618b
AD
1405 } catch (e) {
1406 exception_error("init", e);
e2ec66a8 1407 }
007bda35 1408}
b1895692 1409
f932bc9f
AD
1410function categorizeSelectedFeeds() {
1411
1412 if (!xmlhttp_ready(xmlhttp)) {
1413 printLockingError();
1414 return
1415 }
1416
1417 var sel_rows = getSelectedFeeds();
1418
1419 var cat_sel = document.getElementById("sfeed_set_fcat");
79f3553b 1420 var cat_id = cat_sel[cat_sel.selectedIndex].value;
f932bc9f
AD
1421
1422 if (sel_rows.length > 0) {
1423
42c32916 1424 notify_progress("Changing category of selected feeds...");
f932bc9f
AD
1425
1426 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1427 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1428 xmlhttp.onreadystatechange=feedlist_callback;
1429 xmlhttp.send(null);
1430
1431 } else {
1432
f3977cf5 1433 alert(__("No feeds are selected."));
f932bc9f
AD
1434
1435 }
1436
1437}
69668465
AD
1438
1439function validatePrefsReset() {
b652c1b7
AD
1440 try {
1441 var ok = confirm(__("Reset to defaults?"));
1442
1443 if (ok) {
1444
1445 var query = Form.serialize("pref_prefs_form");
1446 query = query + "&subop=reset-config";
1447 debug(query);
1448
1449 xmlhttp.open("POST", "backend.php", true);
1450 xmlhttp.onreadystatechange=prefs_reset_callback;
1451 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1452 xmlhttp.send(query);
1453 }
1454
1455 } catch (e) {
1456 exception_error("validatePrefsSave", e);
1457 }
1458
1459 return false;
1460
69668465 1461}
f9cb39ac 1462
6311acbe 1463function browseFeeds(limit) {
f9cb39ac
AD
1464
1465 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1466 xmlhttp.onreadystatechange=infobox_callback;
1467 xmlhttp.send(null);
1468
1469}
a0476535
AD
1470
1471function feedBrowserSubscribe() {
1472 try {
a0476535 1473
c0ae0fdb 1474 var selected = getSelectedFeedsFromBrowser();
a0476535
AD
1475
1476 if (selected.length > 0) {
1477 closeInfoBox();
1478 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1479 param_escape(selected.toString()), true);
1480 xmlhttp.onreadystatechange=feedlist_callback;
1481 xmlhttp.send(null);
1482 } else {
89cb787e 1483 alert(__("No feeds are selected."));
a0476535
AD
1484 }
1485
1486 } catch (e) {
1487 exception_error("feedBrowserSubscribe", e);
1488 }
1489}
c6232e43 1490
ce8de904
AD
1491function updateBigFeedBrowserBtn() {
1492 notify_progress("Loading, please wait...");
1493 return updateBigFeedBrowser();
1494}
1495
1496function updateBigFeedBrowser(limit, from_button) {
c6232e43
AD
1497
1498 if (!xmlhttp_ready(xmlhttp)) {
1499 printLockingError();
1500 return
1501 }
1502
6311acbe
AD
1503 var query = "backend.php?op=pref-feed-browser";
1504
1505 var limit_sel = document.getElementById("feedBrowserLimit");
1506
1507 if (limit_sel) {
1508 var limit = limit_sel[limit_sel.selectedIndex].value;
1509 query = query + "&limit=" + param_escape(limit);
1510 }
1511
76e9a473
AD
1512 var search = document.getElementById("feed_browser_search");
1513
1514 if (search) {
1515 query = query + "&search=" + param_escape(search.value);
1516 }
1517
6311acbe 1518 xmlhttp.open("GET", query, true);
c6232e43
AD
1519 xmlhttp.onreadystatechange=feed_browser_callback;
1520 xmlhttp.send(null);
c6232e43
AD
1521}
1522
c2b2aee0 1523function browserToggleExpand(id) {
c6232e43
AD
1524 try {
1525/* if (feed_to_expand && feed_to_expand != id) {
1526 var d = document.getElementById("BRDET-" + feed_to_expand);
1527 d.style.display = "none";
1528 } */
c2b2aee0 1529
ff725e9b
AD
1530 if (!xmlhttp_ready(xmlhttp)) {
1531 printLockingError();
1532 return
1533 }
1534
051c4d56
AD
1535/* if (feed_to_expand && id != feed_to_expand) {
1536 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1537 } */
c2b2aee0 1538
051c4d56 1539 var d = document.getElementById("BRDET-" + id);
c6232e43 1540
de84c092
AD
1541 notify_progress("Loading, please wait...");
1542
34a01a20 1543 if (Element.visible(d)) {
051c4d56 1544 Effect.Fade(d, {duration : 0.5});
34a01a20 1545 } else {
c2b2aee0 1546 feed_to_expand = id;
c6232e43 1547
c2b2aee0
AD
1548 xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1549 + param_escape(id), true);
1550 xmlhttp.onreadystatechange=expand_feed_callback;
1551 xmlhttp.send(null);
1552 }
c6232e43
AD
1553
1554 } catch (e) {
34a01a20 1555 exception_error("browserToggleExpand", e);
c6232e43
AD
1556 }
1557}
64dc5976 1558
ce3bf408
AD
1559function selectPrefRows(kind, select) {
1560
1561 if (kind) {
1562 var opbarid = false;
1563 var nchk = false;
1564 var nrow = false;
1565 var lname = false;
1566
1567 if (kind == "feed") {
1568 opbarid = "feedOpToolbar";
1569 nrow = "FEEDR-";
1570 nchk = "FRCHK-";
1571 lname = "prefFeedList";
1572 } else if (kind == "fcat") {
1573 opbarid = "catOpToolbar";
1574 nrow = "FCATR-";
9c483746 1575 nchk = "FCCHK-";
ce3bf408
AD
1576 lname = "prefFeedCatList";
1577 } else if (kind == "filter") {
1578 opbarid = "filterOpToolbar";
1579 nrow = "FILRR-";
1580 nchk = "FICHK-";
1581 lname = "prefFilterList";
1582 } else if (kind == "label") {
1583 opbarid = "labelOpToolbar";
1584 nrow = "LILRR-";
a4dbc524 1585 nchk = "LICHK-";
ce3bf408
AD
1586 lname = "prefLabelList";
1587 } else if (kind == "user") {
1588 opbarid = "userOpToolbar";
1589 nrow = "UMRR-";
1590 nchk = "UMCHK-";
1591 lname = "prefUserList";
1592 }
1593
1594 if (opbarid) {
1595 selectTableRowsByIdPrefix(lname, nrow, nchk, select);
1596 disableContainerChildren(opbarid, !select);
1597 }
1598
1599 }
1600}
1601
1602
1603function toggleSelectPrefRow(sender, kind) {
1604
1605 toggleSelectRow(sender);
1606
1607 if (kind) {
1608 var opbarid = false;
1609 var nsel = -1;
1610
1611 if (kind == "feed") {
1612 opbarid = "feedOpToolbar";
1613 nsel = getSelectedFeeds();
1614 } else if (kind == "fcat") {
1615 opbarid = "catOpToolbar";
1616 nsel = getSelectedFeedCats();
1617 } else if (kind == "filter") {
1618 opbarid = "filterOpToolbar";
1619 nsel = getSelectedFilters();
1620 } else if (kind == "label") {
1621 opbarid = "labelOpToolbar";
1622 nsel = getSelectedLabels();
1623 } else if (kind == "user") {
1624 opbarid = "userOpToolbar";
1625 nsel = getSelectedUsers();
1626 }
1627
1628 if (opbarid && nsel != -1) {
1629 disableContainerChildren(opbarid, nsel == false);
1630 }
1631
1632 }
1633}
1634
c0ae0fdb
AD
1635function toggleSelectFBListRow(sender) {
1636 toggleSelectListRow(sender);
1637 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1638}
d437c8cf
AD
1639
1640var seq = "";
1641
1642function pref_hotkey_handler(e) {
1643 try {
1644
1645 var keycode;
746dcf42
AD
1646 var shift_key = false;
1647
1648 try {
1649 shift_key = e.shiftKey;
1650 } catch (e) {
1651
1652 }
1653
d437c8cf
AD
1654 if (window.event) {
1655 keycode = window.event.keyCode;
1656 } else if (e) {
1657 keycode = e.which;
1658 }
746dcf42 1659
eec498c3
AD
1660 var keychar = String.fromCharCode(keycode);
1661
746dcf42
AD
1662 if (keycode == 27) { // escape
1663 if (Element.visible("hotkey_help_overlay")) {
1664 Element.hide("hotkey_help_overlay");
1665 }
1666 hotkey_prefix = false;
1667 closeInfoBox();
1668 }
1669
1670 if (!hotkeys_enabled) {
1671 debug("hotkeys disabled");
1672 return;
1673 }
1674
1675 if (keycode == 16) return; // ignore lone shift
1676
6068d33b
AD
1677 if ((keycode == 67 || keycode == 71) && !hotkey_prefix) {
1678 hotkey_prefix = keycode;
eec498c3 1679 debug("KP: PREFIX=" + keycode + " CHAR=" + keychar);
6068d33b
AD
1680 return;
1681 }
1682
746dcf42
AD
1683 if (Element.visible("hotkey_help_overlay")) {
1684 Element.hide("hotkey_help_overlay");
1685 }
1686
d437c8cf
AD
1687 if (keycode == 13 || keycode == 27) {
1688 seq = "";
1689 } else {
1690 seq = seq + "" + keycode;
1691 }
1692
746dcf42 1693 /* Global hotkeys */
d437c8cf 1694
746dcf42
AD
1695 if (!hotkey_prefix) {
1696
1697 if (keycode == 68 && shift_key) { // d
8836613c
AD
1698 if (!Element.visible("debug_output")) {
1699 Element.show("debug_output");
746dcf42
AD
1700 debug('debug mode activated');
1701 } else {
8836613c 1702 Element.hide("debug_output");
746dcf42 1703 }
746dcf42
AD
1704 return;
1705 }
1706
eec498c3 1707 if ((keycode == 191 || keychar == '?') && shift_key) { // ?
746dcf42 1708 if (!Element.visible("hotkey_help_overlay")) {
86deaa0e
AD
1709 //Element.show("hotkey_help_overlay");
1710 Effect.Appear("hotkey_help_overlay", {duration : 0.3});
746dcf42
AD
1711 } else {
1712 Element.hide("hotkey_help_overlay");
1713 }
eec498c3 1714 return false;
746dcf42
AD
1715 }
1716
eec498c3 1717 if (keycode == 191 || keychar == '/') { // /
477402d8 1718 var search_boxes = new Array("label_search",
e8be0f5b 1719 "feed_search", "filter_search", "user_search", "feed_browser_search");
477402d8
AD
1720
1721 for (var i = 0; i < search_boxes.length; i++) {
1722 var elem = document.getElementById(search_boxes[i]);
1723 if (elem) {
eec498c3
AD
1724 focus_element(search_boxes[i]);
1725 return false;
477402d8
AD
1726 }
1727 }
477402d8 1728 }
6068d33b
AD
1729 }
1730
1731 /* Prefix c */
1732
1733 if (hotkey_prefix == 67) { // c
1734 hotkey_prefix = false;
1735
1736 if (keycode == 70) { // f
eec498c3
AD
1737 displayDlg("quickAddFilter");
1738 return false;
6068d33b
AD
1739 }
1740
1741 if (keycode == 83) { // s
eec498c3
AD
1742 displayDlg("quickAddFeed");
1743 return false;
6068d33b
AD
1744 }
1745
ceb30ba4 1746/* if (keycode == 76) { // l
eec498c3
AD
1747 displayDlg("quickAddLabel");
1748 return false;
ceb30ba4 1749 } */
6068d33b
AD
1750
1751 if (keycode == 85) { // u
1752 // no-op
1753 }
1754
57f734c8 1755 if (keycode == 67) { // c
eec498c3
AD
1756 editFeedCats();
1757 return false;
57f734c8
AD
1758 }
1759
a80b05ea 1760 if (keycode == 84 && shift_key) { // T
eec498c3
AD
1761 browseFeeds();
1762 return false;
a80b05ea
AD
1763 }
1764
6068d33b
AD
1765 }
1766
1767 /* Prefix g */
1768
1769 if (hotkey_prefix == 71) { // g
1770
1771 hotkey_prefix = false;
1772
1773 if (keycode == 49 && document.getElementById("genConfigTab")) { // 1
746dcf42 1774 selectTab("genConfig");
eec498c3 1775 return false;
746dcf42
AD
1776 }
1777
1778 if (keycode == 50 && document.getElementById("feedConfigTab")) { // 2
eec498c3
AD
1779 selectTab("feedConfig");
1780 return false;
746dcf42
AD
1781 }
1782
1783 if (keycode == 51 && document.getElementById("feedBrowserTab")) { // 3
eec498c3
AD
1784 selectTab("feedBrowser");
1785 return false;
746dcf42
AD
1786 }
1787
1788 if (keycode == 52 && document.getElementById("filterConfigTab")) { // 4
eec498c3
AD
1789 selectTab("filterConfig");
1790 return false;
746dcf42
AD
1791 }
1792
1793 if (keycode == 53 && document.getElementById("labelConfigTab")) { // 5
eec498c3
AD
1794 selectTab("labelConfig");
1795 return false;
746dcf42
AD
1796 }
1797
1798 if (keycode == 54 && document.getElementById("userConfigTab")) { // 6
eec498c3
AD
1799 selectTab("userConfig");
1800 return false;
746dcf42
AD
1801 }
1802
8d727bfc
AD
1803 if (keycode == 88) { // x
1804 return gotoMain();
1805 }
1806
746dcf42
AD
1807 }
1808
1809 if (document.getElementById("piggie")) {
1810
1811 if (seq.match("807371717369")) {
1812 seq = "";
eec498c3 1813 piggie(true);
746dcf42 1814 } else {
eec498c3 1815 piggie(false);
746dcf42
AD
1816 }
1817 }
1818
1819 if (hotkey_prefix) {
eec498c3 1820 debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode + " CHAR=" + keychar);
d437c8cf 1821 } else {
eec498c3 1822 debug("KP: CODE=" + keycode + " CHAR=" + keychar);
d437c8cf 1823 }
d437c8cf
AD
1824
1825 } catch (e) {
1826 exception_error("pref_hotkey_handler", e);
1827 }
1828}
1829
9c483746
AD
1830function editFeedCats() {
1831 if (!xmlhttp_ready(xmlhttp)) {
1832 printLockingError();
1833 return
1834 }
1835
a349077c
AD
1836 document.getElementById("subscribe_to_feed_btn").disabled = true;
1837
1838 try {
1839 document.getElementById("top25_feeds_btn").disabled = true;
1840 } catch (e) {
1841 // this button is not always available, no-op if not found
1842 }
1843
9c483746 1844 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
11f083e7 1845 xmlhttp.onreadystatechange=infobox_feed_cat_callback;
9c483746
AD
1846 xmlhttp.send(null);
1847}
a3656a41
AD
1848
1849function showFeedsWithErrors() {
1850 displayDlg('feedUpdateErrors');
1851}
073ca0e6 1852
d95bd220
AD
1853function changeUserPassword() {
1854
1855 try {
1856
1857 if (!xmlhttp_ready(xmlhttp)) {
1858 printLockingError();
1859 return false;
1860 }
1861
ae661a8c
AD
1862 var f = document.forms["change_pass_form"];
1863
1864 if (f) {
1865 if (f.OLD_PASSWORD.value == "") {
1866 new Effect.Highlight(f.OLD_PASSWORD);
1867 notify_error("Old password cannot be blank.");
1868 return false;
1869 }
1870
1871 if (f.NEW_PASSWORD.value == "") {
1872 new Effect.Highlight(f.NEW_PASSWORD);
1873 notify_error("New password cannot be blank.");
1874 return false;
1875 }
1876
1877 if (f.CONFIRM_PASSWORD.value == "") {
1878 new Effect.Highlight(f.CONFIRM_PASSWORD);
1879 notify_error("Entered passwords do not match.");
1880 return false;
1881 }
1882
1883 if (f.CONFIRM_PASSWORD.value != f.NEW_PASSWORD.value) {
1884 new Effect.Highlight(f.CONFIRM_PASSWORD);
1885 new Effect.Highlight(f.NEW_PASSWORD);
1886 notify_error("Entered passwords do not match.");
1887 return false;
1888 }
1889
1890 }
1891
d95bd220
AD
1892 var query = Form.serialize("change_pass_form");
1893
1894 notify_progress("Trying to change password...");
1895
1896 xmlhttp.open("POST", "backend.php", true);
1897 xmlhttp.onreadystatechange=changepass_callback;
1898 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1899 xmlhttp.send(query);
1900
1901 } catch (e) {
1902 exception_error("changeUserPassword", e);
1903 }
1904
1905 return false;
1906}
073ca0e6 1907
42395d28
AD
1908function changeUserEmail() {
1909
1910 try {
1911
1912 if (!xmlhttp_ready(xmlhttp)) {
1913 printLockingError();
1914 return false;
1915 }
1916
1917 var query = Form.serialize("change_email_form");
1918
1919 notify_progress("Trying to change e-mail...");
1920
1921 xmlhttp.open("POST", "backend.php", true);
1922 xmlhttp.onreadystatechange=notify_callback;
1923 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1924 xmlhttp.send(query);
1925
1926 } catch (e) {
1927 exception_error("changeUserPassword", e);
1928 }
1929
1930 return false;
1931
1932}
400b60d8
AD
1933
1934function feedlistToggleSLAT() {
1935 notify_progress("Loading, please wait...");
1936 updateFeedList()
1937}
bc0ed820 1938
e4f4b46f
AD
1939function pubRegenKey() {
1940
bc0ed820
AD
1941 if (!xmlhttp_ready(xmlhttp)) {
1942 printLockingError();
e4f4b46f 1943 return false;
bc0ed820
AD
1944 }
1945
f56e3080 1946 var ok = confirm(__("Replace current publishing address with a new one?"));
bc0ed820 1947
e4f4b46f
AD
1948 if (ok) {
1949
1950 notify_progress("Trying to change address...");
1951
945c243e 1952 xmlhttp.open("GET", "backend.php?op=rpc&subop=regenPubKey");
e4f4b46f
AD
1953 xmlhttp.onreadystatechange=replace_pubkey_callback;
1954 xmlhttp.send(null);
1955 }
1956
1957 return false;
945c243e 1958}
b652c1b7 1959
e635d56a
AD
1960function pubToClipboard() {
1961
1962 try {
1963
1964 if (!xmlhttp_ready(xmlhttp)) {
1965 printLockingError();
1966 return false;
1967 }
1968
1969 var link = document.getElementById("pubGenAddress");
1970 alert(link.href);
1971
1972 } catch (e) {
1973 exception_error("pubToClipboard", e);
1974 }
1975
1976 return false;
1977}
1978
b652c1b7
AD
1979function validatePrefsSave() {
1980 try {
1981
1982 var ok = confirm(__("Save current configuration?"));
1983
1984 if (ok) {
1985
1986 var query = Form.serialize("pref_prefs_form");
1987 query = query + "&subop=save-config";
1988 debug(query);
1989
1990 xmlhttp.open("POST", "backend.php", true);
1991 xmlhttp.onreadystatechange=notify_callback;
1992 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1993 xmlhttp.send(query);
1994 }
1995
1996 } catch (e) {
1997 exception_error("validatePrefsSave", e);
1998 }
1999
2000 return false;
2001}
c4a36709
AD
2002
2003function feedActionChange() {
2004 try {
2005 var chooser = document.getElementById("feedActionChooser");
2006 var opid = chooser[chooser.selectedIndex].value;
2007
2008 chooser.selectedIndex = 0;
2009 feedActionGo(opid);
2010 } catch (e) {
2011 exception_error("feedActionChange", e);
2012 }
2013}
2014
2015function feedActionGo(op) {
2016 try {
2017 if (op == "facEdit") {
cd935c42
AD
2018
2019 var rows = getSelectedFeeds();
2020
2021 if (rows.length > 1) {
2022 editSelectedFeeds();
2023 } else {
2024 editSelectedFeed();
2025 }
c4a36709
AD
2026 }
2027
2028 if (op == "facClear") {
2029 clearSelectedFeeds();
2030 }
2031
2032 if (op == "facPurge") {
2033 purgeSelectedFeeds();
2034 }
2035
e88a65f4
AD
2036 if (op == "facEditCats") {
2037 editFeedCats();
2038 }
2039
fee840fb
AD
2040 if (op == "facRescore") {
2041 rescoreSelectedFeeds();
2042 }
2043
c4a36709
AD
2044 if (op == "facUnsubscribe") {
2045 removeSelectedFeeds();
2046 }
2047
2048 } catch (e) {
2049 exception_error("feedActionGo", e);
2050
2051 }
2052}
2053
2054function clearFeedArticles(feed_id) {
2055
2056 notify_progress("Clearing feed...");
2057
2058 var query = "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id;
2059
2060 new Ajax.Request(query, {
2061 onComplete: function(transport) {
2062 notify('');
2063 } });
2064
2065 return false;
2066}
2067
fee840fb
AD
2068function rescoreSelectedFeeds() {
2069
2070 if (!xmlhttp_ready(xmlhttp)) {
2071 printLockingError();
2072 return
2073 }
2074
2075 var sel_rows = getSelectedFeeds();
2076
2077 if (sel_rows.length > 0) {
2078
ef1b0366
AD
2079 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
2080 var ok = confirm(__("Rescore articles in selected feeds?"));
fee840fb
AD
2081
2082 if (ok) {
3df4869b 2083 notify_progress("Rescoring selected feeds...", true);
fee840fb
AD
2084
2085 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
2086 param_escape(sel_rows.toString()), true);
2087 xmlhttp.onreadystatechange=notify_callback;
2088 xmlhttp.send(null);
2089 }
2090 } else {
2091 alert(__("No feeds are selected."));
2092 }
2093
2094 return false;
2095}
c4a36709 2096
95a948a5
AD
2097function rescore_all_feeds() {
2098 var ok = confirm(__("Rescore all articles? This operation may take a lot of time."));
2099
2100 if (ok) {
3df4869b 2101 notify_progress("Rescoring feeds...", true);
95a948a5
AD
2102
2103 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
2104 xmlhttp.onreadystatechange=notify_callback;
2105 xmlhttp.send(null);
2106 }
a80b05ea 2107}
a44db887
AD
2108
2109function removeFilter(id, title) {
2110
2111 if (!xmlhttp_ready(xmlhttp)) {
2112 printLockingError();
2113 return
2114 }
2115
2116 var msg = __("Remove filter %s?").replace("%s", title);
2117
2118 var ok = confirm(msg);
2119
2120 if (ok) {
2121 closeInfoBox();
2122
2123 notify_progress("Removing filter...");
2124
2125 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
2126 param_escape(id), true);
2127 xmlhttp.onreadystatechange=filterlist_callback;
2128 xmlhttp.send(null);
2129 }
2130
2131 return false;
2132}
2133
c8d5dcfe
AD
2134function unsubscribeFeed(id, title) {
2135
2136 if (!xmlhttp_ready(xmlhttp)) {
2137 printLockingError();
2138 return
2139 }
2140
2141 var msg = __("Unsubscribe from %s?").replace("%s", title);
2142
2143 var ok = confirm(msg);
2144
2145 if (ok) {
2146 closeInfoBox();
2147
2148 notify_progress("Removing feed...");
2149
2150 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
2151 param_escape(id), true);
2152 xmlhttp.onreadystatechange=filterlist_callback;
2153 xmlhttp.send(null);
2154 }
2155
2156 return false;
2157
2158 return false;
2159
2160}
2161
758e1c4a
AD
2162function feedsEditSave() {
2163 try {
2164
2165 if (!xmlhttp_ready(xmlhttp)) {
2166 printLockingError();
2167 return
2168 }
2169
cd935c42 2170 var ok = confirm(__("Save changes to selected feeds?"));
758e1c4a 2171
b0f015a2
AD
2172 if (ok) {
2173
5d538f4f
AD
2174 var f = document.forms["batch_edit_feed_form"];
2175
b0f015a2 2176 var query = Form.serialize("batch_edit_feed_form");
5d538f4f
AD
2177
2178 /* Form.serialize ignores unchecked checkboxes */
2179
cd935c42 2180 if (!query.match("&hidden=") &&
5d538f4f
AD
2181 f.hidden.disabled == false) {
2182 query = query + "&hidden=false";
2183 }
2184
cd935c42 2185 if (!query.match("&rtl_content=") &&
5d538f4f
AD
2186 f.rtl_content.disabled == false) {
2187 query = query + "&rtl_content=false";
2188 }
2189
cd935c42 2190 if (!query.match("&private=") &&
5d538f4f
AD
2191 f.private.disabled == false) {
2192 query = query + "&private=false";
2193 }
2194
cd935c42 2195 if (!query.match("&cache_images=") &&
5d538f4f
AD
2196 f.cache_images.disabled == false) {
2197 query = query + "&cache_images=false";
2198 }
2199
cd935c42 2200 if (!query.match("&include_in_digest=") &&
5d538f4f
AD
2201 f.include_in_digest.disabled == false) {
2202 query = query + "&include_in_digest=false";
2203 }
b0f015a2
AD
2204
2205 closeInfoBox();
2206
2207 notify_progress("Saving feeds...");
2208
2209 xmlhttp.open("POST", "backend.php", true);
2210 xmlhttp.onreadystatechange=feedlist_callback;
2211 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2212 xmlhttp.send(query);
2213 }
758e1c4a
AD
2214
2215 return false;
2216 } catch (e) {
2217 exception_error("feedsEditSave", e);
2218 }
2219}
2220
2221function batchFeedsToggleField(cb, elem, label) {
2222 try {
2223 var f = document.forms["batch_edit_feed_form"];
2224 var l = document.getElementById(label);
2225
2226 if (cb.checked) {
2227 f[elem].disabled = false;
2228
2229 if (l) {
2230 l.className = "";
2231 };
2232
2233// new Effect.Highlight(f[elem], {duration: 1, startcolor: "#fff7d5",
2234// queue: { position:'end', scope: 'BPEFQ', limit: 1 } } );
2235
2236 } else {
2237 f[elem].disabled = true;
2238
2239 if (l) {
2240 l.className = "insensitive";
2241 };
2242
2243 }
2244 } catch (e) {
2245 exception_error("batchFeedsToggleField", e);
2246 }
2247}
2248