]> git.wh0rd.org - tt-rss.git/blame - prefs.js
published feeds work
[tt-rss.git] / prefs.js
CommitLineData
007bda35
AD
1var xmlhttp = false;
2
91ff844a 3var active_feed_cat = false;
48f0adb0 4var active_label = false;
f5a50b25 5var active_tab = false;
c6232e43 6var feed_to_expand = false;
f5a50b25 7
1cac3c31
AD
8var piggie_top = -400;
9var piggie_fwd = true;
10
a58069db 11var xmlhttp = Ajax.getTransport();
007bda35 12
a7565293
AD
13var init_params = new Array();
14
e513a74a
AD
15var caller_subop = false;
16
7a09510c
AD
17var sanity_check_done = false;
18
e4f4b46f
AD
19/*
20function replace_pubkey_callback() {
c6232e43
AD
21 if (xmlhttp.readyState == 4) {
22 try {
e4f4b46f
AD
23 var link = document.getElementById("pubGenAddress");
24
25 if (xmlhttp.responseXML) {
26
27
28 } else {
29 notify_error("Error while changing adress");
30 }
c6232e43 31 } catch (e) {
e4f4b46f 32 exception_error("replace_pubkey_callback", e);
c6232e43
AD
33 }
34 }
e4f4b46f 35} */
c6232e43 36
e4f4b46f 37function expand_feed_callback() {
bc0ed820
AD
38 if (xmlhttp.readyState == 4) {
39 try {
e4f4b46f 40 var container = document.getElementById("BRDET-" + feed_to_expand);
bc0ed820 41 container.innerHTML=xmlhttp.responseText;
e4f4b46f
AD
42 container.style.display = "block";
43// p_notify("");
bc0ed820 44 } catch (e) {
e4f4b46f 45 exception_error("expand_feed_callback", e);
bc0ed820
AD
46 }
47 }
48}
49
007bda35 50function feedlist_callback() {
007bda35 51 if (xmlhttp.readyState == 4) {
47c6c988
AD
52 try {
53 var container = document.getElementById('prefContent');
54 container.innerHTML=xmlhttp.responseText;
a7f22b70 55 selectTab("feedConfig", true);
e513a74a
AD
56
57 if (caller_subop) {
58 var tuple = caller_subop.split(":");
59 if (tuple[0] == 'editFeed') {
60 window.setTimeout('editFeed('+tuple[1]+')', 100);
61 }
62
63 caller_subop = false;
64 }
23943c9b
AD
65 if (typeof correctPNG != 'undefined') {
66 correctPNG();
67 }
7f74a9da 68 notify("");
47c6c988
AD
69 } catch (e) {
70 exception_error("feedlist_callback", e);
961513a3 71 }
007bda35
AD
72 }
73}
74
442d77f1
AD
75/* stub for subscription dialog */
76
77function dlg_frefresh_callback() {
78 if (xmlhttp.readyState == 4) {
79 // setTimeout("updateFeedList()", 500);
80
81 try {
82 var container = document.getElementById('prefContent');
83 container.innerHTML=xmlhttp.responseText;
84 selectTab("feedConfig", true);
85
86 if (caller_subop) {
87 var tuple = caller_subop.split(":");
88 if (tuple[0] == 'editFeed') {
89 window.setTimeout('editFeed('+tuple[1]+')', 100);
90 }
91
92 caller_subop = false;
93 }
94 if (typeof correctPNG != 'undefined') {
95 correctPNG();
96 }
97 notify("");
98 } catch (e) {
99 exception_error("feedlist_callback", e);
100 }
101 }
102}
103
a0d53889 104function filterlist_callback() {
f5a50b25 105 var container = document.getElementById('prefContent');
a0d53889
AD
106 if (xmlhttp.readyState == 4) {
107 container.innerHTML=xmlhttp.responseText;
23943c9b
AD
108 if (typeof correctPNG != 'undefined') {
109 correctPNG();
110 }
7f74a9da 111 notify("");
a0d53889
AD
112 }
113}
114
48f0adb0 115function labellist_callback() {
f5a50b25 116 var container = document.getElementById('prefContent');
48f0adb0 117 if (xmlhttp.readyState == 4) {
f156fd00 118 closeInfoBox();
48f0adb0 119 container.innerHTML=xmlhttp.responseText;
967955b7 120 if (active_label) {
48f0adb0
AD
121 var row = document.getElementById("LILRR-" + active_label);
122 if (row) {
123 if (!row.className.match("Selected")) {
124 row.className = row.className + "Selected";
125 }
126 }
127 var checkbox = document.getElementById("LICHK-" + active_label);
128
129 if (checkbox) {
130 checkbox.checked = true;
131 }
132 }
23943c9b
AD
133 if (typeof correctPNG != 'undefined') {
134 correctPNG();
135 }
7f74a9da 136 notify("");
48f0adb0
AD
137 }
138}
4255b24c 139
a4dbc524
AD
140function labeltest_callback() {
141 var container = document.getElementById('label_test_result');
142 if (xmlhttp.readyState == 4) {
143 container.innerHTML=xmlhttp.responseText;
144 notify("");
145 }
146}
147
c6232e43
AD
148function feed_browser_callback() {
149 var container = document.getElementById('prefContent');
150 if (xmlhttp.readyState == 4) {
151 container.innerHTML=xmlhttp.responseText;
7f74a9da 152 notify("");
c6232e43
AD
153 }
154}
155
e6cb77a0
AD
156function userlist_callback() {
157 var container = document.getElementById('prefContent');
158 if (xmlhttp.readyState == 4) {
159 container.innerHTML=xmlhttp.responseText;
7f74a9da 160 notify("");
e6cb77a0
AD
161 }
162}
163
4255b24c
AD
164function prefslist_callback() {
165 var container = document.getElementById('prefContent');
166 if (xmlhttp.readyState == 4) {
167
168 container.innerHTML=xmlhttp.responseText;
7f74a9da
AD
169
170 notify("");
4255b24c
AD
171 }
172}
173
b1895692
AD
174function gethelp_callback() {
175 var container = document.getElementById('prefHelpBox');
176 if (xmlhttp.readyState == 4) {
177
178 container.innerHTML = xmlhttp.responseText;
179 container.style.display = "block";
180
181 }
182}
4255b24c 183
0e091d38 184function notify_callback() {
0e091d38 185 if (xmlhttp.readyState == 4) {
42c32916
AD
186 notify_info(xmlhttp.responseText);
187 }
0e091d38
AD
188}
189
d95bd220
AD
190
191function changepass_callback() {
42395d28
AD
192 try {
193 if (xmlhttp.readyState == 4) {
194
195 if (xmlhttp.responseText.indexOf("ERROR: ") == 0) {
196 notify_error(xmlhttp.responseText.replace("ERROR: ", ""));
197 } else {
198 notify_info(xmlhttp.responseText);
199 var warn = document.getElementById("default_pass_warning");
200 if (warn) warn.style.display = "none";
201 }
202
203 document.forms['change_pass_form'].reset();
d95bd220 204
42395d28
AD
205 }
206 } catch (e) {
207 exception_error("changepass_callback", e);
208 }
d95bd220
AD
209}
210
b83c7545 211function updateFeedList(sort_key) {
007bda35 212
c0e5a40e 213 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
214 printLockingError();
215 return
216 }
217
f5a50b25
AD
218// document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
219
ce3bf408 220// p_notify("Loading, please wait...");
007bda35 221
f932bc9f
AD
222 var feed_search = document.getElementById("feed_search");
223 var search = "";
224 if (feed_search) { search = feed_search.value; }
225
400b60d8
AD
226 var slat = document.getElementById("show_last_article_times");
227
228 var slat_checked = false;
229 if (slat) {
230 slat_checked = slat.checked;
231 }
232
b83c7545 233 xmlhttp.open("GET", "backend.php?op=pref-feeds" +
f932bc9f 234 "&sort=" + param_escape(sort_key) +
400b60d8 235 "&slat=" + param_escape(slat_checked) +
f932bc9f 236 "&search=" + param_escape(search), true);
007bda35
AD
237 xmlhttp.onreadystatechange=feedlist_callback;
238 xmlhttp.send(null);
239
240}
241
79ec0f2f 242function updateUsersList(sort_key) {
e6cb77a0
AD
243
244 if (!xmlhttp_ready(xmlhttp)) {
245 printLockingError();
246 return
247 }
248
249// document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
250
ce3bf408 251// p_notify("Loading, please wait...");
e6cb77a0 252
79ec0f2f
AD
253 xmlhttp.open("GET", "backend.php?op=pref-users&sort="
254 + param_escape(sort_key), true);
e6cb77a0
AD
255 xmlhttp.onreadystatechange=userlist_callback;
256 xmlhttp.send(null);
257
258}
259
48f0adb0
AD
260function addLabel() {
261
262 if (!xmlhttp_ready(xmlhttp)) {
263 printLockingError();
264 return
265 }
266
f156fd00 267 var form = document.forms['label_edit_form'];
48f0adb0 268
f156fd00
AD
269 var sql_exp = form.sql_exp.value;
270 var description = form.description.value;
48f0adb0 271
f156fd00
AD
272 if (sql_exp == "") {
273 alert("Can't create label: missing SQL expression.");
274 return false;
48f0adb0
AD
275 }
276
f156fd00
AD
277 if (description == "") {
278 alert("Can't create label: missing caption.");
279 return false;
de435974
AD
280 }
281
f156fd00 282 var query = Form.serialize("label_edit_form");
de435974 283
f156fd00
AD
284 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true);
285 xmlhttp.onreadystatechange=infobox_submit_callback;
286 xmlhttp.send(null);
de435974 287}
48f0adb0 288
71ad3959
AD
289function addFeed() {
290
c0e5a40e 291 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
292 printLockingError();
293 return
294 }
295
331900c6
AD
296 var link = document.getElementById("fadd_link");
297
83fe4d6d 298 if (link.value.length == 0) {
f3977cf5 299 alert(__("Error: No feed URL given."));
605f7d46 300 } else if (!isValidURL(link.value)) {
f3977cf5 301 alert(__("Error: Invalid feed URL."));
331900c6 302 } else {
42c32916 303 notify_progress("Adding feed...");
331900c6 304
e513a74a 305 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
331900c6
AD
306 param_escape(link.value), true);
307 xmlhttp.onreadystatechange=feedlist_callback;
308 xmlhttp.send(null);
309
310 link.value = "";
311
312 }
313
314}
315
91ff844a
AD
316function addFeedCat() {
317
318 if (!xmlhttp_ready(xmlhttp)) {
319 printLockingError();
320 return
321 }
322
323 var cat = document.getElementById("fadd_cat");
324
325 if (cat.value.length == 0) {
f3977cf5 326 alert(__("Can't add category: no name specified."));
91ff844a 327 } else {
42c32916 328 notify_progress("Adding feed category...");
91ff844a 329
9c483746 330 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
91ff844a 331 param_escape(cat.value), true);
9c483746 332 xmlhttp.onreadystatechange=infobox_callback;
91ff844a
AD
333 xmlhttp.send(null);
334
335 link.value = "";
336
337 }
338
339}
e6cb77a0
AD
340function addUser() {
341
342 if (!xmlhttp_ready(xmlhttp)) {
343 printLockingError();
344 return
345 }
346
347 var sqlexp = document.getElementById("uadd_box");
348
349 if (sqlexp.value.length == 0) {
01b3e191 350 alert("Can't add user: no login specified.");
e6cb77a0 351 } else {
42c32916 352 notify_progress("Adding user...");
e6cb77a0
AD
353
354 xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
355 param_escape(sqlexp.value), true);
356
357 xmlhttp.onreadystatechange=userlist_callback;
358 xmlhttp.send(null);
359
360 sqlexp.value = "";
361 }
362
363}
364
48f0adb0
AD
365function editLabel(id) {
366
367 if (!xmlhttp_ready(xmlhttp)) {
368 printLockingError();
369 return
370 }
371
9e31e1b9
AD
372 notify_progress("Loading, please wait...");
373
f156fd00
AD
374 document.getElementById("label_create_btn").disabled = true;
375
48f0adb0
AD
376 active_label = id;
377
a4dbc524
AD
378 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
379 selectTableRowById('LILRR-'+id, 'LICHK-'+id, true);
380
48f0adb0
AD
381 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
382 param_escape(id), true);
a4dbc524 383 xmlhttp.onreadystatechange=infobox_callback;
48f0adb0
AD
384 xmlhttp.send(null);
385
386}
387
e6cb77a0
AD
388function editUser(id) {
389
390 if (!xmlhttp_ready(xmlhttp)) {
391 printLockingError();
392 return
393 }
394
9e31e1b9
AD
395 notify_progress("Loading, please wait...");
396
3c5783b7
AD
397 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
398 selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true);
e6cb77a0
AD
399
400 xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
401 param_escape(id), true);
3c5783b7 402 xmlhttp.onreadystatechange=infobox_callback;
e6cb77a0
AD
403 xmlhttp.send(null);
404
405}
406
a0d53889
AD
407function editFilter(id) {
408
409 if (!xmlhttp_ready(xmlhttp)) {
410 printLockingError();
411 return
412 }
413
9e31e1b9
AD
414 notify_progress("Loading, please wait...");
415
4220b0bd
AD
416 document.getElementById("create_filter_btn").disabled = true;
417
07164479
AD
418 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
419 selectTableRowById('FILRR-'+id, 'FICHK-'+id, true);
a0d53889 420
07164479
AD
421 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id), true);
422 xmlhttp.onreadystatechange=infobox_callback;
a0d53889 423 xmlhttp.send(null);
a0d53889
AD
424}
425
331900c6
AD
426function editFeed(feed) {
427
508a81e1
AD
428// notify("Editing feed...");
429
c0e5a40e 430 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
431 printLockingError();
432 return
433 }
331900c6 434
9e31e1b9
AD
435 notify_progress("Loading, please wait...");
436
a349077c
AD
437 document.getElementById("subscribe_to_feed_btn").disabled = true;
438
439 try {
440 document.getElementById("top25_feeds_btn").disabled = true;
441 } catch (e) {
442 // this button is not always available, no-op if not found
443 }
444
673d54ca 445 // clean selection from all rows & select row being edited
0ea4fb50 446 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
6c12c809 447 selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
0ea4fb50
AD
448
449 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
3c5783b7 450 param_escape(feed), true);
0ea4fb50
AD
451
452 xmlhttp.onreadystatechange=infobox_callback;
331900c6
AD
453 xmlhttp.send(null);
454
455}
456
91ff844a 457function editFeedCat(cat) {
48f0adb0 458
91ff844a
AD
459 if (!xmlhttp_ready(xmlhttp)) {
460 printLockingError();
461 return
48f0adb0
AD
462 }
463
9e31e1b9
AD
464 notify_progress("Loading, please wait...");
465
91ff844a 466 active_feed_cat = cat;
e6cb77a0 467
9c483746 468 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
91ff844a 469 param_escape(cat), true);
9c483746 470 xmlhttp.onreadystatechange=infobox_callback;
91ff844a 471 xmlhttp.send(null);
e6cb77a0 472
e6cb77a0
AD
473}
474
91ff844a
AD
475function getSelectedLabels() {
476 return getSelectedTableRowIds("prefLabelList", "LILRR");
477}
48f0adb0 478
91ff844a
AD
479function getSelectedUsers() {
480 return getSelectedTableRowIds("prefUserList", "UMRR");
a0d53889
AD
481}
482
83fe4d6d 483function getSelectedFeeds() {
91ff844a
AD
484 return getSelectedTableRowIds("prefFeedList", "FEEDR");
485}
331900c6 486
91ff844a
AD
487function getSelectedFilters() {
488 return getSelectedTableRowIds("prefFilterList", "FILRR");
489}
331900c6 490
91ff844a
AD
491function getSelectedFeedCats() {
492 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
83fe4d6d
AD
493}
494
c0ae0fdb
AD
495function getSelectedFeedsFromBrowser() {
496
497 var list = document.getElementById("browseFeedList");
498 if (!list) list = document.getElementById("browseBigFeedList");
499
500 var selected = new Array();
501
502 for (i = 0; i < list.childNodes.length; i++) {
503 var child = list.childNodes[i];
504 if (child.id && child.id.match("FBROW-")) {
505 var id = child.id.replace("FBROW-", "");
506
507 var cb = document.getElementById("FBCHK-" + id);
508
509 if (cb.checked) {
510 selected.push(id);
511 }
512 }
513 }
514
515 return selected;
516}
517
48f0adb0
AD
518function removeSelectedLabels() {
519
520 if (!xmlhttp_ready(xmlhttp)) {
521 printLockingError();
522 return
523 }
524
525 var sel_rows = getSelectedLabels();
526
527 if (sel_rows.length > 0) {
528
69668465 529 var ok = confirm("Remove selected labels?");
48f0adb0 530
69668465 531 if (ok) {
42c32916 532 notify_progress("Removing selected labels...");
69668465
AD
533
534 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
535 param_escape(sel_rows.toString()), true);
536 xmlhttp.onreadystatechange=labellist_callback;
537 xmlhttp.send(null);
538 }
48f0adb0 539 } else {
01b3e191 540 alert("No labels are selected.");
48f0adb0 541 }
90ac84df
AD
542
543 return false;
48f0adb0
AD
544}
545
e6cb77a0
AD
546function removeSelectedUsers() {
547
548 if (!xmlhttp_ready(xmlhttp)) {
549 printLockingError();
550 return
551 }
552
553 var sel_rows = getSelectedUsers();
554
555 if (sel_rows.length > 0) {
556
69668465 557 var ok = confirm("Remove selected users?");
e6cb77a0 558
69668465 559 if (ok) {
42c32916 560 notify_progress("Removing selected users...");
69668465
AD
561
562 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
563 param_escape(sel_rows.toString()), true);
564 xmlhttp.onreadystatechange=userlist_callback;
565 xmlhttp.send(null);
566 }
e6cb77a0
AD
567
568 } else {
01b3e191 569 alert("No users are selected.");
e6cb77a0 570 }
90ac84df
AD
571
572 return false;
e6cb77a0
AD
573}
574
48f0adb0
AD
575function removeSelectedFilters() {
576
577 if (!xmlhttp_ready(xmlhttp)) {
578 printLockingError();
579 return
580 }
581
582 var sel_rows = getSelectedFilters();
583
584 if (sel_rows.length > 0) {
585
69668465 586 var ok = confirm("Remove selected filters?");
48f0adb0 587
69668465 588 if (ok) {
42c32916 589 notify_progress("Removing selected filters...");
69668465
AD
590
591 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
592 param_escape(sel_rows.toString()), true);
593 xmlhttp.onreadystatechange=filterlist_callback;
594 xmlhttp.send(null);
595 }
48f0adb0 596 } else {
01b3e191 597 alert("No filters are selected.");
48f0adb0 598 }
90ac84df
AD
599
600 return false;
48f0adb0
AD
601}
602
603
83fe4d6d
AD
604function removeSelectedFeeds() {
605
c0e5a40e 606 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
607 printLockingError();
608 return
609 }
610
83fe4d6d
AD
611 var sel_rows = getSelectedFeeds();
612
331900c6
AD
613 if (sel_rows.length > 0) {
614
1d7bf5a0 615 var ok = confirm("Unsubscribe from selected feeds?");
331900c6 616
69668465
AD
617 if (ok) {
618
42c32916 619 notify_progress("Unsubscribing from selected feeds...");
69668465
AD
620
621 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
622 param_escape(sel_rows.toString()), true);
623 xmlhttp.onreadystatechange=feedlist_callback;
624 xmlhttp.send(null);
625 }
71ad3959 626
71ad3959 627 } else {
331900c6 628
01b3e191 629 alert("No feeds are selected.");
331900c6 630
71ad3959 631 }
90ac84df
AD
632
633 return false;
71ad3959 634}
007bda35 635
91ff844a
AD
636function removeSelectedFeedCats() {
637
638 if (!xmlhttp_ready(xmlhttp)) {
639 printLockingError();
640 return
641 }
642
643 var sel_rows = getSelectedFeedCats();
644
645 if (sel_rows.length > 0) {
646
69668465 647 var ok = confirm("Remove selected categories?");
91ff844a 648
69668465 649 if (ok) {
42c32916 650 notify_progress("Removing selected categories...");
69668465 651
9c483746 652 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
69668465 653 param_escape(sel_rows.toString()), true);
9c483746 654 xmlhttp.onreadystatechange=infobox_callback;
69668465
AD
655 xmlhttp.send(null);
656 }
91ff844a
AD
657
658 } else {
659
01b3e191 660 alert("No categories are selected.");
91ff844a
AD
661
662 }
663
90ac84df 664 return false;
91ff844a
AD
665}
666
508a81e1
AD
667function feedEditCancel() {
668
c0e5a40e 669 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
670 printLockingError();
671 return
672 }
673
a349077c
AD
674 document.getElementById("subscribe_to_feed_btn").disabled = false;
675
676 try {
677 document.getElementById("top25_feeds_btn").disabled = false;
678 } catch (e) {
679 // this button is not always available, no-op if not found
680 }
681
327a3bbe
AD
682 closeInfoBox();
683
673d54ca 684 selectPrefRows('feed', false); // cleanup feed selection
508a81e1 685
90ac84df 686 return false;
508a81e1
AD
687}
688
91ff844a
AD
689function feedCatEditCancel() {
690
691 if (!xmlhttp_ready(xmlhttp)) {
692 printLockingError();
693 return
694 }
695
696 active_feed_cat = false;
697
0ceded7a 698// notify("Operation cancelled.");
91ff844a 699
9c483746
AD
700 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
701 xmlhttp.onreadystatechange=infobox_callback;
91ff844a
AD
702 xmlhttp.send(null);
703
90ac84df 704 return false;
91ff844a
AD
705}
706
603c27f8
AD
707function feedEditSave() {
708
47c6c988 709 try {
47c6c988
AD
710
711 if (!xmlhttp_ready(xmlhttp)) {
712 printLockingError();
713 return
714 }
ad815c71 715
14f69488 716 // FIXME: add parameter validation
e3c99f3b 717
14f69488 718 var query = Form.serialize("edit_feed_form");
b0da3a7b 719
42c32916 720 notify_progress("Saving feed...");
673d54ca 721
47c6c988
AD
722 xmlhttp.open("POST", "backend.php", true);
723 xmlhttp.onreadystatechange=feedlist_callback;
724 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
14f69488
AD
725 xmlhttp.send(query);
726
59a543f0
AD
727 closeInfoBox();
728
c14b5566
AD
729 return false;
730
47c6c988
AD
731 } catch (e) {
732 exception_error("feedEditSave", e);
b0da3a7b 733 }
508a81e1
AD
734}
735
5ddadb4c
AD
736function feedCatEditSave() {
737
738 if (!xmlhttp_ready(xmlhttp)) {
739 printLockingError();
740 return
741 }
742
42c32916 743 notify_progress("Saving category...");
5ddadb4c 744
0666e120
AD
745 var query = Form.serialize("feed_cat_edit_form");
746
747 xmlhttp.open("GET", "backend.php?" + query, true);
9c483746 748 xmlhttp.onreadystatechange=infobox_callback;
5ddadb4c
AD
749 xmlhttp.send(null);
750
751 active_feed_cat = false;
752
90ac84df 753 return false;
5ddadb4c
AD
754}
755
756
d9dde1d6
AD
757function labelTest() {
758
a4dbc524
AD
759 var container = document.getElementById('label_test_result');
760 container.style.display = "block";
761 container.innerHTML = "<p>Loading, please wait...</p>";
762
f3120e5a
AD
763 var form = document.forms['label_edit_form'];
764
765 var sql_exp = form.sql_exp.value;
766 var description = form.description.value;
d9dde1d6
AD
767
768 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
f3120e5a 769 param_escape(sql_exp) + "&descr=" + param_escape(description), true);
d9dde1d6 770
a4dbc524 771 xmlhttp.onreadystatechange=labeltest_callback;
d9dde1d6
AD
772 xmlhttp.send(null);
773
90ac84df 774 return false;
d9dde1d6
AD
775}
776
01c9c74a
AD
777function displayHelpInfobox(topic_id) {
778
442d77f1 779/* if (!xmlhttp_ready(xmlhttp)) {
9e31e1b9
AD
780 printLockingError();
781 return
782 }
783
784 notify_progress("Loading help...");
785
01c9c74a 786 xmlhttp.open("GET", "backend.php?op=help&tid=" +
442d77f1 787 param_escape(topic_id), true);
01c9c74a 788
442d77f1
AD
789 xmlhttp.onreadystatechange=helpbox_callback;
790 xmlhttp.send(null); */
791
792 var url = "backend.php?op=help&tid=" + param_escape(topic_id);
793
794 var w = window.open(url, "ttrss_help",
795 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
01c9c74a
AD
796
797}
798
48f0adb0
AD
799function labelEditCancel() {
800
801 if (!xmlhttp_ready(xmlhttp)) {
802 printLockingError();
803 return
804 }
805
f156fd00
AD
806 document.getElementById("label_create_btn").disabled = false;
807
48f0adb0
AD
808 active_label = false;
809
a4dbc524 810 selectPrefRows('label', false); // cleanup feed selection
50bad812
AD
811 closeInfoBox();
812
90ac84df 813 return false;
48f0adb0
AD
814}
815
e6cb77a0
AD
816function userEditCancel() {
817
818 if (!xmlhttp_ready(xmlhttp)) {
819 printLockingError();
820 return
821 }
822
3c5783b7 823 selectPrefRows('user', false); // cleanup feed selection
3c5783b7 824 closeInfoBox();
90ac84df
AD
825
826 return false;
e6cb77a0 827}
48f0adb0 828
a0d53889
AD
829function filterEditCancel() {
830
831 if (!xmlhttp_ready(xmlhttp)) {
832 printLockingError();
833 return
834 }
4220b0bd
AD
835
836 document.getElementById("create_filter_btn").disabled = false;
07164479
AD
837
838 selectPrefRows('filter', false); // cleanup feed selection
839 closeInfoBox();
90ac84df
AD
840
841 return false;
a0d53889
AD
842}
843
48f0adb0
AD
844function labelEditSave() {
845
846 var label = active_label;
847
848 if (!xmlhttp_ready(xmlhttp)) {
849 printLockingError();
850 return
851 }
852
9ee3ac59 853/* if (!is_opera()) {
48f0adb0 854
7c620da8
AD
855 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
856 var description = document.forms["label_edit_form"].description.value;
857
858 if (sql_exp.length == 0) {
859 alert("SQL Expression cannot be blank.");
860 return false;
861 }
862
863 if (description.length == 0) {
864 alert("Caption field cannot be blank.");
865 return false;
866 }
9ee3ac59 867 } */
48f0adb0 868
50bad812
AD
869 closeInfoBox();
870
42c32916 871 notify_progress("Saving label...");
dbd9e2f1 872
48f0adb0
AD
873 active_label = false;
874
f3120e5a
AD
875 query = Form.serialize("label_edit_form");
876
50bad812 877 xmlhttp.open("GET", "backend.php?" + query, true);
48f0adb0
AD
878 xmlhttp.onreadystatechange=labellist_callback;
879 xmlhttp.send(null);
880
90ac84df 881 return false;
48f0adb0
AD
882}
883
e6cb77a0
AD
884function userEditSave() {
885
e6cb77a0
AD
886 if (!xmlhttp_ready(xmlhttp)) {
887 printLockingError();
888 return
889 }
890
3c5783b7 891 var login = document.forms["user_edit_form"].login.value;
e6cb77a0
AD
892
893 if (login.length == 0) {
3c5783b7 894 alert("Login field cannot be blank.");
e6cb77a0
AD
895 return;
896 }
3c5783b7 897
42c32916 898 notify_progress("Saving user...");
4220b0bd
AD
899
900 closeInfoBox();
901
3c5783b7
AD
902 var query = Form.serialize("user_edit_form");
903
904 xmlhttp.open("GET", "backend.php?" + query, true);
dbd9e2f1 905 xmlhttp.onreadystatechange=userlist_callback;
e6cb77a0 906 xmlhttp.send(null);
90ac84df
AD
907
908 return false;
e6cb77a0
AD
909}
910
911
a0d53889
AD
912function filterEditSave() {
913
a0d53889
AD
914 if (!xmlhttp_ready(xmlhttp)) {
915 printLockingError();
916 return
917 }
918
9ee3ac59 919/* if (!is_opera()) {
7c620da8
AD
920 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
921
922 if (reg_exp.length == 0) {
923 alert("Filter expression field cannot be blank.");
924 return;
925 }
9ee3ac59 926 } */
a0d53889 927
42c32916 928 notify_progress("Saving filter...");
a0d53889 929
7e939457 930 var query = Form.serialize("filter_edit_form");
dbd9e2f1 931
07164479
AD
932 closeInfoBox();
933
4220b0bd
AD
934 document.getElementById("create_filter_btn").disabled = false;
935
7e939457 936 xmlhttp.open("GET", "backend.php?" + query, true);
a0d53889 937 xmlhttp.onreadystatechange=filterlist_callback;
7e939457 938 xmlhttp.send(null);
a0d53889 939
90ac84df 940 return false;
a0d53889
AD
941}
942
48f0adb0
AD
943function editSelectedLabel() {
944 var rows = getSelectedLabels();
a0d53889 945
48f0adb0 946 if (rows.length == 0) {
f3977cf5 947 alert(__("No labels are selected."));
48f0adb0 948 return;
a0d53889
AD
949 }
950
48f0adb0 951 if (rows.length > 1) {
f3977cf5 952 alert(__("Please select only one label."));
48f0adb0
AD
953 return;
954 }
a0d53889 955
dbd9e2f1
AD
956 notify("");
957
48f0adb0 958 editLabel(rows[0]);
a0d53889 959
a0d53889
AD
960}
961
e6cb77a0
AD
962function editSelectedUser() {
963 var rows = getSelectedUsers();
964
965 if (rows.length == 0) {
f3977cf5 966 alert(__("No users are selected."));
e6cb77a0
AD
967 return;
968 }
969
970 if (rows.length > 1) {
f3977cf5 971 alert(__("Please select only one user."));
e6cb77a0
AD
972 return;
973 }
974
dbd9e2f1
AD
975 notify("");
976
e6cb77a0
AD
977 editUser(rows[0]);
978}
979
980function resetSelectedUserPass() {
981 var rows = getSelectedUsers();
982
983 if (rows.length == 0) {
f3977cf5 984 alert(__("No users are selected."));
e6cb77a0
AD
985 return;
986 }
987
988 if (rows.length > 1) {
f3977cf5 989 alert(__("Please select only one user."));
e6cb77a0
AD
990 return;
991 }
992
f3977cf5 993 var ok = confirm(__("Reset password of selected user?"));
e6cb77a0 994
69668465 995 if (ok) {
42c32916 996 notify_progress("Resetting password for selected user...");
69668465
AD
997
998 var id = rows[0];
999
1000 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1001 param_escape(id), true);
1002 xmlhttp.onreadystatechange=userlist_callback;
1003 xmlhttp.send(null);
1004 }
e6cb77a0
AD
1005}
1006
717f5e64 1007function selectedUserDetails() {
e6cb77a0 1008
1a7572cb
AD
1009 if (!xmlhttp_ready(xmlhttp)) {
1010 printLockingError();
1011 return
1012 }
1013
717f5e64
AD
1014 var rows = getSelectedUsers();
1015
1016 if (rows.length == 0) {
f3977cf5 1017 alert(__("No users are selected."));
717f5e64
AD
1018 return;
1019 }
1020
1021 if (rows.length > 1) {
f3977cf5 1022 alert(__("Please select only one user."));
717f5e64
AD
1023 return;
1024 }
1025
0077a65c 1026 notify_progress("Loading, please wait...");
717f5e64 1027
0077a65c 1028 var id = rows[0];
dbd9e2f1 1029
1a7572cb 1030 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
c6c3a07f
AD
1031 xmlhttp.onreadystatechange=infobox_callback;
1032 xmlhttp.send(null);
1033
1034}
1035
1036function selectedFeedDetails() {
1037
1038 if (!xmlhttp_ready(xmlhttp)) {
1039 printLockingError();
1040 return
1041 }
1042
1043 var rows = getSelectedFeeds();
1044
1045 if (rows.length == 0) {
f3977cf5 1046 alert(__("No feeds are selected."));
c6c3a07f
AD
1047 return;
1048 }
1049
01b3e191 1050 if (rows.length > 1) {
f3977cf5 1051 alert(__("Please select only one feed."));
01b3e191
AD
1052 return;
1053 }
c6c3a07f 1054
df268d47 1055// var id = rows[0];
c6c3a07f 1056
dbd9e2f1
AD
1057 notify("");
1058
df268d47
AD
1059 xmlhttp.open("GET", "backend.php?op=feed-details&id=" +
1060 param_escape(rows.toString()), true);
c6c3a07f 1061 xmlhttp.onreadystatechange=infobox_callback;
1a7572cb 1062 xmlhttp.send(null);
717f5e64
AD
1063
1064}
a0d53889
AD
1065
1066function editSelectedFilter() {
1067 var rows = getSelectedFilters();
1068
1069 if (rows.length == 0) {
f3977cf5 1070 alert(__("No filters are selected."));
a0d53889
AD
1071 return;
1072 }
1073
1074 if (rows.length > 1) {
f3977cf5 1075 alert(__("Please select only one filter."));
a0d53889
AD
1076 return;
1077 }
1078
dbd9e2f1
AD
1079 notify("");
1080
a0d53889
AD
1081 editFilter(rows[0]);
1082
1083}
1084
1085
508a81e1
AD
1086function editSelectedFeed() {
1087 var rows = getSelectedFeeds();
1088
1089 if (rows.length == 0) {
f3977cf5 1090 alert(__("No feeds are selected."));
508a81e1
AD
1091 return;
1092 }
1093
1094 if (rows.length > 1) {
f3977cf5 1095 alert(__("Please select one feed."));
508a81e1
AD
1096 return;
1097 }
1098
dbd9e2f1
AD
1099 notify("");
1100
508a81e1 1101 editFeed(rows[0]);
91ff844a
AD
1102
1103}
1104
1105function editSelectedFeedCat() {
1106 var rows = getSelectedFeedCats();
1107
1108 if (rows.length == 0) {
f3977cf5 1109 alert(__("No categories are selected."));
91ff844a
AD
1110 return;
1111 }
1112
1113 if (rows.length > 1) {
f3977cf5 1114 alert(__("Please select only one category."));
91ff844a
AD
1115 return;
1116 }
1117
1118 notify("");
1119
1120 editFeedCat(rows[0]);
508a81e1
AD
1121
1122}
1123
1cac3c31
AD
1124function piggie_callback() {
1125 var piggie = document.getElementById("piggie");
1126
1127 piggie.style.top = piggie_top;
e0b6a737
AD
1128 piggie.style.backgroundColor = "white";
1129 piggie.style.borderWidth = "1px";
1cac3c31
AD
1130
1131 if (piggie_fwd && piggie_top < 0) {
1132 setTimeout("piggie_callback()", 50);
1133 piggie_top = piggie_top + 10;
1134 } else if (piggie_fwd && piggie_top >= 0) {
1135 piggie_fwd = false;
1136 setTimeout("piggie_callback()", 50);
1137 } else if (!piggie_fwd && piggie_top > -400) {
1138 setTimeout("piggie_callback()", 50);
1139 piggie_top = piggie_top - 10;
1140 } else if (!piggie_fwd && piggie_top <= -400) {
1141 piggie.style.display = "none";
1142 piggie_fwd = true;
1143 }
1144}
1145
33377ef3
AD
1146var piggie_opacity = 0;
1147
1148function piggie2_callback() {
1149 var piggie = document.getElementById("piggie");
1150 piggie.style.top = 0;
1151 piggie.style.opacity = piggie_opacity;
e0b6a737
AD
1152 piggie.style.backgroundColor = "transparent";
1153 piggie.style.borderWidth = "0px";
33377ef3
AD
1154
1155 if (piggie_fwd && piggie_opacity < 1) {
1156 setTimeout("piggie2_callback()", 50);
1157 piggie_opacity = piggie_opacity + 0.03;
1158 } else if (piggie_fwd && piggie_opacity >= 1) {
1159 piggie_fwd = false;
1160 setTimeout("piggie2_callback()", 50);
1161 } else if (!piggie_fwd && piggie_opacity > 0) {
1162 setTimeout("piggie2_callback()", 50);
1163 piggie_opacity = piggie_opacity - 0.03;
1164 } else if (!piggie_fwd && piggie_opacity <= 0) {
1165 piggie.style.display = "none";
1166 piggie_fwd = true;
1167 }
1168}
1169
13ad9102
AD
1170function localPiggieFunction(enable) {
1171 if (enable) {
d437c8cf 1172 debug("I LOVEDED IT!");
1cac3c31 1173 var piggie = document.getElementById("piggie");
508a81e1 1174 piggie.style.display = "block";
33377ef3 1175
292a8a12 1176 if (navigator.userAgent.match("Gecko") && Math.random(1) > 0.5) {
33377ef3
AD
1177 piggie2_callback();
1178 } else {
1179 piggie_callback();
1180 }
508a81e1 1181 }
508a81e1
AD
1182}
1183
9f311df6
AD
1184function validateOpmlImport() {
1185
1186 var opml_file = document.getElementById("opml_file");
1187
1188 if (opml_file.value.length == 0) {
f3977cf5 1189 alert(__("No OPML file to upload."));
9f311df6
AD
1190 return false;
1191 } else {
1192 return true;
1193 }
1194}
1195
0e317f9d 1196function updateFilterList(sort_key) {
a0d53889
AD
1197
1198 if (!xmlhttp_ready(xmlhttp)) {
1199 printLockingError();
1200 return
1201 }
1202
f5a50b25
AD
1203// document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1204
ce3bf408 1205// p_notify("Loading, please wait...");
a0d53889 1206
e161a2cc
AD
1207 xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" +
1208 param_escape(sort_key), true);
a0d53889
AD
1209 xmlhttp.onreadystatechange=filterlist_callback;
1210 xmlhttp.send(null);
1211
1212}
1213
e161a2cc 1214function updateLabelList(sort_key) {
48f0adb0
AD
1215
1216 if (!xmlhttp_ready(xmlhttp)) {
1217 printLockingError();
1218 return
1219 }
1220
ce3bf408 1221// p_notify("Loading, please wait...");
f5a50b25
AD
1222
1223// document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
48f0adb0 1224
e161a2cc
AD
1225 xmlhttp.open("GET", "backend.php?op=pref-labels&sort=" +
1226 param_escape(sort_key), true);
48f0adb0
AD
1227 xmlhttp.onreadystatechange=labellist_callback;
1228 xmlhttp.send(null);
48f0adb0
AD
1229}
1230
4255b24c
AD
1231function updatePrefsList() {
1232
1233 if (!xmlhttp_ready(xmlhttp)) {
1234 printLockingError();
1235 return
1236 }
1237
ce3bf408 1238// p_notify("Loading, please wait...");
4255b24c
AD
1239
1240 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1241 xmlhttp.onreadystatechange=prefslist_callback;
1242 xmlhttp.send(null);
1243
1244}
1245
e513a74a 1246function selectTab(id, noupdate, subop) {
a7f22b70
AD
1247
1248// alert(id);
48f0adb0 1249
b2caf812 1250 if (!id) id = active_tab;
7f74a9da 1251
b2caf812 1252 try {
59a543f0 1253
b2caf812
AD
1254 if (!xmlhttp_ready(xmlhttp)) {
1255 printLockingError();
1256 return
a7f22b70 1257 }
f5a50b25 1258
a422968f
AD
1259 try {
1260 var c = document.getElementById('prefContent');
1261 c.scrollTop = 0;
1262 } catch (e) { };
1263
b2caf812 1264 if (!noupdate) {
f5a50b25 1265
b2caf812
AD
1266 debug("selectTab: " + id + "(NU: " + noupdate + ")");
1267
9e31e1b9 1268 notify_progress("Loading, please wait...");
b2caf812
AD
1269
1270 // close active infobox if needed
1271 closeInfoBox();
1272
1273 // clean up all current selections, just in case
1274 active_feed_cat = false;
1275 active_label = false;
1276
1277 if (id == "feedConfig") {
1278 updateFeedList();
1279 } else if (id == "filterConfig") {
1280 updateFilterList();
1281 } else if (id == "labelConfig") {
1282 updateLabelList();
1283 } else if (id == "genConfig") {
1284 updatePrefsList();
1285 } else if (id == "userConfig") {
1286 updateUsersList();
1287 } else if (id == "feedBrowser") {
1288 updateBigFeedBrowser();
1289 }
f5a50b25 1290 }
b2caf812
AD
1291
1292 var tab = document.getElementById(active_tab + "Tab");
1293
1294 if (tab) {
1295 if (tab.className.match("Selected")) {
1296 tab.className = "prefsTab";
1297 }
f5a50b25 1298 }
b2caf812
AD
1299
1300 tab = document.getElementById(id + "Tab");
1301
1302 if (tab) {
1303 if (!tab.className.match("Selected")) {
1304 tab.className = tab.className + "Selected";
1305 }
1306 }
1307
b2caf812 1308 active_tab = id;
f5a50b25 1309
b2caf812
AD
1310 } catch (e) {
1311 exception_error("selectTab", e);
a7565293 1312 }
a7565293
AD
1313}
1314
1315function backend_sanity_check_callback() {
f5a50b25 1316
a7565293
AD
1317 if (xmlhttp.readyState == 4) {
1318
1319 try {
7a09510c
AD
1320
1321 if (sanity_check_done) {
81352b54
AD
1322 fatalError(11, "Sanity check request received twice. This can indicate "+
1323 "presence of Firebug or some other disrupting extension. "+
1324 "Please disable it and try again.");
7a09510c
AD
1325 return;
1326 }
1327
a7565293
AD
1328 if (!xmlhttp.responseXML) {
1329 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText);
1330 return;
1331 }
1332
1333 var reply = xmlhttp.responseXML.firstChild.firstChild;
1334
1335 if (!reply) {
1336 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText);
1337 return;
1338 }
1339
1340 var error_code = reply.getAttribute("error-code");
1341
1342 if (error_code && error_code != 0) {
1343 return fatalError(error_code, reply.getAttribute("error-msg"));
1344 }
1345
1346 debug("sanity check ok");
1347
1348 var params = reply.nextSibling;
1349
1350 if (params) {
1351 debug('reading init-params...');
1352 var param = params.firstChild;
1353
1354 while (param) {
1355 var k = param.getAttribute("key");
1356 var v = param.getAttribute("value");
1357 debug(k + " => " + v);
1358 init_params[k] = v;
1359 param = param.nextSibling;
1360 }
1361 }
1362
7a09510c
AD
1363 sanity_check_done = true;
1364
a7565293
AD
1365 init_second_stage();
1366
1367 } catch (e) {
1368 exception_error("backend_sanity_check_callback", e);
1369 }
1370 }
1371}
1372
1373function init_second_stage() {
1374
b2caf812
AD
1375 try {
1376 active_tab = getInitParam("prefs_active_tab");
fe8d2059 1377 if (!active_tab || active_tab == '0') active_tab = "genConfig";
4da47970 1378
d437c8cf
AD
1379 document.onkeydown = pref_hotkey_handler;
1380
e513a74a
AD
1381 var tab = getURLParam('tab');
1382
1383 caller_subop = getURLParam('subop');
1384
1385 if (tab) {
1386 active_tab = tab;
1387 }
1388
b2caf812
AD
1389 if (navigator.userAgent.match("Opera")) {
1390 setTimeout("selectTab()", 500);
1391 } else {
1392 selectTab(active_tab);
1393 }
1394 notify("");
1395 } catch (e) {
1396 exception_error("init_second_stage", e);
1397 }
a0d53889
AD
1398}
1399
007bda35 1400function init() {
e2ec66a8 1401
7719618b
AD
1402 try {
1403
97dcd654
AD
1404 if (arguments.callee.done) return;
1405 arguments.callee.done = true;
1406
a7565293
AD
1407 if (getURLParam('debug')) {
1408 document.getElementById('debug_output').style.display = 'block';
1409 debug('debug mode activated');
1410 }
1411
7719618b
AD
1412 // IE kludge
1413 if (!xmlhttp) {
1414 document.getElementById("prefContent").innerHTML =
1415 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1416 "to function properly. Your browser doesn't seem to support it.";
1417 return;
1418 }
4da47970 1419
a7565293
AD
1420 xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1421 xmlhttp.onreadystatechange=backend_sanity_check_callback;
1422 xmlhttp.send(null);
1423
7719618b
AD
1424 } catch (e) {
1425 exception_error("init", e);
e2ec66a8 1426 }
007bda35 1427}
b1895692 1428
f932bc9f
AD
1429function categorizeSelectedFeeds() {
1430
1431 if (!xmlhttp_ready(xmlhttp)) {
1432 printLockingError();
1433 return
1434 }
1435
1436 var sel_rows = getSelectedFeeds();
1437
1438 var cat_sel = document.getElementById("sfeed_set_fcat");
79f3553b 1439 var cat_id = cat_sel[cat_sel.selectedIndex].value;
f932bc9f
AD
1440
1441 if (sel_rows.length > 0) {
1442
42c32916 1443 notify_progress("Changing category of selected feeds...");
f932bc9f
AD
1444
1445 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1446 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1447 xmlhttp.onreadystatechange=feedlist_callback;
1448 xmlhttp.send(null);
1449
1450 } else {
1451
f3977cf5 1452 alert(__("No feeds are selected."));
f932bc9f
AD
1453
1454 }
1455
1456}
69668465
AD
1457
1458function validatePrefsReset() {
f3977cf5 1459 return confirm(__("Reset to defaults?"));
69668465 1460}
f9cb39ac 1461
6311acbe 1462function browseFeeds(limit) {
f9cb39ac
AD
1463
1464 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1465 xmlhttp.onreadystatechange=infobox_callback;
1466 xmlhttp.send(null);
1467
1468}
a0476535
AD
1469
1470function feedBrowserSubscribe() {
1471 try {
a0476535 1472
c0ae0fdb 1473 var selected = getSelectedFeedsFromBrowser();
a0476535
AD
1474
1475 if (selected.length > 0) {
1476 closeInfoBox();
1477 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1478 param_escape(selected.toString()), true);
1479 xmlhttp.onreadystatechange=feedlist_callback;
1480 xmlhttp.send(null);
1481 } else {
1482 alert("No feeds are selected.");
1483 }
1484
1485 } catch (e) {
1486 exception_error("feedBrowserSubscribe", e);
1487 }
1488}
c6232e43 1489
6311acbe 1490function updateBigFeedBrowser(limit) {
c6232e43
AD
1491
1492 if (!xmlhttp_ready(xmlhttp)) {
1493 printLockingError();
1494 return
1495 }
1496
ce3bf408 1497// p_notify("Loading, please wait...");
c6232e43 1498
6311acbe
AD
1499 var query = "backend.php?op=pref-feed-browser";
1500
1501 var limit_sel = document.getElementById("feedBrowserLimit");
1502
1503 if (limit_sel) {
1504 var limit = limit_sel[limit_sel.selectedIndex].value;
1505 query = query + "&limit=" + param_escape(limit);
1506 }
1507
1508 xmlhttp.open("GET", query, true);
c6232e43
AD
1509 xmlhttp.onreadystatechange=feed_browser_callback;
1510 xmlhttp.send(null);
c6232e43
AD
1511}
1512
c2b2aee0 1513function browserToggleExpand(id) {
c6232e43
AD
1514 try {
1515/* if (feed_to_expand && feed_to_expand != id) {
1516 var d = document.getElementById("BRDET-" + feed_to_expand);
1517 d.style.display = "none";
1518 } */
c2b2aee0 1519
ff725e9b
AD
1520 if (!xmlhttp_ready(xmlhttp)) {
1521 printLockingError();
1522 return
1523 }
1524
c2b2aee0
AD
1525 var d = document.getElementById("BRDET-" + id);
1526
1527 if (d.style.display == "block") {
1528 d.style.display = "none";
1529
1530 } else {
c6232e43 1531
c2b2aee0 1532 feed_to_expand = id;
c6232e43 1533
ff725e9b
AD
1534 d.style.display = "block";
1535 d.innerHTML = "Loading, please wait...";
1536
c2b2aee0
AD
1537 xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1538 + param_escape(id), true);
1539 xmlhttp.onreadystatechange=expand_feed_callback;
1540 xmlhttp.send(null);
1541 }
c6232e43
AD
1542
1543 } catch (e) {
1544 exception_error("browserExpand", e);
1545 }
1546}
64dc5976 1547
ce3bf408
AD
1548function selectPrefRows(kind, select) {
1549
1550 if (kind) {
1551 var opbarid = false;
1552 var nchk = false;
1553 var nrow = false;
1554 var lname = false;
1555
1556 if (kind == "feed") {
1557 opbarid = "feedOpToolbar";
1558 nrow = "FEEDR-";
1559 nchk = "FRCHK-";
1560 lname = "prefFeedList";
1561 } else if (kind == "fcat") {
1562 opbarid = "catOpToolbar";
1563 nrow = "FCATR-";
9c483746 1564 nchk = "FCCHK-";
ce3bf408
AD
1565 lname = "prefFeedCatList";
1566 } else if (kind == "filter") {
1567 opbarid = "filterOpToolbar";
1568 nrow = "FILRR-";
1569 nchk = "FICHK-";
1570 lname = "prefFilterList";
1571 } else if (kind == "label") {
1572 opbarid = "labelOpToolbar";
1573 nrow = "LILRR-";
a4dbc524 1574 nchk = "LICHK-";
ce3bf408
AD
1575 lname = "prefLabelList";
1576 } else if (kind == "user") {
1577 opbarid = "userOpToolbar";
1578 nrow = "UMRR-";
1579 nchk = "UMCHK-";
1580 lname = "prefUserList";
1581 }
1582
1583 if (opbarid) {
1584 selectTableRowsByIdPrefix(lname, nrow, nchk, select);
1585 disableContainerChildren(opbarid, !select);
1586 }
1587
1588 }
1589}
1590
1591
1592function toggleSelectPrefRow(sender, kind) {
1593
1594 toggleSelectRow(sender);
1595
1596 if (kind) {
1597 var opbarid = false;
1598 var nsel = -1;
1599
1600 if (kind == "feed") {
1601 opbarid = "feedOpToolbar";
1602 nsel = getSelectedFeeds();
1603 } else if (kind == "fcat") {
1604 opbarid = "catOpToolbar";
1605 nsel = getSelectedFeedCats();
1606 } else if (kind == "filter") {
1607 opbarid = "filterOpToolbar";
1608 nsel = getSelectedFilters();
1609 } else if (kind == "label") {
1610 opbarid = "labelOpToolbar";
1611 nsel = getSelectedLabels();
1612 } else if (kind == "user") {
1613 opbarid = "userOpToolbar";
1614 nsel = getSelectedUsers();
1615 }
1616
1617 if (opbarid && nsel != -1) {
1618 disableContainerChildren(opbarid, nsel == false);
1619 }
1620
1621 }
1622}
1623
c0ae0fdb
AD
1624function toggleSelectFBListRow(sender) {
1625 toggleSelectListRow(sender);
1626 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1627}
d437c8cf
AD
1628
1629var seq = "";
1630
1631function pref_hotkey_handler(e) {
1632 try {
1633
1634 var keycode;
1635
1636 if (!hotkeys_enabled) return;
1637
1638 if (window.event) {
1639 keycode = window.event.keyCode;
1640 } else if (e) {
1641 keycode = e.which;
1642 }
1643
1644 if (keycode == 13 || keycode == 27) {
1645 seq = "";
1646 } else {
1647 seq = seq + "" + keycode;
1648 }
1649
1650
1651 if (document.getElementById("piggie")) {
1652
1653 if (seq.match("807371717369")) {
1654 seq = "";
1655 localPiggieFunction(true);
1656 } else {
1657 localPiggieFunction(false);
1658 }
1659 }
1660
1661 } catch (e) {
1662 exception_error("pref_hotkey_handler", e);
1663 }
1664}
1665
23c2a4e7
AD
1666function userSwitch() {
1667 var chooser = document.getElementById("userSwitch");
1668 var user = chooser[chooser.selectedIndex].value;
1669 window.location = "prefs.php?swu=" + user;
1670}
9c483746
AD
1671
1672function editFeedCats() {
1673 if (!xmlhttp_ready(xmlhttp)) {
1674 printLockingError();
1675 return
1676 }
1677
a349077c
AD
1678 document.getElementById("subscribe_to_feed_btn").disabled = true;
1679
1680 try {
1681 document.getElementById("top25_feeds_btn").disabled = true;
1682 } catch (e) {
1683 // this button is not always available, no-op if not found
1684 }
1685
9c483746
AD
1686 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1687 xmlhttp.onreadystatechange=infobox_callback;
1688 xmlhttp.send(null);
1689}
a3656a41
AD
1690
1691function showFeedsWithErrors() {
1692 displayDlg('feedUpdateErrors');
1693}
073ca0e6 1694
d95bd220
AD
1695function changeUserPassword() {
1696
1697 try {
1698
1699 if (!xmlhttp_ready(xmlhttp)) {
1700 printLockingError();
1701 return false;
1702 }
1703
1704 var query = Form.serialize("change_pass_form");
1705
1706 notify_progress("Trying to change password...");
1707
1708 xmlhttp.open("POST", "backend.php", true);
1709 xmlhttp.onreadystatechange=changepass_callback;
1710 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1711 xmlhttp.send(query);
1712
1713 } catch (e) {
1714 exception_error("changeUserPassword", e);
1715 }
1716
1717 return false;
1718}
073ca0e6 1719
42395d28
AD
1720function changeUserEmail() {
1721
1722 try {
1723
1724 if (!xmlhttp_ready(xmlhttp)) {
1725 printLockingError();
1726 return false;
1727 }
1728
1729 var query = Form.serialize("change_email_form");
1730
1731 notify_progress("Trying to change e-mail...");
1732
1733 xmlhttp.open("POST", "backend.php", true);
1734 xmlhttp.onreadystatechange=notify_callback;
1735 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1736 xmlhttp.send(query);
1737
1738 } catch (e) {
1739 exception_error("changeUserPassword", e);
1740 }
1741
1742 return false;
1743
1744}
400b60d8
AD
1745
1746function feedlistToggleSLAT() {
1747 notify_progress("Loading, please wait...");
1748 updateFeedList()
1749}
bc0ed820 1750
e4f4b46f
AD
1751/*
1752function pubRegenKey() {
1753
bc0ed820
AD
1754 if (!xmlhttp_ready(xmlhttp)) {
1755 printLockingError();
e4f4b46f 1756 return false;
bc0ed820
AD
1757 }
1758
e4f4b46f 1759 var ok = confirm("Replace current publishing address with a new one?");
bc0ed820 1760
e4f4b46f
AD
1761 if (ok) {
1762
1763 notify_progress("Trying to change address...");
1764
1765 xmlhttp.open("GET", "backend.php?op=backend-rpc&subop=regen-pub-key");
1766 xmlhttp.onreadystatechange=replace_pubkey_callback;
1767 xmlhttp.send(null);
1768 }
1769
1770 return false;
1771} */