]> git.wh0rd.org Git - tt-rss.git/blob - prefs.js
user manager
[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_filter) {
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_filter) {
105                         var row = document.getElementById("ULRR-" + active_label);
106                         if (row) {
107                                 if (!row.className.match("Selected")) {
108                                         row.className = row.className + "Selected";
109                                 }               
110                         }
111                         var checkbox = document.getElementById("LICHK-" + active_label);
112                         
113                         if (checkbox) {
114                                 checkbox.checked = true;
115                         }
116                 } */
117                 p_notify("");
118         }
119 }
120
121 function prefslist_callback() {
122         var container = document.getElementById('prefContent');
123         if (xmlhttp.readyState == 4) {
124
125                 container.innerHTML=xmlhttp.responseText;
126
127                 p_notify("");
128         }
129 }
130
131 function gethelp_callback() {
132         var container = document.getElementById('prefHelpBox');
133         if (xmlhttp.readyState == 4) {
134
135                 container.innerHTML = xmlhttp.responseText;
136                 container.style.display = "block";
137
138         }
139 }
140
141
142 function notify_callback() {
143         var container = document.getElementById('notify');
144         if (xmlhttp.readyState == 4) {
145                 container.innerHTML=xmlhttp.responseText;
146         }
147 }
148
149
150 function updateFeedList() {
151
152         if (!xmlhttp_ready(xmlhttp)) {
153                 printLockingError();
154                 return
155         }
156
157 //      document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
158
159         p_notify("Loading, please wait...");
160
161         xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
162         xmlhttp.onreadystatechange=feedlist_callback;
163         xmlhttp.send(null);
164
165 }
166
167 function updateUsersList() {
168
169         if (!xmlhttp_ready(xmlhttp)) {
170                 printLockingError();
171                 return
172         }
173
174 //      document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
175
176         p_notify("Loading, please wait...");
177
178         xmlhttp.open("GET", "backend.php?op=pref-users", true);
179         xmlhttp.onreadystatechange=userlist_callback;
180         xmlhttp.send(null);
181
182 }
183
184 function toggleSelectRow(sender) {
185         var parent_row = sender.parentNode.parentNode;
186
187         if (sender.checked) {
188                 if (!parent_row.className.match("Selected")) {
189                         parent_row.className = parent_row.className + "Selected";
190                 }
191         } else {
192                 if (parent_row.className.match("Selected")) {
193                         parent_row.className = parent_row.className.replace("Selected", "");
194                 }
195         }
196 }
197
198 function addLabel() {
199
200         if (!xmlhttp_ready(xmlhttp)) {
201                 printLockingError();
202                 return
203         }
204
205         var sqlexp = document.getElementById("ladd_expr");
206
207         if (sqlexp.value.length == 0) {
208                 notify("Missing SQL expression.");
209         } else {
210                 notify("Adding label...");
211
212                 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
213                         param_escape(sqlexp.value), true);                      
214                         
215                 xmlhttp.onreadystatechange=labellist_callback;
216                 xmlhttp.send(null);
217
218                 sqlexp.value = "";
219         }
220
221 }
222
223 function addFilter() {
224
225         if (!xmlhttp_ready(xmlhttp)) {
226                 printLockingError();
227                 return
228         }
229
230         var regexp = document.getElementById("fadd_regexp");
231         var match = document.getElementById("fadd_match");
232
233         if (regexp.value.length == 0) {
234                 notify("Missing filter expression.");
235         } else {
236                 notify("Adding filter...");
237
238                 var v_match = match[match.selectedIndex].text;
239
240                 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add&regexp=" +
241                         param_escape(regexp.value) + "&match=" + v_match, true);                        
242                         
243                 xmlhttp.onreadystatechange=filterlist_callback;
244                 xmlhttp.send(null);
245
246                 regexp.value = "";
247         }
248
249 }
250
251 function addFeed() {
252
253         if (!xmlhttp_ready(xmlhttp)) {
254                 printLockingError();
255                 return
256         }
257
258         var link = document.getElementById("fadd_link");
259
260         if (link.value.length == 0) {
261                 notify("Missing feed URL.");
262         } else {
263                 notify("Adding feed...");
264
265                 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
266                         param_escape(link.value), true);
267                 xmlhttp.onreadystatechange=feedlist_callback;
268                 xmlhttp.send(null);
269
270                 link.value = "";
271
272         }
273
274 }
275
276 function addUser() {
277
278         if (!xmlhttp_ready(xmlhttp)) {
279                 printLockingError();
280                 return
281         }
282
283         var sqlexp = document.getElementById("uadd_box");
284
285         if (sqlexp.value.length == 0) {
286                 notify("Missing user login.");
287         } else {
288                 notify("Adding user...");
289
290                 xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
291                         param_escape(sqlexp.value), true);                      
292                         
293                 xmlhttp.onreadystatechange=userlist_callback;
294                 xmlhttp.send(null);
295
296                 sqlexp.value = "";
297         }
298
299 }
300
301 function editLabel(id) {
302
303         if (!xmlhttp_ready(xmlhttp)) {
304                 printLockingError();
305                 return
306         }
307
308         active_label = id;
309
310         xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
311                 param_escape(id), true);
312         xmlhttp.onreadystatechange=labellist_callback;
313         xmlhttp.send(null);
314
315 }
316
317 function editUser(id) {
318
319         if (!xmlhttp_ready(xmlhttp)) {
320                 printLockingError();
321                 return
322         }
323
324         active_user = id;
325
326         xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
327                 param_escape(id), true);
328         xmlhttp.onreadystatechange=userlist_callback;
329         xmlhttp.send(null);
330
331 }
332
333 function editFilter(id) {
334
335         if (!xmlhttp_ready(xmlhttp)) {
336                 printLockingError();
337                 return
338         }
339
340         active_filter = id;
341
342         xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
343                 param_escape(id), true);
344         xmlhttp.onreadystatechange=filterlist_callback;
345         xmlhttp.send(null);
346
347 }
348
349 function editFeed(feed) {
350
351 //      notify("Editing feed...");
352
353         if (!xmlhttp_ready(xmlhttp)) {
354                 printLockingError();
355                 return
356         }
357
358         active_feed = feed;
359
360         xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
361                 param_escape(feed), true);
362         xmlhttp.onreadystatechange=feedlist_callback;
363         xmlhttp.send(null);
364
365 }
366
367 function getSelectedLabels() {
368
369         var content = document.getElementById("prefLabelList");
370
371         var sel_rows = new Array();
372
373         for (i = 0; i < content.rows.length; i++) {
374                 if (content.rows[i].className.match("Selected")) {
375                         var row_id = content.rows[i].id.replace("LILRR-", "");
376                         sel_rows.push(row_id);  
377                 }
378         }
379
380         return sel_rows;
381 }
382
383 function getSelectedUsers() {
384
385         var content = document.getElementById("prefUserList");
386
387         var sel_rows = new Array();
388
389         for (i = 0; i < content.rows.length; i++) {
390                 if (content.rows[i].className.match("Selected")) {
391                         var row_id = content.rows[i].id.replace("UMRR-", "");
392                         sel_rows.push(row_id);  
393                 }
394         }
395
396         return sel_rows;
397 }
398
399
400 function getSelectedFilters() {
401
402         var content = document.getElementById("prefFilterList");
403
404         var sel_rows = new Array();
405
406         for (i = 0; i < content.rows.length; i++) {
407                 if (content.rows[i].className.match("Selected")) {
408                         var row_id = content.rows[i].id.replace("FILRR-", "");
409                         sel_rows.push(row_id);  
410                 }
411         }
412
413         return sel_rows;
414 }
415
416 function getSelectedFeeds() {
417
418         var content = document.getElementById("prefFeedList");
419
420         var sel_rows = new Array();
421
422         for (i = 0; i < content.rows.length; i++) {
423                 if (content.rows[i].className.match("Selected")) {
424                         var row_id = content.rows[i].id.replace("FEEDR-", "");
425                         sel_rows.push(row_id);  
426                 }
427         }
428
429         return sel_rows;
430 }
431
432 function readSelectedFeeds() {
433
434         if (!xmlhttp_ready(xmlhttp)) {
435                 printLockingError();
436                 return
437         }
438
439         var sel_rows = getSelectedFeeds();
440
441         if (sel_rows.length > 0) {
442
443                 notify("Marking selected feeds as read...");
444
445                 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
446                         param_escape(sel_rows.toString()), true);
447                 xmlhttp.onreadystatechange=notify_callback;
448                 xmlhttp.send(null);
449
450         } else {
451
452                 notify("Please select some feeds first.");
453
454         }
455 }
456
457 function unreadSelectedFeeds() {
458
459         if (!xmlhttp_ready(xmlhttp)) {
460                 printLockingError();
461                 return
462         }
463
464         var sel_rows = getSelectedFeeds();
465
466         if (sel_rows.length > 0) {
467
468                 notify("Marking selected feeds as unread...");
469
470                 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
471                         param_escape(sel_rows.toString()), true);
472                 xmlhttp.onreadystatechange=notify_callback;
473                 xmlhttp.send(null);
474
475         } else {
476
477                 notify("Please select some feeds first.");
478
479         }
480 }
481
482 function 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
505 function 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
528 function 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
552 function removeSelectedFeeds() {
553
554         if (!xmlhttp_ready(xmlhttp)) {
555                 printLockingError();
556                 return
557         }
558
559         var sel_rows = getSelectedFeeds();
560
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);
569
570         } else {
571
572                 notify("Please select some feeds first.");
573
574         }
575
576 }
577
578 function feedEditCancel() {
579
580         if (!xmlhttp_ready(xmlhttp)) {
581                 printLockingError();
582                 return
583         }
584
585         active_feed = false;
586
587         notify("Operation cancelled.");
588
589         xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
590         xmlhttp.onreadystatechange=feedlist_callback;
591         xmlhttp.send(null);
592
593 }
594
595 function feedEditSave() {
596
597         var feed = active_feed;
598
599         if (!xmlhttp_ready(xmlhttp)) {
600                 printLockingError();
601                 return
602         }
603
604         var link = document.getElementById("iedit_link").value;
605         var title = document.getElementById("iedit_title").value;
606         var upd_intl = document.getElementById("iedit_updintl").value;
607         var purge_intl = document.getElementById("iedit_purgintl").value;
608
609 //      notify("Saving feed.");
610
611 /*      if (upd_intl < 0) {
612                 notify("Update interval must be &gt;= 0 (0 = default)");
613                 return;
614         }
615
616         if (purge_intl < 0) {
617                 notify("Purge days must be &gt;= 0 (0 = default)");
618                 return;
619         } */
620
621         if (link.length == 0) {
622                 notify("Feed link cannot be blank.");
623                 return;
624         }
625
626         if (title.length == 0) {
627                 notify("Feed title cannot be blank.");
628                 return;
629         }
630
631         active_feed = false;
632
633         xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
634                 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
635                 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl), true);
636         xmlhttp.onreadystatechange=feedlist_callback;
637         xmlhttp.send(null);
638
639 }
640
641 function labelEditCancel() {
642
643         if (!xmlhttp_ready(xmlhttp)) {
644                 printLockingError();
645                 return
646         }
647
648         active_label = false;
649
650         notify("Operation cancelled.");
651
652         xmlhttp.open("GET", "backend.php?op=pref-labels", true);
653         xmlhttp.onreadystatechange=labellist_callback;
654         xmlhttp.send(null);
655
656 }
657
658 function userEditCancel() {
659
660         if (!xmlhttp_ready(xmlhttp)) {
661                 printLockingError();
662                 return
663         }
664
665         active_user = false;
666
667         notify("Operation cancelled.");
668
669         xmlhttp.open("GET", "backend.php?op=pref-users", true);
670         xmlhttp.onreadystatechange=userlist_callback;
671         xmlhttp.send(null);
672
673 }
674
675 function filterEditCancel() {
676
677         if (!xmlhttp_ready(xmlhttp)) {
678                 printLockingError();
679                 return
680         }
681
682         active_filter = false;
683
684         notify("Operation cancelled.");
685
686         xmlhttp.open("GET", "backend.php?op=pref-filters", true);
687         xmlhttp.onreadystatechange=filterlist_callback;
688         xmlhttp.send(null);
689
690 }
691
692 function labelEditSave() {
693
694         var label = active_label;
695
696         if (!xmlhttp_ready(xmlhttp)) {
697                 printLockingError();
698                 return
699         }
700
701         var sqlexp = document.getElementById("iedit_expr").value;
702         var descr = document.getElementById("iedit_descr").value;
703
704 //      notify("Saving label " + sqlexp + ": " + descr);
705
706         if (sqlexp.length == 0) {
707                 notify("SQL expression cannot be blank.");
708                 return;
709         }
710
711         if (descr.length == 0) {
712                 notify("Caption cannot be blank.");
713                 return;
714         }
715
716         active_label = false;
717
718         xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
719                 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
720                 true);
721                 
722         xmlhttp.onreadystatechange=labellist_callback;
723         xmlhttp.send(null);
724
725 }
726
727 function userEditSave() {
728
729         var user = active_user;
730
731         if (!xmlhttp_ready(xmlhttp)) {
732                 printLockingError();
733                 return
734         }
735
736         var login = document.getElementById("iedit_ulogin").value;
737         var level = document.getElementById("iedit_ulevel").value;
738
739         if (login.length == 0) {
740                 notify("Login cannot be blank.");
741                 return;
742         }
743
744         if (level.length == 0) {
745                 notify("User level cannot be blank.");
746                 return;
747         }
748
749         active_user = false;
750
751         xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
752                 user + "&l=" + param_escape(login) + "&al=" + param_escape(level),
753                 true);
754                 
755         xmlhttp.onreadystatechange=labellist_callback;
756         xmlhttp.send(null);
757
758 }
759
760
761 function filterEditSave() {
762
763         var filter = active_filter;
764
765         if (!xmlhttp_ready(xmlhttp)) {
766                 printLockingError();
767                 return
768         }
769
770         var regexp = document.getElementById("iedit_regexp").value;
771         var descr = document.getElementById("iedit_descr").value;
772         var match = document.getElementById("iedit_match");
773
774         var v_match = match[match.selectedIndex].text;
775
776 //      notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
777
778         if (regexp.length == 0) {
779                 notify("Filter expression cannot be blank.");
780                 return;
781         }
782
783         active_filter = false;
784
785         xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
786                 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
787                 "&m=" + param_escape(v_match), true);
788                 
789         xmlhttp.onreadystatechange=filterlist_callback;
790         xmlhttp.send(null); 
791
792 }
793
794 function editSelectedLabel() {
795         var rows = getSelectedLabels();
796
797         if (rows.length == 0) {
798                 notify("No labels are selected.");
799                 return;
800         }
801
802         if (rows.length > 1) {
803                 notify("Please select one label.");
804                 return;
805         }
806
807         editLabel(rows[0]);
808
809 }
810
811 function editSelectedUser() {
812         var rows = getSelectedUsers();
813
814         if (rows.length == 0) {
815                 notify("No users are selected.");
816                 return;
817         }
818
819         if (rows.length > 1) {
820                 notify("Please select one user.");
821                 return;
822         }
823
824         editUser(rows[0]);
825 }
826
827 function resetSelectedUserPass() {
828         var rows = getSelectedUsers();
829
830         if (rows.length == 0) {
831                 notify("No users are selected.");
832                 return;
833         }
834
835         if (rows.length > 1) {
836                 notify("Please select one user.");
837                 return;
838         }
839
840         notify("Resetting password for selected user...");
841
842         var id = rows[0];
843
844         xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
845                 param_escape(id), true);
846         xmlhttp.onreadystatechange=userlist_callback;
847         xmlhttp.send(null);
848
849 }
850
851
852
853 function editSelectedFilter() {
854         var rows = getSelectedFilters();
855
856         if (rows.length == 0) {
857                 notify("No filters are selected.");
858                 return;
859         }
860
861         if (rows.length > 1) {
862                 notify("Please select one filter.");
863                 return;
864         }
865
866         editFilter(rows[0]);
867
868 }
869
870
871 function editSelectedFeed() {
872         var rows = getSelectedFeeds();
873
874         if (rows.length == 0) {
875                 notify("No feeds are selected.");
876                 return;
877         }
878
879         if (rows.length > 1) {
880                 notify("Please select one feed.");
881                 return;
882         }
883
884         editFeed(rows[0]);
885
886 }
887
888 function localPiggieFunction(enable) {
889         if (enable) {
890                 piggie.style.display = "block";
891                 seq = "";
892                 notify("I loveded it!!!");
893         } else {
894                 piggie.style.display = "none";
895                 notify("");
896         }
897 }
898
899 function validateOpmlImport() {
900         
901         var opml_file = document.getElementById("opml_file");
902
903         if (opml_file.value.length == 0) {
904                 notify("Please select OPML file to upload.");
905                 return false;
906         } else {
907                 return true;
908         }
909 }
910
911 function updateFilterList() {
912
913         if (!xmlhttp_ready(xmlhttp)) {
914                 printLockingError();
915                 return
916         }
917
918 //      document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
919
920         p_notify("Loading, please wait...");
921
922         xmlhttp.open("GET", "backend.php?op=pref-filters", true);
923         xmlhttp.onreadystatechange=filterlist_callback;
924         xmlhttp.send(null);
925
926 }
927
928 function updateLabelList() {
929
930         if (!xmlhttp_ready(xmlhttp)) {
931                 printLockingError();
932                 return
933         }
934
935         p_notify("Loading, please wait...");
936
937 //      document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
938
939         xmlhttp.open("GET", "backend.php?op=pref-labels", true);
940         xmlhttp.onreadystatechange=labellist_callback;
941         xmlhttp.send(null);
942 }
943
944 function updatePrefsList() {
945
946         if (!xmlhttp_ready(xmlhttp)) {
947                 printLockingError();
948                 return
949         }
950
951         p_notify("Loading, please wait...");
952
953         xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
954         xmlhttp.onreadystatechange=prefslist_callback;
955         xmlhttp.send(null);
956
957 }
958
959 function selectTab(id) {
960
961         if (id == "feedConfig") {
962                 updateFeedList();
963         } else if (id == "filterConfig") {
964                 updateFilterList();
965         } else if (id == "labelConfig") {
966                 updateLabelList();
967         } else if (id == "genConfig") {
968                 updatePrefsList();
969         } else if (id == "userConfig") {
970                 updateUsersList();
971         }
972
973         var tab = document.getElementById(active_tab + "Tab");
974
975         if (tab) {
976                 if (tab.className.match("Selected")) {
977                         tab.className = "prefsTab";
978                 }
979         }
980
981         tab = document.getElementById(id + "Tab");
982
983         if (tab) {
984                 if (!tab.className.match("Selected")) {
985                         tab.className = tab.className + "Selected";
986                 }
987         }
988
989         active_tab = id;
990
991 }
992
993 function init() {
994
995         // IE kludge
996
997         if (!xmlhttp) {
998                 document.getElementById("prefContent").innerHTML = 
999                         "<b>Fatal error:</b> This program needs XmlHttpRequest " + 
1000                         "to function properly. Your browser doesn't seem to support it.";
1001                 return;
1002         }
1003
1004         selectTab("genConfig");
1005
1006         document.onkeydown = hotkey_handler;
1007         notify("");
1008
1009 }
1010
1011 /*
1012 var help_topic_id = false;
1013
1014 function do_dispOptionHelp() {
1015
1016         if (!xmlhttp_ready(xmlhttp))
1017                 return;
1018
1019         xmlhttp.open("GET", "backend.php?op=pref-prefs&subop=getHelp&pn=" +
1020                 param_escape(help_topic_id), true);
1021         xmlhttp.onreadystatechange=gethelp_callback;
1022         xmlhttp.send(null);
1023
1024 }
1025
1026 function dispOptionHelp(event, sender) {
1027
1028         help_topic_id = sender.id;
1029
1030 //      document.setTimeout("do_dispOptionHelp()", 100);
1031
1032 } */
1033
1034