]> git.wh0rd.org - tt-rss.git/blame - prefs.js
cleaned up unread/selected style mess
[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
4f3a84f4 451function readSelectedFeeds(read) {
83fe4d6d 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
4f3a84f4
AD
462 if (!read) {
463 op = "unread";
464 } else {
465 op = "read";
466 }
83fe4d6d 467
4f3a84f4 468 notify("Marking selected feeds as " + op + "...");
83fe4d6d 469
4f3a84f4 470 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=" + op + "&ids="+
83fe4d6d 471 param_escape(sel_rows.toString()), true);
0e091d38 472 xmlhttp.onreadystatechange=notify_callback;
83fe4d6d
AD
473 xmlhttp.send(null);
474
475 } else {
476
c753cd32 477 notify("Please select some feeds first.");
83fe4d6d
AD
478
479 }
480}
481
48f0adb0
AD
482function removeSelectedLabels() {
483
484 if (!xmlhttp_ready(xmlhttp)) {
485 printLockingError();
486 return
487 }
488
489 var sel_rows = getSelectedLabels();
490
491 if (sel_rows.length > 0) {
492
493 notify("Removing selected labels...");
494
495 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
496 param_escape(sel_rows.toString()), true);
497 xmlhttp.onreadystatechange=labellist_callback;
498 xmlhttp.send(null);
499
500 } else {
501 notify("Please select some labels first.");
502 }
503}
504
e6cb77a0
AD
505function removeSelectedUsers() {
506
507 if (!xmlhttp_ready(xmlhttp)) {
508 printLockingError();
509 return
510 }
511
512 var sel_rows = getSelectedUsers();
513
514 if (sel_rows.length > 0) {
515
516 notify("Removing selected users...");
517
518 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
519 param_escape(sel_rows.toString()), true);
520 xmlhttp.onreadystatechange=userlist_callback;
521 xmlhttp.send(null);
522
523 } else {
524 notify("Please select some labels first.");
525 }
526}
527
48f0adb0
AD
528function removeSelectedFilters() {
529
530 if (!xmlhttp_ready(xmlhttp)) {
531 printLockingError();
532 return
533 }
534
535 var sel_rows = getSelectedFilters();
536
537 if (sel_rows.length > 0) {
538
539 notify("Removing selected filters...");
540
541 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
542 param_escape(sel_rows.toString()), true);
543 xmlhttp.onreadystatechange=filterlist_callback;
544 xmlhttp.send(null);
545
546 } else {
547 notify("Please select some filters first.");
548 }
549}
550
551
83fe4d6d
AD
552function removeSelectedFeeds() {
553
c0e5a40e 554 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
555 printLockingError();
556 return
557 }
558
83fe4d6d
AD
559 var sel_rows = getSelectedFeeds();
560
331900c6
AD
561 if (sel_rows.length > 0) {
562
563 notify("Removing selected feeds...");
564
565 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
566 param_escape(sel_rows.toString()), true);
567 xmlhttp.onreadystatechange=feedlist_callback;
568 xmlhttp.send(null);
71ad3959 569
71ad3959 570 } else {
331900c6 571
c753cd32 572 notify("Please select some feeds first.");
331900c6 573
71ad3959
AD
574 }
575
576}
007bda35 577
91ff844a
AD
578function removeSelectedFeedCats() {
579
580 if (!xmlhttp_ready(xmlhttp)) {
581 printLockingError();
582 return
583 }
584
585 var sel_rows = getSelectedFeedCats();
586
587 if (sel_rows.length > 0) {
588
589 notify("Removing selected categories...");
590
591 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
592 param_escape(sel_rows.toString()), true);
593 xmlhttp.onreadystatechange=feedlist_callback;
594 xmlhttp.send(null);
595
596 } else {
597
598 notify("Please select some feeds first.");
599
600 }
601
602}
603
508a81e1
AD
604function feedEditCancel() {
605
c0e5a40e 606 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
607 printLockingError();
608 return
609 }
610
961513a3
AD
611 active_feed = false;
612
508a81e1
AD
613 notify("Operation cancelled.");
614
615 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
616 xmlhttp.onreadystatechange=feedlist_callback;
617 xmlhttp.send(null);
618
619}
620
91ff844a
AD
621function feedCatEditCancel() {
622
623 if (!xmlhttp_ready(xmlhttp)) {
624 printLockingError();
625 return
626 }
627
628 active_feed_cat = false;
629
630 notify("Operation cancelled.");
631
632 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
633 xmlhttp.onreadystatechange=feedlist_callback;
634 xmlhttp.send(null);
635
636}
637
603c27f8
AD
638function feedEditSave() {
639
640 var feed = active_feed;
508a81e1 641
c0e5a40e 642 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
643 printLockingError();
644 return
645 }
646
603c27f8
AD
647 var link = document.getElementById("iedit_link").value;
648 var title = document.getElementById("iedit_title").value;
d148926e 649 var upd_intl = document.getElementById("iedit_updintl").value;
5d73494a 650 var purge_intl = document.getElementById("iedit_purgintl").value;
91ff844a
AD
651 var fcat = document.getElementById("iedit_fcat");
652
653 var fcat_id = fcat[fcat.selectedIndex].id;
508a81e1 654
603c27f8 655// notify("Saving feed.");
508a81e1 656
140aae81 657/* if (upd_intl < 0) {
d148926e
AD
658 notify("Update interval must be &gt;= 0 (0 = default)");
659 return;
660 }
661
5d73494a
AD
662 if (purge_intl < 0) {
663 notify("Purge days must be &gt;= 0 (0 = default)");
664 return;
140aae81 665 } */
d148926e 666
508a81e1
AD
667 if (link.length == 0) {
668 notify("Feed link cannot be blank.");
669 return;
670 }
671
672 if (title.length == 0) {
673 notify("Feed title cannot be blank.");
674 return;
675 }
676
603c27f8
AD
677 active_feed = false;
678
dbd9e2f1
AD
679 notify("");
680
508a81e1 681 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
d148926e 682 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
91ff844a
AD
683 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
684 "&catid=" + param_escape(fcat_id), true);
508a81e1
AD
685 xmlhttp.onreadystatechange=feedlist_callback;
686 xmlhttp.send(null);
687
688}
689
d9dde1d6
AD
690function labelTest() {
691
692 var sqlexp = document.getElementById("iedit_expr").value;
693 var descr = document.getElementById("iedit_descr").value;
694
695 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
696 param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
697
698 xmlhttp.onreadystatechange=infobox_callback;
699 xmlhttp.send(null);
700
701}
702
48f0adb0
AD
703function labelEditCancel() {
704
705 if (!xmlhttp_ready(xmlhttp)) {
706 printLockingError();
707 return
708 }
709
710 active_label = false;
711
712 notify("Operation cancelled.");
713
714 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
715 xmlhttp.onreadystatechange=labellist_callback;
716 xmlhttp.send(null);
717
718}
719
e6cb77a0
AD
720function userEditCancel() {
721
722 if (!xmlhttp_ready(xmlhttp)) {
723 printLockingError();
724 return
725 }
726
727 active_user = false;
728
729 notify("Operation cancelled.");
730
731 xmlhttp.open("GET", "backend.php?op=pref-users", true);
732 xmlhttp.onreadystatechange=userlist_callback;
733 xmlhttp.send(null);
734
735}
48f0adb0 736
a0d53889
AD
737function filterEditCancel() {
738
739 if (!xmlhttp_ready(xmlhttp)) {
740 printLockingError();
741 return
742 }
743
744 active_filter = false;
745
746 notify("Operation cancelled.");
747
748 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
749 xmlhttp.onreadystatechange=filterlist_callback;
750 xmlhttp.send(null);
751
752}
753
48f0adb0
AD
754function labelEditSave() {
755
756 var label = active_label;
757
758 if (!xmlhttp_ready(xmlhttp)) {
759 printLockingError();
760 return
761 }
762
763 var sqlexp = document.getElementById("iedit_expr").value;
764 var descr = document.getElementById("iedit_descr").value;
765
766// notify("Saving label " + sqlexp + ": " + descr);
767
768 if (sqlexp.length == 0) {
769 notify("SQL expression cannot be blank.");
770 return;
771 }
772
773 if (descr.length == 0) {
774 notify("Caption cannot be blank.");
775 return;
776 }
777
dbd9e2f1
AD
778 notify("");
779
48f0adb0
AD
780 active_label = false;
781
782 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
783 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
784 true);
785
786 xmlhttp.onreadystatechange=labellist_callback;
787 xmlhttp.send(null);
788
789}
790
e6cb77a0
AD
791function userEditSave() {
792
793 var user = active_user;
794
795 if (!xmlhttp_ready(xmlhttp)) {
796 printLockingError();
797 return
798 }
799
800 var login = document.getElementById("iedit_ulogin").value;
801 var level = document.getElementById("iedit_ulevel").value;
802
803 if (login.length == 0) {
804 notify("Login cannot be blank.");
805 return;
806 }
807
808 if (level.length == 0) {
809 notify("User level cannot be blank.");
810 return;
811 }
812
813 active_user = false;
814
dbd9e2f1
AD
815 notify("");
816
e6cb77a0
AD
817 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
818 user + "&l=" + param_escape(login) + "&al=" + param_escape(level),
819 true);
820
dbd9e2f1 821 xmlhttp.onreadystatechange=userlist_callback;
e6cb77a0
AD
822 xmlhttp.send(null);
823
824}
825
826
a0d53889
AD
827function filterEditSave() {
828
829 var filter = active_filter;
830
831 if (!xmlhttp_ready(xmlhttp)) {
832 printLockingError();
833 return
834 }
835
836 var regexp = document.getElementById("iedit_regexp").value;
837 var descr = document.getElementById("iedit_descr").value;
25cb5736 838 var match = document.getElementById("iedit_match");
ead60402 839
25cb5736 840 var v_match = match[match.selectedIndex].text;
a0d53889 841
ead60402
AD
842 var feed = document.getElementById("iedit_feed");
843 var feed_id = feed[feed.selectedIndex].id;
844
a0d53889
AD
845// notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
846
847 if (regexp.length == 0) {
848 notify("Filter expression cannot be blank.");
849 return;
850 }
851
852 active_filter = false;
853
854 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
855 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
ead60402 856 "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id), true);
dbd9e2f1
AD
857
858 notify("");
859
a0d53889
AD
860 xmlhttp.onreadystatechange=filterlist_callback;
861 xmlhttp.send(null);
862
863}
864
48f0adb0
AD
865function editSelectedLabel() {
866 var rows = getSelectedLabels();
a0d53889 867
48f0adb0
AD
868 if (rows.length == 0) {
869 notify("No labels are selected.");
870 return;
a0d53889
AD
871 }
872
48f0adb0
AD
873 if (rows.length > 1) {
874 notify("Please select one label.");
875 return;
876 }
a0d53889 877
dbd9e2f1
AD
878 notify("");
879
48f0adb0 880 editLabel(rows[0]);
a0d53889 881
a0d53889
AD
882}
883
e6cb77a0
AD
884function editSelectedUser() {
885 var rows = getSelectedUsers();
886
887 if (rows.length == 0) {
888 notify("No users are selected.");
889 return;
890 }
891
892 if (rows.length > 1) {
893 notify("Please select one user.");
894 return;
895 }
896
dbd9e2f1
AD
897 notify("");
898
e6cb77a0
AD
899 editUser(rows[0]);
900}
901
902function resetSelectedUserPass() {
903 var rows = getSelectedUsers();
904
905 if (rows.length == 0) {
906 notify("No users are selected.");
907 return;
908 }
909
910 if (rows.length > 1) {
911 notify("Please select one user.");
912 return;
913 }
914
915 notify("Resetting password for selected user...");
916
917 var id = rows[0];
918
919 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
920 param_escape(id), true);
921 xmlhttp.onreadystatechange=userlist_callback;
922 xmlhttp.send(null);
923
924}
925
717f5e64 926function selectedUserDetails() {
e6cb77a0 927
1a7572cb
AD
928 if (!xmlhttp_ready(xmlhttp)) {
929 printLockingError();
930 return
931 }
932
717f5e64
AD
933 var rows = getSelectedUsers();
934
935 if (rows.length == 0) {
936 notify("No users are selected.");
937 return;
938 }
939
940 if (rows.length > 1) {
941 notify("Please select one user.");
942 return;
943 }
944
945 var id = rows[0];
946
dbd9e2f1
AD
947 notify("");
948
1a7572cb 949 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
c6c3a07f
AD
950 xmlhttp.onreadystatechange=infobox_callback;
951 xmlhttp.send(null);
952
953}
954
955function selectedFeedDetails() {
956
957 if (!xmlhttp_ready(xmlhttp)) {
958 printLockingError();
959 return
960 }
961
962 var rows = getSelectedFeeds();
963
964 if (rows.length == 0) {
965 notify("No feeds are selected.");
966 return;
967 }
968
969 if (rows.length > 1) {
970 notify("Please select one feed.");
971 return;
972 }
973
974 var id = rows[0];
975
dbd9e2f1
AD
976 notify("");
977
c6c3a07f
AD
978 xmlhttp.open("GET", "backend.php?op=feed-details&id=" + id, true);
979 xmlhttp.onreadystatechange=infobox_callback;
1a7572cb 980 xmlhttp.send(null);
717f5e64
AD
981
982}
a0d53889
AD
983
984function editSelectedFilter() {
985 var rows = getSelectedFilters();
986
987 if (rows.length == 0) {
988 notify("No filters are selected.");
989 return;
990 }
991
992 if (rows.length > 1) {
993 notify("Please select one filter.");
994 return;
995 }
996
dbd9e2f1
AD
997 notify("");
998
a0d53889
AD
999 editFilter(rows[0]);
1000
1001}
1002
1003
508a81e1
AD
1004function editSelectedFeed() {
1005 var rows = getSelectedFeeds();
1006
1007 if (rows.length == 0) {
1008 notify("No feeds are selected.");
1009 return;
1010 }
1011
1012 if (rows.length > 1) {
1013 notify("Please select one feed.");
1014 return;
1015 }
1016
dbd9e2f1
AD
1017 notify("");
1018
508a81e1 1019 editFeed(rows[0]);
91ff844a
AD
1020
1021}
1022
1023function editSelectedFeedCat() {
1024 var rows = getSelectedFeedCats();
1025
1026 if (rows.length == 0) {
1027 notify("No categories are selected.");
1028 return;
1029 }
1030
1031 if (rows.length > 1) {
1032 notify("Please select one category.");
1033 return;
1034 }
1035
1036 notify("");
1037
1038 editFeedCat(rows[0]);
508a81e1
AD
1039
1040}
1041
13ad9102
AD
1042function localPiggieFunction(enable) {
1043 if (enable) {
508a81e1
AD
1044 piggie.style.display = "block";
1045 seq = "";
1046 notify("I loveded it!!!");
1047 } else {
1048 piggie.style.display = "none";
1049 notify("");
1050 }
508a81e1
AD
1051}
1052
9f311df6
AD
1053function validateOpmlImport() {
1054
1055 var opml_file = document.getElementById("opml_file");
1056
1057 if (opml_file.value.length == 0) {
1058 notify("Please select OPML file to upload.");
1059 return false;
1060 } else {
1061 return true;
1062 }
1063}
1064
a0d53889
AD
1065function updateFilterList() {
1066
1067 if (!xmlhttp_ready(xmlhttp)) {
1068 printLockingError();
1069 return
1070 }
1071
f5a50b25
AD
1072// document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1073
1074 p_notify("Loading, please wait...");
a0d53889
AD
1075
1076 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1077 xmlhttp.onreadystatechange=filterlist_callback;
1078 xmlhttp.send(null);
1079
1080}
1081
48f0adb0
AD
1082function updateLabelList() {
1083
1084 if (!xmlhttp_ready(xmlhttp)) {
1085 printLockingError();
1086 return
1087 }
1088
f5a50b25
AD
1089 p_notify("Loading, please wait...");
1090
1091// document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
48f0adb0
AD
1092
1093 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1094 xmlhttp.onreadystatechange=labellist_callback;
1095 xmlhttp.send(null);
48f0adb0
AD
1096}
1097
4255b24c
AD
1098function updatePrefsList() {
1099
1100 if (!xmlhttp_ready(xmlhttp)) {
1101 printLockingError();
1102 return
1103 }
1104
1105 p_notify("Loading, please wait...");
1106
1107 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1108 xmlhttp.onreadystatechange=prefslist_callback;
1109 xmlhttp.send(null);
1110
1111}
1112
f5a50b25 1113function selectTab(id) {
48f0adb0 1114
c6c3a07f
AD
1115 if (!xmlhttp_ready(xmlhttp)) {
1116 printLockingError();
1117 return
1118 }
1119
f5a50b25 1120 if (id == "feedConfig") {
a0d53889 1121 updateFeedList();
f5a50b25 1122 } else if (id == "filterConfig") {
a0d53889 1123 updateFilterList();
f5a50b25 1124 } else if (id == "labelConfig") {
48f0adb0 1125 updateLabelList();
4255b24c
AD
1126 } else if (id == "genConfig") {
1127 updatePrefsList();
e6cb77a0
AD
1128 } else if (id == "userConfig") {
1129 updateUsersList();
a0d53889 1130 }
f5a50b25
AD
1131
1132 var tab = document.getElementById(active_tab + "Tab");
1133
1134 if (tab) {
1135 if (tab.className.match("Selected")) {
1136 tab.className = "prefsTab";
1137 }
1138 }
1139
1140 tab = document.getElementById(id + "Tab");
1141
1142 if (tab) {
1143 if (!tab.className.match("Selected")) {
1144 tab.className = tab.className + "Selected";
1145 }
1146 }
1147
1148 active_tab = id;
1149
a0d53889
AD
1150}
1151
007bda35 1152function init() {
e2ec66a8
AD
1153
1154 // IE kludge
1155
ad095c16 1156 if (!xmlhttp) {
e2ec66a8
AD
1157 document.getElementById("prefContent").innerHTML =
1158 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1159 "to function properly. Your browser doesn't seem to support it.";
1160 return;
1161 }
1162
77e96719 1163 selectTab("genConfig");
f5a50b25 1164
508a81e1 1165 document.onkeydown = hotkey_handler;
857a9270
AD
1166 notify("");
1167
007bda35 1168}
b1895692
AD
1169
1170/*
1171var help_topic_id = false;
1172
1173function do_dispOptionHelp() {
1174
1175 if (!xmlhttp_ready(xmlhttp))
1176 return;
1177
1178 xmlhttp.open("GET", "backend.php?op=pref-prefs&subop=getHelp&pn=" +
1179 param_escape(help_topic_id), true);
1180 xmlhttp.onreadystatechange=gethelp_callback;
1181 xmlhttp.send(null);
1182
1183}
1184
1185function dispOptionHelp(event, sender) {
1186
1187 help_topic_id = sender.id;
1188
1189// document.setTimeout("do_dispOptionHelp()", 100);
1190
1191} */
1192
c6c3a07f 1193function closeInfoBox() {
2317ffaa
AD
1194 var box = document.getElementById('infoBox');
1195 var shadow = document.getElementById('infoBoxShadow');
1196
1197 if (shadow) {
1198 shadow.style.display = "none";
1199 } else if (box) {
1200 box.style.display = "none";
1201 }
1a7572cb 1202}