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