]> git.wh0rd.org - tt-rss.git/blob - prefs.js
fix headlineToolbar initialization on load
[tt-rss.git] / prefs.js
1 var xmlhttp = false;
2
3 var active_feed = false;
4 var active_feed_cat = false;
5 var active_filter = false;
6 var active_label = false;
7 var active_user = false;
8
9 var 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.
15 try {
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
26 if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
27 xmlhttp = new XMLHttpRequest();
28 }
29
30 function 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
54 function filterlist_callback() {
55 var container = document.getElementById('prefContent');
56 if (xmlhttp.readyState == 4) {
57
58 container.innerHTML=xmlhttp.responseText;
59
60 if (active_filter) {
61 var row = document.getElementById("FILRR-" + active_filter);
62 if (row) {
63 if (!row.className.match("Selected")) {
64 row.className = row.className + "Selected";
65 }
66 }
67 var checkbox = document.getElementById("FICHK-" + active_filter);
68
69 if (checkbox) {
70 checkbox.checked = true;
71 }
72 }
73 p_notify("");
74 }
75 }
76
77 function labellist_callback() {
78 var container = document.getElementById('prefContent');
79 if (xmlhttp.readyState == 4) {
80 container.innerHTML=xmlhttp.responseText;
81
82 if (active_label) {
83 var row = document.getElementById("LILRR-" + active_label);
84 if (row) {
85 if (!row.className.match("Selected")) {
86 row.className = row.className + "Selected";
87 }
88 }
89 var checkbox = document.getElementById("LICHK-" + active_label);
90
91 if (checkbox) {
92 checkbox.checked = true;
93 }
94 }
95 p_notify("");
96 }
97 }
98
99 function userlist_callback() {
100 var container = document.getElementById('prefContent');
101 if (xmlhttp.readyState == 4) {
102 container.innerHTML=xmlhttp.responseText;
103
104 if (active_user) {
105 var row = document.getElementById("UMRR-" + active_user);
106 if (row) {
107 if (!row.className.match("Selected")) {
108 row.className = row.className + "Selected";
109 }
110 }
111 var checkbox = document.getElementById("UMCHK-" + active_user);
112
113 if (checkbox) {
114 checkbox.checked = true;
115 }
116 }
117
118 p_notify("");
119 }
120 }
121
122 function infobox_callback() {
123 if (xmlhttp.readyState == 4) {
124 var box = document.getElementById('infoBox');
125 var shadow = document.getElementById('infoBoxShadow');
126
127 if (box) {
128 box.innerHTML=xmlhttp.responseText;
129 if (shadow) {
130 shadow.style.display = "block";
131 } else {
132 box.style.display = "block";
133 }
134 }
135 }
136 }
137
138
139 function prefslist_callback() {
140 var container = document.getElementById('prefContent');
141 if (xmlhttp.readyState == 4) {
142
143 container.innerHTML=xmlhttp.responseText;
144
145 p_notify("");
146 }
147 }
148
149 function gethelp_callback() {
150 var container = document.getElementById('prefHelpBox');
151 if (xmlhttp.readyState == 4) {
152
153 container.innerHTML = xmlhttp.responseText;
154 container.style.display = "block";
155
156 }
157 }
158
159
160 function notify_callback() {
161 var container = document.getElementById('notify');
162 if (xmlhttp.readyState == 4) {
163 container.innerHTML=xmlhttp.responseText;
164 }
165 }
166
167 function 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
190 function 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
207 function 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
232 function 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
265 function 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
290 function 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 }
314 function 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
339 function 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
355 function 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
371 function 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
387 function 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, true);
405
406 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
407 param_escape(active_feed), true);
408
409 xmlhttp.onreadystatechange=infobox_callback;
410 xmlhttp.send(null);
411
412 }
413
414 function editFeedCat(cat) {
415
416 if (!xmlhttp_ready(xmlhttp)) {
417 printLockingError();
418 return
419 }
420
421 active_feed_cat = cat;
422
423 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
424 param_escape(cat), true);
425 xmlhttp.onreadystatechange=feedlist_callback;
426 xmlhttp.send(null);
427
428 }
429
430 function getSelectedLabels() {
431 return getSelectedTableRowIds("prefLabelList", "LILRR");
432 }
433
434 function getSelectedUsers() {
435 return getSelectedTableRowIds("prefUserList", "UMRR");
436 }
437
438 function getSelectedFeeds() {
439 return getSelectedTableRowIds("prefFeedList", "FEEDR");
440 }
441
442 function getSelectedFilters() {
443 return getSelectedTableRowIds("prefFilterList", "FILRR");
444 }
445
446 function getSelectedFeedCats() {
447 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
448 }
449
450
451 function readSelectedFeeds(read) {
452
453 if (!xmlhttp_ready(xmlhttp)) {
454 printLockingError();
455 return
456 }
457
458 var sel_rows = getSelectedFeeds();
459
460 if (sel_rows.length > 0) {
461
462 if (!read) {
463 op = "unread";
464 } else {
465 op = "read";
466 }
467
468 notify("Marking selected feeds as " + op + "...");
469
470 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=" + op + "&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 var ok = confirm("Remove selected labels?");
494
495 if (ok) {
496 notify("Removing selected labels...");
497
498 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
499 param_escape(sel_rows.toString()), true);
500 xmlhttp.onreadystatechange=labellist_callback;
501 xmlhttp.send(null);
502 }
503 } else {
504 notify("Please select some labels first.");
505 }
506 }
507
508 function removeSelectedUsers() {
509
510 if (!xmlhttp_ready(xmlhttp)) {
511 printLockingError();
512 return
513 }
514
515 var sel_rows = getSelectedUsers();
516
517 if (sel_rows.length > 0) {
518
519 var ok = confirm("Remove selected users?");
520
521 if (ok) {
522 notify("Removing selected users...");
523
524 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
525 param_escape(sel_rows.toString()), true);
526 xmlhttp.onreadystatechange=userlist_callback;
527 xmlhttp.send(null);
528 }
529
530 } else {
531 notify("Please select some labels first.");
532 }
533 }
534
535 function removeSelectedFilters() {
536
537 if (!xmlhttp_ready(xmlhttp)) {
538 printLockingError();
539 return
540 }
541
542 var sel_rows = getSelectedFilters();
543
544 if (sel_rows.length > 0) {
545
546 var ok = confirm("Remove selected filters?");
547
548 if (ok) {
549 notify("Removing selected filters...");
550
551 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
552 param_escape(sel_rows.toString()), true);
553 xmlhttp.onreadystatechange=filterlist_callback;
554 xmlhttp.send(null);
555 }
556 } else {
557 notify("Please select some filters first.");
558 }
559 }
560
561
562 function removeSelectedFeeds() {
563
564 if (!xmlhttp_ready(xmlhttp)) {
565 printLockingError();
566 return
567 }
568
569 var sel_rows = getSelectedFeeds();
570
571 if (sel_rows.length > 0) {
572
573 var ok = confirm("Remove selected feeds?");
574
575 if (ok) {
576
577 notify("Removing selected feeds...");
578
579 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
580 param_escape(sel_rows.toString()), true);
581 xmlhttp.onreadystatechange=feedlist_callback;
582 xmlhttp.send(null);
583 }
584
585 } else {
586
587 notify("Please select some feeds first.");
588
589 }
590
591 }
592
593 function removeSelectedFeedCats() {
594
595 if (!xmlhttp_ready(xmlhttp)) {
596 printLockingError();
597 return
598 }
599
600 var sel_rows = getSelectedFeedCats();
601
602 if (sel_rows.length > 0) {
603
604 var ok = confirm("Remove selected categories?");
605
606 if (ok) {
607 notify("Removing selected categories...");
608
609 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
610 param_escape(sel_rows.toString()), true);
611 xmlhttp.onreadystatechange=feedlist_callback;
612 xmlhttp.send(null);
613 }
614
615 } else {
616
617 notify("Please select some feeds first.");
618
619 }
620
621 }
622
623 function feedEditCancel() {
624
625 if (!xmlhttp_ready(xmlhttp)) {
626 printLockingError();
627 return
628 }
629
630 closeInfoBox();
631
632 active_feed = false;
633
634 notify("Operation cancelled.");
635
636 /* xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
637 xmlhttp.onreadystatechange=feedlist_callback;
638 xmlhttp.send(null); */
639
640 }
641
642 function feedCatEditCancel() {
643
644 if (!xmlhttp_ready(xmlhttp)) {
645 printLockingError();
646 return
647 }
648
649 active_feed_cat = false;
650
651 notify("Operation cancelled.");
652
653 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
654 xmlhttp.onreadystatechange=feedlist_callback;
655 xmlhttp.send(null);
656
657 }
658
659 function feedEditSave() {
660
661 try {
662
663 var feed = active_feed;
664
665 if (!xmlhttp_ready(xmlhttp)) {
666 printLockingError();
667 return
668 }
669
670 var link = document.getElementById("iedit_link").value;
671 var title = document.getElementById("iedit_title").value;
672 var upd_intl = document.getElementById("iedit_updintl").value;
673 var purge_intl = document.getElementById("iedit_purgintl").value;
674 var fcat = document.getElementById("iedit_fcat");
675
676 var fcat_id = fcat[fcat.selectedIndex].id;
677
678 // notify("Saving feed.");
679
680 /* if (upd_intl < 0) {
681 notify("Update interval must be &gt;= 0 (0 = default)");
682 return;
683 }
684
685 if (purge_intl < 0) {
686 notify("Purge days must be &gt;= 0 (0 = default)");
687 return;
688 } */
689
690 if (link.length == 0) {
691 notify("Feed link cannot be blank.");
692 return;
693 }
694
695 if (title.length == 0) {
696 notify("Feed title cannot be blank.");
697 return;
698 }
699
700 var auth_login = document.getElementById("iedit_login").value;
701 var auth_pass = document.getElementById("iedit_pass").value;
702
703 active_feed = false;
704
705 notify("Saving feed...");
706
707 var query = "op=pref-feeds&subop=editSave&id=" +
708 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
709 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
710 "&catid=" + param_escape(fcat_id) + "&login=" + param_escape(auth_login) +
711 "&pass=" + param_escape(auth_pass);
712
713 xmlhttp.open("POST", "backend.php", true);
714 xmlhttp.onreadystatechange=feedlist_callback;
715 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
716 xmlhttp.send(query);
717
718 } catch (e) {
719 exception_error("feedEditSave", e);
720 }
721 }
722
723 function feedCatEditSave() {
724
725 if (!xmlhttp_ready(xmlhttp)) {
726 printLockingError();
727 return
728 }
729
730 notify("Saving category...");
731
732 var cat_title = document.getElementById("iedit_title").value;
733
734 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=saveCat&id=" +
735 param_escape(active_feed_cat) + "&title=" + param_escape(cat_title),
736 true);
737 xmlhttp.onreadystatechange=feedlist_callback;
738 xmlhttp.send(null);
739
740 active_feed_cat = false;
741
742 }
743
744
745 function labelTest() {
746
747 var sqlexp = document.getElementById("iedit_expr").value;
748 var descr = document.getElementById("iedit_descr").value;
749
750 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
751 param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
752
753 xmlhttp.onreadystatechange=infobox_callback;
754 xmlhttp.send(null);
755
756 }
757
758 function displayHelpInfobox(topic_id) {
759
760 xmlhttp.open("GET", "backend.php?op=help&tid=" +
761 param_escape(topic_id) + "&noheaders=1", true);
762
763 xmlhttp.onreadystatechange=infobox_callback;
764 xmlhttp.send(null);
765
766 }
767
768 function labelEditCancel() {
769
770 if (!xmlhttp_ready(xmlhttp)) {
771 printLockingError();
772 return
773 }
774
775 active_label = false;
776
777 notify("Operation cancelled.");
778
779 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
780 xmlhttp.onreadystatechange=labellist_callback;
781 xmlhttp.send(null);
782
783 }
784
785 function userEditCancel() {
786
787 if (!xmlhttp_ready(xmlhttp)) {
788 printLockingError();
789 return
790 }
791
792 active_user = false;
793
794 notify("Operation cancelled.");
795
796 xmlhttp.open("GET", "backend.php?op=pref-users", true);
797 xmlhttp.onreadystatechange=userlist_callback;
798 xmlhttp.send(null);
799
800 }
801
802 function filterEditCancel() {
803
804 if (!xmlhttp_ready(xmlhttp)) {
805 printLockingError();
806 return
807 }
808
809 active_filter = false;
810
811 notify("Operation cancelled.");
812
813 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
814 xmlhttp.onreadystatechange=filterlist_callback;
815 xmlhttp.send(null);
816
817 }
818
819 function labelEditSave() {
820
821 var label = active_label;
822
823 if (!xmlhttp_ready(xmlhttp)) {
824 printLockingError();
825 return
826 }
827
828 var sqlexp = document.getElementById("iedit_expr").value;
829 var descr = document.getElementById("iedit_descr").value;
830
831 // notify("Saving label " + sqlexp + ": " + descr);
832
833 if (sqlexp.length == 0) {
834 notify("SQL expression cannot be blank.");
835 return;
836 }
837
838 if (descr.length == 0) {
839 notify("Caption cannot be blank.");
840 return;
841 }
842
843 notify("Saving label...");
844
845 active_label = false;
846
847 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
848 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
849 true);
850
851 xmlhttp.onreadystatechange=labellist_callback;
852 xmlhttp.send(null);
853
854 }
855
856 function userEditSave() {
857
858 var user = active_user;
859
860 if (!xmlhttp_ready(xmlhttp)) {
861 printLockingError();
862 return
863 }
864
865 var login = document.getElementById("iedit_ulogin").value;
866 var level = document.getElementById("iedit_ulevel").value;
867 var email = document.getElementById("iedit_email").value;
868
869 if (login.length == 0) {
870 notify("Login cannot be blank.");
871 return;
872 }
873
874 if (level.length == 0) {
875 notify("User level cannot be blank.");
876 return;
877 }
878
879 active_user = false;
880
881 notify("Saving user...");
882
883 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
884 user + "&l=" + param_escape(login) + "&al=" + param_escape(level) +
885 "&e=" + param_escape(email), true);
886
887 xmlhttp.onreadystatechange=userlist_callback;
888 xmlhttp.send(null);
889
890 }
891
892
893 function filterEditSave() {
894
895 var filter = active_filter;
896
897 if (!xmlhttp_ready(xmlhttp)) {
898 printLockingError();
899 return
900 }
901
902 var regexp = document.getElementById("iedit_regexp").value;
903 var descr = document.getElementById("iedit_descr").value;
904 var match = document.getElementById("iedit_match");
905
906 var v_match = match[match.selectedIndex].text;
907
908 var feed = document.getElementById("iedit_feed");
909 var feed_id = feed[feed.selectedIndex].id;
910
911 var action = document.getElementById("iedit_filter_action");
912 var action_id = action[action.selectedIndex].id;
913
914 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
915
916 if (regexp.length == 0) {
917 notify("Filter expression cannot be blank.");
918 return;
919 }
920
921 active_filter = false;
922
923 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
924 filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
925 "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id) +
926 "&aid=" + param_escape(action_id), true);
927
928 notify("Saving filter...");
929
930 xmlhttp.onreadystatechange=filterlist_callback;
931 xmlhttp.send(null);
932
933 }
934
935 function editSelectedLabel() {
936 var rows = getSelectedLabels();
937
938 if (rows.length == 0) {
939 notify("No labels are selected.");
940 return;
941 }
942
943 if (rows.length > 1) {
944 notify("Please select one label.");
945 return;
946 }
947
948 notify("");
949
950 editLabel(rows[0]);
951
952 }
953
954 function editSelectedUser() {
955 var rows = getSelectedUsers();
956
957 if (rows.length == 0) {
958 notify("No users are selected.");
959 return;
960 }
961
962 if (rows.length > 1) {
963 notify("Please select one user.");
964 return;
965 }
966
967 notify("");
968
969 editUser(rows[0]);
970 }
971
972 function resetSelectedUserPass() {
973 var rows = getSelectedUsers();
974
975 if (rows.length == 0) {
976 notify("No users are selected.");
977 return;
978 }
979
980 if (rows.length > 1) {
981 notify("Please select one user.");
982 return;
983 }
984
985 var ok = confirm("Reset password of selected user?");
986
987 if (ok) {
988 notify("Resetting password for selected user...");
989
990 var id = rows[0];
991
992 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
993 param_escape(id), true);
994 xmlhttp.onreadystatechange=userlist_callback;
995 xmlhttp.send(null);
996 }
997 }
998
999 function selectedUserDetails() {
1000
1001 if (!xmlhttp_ready(xmlhttp)) {
1002 printLockingError();
1003 return
1004 }
1005
1006 var rows = getSelectedUsers();
1007
1008 if (rows.length == 0) {
1009 notify("No users are selected.");
1010 return;
1011 }
1012
1013 if (rows.length > 1) {
1014 notify("Please select one user.");
1015 return;
1016 }
1017
1018 var id = rows[0];
1019
1020 notify("");
1021
1022 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
1023 xmlhttp.onreadystatechange=infobox_callback;
1024 xmlhttp.send(null);
1025
1026 }
1027
1028 function selectedFeedDetails() {
1029
1030 if (!xmlhttp_ready(xmlhttp)) {
1031 printLockingError();
1032 return
1033 }
1034
1035 var rows = getSelectedFeeds();
1036
1037 if (rows.length == 0) {
1038 notify("No feeds are selected.");
1039 return;
1040 }
1041
1042 // if (rows.length > 1) {
1043 // notify("Please select one feed.");
1044 // return;
1045 // }
1046
1047 // var id = rows[0];
1048
1049 notify("");
1050
1051 xmlhttp.open("GET", "backend.php?op=feed-details&id=" +
1052 param_escape(rows.toString()), true);
1053 xmlhttp.onreadystatechange=infobox_callback;
1054 xmlhttp.send(null);
1055
1056 }
1057
1058 function editSelectedFilter() {
1059 var rows = getSelectedFilters();
1060
1061 if (rows.length == 0) {
1062 notify("No filters are selected.");
1063 return;
1064 }
1065
1066 if (rows.length > 1) {
1067 notify("Please select one filter.");
1068 return;
1069 }
1070
1071 notify("");
1072
1073 editFilter(rows[0]);
1074
1075 }
1076
1077
1078 function editSelectedFeed() {
1079 var rows = getSelectedFeeds();
1080
1081 if (rows.length == 0) {
1082 notify("No feeds are selected.");
1083 return;
1084 }
1085
1086 if (rows.length > 1) {
1087 notify("Please select one feed.");
1088 return;
1089 }
1090
1091 notify("");
1092
1093 editFeed(rows[0]);
1094
1095 }
1096
1097 function editSelectedFeedCat() {
1098 var rows = getSelectedFeedCats();
1099
1100 if (rows.length == 0) {
1101 notify("No categories are selected.");
1102 return;
1103 }
1104
1105 if (rows.length > 1) {
1106 notify("Please select one category.");
1107 return;
1108 }
1109
1110 notify("");
1111
1112 editFeedCat(rows[0]);
1113
1114 }
1115
1116 function localPiggieFunction(enable) {
1117 if (enable) {
1118 piggie.style.display = "block";
1119 seq = "";
1120 notify("I loveded it!!!");
1121 } else {
1122 piggie.style.display = "none";
1123 notify("");
1124 }
1125 }
1126
1127 function validateOpmlImport() {
1128
1129 var opml_file = document.getElementById("opml_file");
1130
1131 if (opml_file.value.length == 0) {
1132 notify("Please select OPML file to upload.");
1133 return false;
1134 } else {
1135 return true;
1136 }
1137 }
1138
1139 function updateFilterList() {
1140
1141 if (!xmlhttp_ready(xmlhttp)) {
1142 printLockingError();
1143 return
1144 }
1145
1146 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1147
1148 p_notify("Loading, please wait...");
1149
1150 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1151 xmlhttp.onreadystatechange=filterlist_callback;
1152 xmlhttp.send(null);
1153
1154 }
1155
1156 function updateLabelList() {
1157
1158 if (!xmlhttp_ready(xmlhttp)) {
1159 printLockingError();
1160 return
1161 }
1162
1163 p_notify("Loading, please wait...");
1164
1165 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1166
1167 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1168 xmlhttp.onreadystatechange=labellist_callback;
1169 xmlhttp.send(null);
1170 }
1171
1172 function updatePrefsList() {
1173
1174 if (!xmlhttp_ready(xmlhttp)) {
1175 printLockingError();
1176 return
1177 }
1178
1179 p_notify("Loading, please wait...");
1180
1181 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1182 xmlhttp.onreadystatechange=prefslist_callback;
1183 xmlhttp.send(null);
1184
1185 }
1186
1187 function selectTab(id) {
1188
1189 if (!xmlhttp_ready(xmlhttp)) {
1190 printLockingError();
1191 return
1192 }
1193
1194 if (id == "feedConfig") {
1195 updateFeedList();
1196 } else if (id == "filterConfig") {
1197 updateFilterList();
1198 } else if (id == "labelConfig") {
1199 updateLabelList();
1200 } else if (id == "genConfig") {
1201 updatePrefsList();
1202 } else if (id == "userConfig") {
1203 updateUsersList();
1204 }
1205
1206 var tab = document.getElementById(active_tab + "Tab");
1207
1208 if (tab) {
1209 if (tab.className.match("Selected")) {
1210 tab.className = "prefsTab";
1211 }
1212 }
1213
1214 tab = document.getElementById(id + "Tab");
1215
1216 if (tab) {
1217 if (!tab.className.match("Selected")) {
1218 tab.className = tab.className + "Selected";
1219 }
1220 }
1221
1222 active_tab = id;
1223
1224 setCookie('ttrss_pref_acttab', active_tab);
1225
1226 }
1227
1228 function init() {
1229
1230 try {
1231
1232 // IE kludge
1233 if (!xmlhttp) {
1234 document.getElementById("prefContent").innerHTML =
1235 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1236 "to function properly. Your browser doesn't seem to support it.";
1237 return;
1238 }
1239
1240 active_tab = getCookie("ttrss_pref_acttab");
1241 if (!active_tab) active_tab = "genConfig";
1242 selectTab(active_tab);
1243
1244 document.onkeydown = hotkey_handler;
1245 notify("");
1246 } catch (e) {
1247 exception_error("init", e);
1248 }
1249 }
1250
1251 function closeInfoBox() {
1252 var box = document.getElementById('infoBox');
1253 var shadow = document.getElementById('infoBoxShadow');
1254
1255 if (shadow) {
1256 shadow.style.display = "none";
1257 } else if (box) {
1258 box.style.display = "none";
1259 }
1260 }
1261
1262 function categorizeSelectedFeeds() {
1263
1264 if (!xmlhttp_ready(xmlhttp)) {
1265 printLockingError();
1266 return
1267 }
1268
1269 var sel_rows = getSelectedFeeds();
1270
1271 var cat_sel = document.getElementById("sfeed_set_fcat");
1272 var cat_id = cat_sel[cat_sel.selectedIndex].id;
1273
1274 if (sel_rows.length > 0) {
1275
1276 notify("Changing category of selected feeds...");
1277
1278 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1279 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1280 xmlhttp.onreadystatechange=feedlist_callback;
1281 xmlhttp.send(null);
1282
1283 } else {
1284
1285 notify("Please select some feeds first.");
1286
1287 }
1288
1289 }
1290
1291 function validatePrefsReset() {
1292 return confirm("Reset to defaults?");
1293 }