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