]> git.wh0rd.org - tt-rss.git/blame_incremental - prefs.js
show all subscribed feeds with scrollbar in user details
[tt-rss.git] / prefs.js
... / ...
CommitLineData
1var xmlhttp = false;
2
3var active_feed = false;
4var active_feed_cat = false;
5var active_filter = false;
6var active_label = false;
7var active_user = false;
8
9var active_tab = false;
10
11/*@cc_on @*/
12/*@if (@_jscript_version >= 5)
13// JScript gives us Conditional compilation, we can cope with old IE versions.
14// and security blocked creation of the objects.
15try {
16 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
17} catch (e) {
18 try {
19 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
20 } catch (E) {
21 xmlhttp = false;
22 }
23}
24@end @*/
25
26if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
27 xmlhttp = new XMLHttpRequest();
28}
29
30function feedlist_callback() {
31 if (xmlhttp.readyState == 4) {
32 try {
33 var container = document.getElementById('prefContent');
34 container.innerHTML=xmlhttp.responseText;
35 if (active_feed) {
36 var row = document.getElementById("FEEDR-" + active_feed);
37 if (row) {
38 if (!row.className.match("Selected")) {
39 row.className = row.className + "Selected";
40 }
41 }
42 var checkbox = document.getElementById("FRCHK-" + active_feed);
43 if (checkbox) {
44 checkbox.checked = true;
45 }
46 }
47 p_notify("");
48 } catch (e) {
49 exception_error("feedlist_callback", e);
50 }
51 }
52}
53
54function 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
77function 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
99function 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
122function 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
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
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}
158
159
160function notify_callback() {
161 var container = document.getElementById('notify');
162 if (xmlhttp.readyState == 4) {
163 container.innerHTML=xmlhttp.responseText;
164 }
165}
166
167function updateFeedList(sort_key) {
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 var feed_search = document.getElementById("feed_search");
179 var search = "";
180 if (feed_search) { search = feed_search.value; }
181
182 xmlhttp.open("GET", "backend.php?op=pref-feeds" +
183 "&sort=" + param_escape(sort_key) +
184 "&search=" + param_escape(search), true);
185 xmlhttp.onreadystatechange=feedlist_callback;
186 xmlhttp.send(null);
187
188}
189
190function updateUsersList() {
191
192 if (!xmlhttp_ready(xmlhttp)) {
193 printLockingError();
194 return
195 }
196
197// document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
198
199 p_notify("Loading, please wait...");
200
201 xmlhttp.open("GET", "backend.php?op=pref-users", true);
202 xmlhttp.onreadystatechange=userlist_callback;
203 xmlhttp.send(null);
204
205}
206
207function addLabel() {
208
209 if (!xmlhttp_ready(xmlhttp)) {
210 printLockingError();
211 return
212 }
213
214 var sqlexp = document.getElementById("ladd_expr");
215
216 if (sqlexp.value.length == 0) {
217 notify("Missing SQL expression.");
218 } else {
219 notify("Adding label...");
220
221 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
222 param_escape(sqlexp.value), true);
223
224 xmlhttp.onreadystatechange=labellist_callback;
225 xmlhttp.send(null);
226
227 sqlexp.value = "";
228 }
229
230}
231
232function addFilter() {
233
234 if (!xmlhttp_ready(xmlhttp)) {
235 printLockingError();
236 return
237 }
238
239 var regexp = document.getElementById("fadd_regexp");
240 var match = document.getElementById("fadd_match");
241 var feed = document.getElementById("fadd_feed");
242 var action = document.getElementById("fadd_action");
243
244 if (regexp.value.length == 0) {
245 notify("Missing filter expression.");
246 } else {
247 notify("Adding filter...");
248
249 var v_match = match[match.selectedIndex].text;
250 var feed_id = feed[feed.selectedIndex].id;
251 var action_id = action[action.selectedIndex].id;
252
253 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add&regexp=" +
254 param_escape(regexp.value) + "&match=" + v_match +
255 "&fid=" + param_escape(feed_id) + "&aid=" + param_escape(action_id), true);
256
257 xmlhttp.onreadystatechange=filterlist_callback;
258 xmlhttp.send(null);
259
260 regexp.value = "";
261 }
262
263}
264
265function addFeed() {
266
267 if (!xmlhttp_ready(xmlhttp)) {
268 printLockingError();
269 return
270 }
271
272 var link = document.getElementById("fadd_link");
273
274 if (link.value.length == 0) {
275 notify("Missing feed URL.");
276 } else {
277 notify("Adding feed...");
278
279 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
280 param_escape(link.value), true);
281 xmlhttp.onreadystatechange=feedlist_callback;
282 xmlhttp.send(null);
283
284 link.value = "";
285
286 }
287
288}
289
290function addFeedCat() {
291
292 if (!xmlhttp_ready(xmlhttp)) {
293 printLockingError();
294 return
295 }
296
297 var cat = document.getElementById("fadd_cat");
298
299 if (cat.value.length == 0) {
300 notify("Missing feed category.");
301 } else {
302 notify("Adding feed category...");
303
304 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
305 param_escape(cat.value), true);
306 xmlhttp.onreadystatechange=feedlist_callback;
307 xmlhttp.send(null);
308
309 link.value = "";
310
311 }
312
313}
314function addUser() {
315
316 if (!xmlhttp_ready(xmlhttp)) {
317 printLockingError();
318 return
319 }
320
321 var sqlexp = document.getElementById("uadd_box");
322
323 if (sqlexp.value.length == 0) {
324 notify("Missing user login.");
325 } else {
326 notify("Adding user...");
327
328 xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
329 param_escape(sqlexp.value), true);
330
331 xmlhttp.onreadystatechange=userlist_callback;
332 xmlhttp.send(null);
333
334 sqlexp.value = "";
335 }
336
337}
338
339function editLabel(id) {
340
341 if (!xmlhttp_ready(xmlhttp)) {
342 printLockingError();
343 return
344 }
345
346 active_label = id;
347
348 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
349 param_escape(id), true);
350 xmlhttp.onreadystatechange=labellist_callback;
351 xmlhttp.send(null);
352
353}
354
355function editUser(id) {
356
357 if (!xmlhttp_ready(xmlhttp)) {
358 printLockingError();
359 return
360 }
361
362 active_user = id;
363
364 xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
365 param_escape(id), true);
366 xmlhttp.onreadystatechange=userlist_callback;
367 xmlhttp.send(null);
368
369}
370
371function editFilter(id) {
372
373 if (!xmlhttp_ready(xmlhttp)) {
374 printLockingError();
375 return
376 }
377
378 active_filter = id;
379
380 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
381 param_escape(id), true);
382 xmlhttp.onreadystatechange=filterlist_callback;
383 xmlhttp.send(null);
384
385}
386
387function editFeed(feed) {
388
389// notify("Editing feed...");
390
391 if (!xmlhttp_ready(xmlhttp)) {
392 printLockingError();
393 return
394 }
395
396 active_feed = feed;
397
398/* xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
399 param_escape(feed), true);
400 xmlhttp.onreadystatechange=feedlist_callback;
401 xmlhttp.send(null); */
402
403 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
404// selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-'+feed, 'FRCHK-'+feed,
405// true, false);
406
407 selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
408
409 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
410 param_escape(active_feed), true);
411
412 xmlhttp.onreadystatechange=infobox_callback;
413 xmlhttp.send(null);
414
415}
416
417function editFeedCat(cat) {
418
419 if (!xmlhttp_ready(xmlhttp)) {
420 printLockingError();
421 return
422 }
423
424 active_feed_cat = cat;
425
426 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
427 param_escape(cat), true);
428 xmlhttp.onreadystatechange=feedlist_callback;
429 xmlhttp.send(null);
430
431}
432
433function getSelectedLabels() {
434 return getSelectedTableRowIds("prefLabelList", "LILRR");
435}
436
437function getSelectedUsers() {
438 return getSelectedTableRowIds("prefUserList", "UMRR");
439}
440
441function getSelectedFeeds() {
442 return getSelectedTableRowIds("prefFeedList", "FEEDR");
443}
444
445function getSelectedFilters() {
446 return getSelectedTableRowIds("prefFilterList", "FILRR");
447}
448
449function getSelectedFeedCats() {
450 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
451}
452
453
454function readSelectedFeeds(read) {
455
456 if (!xmlhttp_ready(xmlhttp)) {
457 printLockingError();
458 return
459 }
460
461 var sel_rows = getSelectedFeeds();
462
463 if (sel_rows.length > 0) {
464
465 if (!read) {
466 op = "unread";
467 } else {
468 op = "read";
469 }
470
471 notify("Marking selected feeds as " + op + "...");
472
473 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=" + op + "&ids="+
474 param_escape(sel_rows.toString()), true);
475 xmlhttp.onreadystatechange=notify_callback;
476 xmlhttp.send(null);
477
478 } else {
479
480 notify("Please select some feeds first.");
481
482 }
483}
484
485function removeSelectedLabels() {
486
487 if (!xmlhttp_ready(xmlhttp)) {
488 printLockingError();
489 return
490 }
491
492 var sel_rows = getSelectedLabels();
493
494 if (sel_rows.length > 0) {
495
496 var ok = confirm("Remove selected labels?");
497
498 if (ok) {
499 notify("Removing selected labels...");
500
501 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
502 param_escape(sel_rows.toString()), true);
503 xmlhttp.onreadystatechange=labellist_callback;
504 xmlhttp.send(null);
505 }
506 } else {
507 notify("Please select some labels first.");
508 }
509}
510
511function removeSelectedUsers() {
512
513 if (!xmlhttp_ready(xmlhttp)) {
514 printLockingError();
515 return
516 }
517
518 var sel_rows = getSelectedUsers();
519
520 if (sel_rows.length > 0) {
521
522 var ok = confirm("Remove selected users?");
523
524 if (ok) {
525 notify("Removing selected users...");
526
527 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
528 param_escape(sel_rows.toString()), true);
529 xmlhttp.onreadystatechange=userlist_callback;
530 xmlhttp.send(null);
531 }
532
533 } else {
534 notify("Please select some labels first.");
535 }
536}
537
538function removeSelectedFilters() {
539
540 if (!xmlhttp_ready(xmlhttp)) {
541 printLockingError();
542 return
543 }
544
545 var sel_rows = getSelectedFilters();
546
547 if (sel_rows.length > 0) {
548
549 var ok = confirm("Remove selected filters?");
550
551 if (ok) {
552 notify("Removing selected filters...");
553
554 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
555 param_escape(sel_rows.toString()), true);
556 xmlhttp.onreadystatechange=filterlist_callback;
557 xmlhttp.send(null);
558 }
559 } else {
560 notify("Please select some filters first.");
561 }
562}
563
564
565function removeSelectedFeeds() {
566
567 if (!xmlhttp_ready(xmlhttp)) {
568 printLockingError();
569 return
570 }
571
572 var sel_rows = getSelectedFeeds();
573
574 if (sel_rows.length > 0) {
575
576 var ok = confirm("Remove selected feeds?");
577
578 if (ok) {
579
580 notify("Removing selected feeds...");
581
582 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
583 param_escape(sel_rows.toString()), true);
584 xmlhttp.onreadystatechange=feedlist_callback;
585 xmlhttp.send(null);
586 }
587
588 } else {
589
590 notify("Please select some feeds first.");
591
592 }
593
594}
595
596function removeSelectedFeedCats() {
597
598 if (!xmlhttp_ready(xmlhttp)) {
599 printLockingError();
600 return
601 }
602
603 var sel_rows = getSelectedFeedCats();
604
605 if (sel_rows.length > 0) {
606
607 var ok = confirm("Remove selected categories?");
608
609 if (ok) {
610 notify("Removing selected categories...");
611
612 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
613 param_escape(sel_rows.toString()), true);
614 xmlhttp.onreadystatechange=feedlist_callback;
615 xmlhttp.send(null);
616 }
617
618 } else {
619
620 notify("Please select some feeds first.");
621
622 }
623
624}
625
626function feedEditCancel() {
627
628 if (!xmlhttp_ready(xmlhttp)) {
629 printLockingError();
630 return
631 }
632
633 closeInfoBox();
634
635 active_feed = false;
636
637 notify("Operation cancelled.");
638
639/* xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
640 xmlhttp.onreadystatechange=feedlist_callback;
641 xmlhttp.send(null); */
642
643}
644
645function feedCatEditCancel() {
646
647 if (!xmlhttp_ready(xmlhttp)) {
648 printLockingError();
649 return
650 }
651
652 active_feed_cat = false;
653
654 notify("Operation cancelled.");
655
656 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
657 xmlhttp.onreadystatechange=feedlist_callback;
658 xmlhttp.send(null);
659
660}
661
662function feedEditSave() {
663
664 try {
665
666 var feed = active_feed;
667
668 if (!xmlhttp_ready(xmlhttp)) {
669 printLockingError();
670 return
671 }
672
673 var link = document.getElementById("iedit_link").value;
674 var title = document.getElementById("iedit_title").value;
675 var upd_intl = document.getElementById("iedit_updintl").value;
676 var purge_intl = document.getElementById("iedit_purgintl").value;
677 var fcat = document.getElementById("iedit_fcat");
678
679 var fcat_id = fcat[fcat.selectedIndex].id;
680
681 var pfeed = document.getElementById("iedit_parent_feed");
682 var parent_feed_id = pfeed[pfeed.selectedIndex].id;
683
684 if (link.length == 0) {
685 notify("Feed link cannot be blank.");
686 return;
687 }
688
689 if (title.length == 0) {
690 notify("Feed title cannot be blank.");
691 return;
692 }
693
694 var auth_login = document.getElementById("iedit_login").value;
695 var auth_pass = document.getElementById("iedit_pass").value;
696
697 active_feed = false;
698
699 notify("Saving feed...");
700
701 var query = "op=pref-feeds&subop=editSave&id=" +
702 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
703 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
704 "&catid=" + param_escape(fcat_id) + "&login=" + param_escape(auth_login) +
705 "&pfeed=" + param_escape(parent_feed_id) + "&pass=" + param_escape(auth_pass);
706
707 xmlhttp.open("POST", "backend.php", true);
708 xmlhttp.onreadystatechange=feedlist_callback;
709 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
710 xmlhttp.send(query);
711
712 } catch (e) {
713 exception_error("feedEditSave", e);
714 }
715}
716
717function feedCatEditSave() {
718
719 if (!xmlhttp_ready(xmlhttp)) {
720 printLockingError();
721 return
722 }
723
724 notify("Saving category...");
725
726 var cat_title = document.getElementById("iedit_title").value;
727
728 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=saveCat&id=" +
729 param_escape(active_feed_cat) + "&title=" + param_escape(cat_title),
730 true);
731 xmlhttp.onreadystatechange=feedlist_callback;
732 xmlhttp.send(null);
733
734 active_feed_cat = false;
735
736}
737
738
739function labelTest() {
740
741 var sqlexp = document.getElementById("iedit_expr").value;
742 var descr = document.getElementById("iedit_descr").value;
743
744 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
745 param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
746
747 xmlhttp.onreadystatechange=infobox_callback;
748 xmlhttp.send(null);
749
750}
751
752function displayHelpInfobox(topic_id) {
753
754 xmlhttp.open("GET", "backend.php?op=help&tid=" +
755 param_escape(topic_id) + "&noheaders=1", true);
756
757 xmlhttp.onreadystatechange=infobox_callback;
758 xmlhttp.send(null);
759
760}
761
762function labelEditCancel() {
763
764 if (!xmlhttp_ready(xmlhttp)) {
765 printLockingError();
766 return
767 }
768
769 active_label = false;
770
771 notify("Operation cancelled.");
772
773 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
774 xmlhttp.onreadystatechange=labellist_callback;
775 xmlhttp.send(null);
776
777}
778
779function userEditCancel() {
780
781 if (!xmlhttp_ready(xmlhttp)) {
782 printLockingError();
783 return
784 }
785
786 active_user = false;
787
788 notify("Operation cancelled.");
789
790 xmlhttp.open("GET", "backend.php?op=pref-users", true);
791 xmlhttp.onreadystatechange=userlist_callback;
792 xmlhttp.send(null);
793
794}
795
796function filterEditCancel() {
797
798 if (!xmlhttp_ready(xmlhttp)) {
799 printLockingError();
800 return
801 }
802
803 active_filter = false;
804
805 notify("Operation cancelled.");
806
807 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
808 xmlhttp.onreadystatechange=filterlist_callback;
809 xmlhttp.send(null);
810
811}
812
813function labelEditSave() {
814
815 var label = active_label;
816
817 if (!xmlhttp_ready(xmlhttp)) {
818 printLockingError();
819 return
820 }
821
822 var sqlexp = document.getElementById("iedit_expr").value;
823 var descr = document.getElementById("iedit_descr").value;
824
825// notify("Saving label " + sqlexp + ": " + descr);
826
827 if (sqlexp.length == 0) {
828 notify("SQL expression cannot be blank.");
829 return;
830 }
831
832 if (descr.length == 0) {
833 notify("Caption cannot be blank.");
834 return;
835 }
836
837 notify("Saving label...");
838
839 active_label = false;
840
841 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
842 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
843 true);
844
845 xmlhttp.onreadystatechange=labellist_callback;
846 xmlhttp.send(null);
847
848}
849
850function userEditSave() {
851
852 var user = active_user;
853
854 if (!xmlhttp_ready(xmlhttp)) {
855 printLockingError();
856 return
857 }
858
859 var login = document.getElementById("iedit_ulogin").value;
860 var level = document.getElementById("iedit_ulevel").value;
861 var email = document.getElementById("iedit_email").value;
862
863 if (login.length == 0) {
864 notify("Login cannot be blank.");
865 return;
866 }
867
868 if (level.length == 0) {
869 notify("User level cannot be blank.");
870 return;
871 }
872
873 active_user = false;
874
875 notify("Saving user...");
876
877 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
878 user + "&l=" + param_escape(login) + "&al=" + param_escape(level) +
879 "&e=" + param_escape(email), true);
880
881 xmlhttp.onreadystatechange=userlist_callback;
882 xmlhttp.send(null);
883
884}
885
886
887function filterEditSave() {
888
889 var filter = active_filter;
890
891 if (!xmlhttp_ready(xmlhttp)) {
892 printLockingError();
893 return
894 }
895
896 var regexp = document.getElementById("iedit_regexp").value;
897 var descr = document.getElementById("iedit_descr").value;
898 var match = document.getElementById("iedit_match");
899
900 var v_match = match[match.selectedIndex].text;
901
902 var feed = document.getElementById("iedit_feed");
903 var feed_id = feed[feed.selectedIndex].id;
904
905 var action = document.getElementById("iedit_filter_action");
906 var action_id = action[action.selectedIndex].id;
907
908// notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
909
910 if (regexp.length == 0) {
911 notify("Filter expression cannot be blank.");
912 return;
913 }
914
915 active_filter = false;
916
917 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
918 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
919 "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id) +
920 "&aid=" + param_escape(action_id), true);
921
922 notify("Saving filter...");
923
924 xmlhttp.onreadystatechange=filterlist_callback;
925 xmlhttp.send(null);
926
927}
928
929function editSelectedLabel() {
930 var rows = getSelectedLabels();
931
932 if (rows.length == 0) {
933 notify("No labels are selected.");
934 return;
935 }
936
937 if (rows.length > 1) {
938 notify("Please select one label.");
939 return;
940 }
941
942 notify("");
943
944 editLabel(rows[0]);
945
946}
947
948function editSelectedUser() {
949 var rows = getSelectedUsers();
950
951 if (rows.length == 0) {
952 notify("No users are selected.");
953 return;
954 }
955
956 if (rows.length > 1) {
957 notify("Please select one user.");
958 return;
959 }
960
961 notify("");
962
963 editUser(rows[0]);
964}
965
966function resetSelectedUserPass() {
967 var rows = getSelectedUsers();
968
969 if (rows.length == 0) {
970 notify("No users are selected.");
971 return;
972 }
973
974 if (rows.length > 1) {
975 notify("Please select one user.");
976 return;
977 }
978
979 var ok = confirm("Reset password of selected user?");
980
981 if (ok) {
982 notify("Resetting password for selected user...");
983
984 var id = rows[0];
985
986 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
987 param_escape(id), true);
988 xmlhttp.onreadystatechange=userlist_callback;
989 xmlhttp.send(null);
990 }
991}
992
993function selectedUserDetails() {
994
995 if (!xmlhttp_ready(xmlhttp)) {
996 printLockingError();
997 return
998 }
999
1000 var rows = getSelectedUsers();
1001
1002 if (rows.length == 0) {
1003 notify("No users are selected.");
1004 return;
1005 }
1006
1007 if (rows.length > 1) {
1008 notify("Please select one user.");
1009 return;
1010 }
1011
1012 var id = rows[0];
1013
1014 notify("");
1015
1016 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
1017 xmlhttp.onreadystatechange=infobox_callback;
1018 xmlhttp.send(null);
1019
1020}
1021
1022function selectedFeedDetails() {
1023
1024 if (!xmlhttp_ready(xmlhttp)) {
1025 printLockingError();
1026 return
1027 }
1028
1029 var rows = getSelectedFeeds();
1030
1031 if (rows.length == 0) {
1032 notify("No feeds are selected.");
1033 return;
1034 }
1035
1036// if (rows.length > 1) {
1037// notify("Please select one feed.");
1038// return;
1039// }
1040
1041// var id = rows[0];
1042
1043 notify("");
1044
1045 xmlhttp.open("GET", "backend.php?op=feed-details&id=" +
1046 param_escape(rows.toString()), true);
1047 xmlhttp.onreadystatechange=infobox_callback;
1048 xmlhttp.send(null);
1049
1050}
1051
1052function editSelectedFilter() {
1053 var rows = getSelectedFilters();
1054
1055 if (rows.length == 0) {
1056 notify("No filters are selected.");
1057 return;
1058 }
1059
1060 if (rows.length > 1) {
1061 notify("Please select one filter.");
1062 return;
1063 }
1064
1065 notify("");
1066
1067 editFilter(rows[0]);
1068
1069}
1070
1071
1072function editSelectedFeed() {
1073 var rows = getSelectedFeeds();
1074
1075 if (rows.length == 0) {
1076 notify("No feeds are selected.");
1077 return;
1078 }
1079
1080 if (rows.length > 1) {
1081 notify("Please select one feed.");
1082 return;
1083 }
1084
1085 notify("");
1086
1087 editFeed(rows[0]);
1088
1089}
1090
1091function editSelectedFeedCat() {
1092 var rows = getSelectedFeedCats();
1093
1094 if (rows.length == 0) {
1095 notify("No categories are selected.");
1096 return;
1097 }
1098
1099 if (rows.length > 1) {
1100 notify("Please select one category.");
1101 return;
1102 }
1103
1104 notify("");
1105
1106 editFeedCat(rows[0]);
1107
1108}
1109
1110function localPiggieFunction(enable) {
1111 if (enable) {
1112 piggie.style.display = "block";
1113 seq = "";
1114 notify("I loveded it!!!");
1115 } else {
1116 piggie.style.display = "none";
1117 notify("");
1118 }
1119}
1120
1121function validateOpmlImport() {
1122
1123 var opml_file = document.getElementById("opml_file");
1124
1125 if (opml_file.value.length == 0) {
1126 notify("Please select OPML file to upload.");
1127 return false;
1128 } else {
1129 return true;
1130 }
1131}
1132
1133function updateFilterList() {
1134
1135 if (!xmlhttp_ready(xmlhttp)) {
1136 printLockingError();
1137 return
1138 }
1139
1140// document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1141
1142 p_notify("Loading, please wait...");
1143
1144 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1145 xmlhttp.onreadystatechange=filterlist_callback;
1146 xmlhttp.send(null);
1147
1148}
1149
1150function updateLabelList() {
1151
1152 if (!xmlhttp_ready(xmlhttp)) {
1153 printLockingError();
1154 return
1155 }
1156
1157 p_notify("Loading, please wait...");
1158
1159// document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1160
1161 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1162 xmlhttp.onreadystatechange=labellist_callback;
1163 xmlhttp.send(null);
1164}
1165
1166function updatePrefsList() {
1167
1168 if (!xmlhttp_ready(xmlhttp)) {
1169 printLockingError();
1170 return
1171 }
1172
1173 p_notify("Loading, please wait...");
1174
1175 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1176 xmlhttp.onreadystatechange=prefslist_callback;
1177 xmlhttp.send(null);
1178
1179}
1180
1181function selectTab(id) {
1182
1183 if (!xmlhttp_ready(xmlhttp)) {
1184 printLockingError();
1185 return
1186 }
1187
1188 if (id == "feedConfig") {
1189 updateFeedList();
1190 } else if (id == "filterConfig") {
1191 updateFilterList();
1192 } else if (id == "labelConfig") {
1193 updateLabelList();
1194 } else if (id == "genConfig") {
1195 updatePrefsList();
1196 } else if (id == "userConfig") {
1197 updateUsersList();
1198 }
1199
1200 var tab = document.getElementById(active_tab + "Tab");
1201
1202 if (tab) {
1203 if (tab.className.match("Selected")) {
1204 tab.className = "prefsTab";
1205 }
1206 }
1207
1208 tab = document.getElementById(id + "Tab");
1209
1210 if (tab) {
1211 if (!tab.className.match("Selected")) {
1212 tab.className = tab.className + "Selected";
1213 }
1214 }
1215
1216 active_tab = id;
1217
1218 setCookie('ttrss_pref_acttab', active_tab);
1219
1220}
1221
1222function init() {
1223
1224 try {
1225
1226 // IE kludge
1227 if (!xmlhttp) {
1228 document.getElementById("prefContent").innerHTML =
1229 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1230 "to function properly. Your browser doesn't seem to support it.";
1231 return;
1232 }
1233
1234 active_tab = getCookie("ttrss_pref_acttab");
1235 if (!active_tab) active_tab = "genConfig";
1236 selectTab(active_tab);
1237
1238 document.onkeydown = hotkey_handler;
1239 notify("");
1240 } catch (e) {
1241 exception_error("init", e);
1242 }
1243}
1244
1245function closeInfoBox() {
1246 var box = document.getElementById('infoBox');
1247 var shadow = document.getElementById('infoBoxShadow');
1248
1249 if (shadow) {
1250 shadow.style.display = "none";
1251 } else if (box) {
1252 box.style.display = "none";
1253 }
1254}
1255
1256function categorizeSelectedFeeds() {
1257
1258 if (!xmlhttp_ready(xmlhttp)) {
1259 printLockingError();
1260 return
1261 }
1262
1263 var sel_rows = getSelectedFeeds();
1264
1265 var cat_sel = document.getElementById("sfeed_set_fcat");
1266 var cat_id = cat_sel[cat_sel.selectedIndex].id;
1267
1268 if (sel_rows.length > 0) {
1269
1270 notify("Changing category of selected feeds...");
1271
1272 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1273 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1274 xmlhttp.onreadystatechange=feedlist_callback;
1275 xmlhttp.send(null);
1276
1277 } else {
1278
1279 notify("Please select some feeds first.");
1280
1281 }
1282
1283}
1284
1285function validatePrefsReset() {
1286 return confirm("Reset to defaults?");
1287}