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