]> git.wh0rd.org - tt-rss.git/blame - prefs.js
possible fix for possible tag bug
[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;
a0d53889 9var active_filter = false;
48f0adb0 10var active_label = false;
e6cb77a0 11var active_user = false;
961513a3 12
f5a50b25
AD
13var active_tab = false;
14
007bda35
AD
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.
19try {
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
30if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
31 xmlhttp = new XMLHttpRequest();
32}
33
007bda35 34function feedlist_callback() {
f5a50b25 35 var container = document.getElementById('prefContent');
007bda35
AD
36 if (xmlhttp.readyState == 4) {
37 container.innerHTML=xmlhttp.responseText;
961513a3
AD
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 }
f5a50b25 50 p_notify("");
007bda35
AD
51 }
52}
53
a0d53889 54function filterlist_callback() {
f5a50b25 55 var container = document.getElementById('prefContent');
a0d53889 56 if (xmlhttp.readyState == 4) {
f5a50b25 57
a0d53889
AD
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 }
f5a50b25 73 p_notify("");
a0d53889
AD
74 }
75}
76
48f0adb0 77function labellist_callback() {
f5a50b25 78 var container = document.getElementById('prefContent');
48f0adb0
AD
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 }
f5a50b25 95 p_notify("");
48f0adb0
AD
96 }
97}
4255b24c 98
e6cb77a0
AD
99function 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
4255b24c
AD
121function 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
b1895692
AD
131function 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}
4255b24c
AD
140
141
0e091d38
AD
142function notify_callback() {
143 var container = document.getElementById('notify');
144 if (xmlhttp.readyState == 4) {
145 container.innerHTML=xmlhttp.responseText;
146 }
147}
148
175847de 149
0e091d38 150function updateFeedList() {
007bda35 151
c0e5a40e 152 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
153 printLockingError();
154 return
155 }
156
f5a50b25
AD
157// document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
158
159 p_notify("Loading, please wait...");
007bda35
AD
160
161 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
162 xmlhttp.onreadystatechange=feedlist_callback;
163 xmlhttp.send(null);
164
165}
166
e6cb77a0
AD
167function 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
007bda35
AD
184function 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
48f0adb0
AD
198function 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
de435974
AD
223function 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
25cb5736
AD
238 var v_match = match[match.selectedIndex].text;
239
de435974 240 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add&regexp=" +
25cb5736 241 param_escape(regexp.value) + "&match=" + v_match, true);
de435974
AD
242
243 xmlhttp.onreadystatechange=filterlist_callback;
244 xmlhttp.send(null);
245
246 regexp.value = "";
247 }
248
249}
48f0adb0 250
71ad3959
AD
251function addFeed() {
252
c0e5a40e 253 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
254 printLockingError();
255 return
256 }
257
331900c6
AD
258 var link = document.getElementById("fadd_link");
259
83fe4d6d 260 if (link.value.length == 0) {
c753cd32 261 notify("Missing feed URL.");
331900c6
AD
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
e6cb77a0
AD
276function 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
48f0adb0
AD
301function 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
e6cb77a0
AD
317function 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
a0d53889
AD
333function 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
331900c6
AD
349function editFeed(feed) {
350
508a81e1
AD
351// notify("Editing feed...");
352
c0e5a40e 353 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
354 printLockingError();
355 return
356 }
331900c6 357
961513a3
AD
358 active_feed = feed;
359
331900c6
AD
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
48f0adb0
AD
367function 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
e6cb77a0
AD
383function 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
48f0adb0 399
a0d53889
AD
400function 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
83fe4d6d 416function getSelectedFeeds() {
331900c6
AD
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
83fe4d6d
AD
429 return sel_rows;
430}
431
432function readSelectedFeeds() {
433
c0e5a40e 434 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
435 printLockingError();
436 return
437 }
438
83fe4d6d
AD
439 var sel_rows = getSelectedFeeds();
440
441 if (sel_rows.length > 0) {
442
443 notify("Marking selected feeds as read...");
444
0e091d38 445 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&ids="+
83fe4d6d 446 param_escape(sel_rows.toString()), true);
0e091d38 447 xmlhttp.onreadystatechange=notify_callback;
83fe4d6d
AD
448 xmlhttp.send(null);
449
450 } else {
451
c753cd32 452 notify("Please select some feeds first.");
83fe4d6d
AD
453
454 }
455}
456
457function unreadSelectedFeeds() {
458
c0e5a40e 459 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
460 printLockingError();
461 return
462 }
463
83fe4d6d
AD
464 var sel_rows = getSelectedFeeds();
465
466 if (sel_rows.length > 0) {
467
468 notify("Marking selected feeds as unread...");
469
0e091d38 470 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=unread&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
508a81e1
AD
578function feedEditCancel() {
579
c0e5a40e 580 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
581 printLockingError();
582 return
583 }
584
961513a3
AD
585 active_feed = false;
586
508a81e1
AD
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
603c27f8
AD
595function feedEditSave() {
596
597 var feed = active_feed;
508a81e1 598
c0e5a40e 599 if (!xmlhttp_ready(xmlhttp)) {
508a81e1
AD
600 printLockingError();
601 return
602 }
603
603c27f8
AD
604 var link = document.getElementById("iedit_link").value;
605 var title = document.getElementById("iedit_title").value;
d148926e 606 var upd_intl = document.getElementById("iedit_updintl").value;
5d73494a 607 var purge_intl = document.getElementById("iedit_purgintl").value;
508a81e1 608
603c27f8 609// notify("Saving feed.");
508a81e1 610
140aae81 611/* if (upd_intl < 0) {
d148926e
AD
612 notify("Update interval must be &gt;= 0 (0 = default)");
613 return;
614 }
615
5d73494a
AD
616 if (purge_intl < 0) {
617 notify("Purge days must be &gt;= 0 (0 = default)");
618 return;
140aae81 619 } */
d148926e 620
508a81e1
AD
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
603c27f8
AD
631 active_feed = false;
632
508a81e1 633 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
d148926e 634 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
5d73494a 635 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl), true);
508a81e1
AD
636 xmlhttp.onreadystatechange=feedlist_callback;
637 xmlhttp.send(null);
638
639}
640
48f0adb0
AD
641function 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
e6cb77a0
AD
658function 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}
48f0adb0 674
a0d53889
AD
675function 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
48f0adb0
AD
692function 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
e6cb77a0
AD
727function 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
a0d53889
AD
761function 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;
25cb5736
AD
772 var match = document.getElementById("iedit_match");
773
774 var v_match = match[match.selectedIndex].text;
a0d53889
AD
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) +
25cb5736 787 "&m=" + param_escape(v_match), true);
a0d53889
AD
788
789 xmlhttp.onreadystatechange=filterlist_callback;
790 xmlhttp.send(null);
791
792}
793
48f0adb0
AD
794function editSelectedLabel() {
795 var rows = getSelectedLabels();
a0d53889 796
48f0adb0
AD
797 if (rows.length == 0) {
798 notify("No labels are selected.");
799 return;
a0d53889
AD
800 }
801
48f0adb0
AD
802 if (rows.length > 1) {
803 notify("Please select one label.");
804 return;
805 }
a0d53889 806
48f0adb0 807 editLabel(rows[0]);
a0d53889 808
a0d53889
AD
809}
810
e6cb77a0
AD
811function 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
827function 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
a0d53889
AD
852
853function 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
508a81e1
AD
871function 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
13ad9102
AD
888function localPiggieFunction(enable) {
889 if (enable) {
508a81e1
AD
890 piggie.style.display = "block";
891 seq = "";
892 notify("I loveded it!!!");
893 } else {
894 piggie.style.display = "none";
895 notify("");
896 }
508a81e1
AD
897}
898
9f311df6
AD
899function 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
a0d53889
AD
911function updateFilterList() {
912
913 if (!xmlhttp_ready(xmlhttp)) {
914 printLockingError();
915 return
916 }
917
f5a50b25
AD
918// document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
919
920 p_notify("Loading, please wait...");
a0d53889
AD
921
922 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
923 xmlhttp.onreadystatechange=filterlist_callback;
924 xmlhttp.send(null);
925
926}
927
48f0adb0
AD
928function updateLabelList() {
929
930 if (!xmlhttp_ready(xmlhttp)) {
931 printLockingError();
932 return
933 }
934
f5a50b25
AD
935 p_notify("Loading, please wait...");
936
937// document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
48f0adb0
AD
938
939 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
940 xmlhttp.onreadystatechange=labellist_callback;
941 xmlhttp.send(null);
48f0adb0
AD
942}
943
4255b24c
AD
944function 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
f5a50b25 959function selectTab(id) {
48f0adb0 960
f5a50b25 961 if (id == "feedConfig") {
a0d53889 962 updateFeedList();
f5a50b25 963 } else if (id == "filterConfig") {
a0d53889 964 updateFilterList();
f5a50b25 965 } else if (id == "labelConfig") {
48f0adb0 966 updateLabelList();
4255b24c
AD
967 } else if (id == "genConfig") {
968 updatePrefsList();
e6cb77a0
AD
969 } else if (id == "userConfig") {
970 updateUsersList();
a0d53889 971 }
f5a50b25
AD
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
a0d53889
AD
991}
992
007bda35 993function init() {
e2ec66a8
AD
994
995 // IE kludge
996
ad095c16 997 if (!xmlhttp) {
e2ec66a8
AD
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
77e96719 1004 selectTab("genConfig");
f5a50b25 1005
508a81e1 1006 document.onkeydown = hotkey_handler;
857a9270
AD
1007 notify("");
1008
007bda35 1009}
b1895692
AD
1010
1011/*
1012var help_topic_id = false;
1013
1014function 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
1026function dispOptionHelp(event, sender) {
1027
1028 help_topic_id = sender.id;
1029
1030// document.setTimeout("do_dispOptionHelp()", 100);
1031
1032} */
1033
1c7f75ed 1034