]> git.wh0rd.org - tt-rss.git/blame - prefs.js
select all/none prompt for pref tables + related API
[tt-rss.git] / prefs.js
CommitLineData
007bda35
AD
1/*
2 This program is Copyright (c) 2003-2005 Andrew Dolgov <cthulhoo@gmail.com>
3 Licensed under GPL v.2 or (at your preference) any later version.
4*/
5
6var xmlhttp = false;
7
961513a3 8var active_feed = false;
91ff844a 9var active_feed_cat = false;
a0d53889 10var active_filter = false;
48f0adb0 11var active_label = false;
e6cb77a0 12var active_user = false;
961513a3 13
f5a50b25
AD
14var active_tab = false;
15
007bda35
AD
16/*@cc_on @*/
17/*@if (@_jscript_version >= 5)
18// JScript gives us Conditional compilation, we can cope with old IE versions.
19// and security blocked creation of the objects.
20try {
21 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
22} catch (e) {
23 try {
24 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
25 } catch (E) {
26 xmlhttp = false;
27 }
28}
29@end @*/
30
31if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
32 xmlhttp = new XMLHttpRequest();
33}
34
007bda35 35function feedlist_callback() {
f5a50b25 36 var container = document.getElementById('prefContent');
007bda35
AD
37 if (xmlhttp.readyState == 4) {
38 container.innerHTML=xmlhttp.responseText;
961513a3
AD
39 if (active_feed) {
40 var row = document.getElementById("FEEDR-" + active_feed);
41 if (row) {
42 if (!row.className.match("Selected")) {
43 row.className = row.className + "Selected";
44 }
45 }
46 var checkbox = document.getElementById("FRCHK-" + active_feed);
47 if (checkbox) {
48 checkbox.checked = true;
49 }
50 }
f5a50b25 51 p_notify("");
007bda35
AD
52 }
53}
54
a0d53889 55function filterlist_callback() {
f5a50b25 56 var container = document.getElementById('prefContent');
a0d53889 57 if (xmlhttp.readyState == 4) {
f5a50b25 58
a0d53889
AD
59 container.innerHTML=xmlhttp.responseText;
60
61 if (active_filter) {
62 var row = document.getElementById("FILRR-" + active_filter);
63 if (row) {
64 if (!row.className.match("Selected")) {
65 row.className = row.className + "Selected";
66 }
67 }
68 var checkbox = document.getElementById("FICHK-" + active_filter);
69
70 if (checkbox) {
71 checkbox.checked = true;
72 }
73 }
f5a50b25 74 p_notify("");
a0d53889
AD
75 }
76}
77
48f0adb0 78function labellist_callback() {
f5a50b25 79 var container = document.getElementById('prefContent');
48f0adb0
AD
80 if (xmlhttp.readyState == 4) {
81 container.innerHTML=xmlhttp.responseText;
82
967955b7 83 if (active_label) {
48f0adb0
AD
84 var row = document.getElementById("LILRR-" + active_label);
85 if (row) {
86 if (!row.className.match("Selected")) {
87 row.className = row.className + "Selected";
88 }
89 }
90 var checkbox = document.getElementById("LICHK-" + active_label);
91
92 if (checkbox) {
93 checkbox.checked = true;
94 }
95 }
f5a50b25 96 p_notify("");
48f0adb0
AD
97 }
98}
4255b24c 99
e6cb77a0
AD
100function userlist_callback() {
101 var container = document.getElementById('prefContent');
102 if (xmlhttp.readyState == 4) {
103 container.innerHTML=xmlhttp.responseText;
104
1a7572cb
AD
105 if (active_user) {
106 var row = document.getElementById("UMRR-" + active_user);
e6cb77a0
AD
107 if (row) {
108 if (!row.className.match("Selected")) {
109 row.className = row.className + "Selected";
110 }
111 }
1a7572cb 112 var checkbox = document.getElementById("UMCHK-" + active_user);
e6cb77a0
AD
113
114 if (checkbox) {
115 checkbox.checked = true;
116 }
1a7572cb
AD
117 }
118
e6cb77a0
AD
119 p_notify("");
120 }
121}
122
c6c3a07f 123function infobox_callback() {
1a7572cb 124 if (xmlhttp.readyState == 4) {
2317ffaa
AD
125 var box = document.getElementById('infoBox');
126 var shadow = document.getElementById('infoBoxShadow');
127
128 if (box) {
129 box.innerHTML=xmlhttp.responseText;
130 if (shadow) {
131 shadow.style.display = "block";
132 } else {
133 box.style.display = "block";
134 }
c6c3a07f 135 }
1a7572cb
AD
136 }
137}
138
139
4255b24c
AD
140function prefslist_callback() {
141 var container = document.getElementById('prefContent');
142 if (xmlhttp.readyState == 4) {
143
144 container.innerHTML=xmlhttp.responseText;
145
146 p_notify("");
147 }
148}
149
b1895692
AD
150function gethelp_callback() {
151 var container = document.getElementById('prefHelpBox');
152 if (xmlhttp.readyState == 4) {
153
154 container.innerHTML = xmlhttp.responseText;
155 container.style.display = "block";
156
157 }
158}
4255b24c
AD
159
160
0e091d38
AD
161function notify_callback() {
162 var container = document.getElementById('notify');
163 if (xmlhttp.readyState == 4) {
164 container.innerHTML=xmlhttp.responseText;
165 }
166}
167
b83c7545 168function updateFeedList(sort_key) {
007bda35 169
c0e5a40e 170 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
171 printLockingError();
172 return
173 }
174
f5a50b25
AD
175// document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
176
177 p_notify("Loading, please wait...");
007bda35 178
b83c7545
AD
179 xmlhttp.open("GET", "backend.php?op=pref-feeds" +
180 "&sort=" + param_escape(sort_key), true);
007bda35
AD
181 xmlhttp.onreadystatechange=feedlist_callback;
182 xmlhttp.send(null);
183
184}
185
e6cb77a0
AD
186function updateUsersList() {
187
188 if (!xmlhttp_ready(xmlhttp)) {
189 printLockingError();
190 return
191 }
192
193// document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
194
195 p_notify("Loading, please wait...");
196
197 xmlhttp.open("GET", "backend.php?op=pref-users", true);
198 xmlhttp.onreadystatechange=userlist_callback;
199 xmlhttp.send(null);
200
201}
202
007bda35
AD
203function toggleSelectRow(sender) {
204 var parent_row = sender.parentNode.parentNode;
205
206 if (sender.checked) {
207 if (!parent_row.className.match("Selected")) {
208 parent_row.className = parent_row.className + "Selected";
209 }
210 } else {
211 if (parent_row.className.match("Selected")) {
212 parent_row.className = parent_row.className.replace("Selected", "");
213 }
214 }
215}
216
48f0adb0
AD
217function addLabel() {
218
219 if (!xmlhttp_ready(xmlhttp)) {
220 printLockingError();
221 return
222 }
223
224 var sqlexp = document.getElementById("ladd_expr");
225
226 if (sqlexp.value.length == 0) {
227 notify("Missing SQL expression.");
228 } else {
229 notify("Adding label...");
230
231 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
232 param_escape(sqlexp.value), true);
233
234 xmlhttp.onreadystatechange=labellist_callback;
235 xmlhttp.send(null);
236
237 sqlexp.value = "";
238 }
239
240}
241
de435974
AD
242function addFilter() {
243
244 if (!xmlhttp_ready(xmlhttp)) {
245 printLockingError();
246 return
247 }
248
249 var regexp = document.getElementById("fadd_regexp");
250 var match = document.getElementById("fadd_match");
ead60402 251 var feed = document.getElementById("fadd_feed");
de435974
AD
252
253 if (regexp.value.length == 0) {
254 notify("Missing filter expression.");
255 } else {
256 notify("Adding filter...");
257
25cb5736
AD
258 var v_match = match[match.selectedIndex].text;
259
ead60402
AD
260 var feed_id = feed[feed.selectedIndex].id;
261
de435974 262 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add&regexp=" +
ead60402
AD
263 param_escape(regexp.value) + "&match=" + v_match +
264 "&fid=" + param_escape(feed_id), true);
de435974
AD
265
266 xmlhttp.onreadystatechange=filterlist_callback;
267 xmlhttp.send(null);
268
269 regexp.value = "";
270 }
271
272}
48f0adb0 273
71ad3959
AD
274function addFeed() {
275
c0e5a40e 276 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
277 printLockingError();
278 return
279 }
280
331900c6
AD
281 var link = document.getElementById("fadd_link");
282
83fe4d6d 283 if (link.value.length == 0) {
c753cd32 284 notify("Missing feed URL.");
331900c6
AD
285 } else {
286 notify("Adding feed...");
287
288 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
289 param_escape(link.value), true);
290 xmlhttp.onreadystatechange=feedlist_callback;
291 xmlhttp.send(null);
292
293 link.value = "";
294
295 }
296
297}
298
91ff844a
AD
299function addFeedCat() {
300
301 if (!xmlhttp_ready(xmlhttp)) {
302 printLockingError();
303 return
304 }
305
306 var cat = document.getElementById("fadd_cat");
307
308 if (cat.value.length == 0) {
309 notify("Missing feed category.");
310 } else {
311 notify("Adding feed category...");
312
313 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
314 param_escape(cat.value), true);
315 xmlhttp.onreadystatechange=feedlist_callback;
316 xmlhttp.send(null);
317
318 link.value = "";
319
320 }
321
322}
e6cb77a0
AD
323function addUser() {
324
325 if (!xmlhttp_ready(xmlhttp)) {
326 printLockingError();
327 return
328 }
329
330 var sqlexp = document.getElementById("uadd_box");
331
332 if (sqlexp.value.length == 0) {
333 notify("Missing user login.");
334 } else {
335 notify("Adding user...");
336
337 xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
338 param_escape(sqlexp.value), true);
339
340 xmlhttp.onreadystatechange=userlist_callback;
341 xmlhttp.send(null);
342
343 sqlexp.value = "";
344 }
345
346}
347
48f0adb0
AD
348function editLabel(id) {
349
350 if (!xmlhttp_ready(xmlhttp)) {
351 printLockingError();
352 return
353 }
354
355 active_label = id;
356
357 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
358 param_escape(id), true);
359 xmlhttp.onreadystatechange=labellist_callback;
360 xmlhttp.send(null);
361
362}
363
e6cb77a0
AD
364function editUser(id) {
365
366 if (!xmlhttp_ready(xmlhttp)) {
367 printLockingError();
368 return
369 }
370
371 active_user = id;
372
373 xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
374 param_escape(id), true);
375 xmlhttp.onreadystatechange=userlist_callback;
376 xmlhttp.send(null);
377
378}
379
a0d53889
AD
380function editFilter(id) {
381
382 if (!xmlhttp_ready(xmlhttp)) {
383 printLockingError();
384 return
385 }
386
387 active_filter = id;
388
389 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
390 param_escape(id), true);
391 xmlhttp.onreadystatechange=filterlist_callback;
392 xmlhttp.send(null);
393
394}
395
331900c6
AD
396function editFeed(feed) {
397
508a81e1
AD
398// notify("Editing feed...");
399
c0e5a40e 400 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
401 printLockingError();
402 return
403 }
331900c6 404
961513a3
AD
405 active_feed = feed;
406
331900c6
AD
407 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
408 param_escape(feed), true);
409 xmlhttp.onreadystatechange=feedlist_callback;
410 xmlhttp.send(null);
411
412}
413
91ff844a 414function editFeedCat(cat) {
48f0adb0 415
91ff844a
AD
416 if (!xmlhttp_ready(xmlhttp)) {
417 printLockingError();
418 return
48f0adb0
AD
419 }
420
91ff844a 421 active_feed_cat = cat;
e6cb77a0 422
91ff844a
AD
423 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
424 param_escape(cat), true);
425 xmlhttp.onreadystatechange=feedlist_callback;
426 xmlhttp.send(null);
e6cb77a0 427
e6cb77a0
AD
428}
429
91ff844a
AD
430function getSelectedLabels() {
431 return getSelectedTableRowIds("prefLabelList", "LILRR");
432}
48f0adb0 433
91ff844a
AD
434function getSelectedUsers() {
435 return getSelectedTableRowIds("prefUserList", "UMRR");
a0d53889
AD
436}
437
83fe4d6d 438function getSelectedFeeds() {
91ff844a
AD
439 return getSelectedTableRowIds("prefFeedList", "FEEDR");
440}
331900c6 441
91ff844a
AD
442function getSelectedFilters() {
443 return getSelectedTableRowIds("prefFilterList", "FILRR");
444}
331900c6 445
91ff844a
AD
446function getSelectedFeedCats() {
447 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
83fe4d6d
AD
448}
449
91ff844a 450
83fe4d6d
AD
451function readSelectedFeeds() {
452
c0e5a40e 453 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
454 printLockingError();
455 return
456 }
457
83fe4d6d
AD
458 var sel_rows = getSelectedFeeds();
459
460 if (sel_rows.length > 0) {
461
462 notify("Marking selected feeds as read...");
463
0e091d38 464 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
83fe4d6d 465 param_escape(sel_rows.toString()), true);
0e091d38 466 xmlhttp.onreadystatechange=notify_callback;
83fe4d6d
AD
467 xmlhttp.send(null);
468
469 } else {
470
c753cd32 471 notify("Please select some feeds first.");
83fe4d6d
AD
472
473 }
474}
475
476function unreadSelectedFeeds() {
477
c0e5a40e 478 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
479 printLockingError();
480 return
481 }
482
83fe4d6d
AD
483 var sel_rows = getSelectedFeeds();
484
485 if (sel_rows.length > 0) {
486
487 notify("Marking selected feeds as unread...");
488
0e091d38 489 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
83fe4d6d 490 param_escape(sel_rows.toString()), true);
0e091d38 491 xmlhttp.onreadystatechange=notify_callback;
83fe4d6d
AD
492 xmlhttp.send(null);
493
494 } else {
495
c753cd32 496 notify("Please select some feeds first.");
83fe4d6d
AD
497
498 }
499}
500
48f0adb0
AD
501function removeSelectedLabels() {
502
503 if (!xmlhttp_ready(xmlhttp)) {
504 printLockingError();
505 return
506 }
507
508 var sel_rows = getSelectedLabels();
509
510 if (sel_rows.length > 0) {
511
512 notify("Removing selected labels...");
513
514 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
515 param_escape(sel_rows.toString()), true);
516 xmlhttp.onreadystatechange=labellist_callback;
517 xmlhttp.send(null);
518
519 } else {
520 notify("Please select some labels first.");
521 }
522}
523
e6cb77a0
AD
524function removeSelectedUsers() {
525
526 if (!xmlhttp_ready(xmlhttp)) {
527 printLockingError();
528 return
529 }
530
531 var sel_rows = getSelectedUsers();
532
533 if (sel_rows.length > 0) {
534
535 notify("Removing selected users...");
536
537 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
538 param_escape(sel_rows.toString()), true);
539 xmlhttp.onreadystatechange=userlist_callback;
540 xmlhttp.send(null);
541
542 } else {
543 notify("Please select some labels first.");
544 }
545}
546
48f0adb0
AD
547function removeSelectedFilters() {
548
549 if (!xmlhttp_ready(xmlhttp)) {
550 printLockingError();
551 return
552 }
553
554 var sel_rows = getSelectedFilters();
555
556 if (sel_rows.length > 0) {
557
558 notify("Removing selected filters...");
559
560 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
561 param_escape(sel_rows.toString()), true);
562 xmlhttp.onreadystatechange=filterlist_callback;
563 xmlhttp.send(null);
564
565 } else {
566 notify("Please select some filters first.");
567 }
568}
569
570
83fe4d6d
AD
571function removeSelectedFeeds() {
572
c0e5a40e 573 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
574 printLockingError();
575 return
576 }
577
83fe4d6d
AD
578 var sel_rows = getSelectedFeeds();
579
331900c6
AD
580 if (sel_rows.length > 0) {
581
582 notify("Removing selected feeds...");
583
584 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
585 param_escape(sel_rows.toString()), true);
586 xmlhttp.onreadystatechange=feedlist_callback;
587 xmlhttp.send(null);
71ad3959 588
71ad3959 589 } else {
331900c6 590
c753cd32 591 notify("Please select some feeds first.");
331900c6 592
71ad3959
AD
593 }
594
595}
007bda35 596
91ff844a
AD
597function removeSelectedFeedCats() {
598
599 if (!xmlhttp_ready(xmlhttp)) {
600 printLockingError();
601 return
602 }
603
604 var sel_rows = getSelectedFeedCats();
605
606 if (sel_rows.length > 0) {
607
608 notify("Removing selected categories...");
609
610 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
611 param_escape(sel_rows.toString()), true);
612 xmlhttp.onreadystatechange=feedlist_callback;
613 xmlhttp.send(null);
614
615 } else {
616
617 notify("Please select some feeds first.");
618
619 }
620
621}
622
508a81e1
AD
623function feedEditCancel() {
624
c0e5a40e 625 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
626 printLockingError();
627 return
628 }
629
961513a3
AD
630 active_feed = false;
631
508a81e1
AD
632 notify("Operation cancelled.");
633
634 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
635 xmlhttp.onreadystatechange=feedlist_callback;
636 xmlhttp.send(null);
637
638}
639
91ff844a
AD
640function feedCatEditCancel() {
641
642 if (!xmlhttp_ready(xmlhttp)) {
643 printLockingError();
644 return
645 }
646
647 active_feed_cat = false;
648
649 notify("Operation cancelled.");
650
651 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
652 xmlhttp.onreadystatechange=feedlist_callback;
653 xmlhttp.send(null);
654
655}
656
603c27f8
AD
657function feedEditSave() {
658
659 var feed = active_feed;
508a81e1 660
c0e5a40e 661 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
662 printLockingError();
663 return
664 }
665
603c27f8
AD
666 var link = document.getElementById("iedit_link").value;
667 var title = document.getElementById("iedit_title").value;
d148926e 668 var upd_intl = document.getElementById("iedit_updintl").value;
5d73494a 669 var purge_intl = document.getElementById("iedit_purgintl").value;
91ff844a
AD
670 var fcat = document.getElementById("iedit_fcat");
671
672 var fcat_id = fcat[fcat.selectedIndex].id;
508a81e1 673
603c27f8 674// notify("Saving feed.");
508a81e1 675
140aae81 676/* if (upd_intl < 0) {
d148926e
AD
677 notify("Update interval must be &gt;= 0 (0 = default)");
678 return;
679 }
680
5d73494a
AD
681 if (purge_intl < 0) {
682 notify("Purge days must be &gt;= 0 (0 = default)");
683 return;
140aae81 684 } */
d148926e 685
508a81e1
AD
686 if (link.length == 0) {
687 notify("Feed link cannot be blank.");
688 return;
689 }
690
691 if (title.length == 0) {
692 notify("Feed title cannot be blank.");
693 return;
694 }
695
603c27f8
AD
696 active_feed = false;
697
dbd9e2f1
AD
698 notify("");
699
508a81e1 700 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
d148926e 701 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
91ff844a
AD
702 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
703 "&catid=" + param_escape(fcat_id), true);
508a81e1
AD
704 xmlhttp.onreadystatechange=feedlist_callback;
705 xmlhttp.send(null);
706
707}
708
d9dde1d6
AD
709function labelTest() {
710
711 var sqlexp = document.getElementById("iedit_expr").value;
712 var descr = document.getElementById("iedit_descr").value;
713
714 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
715 param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
716
717 xmlhttp.onreadystatechange=infobox_callback;
718 xmlhttp.send(null);
719
720}
721
48f0adb0
AD
722function labelEditCancel() {
723
724 if (!xmlhttp_ready(xmlhttp)) {
725 printLockingError();
726 return
727 }
728
729 active_label = false;
730
731 notify("Operation cancelled.");
732
733 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
734 xmlhttp.onreadystatechange=labellist_callback;
735 xmlhttp.send(null);
736
737}
738
e6cb77a0
AD
739function userEditCancel() {
740
741 if (!xmlhttp_ready(xmlhttp)) {
742 printLockingError();
743 return
744 }
745
746 active_user = false;
747
748 notify("Operation cancelled.");
749
750 xmlhttp.open("GET", "backend.php?op=pref-users", true);
751 xmlhttp.onreadystatechange=userlist_callback;
752 xmlhttp.send(null);
753
754}
48f0adb0 755
a0d53889
AD
756function filterEditCancel() {
757
758 if (!xmlhttp_ready(xmlhttp)) {
759 printLockingError();
760 return
761 }
762
763 active_filter = false;
764
765 notify("Operation cancelled.");
766
767 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
768 xmlhttp.onreadystatechange=filterlist_callback;
769 xmlhttp.send(null);
770
771}
772
48f0adb0
AD
773function labelEditSave() {
774
775 var label = active_label;
776
777 if (!xmlhttp_ready(xmlhttp)) {
778 printLockingError();
779 return
780 }
781
782 var sqlexp = document.getElementById("iedit_expr").value;
783 var descr = document.getElementById("iedit_descr").value;
784
785// notify("Saving label " + sqlexp + ": " + descr);
786
787 if (sqlexp.length == 0) {
788 notify("SQL expression cannot be blank.");
789 return;
790 }
791
792 if (descr.length == 0) {
793 notify("Caption cannot be blank.");
794 return;
795 }
796
dbd9e2f1
AD
797 notify("");
798
48f0adb0
AD
799 active_label = false;
800
801 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
802 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
803 true);
804
805 xmlhttp.onreadystatechange=labellist_callback;
806 xmlhttp.send(null);
807
808}
809
e6cb77a0
AD
810function userEditSave() {
811
812 var user = active_user;
813
814 if (!xmlhttp_ready(xmlhttp)) {
815 printLockingError();
816 return
817 }
818
819 var login = document.getElementById("iedit_ulogin").value;
820 var level = document.getElementById("iedit_ulevel").value;
821
822 if (login.length == 0) {
823 notify("Login cannot be blank.");
824 return;
825 }
826
827 if (level.length == 0) {
828 notify("User level cannot be blank.");
829 return;
830 }
831
832 active_user = false;
833
dbd9e2f1
AD
834 notify("");
835
e6cb77a0
AD
836 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
837 user + "&l=" + param_escape(login) + "&al=" + param_escape(level),
838 true);
839
dbd9e2f1 840 xmlhttp.onreadystatechange=userlist_callback;
e6cb77a0
AD
841 xmlhttp.send(null);
842
843}
844
845
a0d53889
AD
846function filterEditSave() {
847
848 var filter = active_filter;
849
850 if (!xmlhttp_ready(xmlhttp)) {
851 printLockingError();
852 return
853 }
854
855 var regexp = document.getElementById("iedit_regexp").value;
856 var descr = document.getElementById("iedit_descr").value;
25cb5736 857 var match = document.getElementById("iedit_match");
ead60402 858
25cb5736 859 var v_match = match[match.selectedIndex].text;
a0d53889 860
ead60402
AD
861 var feed = document.getElementById("iedit_feed");
862 var feed_id = feed[feed.selectedIndex].id;
863
a0d53889
AD
864// notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
865
866 if (regexp.length == 0) {
867 notify("Filter expression cannot be blank.");
868 return;
869 }
870
871 active_filter = false;
872
873 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
874 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
ead60402 875 "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id), true);
dbd9e2f1
AD
876
877 notify("");
878
a0d53889
AD
879 xmlhttp.onreadystatechange=filterlist_callback;
880 xmlhttp.send(null);
881
882}
883
48f0adb0
AD
884function editSelectedLabel() {
885 var rows = getSelectedLabels();
a0d53889 886
48f0adb0
AD
887 if (rows.length == 0) {
888 notify("No labels are selected.");
889 return;
a0d53889
AD
890 }
891
48f0adb0
AD
892 if (rows.length > 1) {
893 notify("Please select one label.");
894 return;
895 }
a0d53889 896
dbd9e2f1
AD
897 notify("");
898
48f0adb0 899 editLabel(rows[0]);
a0d53889 900
a0d53889
AD
901}
902
e6cb77a0
AD
903function editSelectedUser() {
904 var rows = getSelectedUsers();
905
906 if (rows.length == 0) {
907 notify("No users are selected.");
908 return;
909 }
910
911 if (rows.length > 1) {
912 notify("Please select one user.");
913 return;
914 }
915
dbd9e2f1
AD
916 notify("");
917
e6cb77a0
AD
918 editUser(rows[0]);
919}
920
921function resetSelectedUserPass() {
922 var rows = getSelectedUsers();
923
924 if (rows.length == 0) {
925 notify("No users are selected.");
926 return;
927 }
928
929 if (rows.length > 1) {
930 notify("Please select one user.");
931 return;
932 }
933
934 notify("Resetting password for selected user...");
935
936 var id = rows[0];
937
938 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
939 param_escape(id), true);
940 xmlhttp.onreadystatechange=userlist_callback;
941 xmlhttp.send(null);
942
943}
944
717f5e64 945function selectedUserDetails() {
e6cb77a0 946
1a7572cb
AD
947 if (!xmlhttp_ready(xmlhttp)) {
948 printLockingError();
949 return
950 }
951
717f5e64
AD
952 var rows = getSelectedUsers();
953
954 if (rows.length == 0) {
955 notify("No users are selected.");
956 return;
957 }
958
959 if (rows.length > 1) {
960 notify("Please select one user.");
961 return;
962 }
963
964 var id = rows[0];
965
dbd9e2f1
AD
966 notify("");
967
1a7572cb 968 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
c6c3a07f
AD
969 xmlhttp.onreadystatechange=infobox_callback;
970 xmlhttp.send(null);
971
972}
973
974function selectedFeedDetails() {
975
976 if (!xmlhttp_ready(xmlhttp)) {
977 printLockingError();
978 return
979 }
980
981 var rows = getSelectedFeeds();
982
983 if (rows.length == 0) {
984 notify("No feeds are selected.");
985 return;
986 }
987
988 if (rows.length > 1) {
989 notify("Please select one feed.");
990 return;
991 }
992
993 var id = rows[0];
994
dbd9e2f1
AD
995 notify("");
996
c6c3a07f
AD
997 xmlhttp.open("GET", "backend.php?op=feed-details&id=" + id, true);
998 xmlhttp.onreadystatechange=infobox_callback;
1a7572cb 999 xmlhttp.send(null);
717f5e64
AD
1000
1001}
a0d53889
AD
1002
1003function editSelectedFilter() {
1004 var rows = getSelectedFilters();
1005
1006 if (rows.length == 0) {
1007 notify("No filters are selected.");
1008 return;
1009 }
1010
1011 if (rows.length > 1) {
1012 notify("Please select one filter.");
1013 return;
1014 }
1015
dbd9e2f1
AD
1016 notify("");
1017
a0d53889
AD
1018 editFilter(rows[0]);
1019
1020}
1021
1022
508a81e1
AD
1023function editSelectedFeed() {
1024 var rows = getSelectedFeeds();
1025
1026 if (rows.length == 0) {
1027 notify("No feeds are selected.");
1028 return;
1029 }
1030
1031 if (rows.length > 1) {
1032 notify("Please select one feed.");
1033 return;
1034 }
1035
dbd9e2f1
AD
1036 notify("");
1037
508a81e1 1038 editFeed(rows[0]);
91ff844a
AD
1039
1040}
1041
1042function editSelectedFeedCat() {
1043 var rows = getSelectedFeedCats();
1044
1045 if (rows.length == 0) {
1046 notify("No categories are selected.");
1047 return;
1048 }
1049
1050 if (rows.length > 1) {
1051 notify("Please select one category.");
1052 return;
1053 }
1054
1055 notify("");
1056
1057 editFeedCat(rows[0]);
508a81e1
AD
1058
1059}
1060
13ad9102
AD
1061function localPiggieFunction(enable) {
1062 if (enable) {
508a81e1
AD
1063 piggie.style.display = "block";
1064 seq = "";
1065 notify("I loveded it!!!");
1066 } else {
1067 piggie.style.display = "none";
1068 notify("");
1069 }
508a81e1
AD
1070}
1071
9f311df6
AD
1072function validateOpmlImport() {
1073
1074 var opml_file = document.getElementById("opml_file");
1075
1076 if (opml_file.value.length == 0) {
1077 notify("Please select OPML file to upload.");
1078 return false;
1079 } else {
1080 return true;
1081 }
1082}
1083
a0d53889
AD
1084function updateFilterList() {
1085
1086 if (!xmlhttp_ready(xmlhttp)) {
1087 printLockingError();
1088 return
1089 }
1090
f5a50b25
AD
1091// document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1092
1093 p_notify("Loading, please wait...");
a0d53889
AD
1094
1095 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1096 xmlhttp.onreadystatechange=filterlist_callback;
1097 xmlhttp.send(null);
1098
1099}
1100
48f0adb0
AD
1101function updateLabelList() {
1102
1103 if (!xmlhttp_ready(xmlhttp)) {
1104 printLockingError();
1105 return
1106 }
1107
f5a50b25
AD
1108 p_notify("Loading, please wait...");
1109
1110// document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
48f0adb0
AD
1111
1112 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1113 xmlhttp.onreadystatechange=labellist_callback;
1114 xmlhttp.send(null);
48f0adb0
AD
1115}
1116
4255b24c
AD
1117function updatePrefsList() {
1118
1119 if (!xmlhttp_ready(xmlhttp)) {
1120 printLockingError();
1121 return
1122 }
1123
1124 p_notify("Loading, please wait...");
1125
1126 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1127 xmlhttp.onreadystatechange=prefslist_callback;
1128 xmlhttp.send(null);
1129
1130}
1131
f5a50b25 1132function selectTab(id) {
48f0adb0 1133
c6c3a07f
AD
1134 if (!xmlhttp_ready(xmlhttp)) {
1135 printLockingError();
1136 return
1137 }
1138
f5a50b25 1139 if (id == "feedConfig") {
a0d53889 1140 updateFeedList();
f5a50b25 1141 } else if (id == "filterConfig") {
a0d53889 1142 updateFilterList();
f5a50b25 1143 } else if (id == "labelConfig") {
48f0adb0 1144 updateLabelList();
4255b24c
AD
1145 } else if (id == "genConfig") {
1146 updatePrefsList();
e6cb77a0
AD
1147 } else if (id == "userConfig") {
1148 updateUsersList();
a0d53889 1149 }
f5a50b25
AD
1150
1151 var tab = document.getElementById(active_tab + "Tab");
1152
1153 if (tab) {
1154 if (tab.className.match("Selected")) {
1155 tab.className = "prefsTab";
1156 }
1157 }
1158
1159 tab = document.getElementById(id + "Tab");
1160
1161 if (tab) {
1162 if (!tab.className.match("Selected")) {
1163 tab.className = tab.className + "Selected";
1164 }
1165 }
1166
1167 active_tab = id;
1168
a0d53889
AD
1169}
1170
007bda35 1171function init() {
e2ec66a8
AD
1172
1173 // IE kludge
1174
ad095c16 1175 if (!xmlhttp) {
e2ec66a8
AD
1176 document.getElementById("prefContent").innerHTML =
1177 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1178 "to function properly. Your browser doesn't seem to support it.";
1179 return;
1180 }
1181
77e96719 1182 selectTab("genConfig");
f5a50b25 1183
508a81e1 1184 document.onkeydown = hotkey_handler;
857a9270
AD
1185 notify("");
1186
007bda35 1187}
b1895692
AD
1188
1189/*
1190var help_topic_id = false;
1191
1192function do_dispOptionHelp() {
1193
1194 if (!xmlhttp_ready(xmlhttp))
1195 return;
1196
1197 xmlhttp.open("GET", "backend.php?op=pref-prefs&subop=getHelp&pn=" +
1198 param_escape(help_topic_id), true);
1199 xmlhttp.onreadystatechange=gethelp_callback;
1200 xmlhttp.send(null);
1201
1202}
1203
1204function dispOptionHelp(event, sender) {
1205
1206 help_topic_id = sender.id;
1207
1208// document.setTimeout("do_dispOptionHelp()", 100);
1209
1210} */
1211
c6c3a07f 1212function closeInfoBox() {
2317ffaa
AD
1213 var box = document.getElementById('infoBox');
1214 var shadow = document.getElementById('infoBoxShadow');
1215
1216 if (shadow) {
1217 shadow.style.display = "none";
1218 } else if (box) {
1219 box.style.display = "none";
1220 }
1a7572cb 1221}