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