]> git.wh0rd.org - tt-rss.git/blob - prefs.js
interface tweaks
[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 var active_tab = false;
9 var feed_to_expand = false;
10
11 var piggie_top = -400;
12 var piggie_fwd = true;
13
14 /*@cc_on @*/
15 /*@if (@_jscript_version >= 5)
16 // JScript gives us Conditional compilation, we can cope with old IE versions.
17 // and security blocked creation of the objects.
18 try {
19 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
20 } catch (e) {
21 try {
22 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
23 } catch (E) {
24 xmlhttp = false;
25 }
26 }
27 @end @*/
28
29 if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
30 xmlhttp = new XMLHttpRequest();
31 }
32
33 function expand_feed_callback() {
34 if (xmlhttp.readyState == 4) {
35 try {
36 var container = document.getElementById("BRDET-" + feed_to_expand);
37 container.innerHTML=xmlhttp.responseText;
38 container.style.display = "block";
39 p_notify("");
40 } catch (e) {
41 exception_error("expand_feed_callback", e);
42 }
43 }
44 }
45
46 function feedlist_callback() {
47 if (xmlhttp.readyState == 4) {
48 try {
49 var container = document.getElementById('prefContent');
50 container.innerHTML=xmlhttp.responseText;
51 selectTab("feedConfig", true);
52
53 if (active_feed) {
54 var row = document.getElementById("FEEDR-" + active_feed);
55 if (row) {
56 if (!row.className.match("Selected")) {
57 row.className = row.className + "Selected";
58 }
59 }
60 var checkbox = document.getElementById("FRCHK-" + active_feed);
61 if (checkbox) {
62 checkbox.checked = true;
63 }
64 }
65 p_notify("");
66 } catch (e) {
67 exception_error("feedlist_callback", e);
68 }
69 }
70 }
71
72 function filterlist_callback() {
73 var container = document.getElementById('prefContent');
74 if (xmlhttp.readyState == 4) {
75
76 container.innerHTML=xmlhttp.responseText;
77
78 if (active_filter) {
79 var row = document.getElementById("FILRR-" + active_filter);
80 if (row) {
81 if (!row.className.match("Selected")) {
82 row.className = row.className + "Selected";
83 }
84 }
85 var checkbox = document.getElementById("FICHK-" + active_filter);
86
87 if (checkbox) {
88 checkbox.checked = true;
89 }
90 }
91 p_notify("");
92 }
93 }
94
95 function labellist_callback() {
96 var container = document.getElementById('prefContent');
97 if (xmlhttp.readyState == 4) {
98 container.innerHTML=xmlhttp.responseText;
99
100 if (active_label) {
101 var row = document.getElementById("LILRR-" + active_label);
102 if (row) {
103 if (!row.className.match("Selected")) {
104 row.className = row.className + "Selected";
105 }
106 }
107 var checkbox = document.getElementById("LICHK-" + active_label);
108
109 if (checkbox) {
110 checkbox.checked = true;
111 }
112 }
113 p_notify("");
114 }
115 }
116
117 function feed_browser_callback() {
118 var container = document.getElementById('prefContent');
119 if (xmlhttp.readyState == 4) {
120 container.innerHTML=xmlhttp.responseText;
121 p_notify("");
122 }
123 }
124
125 function userlist_callback() {
126 var container = document.getElementById('prefContent');
127 if (xmlhttp.readyState == 4) {
128 container.innerHTML=xmlhttp.responseText;
129
130 if (active_user) {
131 var row = document.getElementById("UMRR-" + active_user);
132 if (row) {
133 if (!row.className.match("Selected")) {
134 row.className = row.className + "Selected";
135 }
136 }
137 var checkbox = document.getElementById("UMCHK-" + active_user);
138
139 if (checkbox) {
140 checkbox.checked = true;
141 }
142 }
143
144 p_notify("");
145 }
146 }
147
148 function prefslist_callback() {
149 var container = document.getElementById('prefContent');
150 if (xmlhttp.readyState == 4) {
151
152 container.innerHTML=xmlhttp.responseText;
153
154 p_notify("");
155 }
156 }
157
158 function gethelp_callback() {
159 var container = document.getElementById('prefHelpBox');
160 if (xmlhttp.readyState == 4) {
161
162 container.innerHTML = xmlhttp.responseText;
163 container.style.display = "block";
164
165 }
166 }
167
168
169 function notify_callback() {
170 var container = document.getElementById('notify');
171 if (xmlhttp.readyState == 4) {
172 container.innerHTML=xmlhttp.responseText;
173 }
174 }
175
176 function updateFeedList(sort_key) {
177
178 if (!xmlhttp_ready(xmlhttp)) {
179 printLockingError();
180 return
181 }
182
183 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
184
185 p_notify("Loading, please wait...");
186
187 var feed_search = document.getElementById("feed_search");
188 var search = "";
189 if (feed_search) { search = feed_search.value; }
190
191 xmlhttp.open("GET", "backend.php?op=pref-feeds" +
192 "&sort=" + param_escape(sort_key) +
193 "&search=" + param_escape(search), true);
194 xmlhttp.onreadystatechange=feedlist_callback;
195 xmlhttp.send(null);
196
197 }
198
199 function updateUsersList() {
200
201 if (!xmlhttp_ready(xmlhttp)) {
202 printLockingError();
203 return
204 }
205
206 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
207
208 p_notify("Loading, please wait...");
209
210 xmlhttp.open("GET", "backend.php?op=pref-users", true);
211 xmlhttp.onreadystatechange=userlist_callback;
212 xmlhttp.send(null);
213
214 }
215
216 function 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 alert("Can't add label: 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
241 function 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");
250 var feed = document.getElementById("fadd_feed");
251 var action = document.getElementById("fadd_action");
252
253 if (regexp.value.length == 0) {
254 alert("Can't add filter: missing filter expression.");
255 } else {
256 notify("Adding filter...");
257
258 var v_match = match[match.selectedIndex].text;
259 var feed_id = feed[feed.selectedIndex].id;
260 var action_id = action[action.selectedIndex].id;
261
262 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add&regexp=" +
263 param_escape(regexp.value) + "&match=" + v_match +
264 "&fid=" + param_escape(feed_id) + "&aid=" + param_escape(action_id), true);
265
266 xmlhttp.onreadystatechange=filterlist_callback;
267 xmlhttp.send(null);
268
269 regexp.value = "";
270 }
271
272 }
273
274 function addFeed() {
275
276 if (!xmlhttp_ready(xmlhttp)) {
277 printLockingError();
278 return
279 }
280
281 var link = document.getElementById("fadd_link");
282
283 if (link.value.length == 0) {
284 alert("Error: No feed URL given.");
285 } else {
286 notify("Adding feed...");
287
288 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
289 param_escape(link.value), true);
290 xmlhttp.onreadystatechange=feedlist_callback;
291 xmlhttp.send(null);
292
293 link.value = "";
294
295 }
296
297 }
298
299 function addFeedCat() {
300
301 if (!xmlhttp_ready(xmlhttp)) {
302 printLockingError();
303 return
304 }
305
306 var cat = document.getElementById("fadd_cat");
307
308 if (cat.value.length == 0) {
309 alert("Can't add category: no name specified.");
310 } else {
311 notify("Adding feed category...");
312
313 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
314 param_escape(cat.value), true);
315 xmlhttp.onreadystatechange=feedlist_callback;
316 xmlhttp.send(null);
317
318 link.value = "";
319
320 }
321
322 }
323 function addUser() {
324
325 if (!xmlhttp_ready(xmlhttp)) {
326 printLockingError();
327 return
328 }
329
330 var sqlexp = document.getElementById("uadd_box");
331
332 if (sqlexp.value.length == 0) {
333 alert("Can't add user: no login specified.");
334 } else {
335 notify("Adding user...");
336
337 xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
338 param_escape(sqlexp.value), true);
339
340 xmlhttp.onreadystatechange=userlist_callback;
341 xmlhttp.send(null);
342
343 sqlexp.value = "";
344 }
345
346 }
347
348 function editLabel(id) {
349
350 if (!xmlhttp_ready(xmlhttp)) {
351 printLockingError();
352 return
353 }
354
355 active_label = id;
356
357 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
358 param_escape(id), true);
359 xmlhttp.onreadystatechange=labellist_callback;
360 xmlhttp.send(null);
361
362 }
363
364 function editUser(id) {
365
366 if (!xmlhttp_ready(xmlhttp)) {
367 printLockingError();
368 return
369 }
370
371 active_user = id;
372
373 xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
374 param_escape(id), true);
375 xmlhttp.onreadystatechange=userlist_callback;
376 xmlhttp.send(null);
377
378 }
379
380 function editFilter(id) {
381
382 if (!xmlhttp_ready(xmlhttp)) {
383 printLockingError();
384 return
385 }
386
387 active_filter = id;
388
389 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
390 param_escape(id), true);
391 xmlhttp.onreadystatechange=filterlist_callback;
392 xmlhttp.send(null);
393
394 }
395
396 function editFeed(feed) {
397
398 // notify("Editing feed...");
399
400 if (!xmlhttp_ready(xmlhttp)) {
401 printLockingError();
402 return
403 }
404
405 active_feed = feed;
406
407 /* xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
408 param_escape(feed), true);
409 xmlhttp.onreadystatechange=feedlist_callback;
410 xmlhttp.send(null); */
411
412 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
413 // selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-'+feed, 'FRCHK-'+feed,
414 // true, false);
415
416 selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
417
418 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
419 param_escape(active_feed), true);
420
421 xmlhttp.onreadystatechange=infobox_callback;
422 xmlhttp.send(null);
423
424 }
425
426 function editFeedCat(cat) {
427
428 if (!xmlhttp_ready(xmlhttp)) {
429 printLockingError();
430 return
431 }
432
433 active_feed_cat = cat;
434
435 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
436 param_escape(cat), true);
437 xmlhttp.onreadystatechange=feedlist_callback;
438 xmlhttp.send(null);
439
440 }
441
442 function getSelectedLabels() {
443 return getSelectedTableRowIds("prefLabelList", "LILRR");
444 }
445
446 function getSelectedUsers() {
447 return getSelectedTableRowIds("prefUserList", "UMRR");
448 }
449
450 function getSelectedFeeds() {
451 return getSelectedTableRowIds("prefFeedList", "FEEDR");
452 }
453
454 function getSelectedFilters() {
455 return getSelectedTableRowIds("prefFilterList", "FILRR");
456 }
457
458 function getSelectedFeedCats() {
459 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
460 }
461
462
463 /*function readSelectedFeeds(read) {
464
465 if (!xmlhttp_ready(xmlhttp)) {
466 printLockingError();
467 return
468 }
469
470 var sel_rows = getSelectedFeeds();
471
472 if (sel_rows.length > 0) {
473
474 if (!read) {
475 op = "unread";
476 } else {
477 op = "read";
478 }
479
480 notify("Marking selected feeds as " + op + "...");
481
482 xmlhttp.open("GET", "backend.php?op=pref-rpc&subop=" + op + "&ids="+
483 param_escape(sel_rows.toString()), true);
484 xmlhttp.onreadystatechange=notify_callback;
485 xmlhttp.send(null);
486
487 } else {
488
489 alert("No feeds are selected.");
490
491 }
492 } */
493
494 function removeSelectedLabels() {
495
496 if (!xmlhttp_ready(xmlhttp)) {
497 printLockingError();
498 return
499 }
500
501 var sel_rows = getSelectedLabels();
502
503 if (sel_rows.length > 0) {
504
505 var ok = confirm("Remove selected labels?");
506
507 if (ok) {
508 notify("Removing selected labels...");
509
510 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
511 param_escape(sel_rows.toString()), true);
512 xmlhttp.onreadystatechange=labellist_callback;
513 xmlhttp.send(null);
514 }
515 } else {
516 alert("No labels are selected.");
517 }
518 }
519
520 function removeSelectedUsers() {
521
522 if (!xmlhttp_ready(xmlhttp)) {
523 printLockingError();
524 return
525 }
526
527 var sel_rows = getSelectedUsers();
528
529 if (sel_rows.length > 0) {
530
531 var ok = confirm("Remove selected users?");
532
533 if (ok) {
534 notify("Removing selected users...");
535
536 xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
537 param_escape(sel_rows.toString()), true);
538 xmlhttp.onreadystatechange=userlist_callback;
539 xmlhttp.send(null);
540 }
541
542 } else {
543 alert("No users are selected.");
544 }
545 }
546
547 function removeSelectedFilters() {
548
549 if (!xmlhttp_ready(xmlhttp)) {
550 printLockingError();
551 return
552 }
553
554 var sel_rows = getSelectedFilters();
555
556 if (sel_rows.length > 0) {
557
558 var ok = confirm("Remove selected filters?");
559
560 if (ok) {
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 alert("No filters are selected.");
570 }
571 }
572
573
574 function removeSelectedFeeds() {
575
576 if (!xmlhttp_ready(xmlhttp)) {
577 printLockingError();
578 return
579 }
580
581 var sel_rows = getSelectedFeeds();
582
583 if (sel_rows.length > 0) {
584
585 var ok = confirm("Remove selected feeds?");
586
587 if (ok) {
588
589 notify("Removing selected feeds...");
590
591 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
592 param_escape(sel_rows.toString()), true);
593 xmlhttp.onreadystatechange=feedlist_callback;
594 xmlhttp.send(null);
595 }
596
597 } else {
598
599 alert("No feeds are selected.");
600
601 }
602
603 }
604
605 function removeSelectedFeedCats() {
606
607 if (!xmlhttp_ready(xmlhttp)) {
608 printLockingError();
609 return
610 }
611
612 var sel_rows = getSelectedFeedCats();
613
614 if (sel_rows.length > 0) {
615
616 var ok = confirm("Remove selected categories?");
617
618 if (ok) {
619 notify("Removing selected categories...");
620
621 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
622 param_escape(sel_rows.toString()), true);
623 xmlhttp.onreadystatechange=feedlist_callback;
624 xmlhttp.send(null);
625 }
626
627 } else {
628
629 alert("No categories are selected.");
630
631 }
632
633 }
634
635 function feedEditCancel() {
636
637 if (!xmlhttp_ready(xmlhttp)) {
638 printLockingError();
639 return
640 }
641
642 closeInfoBox();
643
644 active_feed = false;
645
646 // notify("Operation cancelled.");
647
648 /* xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
649 xmlhttp.onreadystatechange=feedlist_callback;
650 xmlhttp.send(null); */
651
652 }
653
654 function feedCatEditCancel() {
655
656 if (!xmlhttp_ready(xmlhttp)) {
657 printLockingError();
658 return
659 }
660
661 active_feed_cat = false;
662
663 // notify("Operation cancelled.");
664
665 xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
666 xmlhttp.onreadystatechange=feedlist_callback;
667 xmlhttp.send(null);
668
669 }
670
671 function feedEditSave() {
672
673 try {
674
675 var feed = active_feed;
676
677 if (!xmlhttp_ready(xmlhttp)) {
678 printLockingError();
679 return
680 }
681
682 var link = document.getElementById("iedit_link").value;
683 var title = document.getElementById("iedit_title").value;
684 var upd_intl = document.getElementById("iedit_updintl");
685
686 upd_intl = upd_intl[upd_intl.selectedIndex].id;
687
688 var purge_intl = document.getElementById("iedit_purgintl");
689
690 purge_intl = purge_intl[purge_intl.selectedIndex].id;
691
692 var fcat = document.getElementById("iedit_fcat");
693
694 var is_pvt = document.getElementById("iedit_private");
695 var is_rtl = document.getElementById("iedit_rtl");
696
697 if (is_pvt) {
698 is_pvt = is_pvt.checked;
699 }
700
701 if (is_rtl) {
702 is_rtl = is_rtl.checked;
703 }
704
705 var fcat_id = 0;
706
707 if (fcat) {
708 fcat_id = fcat[fcat.selectedIndex].id;
709 }
710
711 var pfeed = document.getElementById("iedit_parent_feed");
712 var parent_feed_id = pfeed[pfeed.selectedIndex].id;
713
714 if (link.length == 0) {
715 notify("Feed link cannot be blank.");
716 return;
717 }
718
719 if (title.length == 0) {
720 notify("Feed title cannot be blank.");
721 return;
722 }
723
724 var auth_login = document.getElementById("iedit_login").value;
725 var auth_pass = document.getElementById("iedit_pass").value;
726
727 active_feed = false;
728
729 notify("Saving feed...");
730
731 var query = "op=pref-feeds&subop=editSave&id=" +
732 feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
733 "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
734 "&catid=" + param_escape(fcat_id) + "&login=" + param_escape(auth_login) +
735 "&pfeed=" + param_escape(parent_feed_id) + "&pass=" + param_escape(auth_pass) +
736 "&is_pvt=" + param_escape(is_pvt) + "&is_rtl=" + param_escape(is_rtl);
737
738 xmlhttp.open("POST", "backend.php", true);
739 xmlhttp.onreadystatechange=feedlist_callback;
740 xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
741 xmlhttp.send(query);
742
743 } catch (e) {
744 exception_error("feedEditSave", e);
745 }
746 }
747
748 function feedCatEditSave() {
749
750 if (!xmlhttp_ready(xmlhttp)) {
751 printLockingError();
752 return
753 }
754
755 notify("Saving category...");
756
757 var cat_title = document.getElementById("iedit_title").value;
758
759 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=saveCat&id=" +
760 param_escape(active_feed_cat) + "&title=" + param_escape(cat_title),
761 true);
762 xmlhttp.onreadystatechange=feedlist_callback;
763 xmlhttp.send(null);
764
765 active_feed_cat = false;
766
767 }
768
769
770 function labelTest() {
771
772 var sqlexp = document.getElementById("iedit_expr").value;
773 var descr = document.getElementById("iedit_descr").value;
774
775 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
776 param_escape(sqlexp) + "&descr=" + param_escape(descr), true);
777
778 xmlhttp.onreadystatechange=infobox_callback;
779 xmlhttp.send(null);
780
781 }
782
783 function displayHelpInfobox(topic_id) {
784
785 xmlhttp.open("GET", "backend.php?op=help&tid=" +
786 param_escape(topic_id) + "&noheaders=1", true);
787
788 xmlhttp.onreadystatechange=infobox_callback;
789 xmlhttp.send(null);
790
791 }
792
793 function labelEditCancel() {
794
795 if (!xmlhttp_ready(xmlhttp)) {
796 printLockingError();
797 return
798 }
799
800 active_label = false;
801
802 // notify("Operation cancelled.");
803
804 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
805 xmlhttp.onreadystatechange=labellist_callback;
806 xmlhttp.send(null);
807
808 }
809
810 function userEditCancel() {
811
812 if (!xmlhttp_ready(xmlhttp)) {
813 printLockingError();
814 return
815 }
816
817 active_user = false;
818
819 // notify("Operation cancelled.");
820
821 xmlhttp.open("GET", "backend.php?op=pref-users", true);
822 xmlhttp.onreadystatechange=userlist_callback;
823 xmlhttp.send(null);
824
825 }
826
827 function filterEditCancel() {
828
829 if (!xmlhttp_ready(xmlhttp)) {
830 printLockingError();
831 return
832 }
833
834 active_filter = false;
835
836 // notify("Operation cancelled.");
837
838 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
839 xmlhttp.onreadystatechange=filterlist_callback;
840 xmlhttp.send(null);
841
842 }
843
844 function labelEditSave() {
845
846 var label = active_label;
847
848 if (!xmlhttp_ready(xmlhttp)) {
849 printLockingError();
850 return
851 }
852
853 var sqlexp = document.getElementById("iedit_expr").value;
854 var descr = document.getElementById("iedit_descr").value;
855
856 // notify("Saving label " + sqlexp + ": " + descr);
857
858 if (sqlexp.length == 0) {
859 notify("SQL expression cannot be blank.");
860 return;
861 }
862
863 if (descr.length == 0) {
864 notify("Caption cannot be blank.");
865 return;
866 }
867
868 notify("Saving label...");
869
870 active_label = false;
871
872 xmlhttp.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
873 label + "&s=" + param_escape(sqlexp) + "&d=" + param_escape(descr),
874 true);
875
876 xmlhttp.onreadystatechange=labellist_callback;
877 xmlhttp.send(null);
878
879 }
880
881 function userEditSave() {
882
883 var user = active_user;
884
885 if (!xmlhttp_ready(xmlhttp)) {
886 printLockingError();
887 return
888 }
889
890 var login = document.getElementById("iedit_ulogin").value;
891 var level = document.getElementById("iedit_ulevel");
892
893 level = level[level.selectedIndex].id;
894
895 var email = document.getElementById("iedit_email").value;
896
897 if (login.length == 0) {
898 notify("Login cannot be blank.");
899 return;
900 }
901
902 if (level.length == 0) {
903 notify("User level cannot be blank.");
904 return;
905 }
906
907 active_user = false;
908
909 notify("Saving user...");
910
911 xmlhttp.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
912 user + "&l=" + param_escape(login) + "&al=" + param_escape(level) +
913 "&e=" + param_escape(email), true);
914
915 xmlhttp.onreadystatechange=userlist_callback;
916 xmlhttp.send(null);
917
918 }
919
920
921 function filterEditSave() {
922
923 var filter = active_filter;
924
925 if (!xmlhttp_ready(xmlhttp)) {
926 printLockingError();
927 return
928 }
929
930 var regexp = document.getElementById("iedit_regexp").value;
931 var match = document.getElementById("iedit_match");
932
933 var v_match = match[match.selectedIndex].text;
934
935 var feed = document.getElementById("iedit_feed");
936 var feed_id = feed[feed.selectedIndex].id;
937
938 var action = document.getElementById("iedit_filter_action");
939 var action_id = action[action.selectedIndex].id;
940
941 if (regexp.length == 0) {
942 alert("Can't save filter: match expression is blank.");
943 return;
944 }
945
946 active_filter = false;
947
948 xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
949 filter + "&r=" + param_escape(regexp) + "&m=" + param_escape(v_match) +
950 "&fid=" + param_escape(feed_id) + "&aid=" + param_escape(action_id), true);
951
952 notify("Saving filter...");
953
954 xmlhttp.onreadystatechange=filterlist_callback;
955 xmlhttp.send(null);
956
957 }
958
959 function editSelectedLabel() {
960 var rows = getSelectedLabels();
961
962 if (rows.length == 0) {
963 alert("No labels are selected.");
964 return;
965 }
966
967 if (rows.length > 1) {
968 alert("Please select only one label.");
969 return;
970 }
971
972 notify("");
973
974 editLabel(rows[0]);
975
976 }
977
978 function editSelectedUser() {
979 var rows = getSelectedUsers();
980
981 if (rows.length == 0) {
982 alert("No users are selected.");
983 return;
984 }
985
986 if (rows.length > 1) {
987 alert("Please select only one user.");
988 return;
989 }
990
991 notify("");
992
993 editUser(rows[0]);
994 }
995
996 function resetSelectedUserPass() {
997 var rows = getSelectedUsers();
998
999 if (rows.length == 0) {
1000 alert("No users are selected.");
1001 return;
1002 }
1003
1004 if (rows.length > 1) {
1005 alert("Please select only one user.");
1006 return;
1007 }
1008
1009 var ok = confirm("Reset password of selected user?");
1010
1011 if (ok) {
1012 notify("Resetting password for selected user...");
1013
1014 var id = rows[0];
1015
1016 xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1017 param_escape(id), true);
1018 xmlhttp.onreadystatechange=userlist_callback;
1019 xmlhttp.send(null);
1020 }
1021 }
1022
1023 function selectedUserDetails() {
1024
1025 if (!xmlhttp_ready(xmlhttp)) {
1026 printLockingError();
1027 return
1028 }
1029
1030 var rows = getSelectedUsers();
1031
1032 if (rows.length == 0) {
1033 alert("No users are selected.");
1034 return;
1035 }
1036
1037 if (rows.length > 1) {
1038 alert("Please select only one user.");
1039 return;
1040 }
1041
1042 var id = rows[0];
1043
1044 notify("");
1045
1046 xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
1047 xmlhttp.onreadystatechange=infobox_callback;
1048 xmlhttp.send(null);
1049
1050 }
1051
1052 function selectedFeedDetails() {
1053
1054 if (!xmlhttp_ready(xmlhttp)) {
1055 printLockingError();
1056 return
1057 }
1058
1059 var rows = getSelectedFeeds();
1060
1061 if (rows.length == 0) {
1062 alert("No feeds are selected.");
1063 return;
1064 }
1065
1066 if (rows.length > 1) {
1067 notify("Please select only one feed.");
1068 return;
1069 }
1070
1071 // var id = rows[0];
1072
1073 notify("");
1074
1075 xmlhttp.open("GET", "backend.php?op=feed-details&id=" +
1076 param_escape(rows.toString()), true);
1077 xmlhttp.onreadystatechange=infobox_callback;
1078 xmlhttp.send(null);
1079
1080 }
1081
1082 function editSelectedFilter() {
1083 var rows = getSelectedFilters();
1084
1085 if (rows.length == 0) {
1086 alert("No filters are selected.");
1087 return;
1088 }
1089
1090 if (rows.length > 1) {
1091 alert("Please select only one filter.");
1092 return;
1093 }
1094
1095 notify("");
1096
1097 editFilter(rows[0]);
1098
1099 }
1100
1101
1102 function editSelectedFeed() {
1103 var rows = getSelectedFeeds();
1104
1105 if (rows.length == 0) {
1106 notify("No feeds are selected.");
1107 return;
1108 }
1109
1110 if (rows.length > 1) {
1111 notify("Please select one feed.");
1112 return;
1113 }
1114
1115 notify("");
1116
1117 editFeed(rows[0]);
1118
1119 }
1120
1121 function editSelectedFeedCat() {
1122 var rows = getSelectedFeedCats();
1123
1124 if (rows.length == 0) {
1125 alert("No categories are selected.");
1126 return;
1127 }
1128
1129 if (rows.length > 1) {
1130 alert("Please select only one category.");
1131 return;
1132 }
1133
1134 notify("");
1135
1136 editFeedCat(rows[0]);
1137
1138 }
1139
1140 function piggie_callback() {
1141 var piggie = document.getElementById("piggie");
1142
1143 piggie.style.top = piggie_top;
1144 piggie.style.backgroundColor = "white";
1145 piggie.style.borderWidth = "1px";
1146
1147 if (piggie_fwd && piggie_top < 0) {
1148 setTimeout("piggie_callback()", 50);
1149 piggie_top = piggie_top + 10;
1150 } else if (piggie_fwd && piggie_top >= 0) {
1151 piggie_fwd = false;
1152 setTimeout("piggie_callback()", 50);
1153 } else if (!piggie_fwd && piggie_top > -400) {
1154 setTimeout("piggie_callback()", 50);
1155 piggie_top = piggie_top - 10;
1156 } else if (!piggie_fwd && piggie_top <= -400) {
1157 piggie.style.display = "none";
1158 piggie_fwd = true;
1159 }
1160 }
1161
1162 var piggie_opacity = 0;
1163
1164 function piggie2_callback() {
1165 var piggie = document.getElementById("piggie");
1166 piggie.style.top = 0;
1167 piggie.style.opacity = piggie_opacity;
1168 piggie.style.backgroundColor = "transparent";
1169 piggie.style.borderWidth = "0px";
1170
1171 if (piggie_fwd && piggie_opacity < 1) {
1172 setTimeout("piggie2_callback()", 50);
1173 piggie_opacity = piggie_opacity + 0.03;
1174 } else if (piggie_fwd && piggie_opacity >= 1) {
1175 piggie_fwd = false;
1176 setTimeout("piggie2_callback()", 50);
1177 } else if (!piggie_fwd && piggie_opacity > 0) {
1178 setTimeout("piggie2_callback()", 50);
1179 piggie_opacity = piggie_opacity - 0.03;
1180 } else if (!piggie_fwd && piggie_opacity <= 0) {
1181 piggie.style.display = "none";
1182 piggie_fwd = true;
1183 }
1184 }
1185
1186 function localPiggieFunction(enable) {
1187 if (enable) {
1188 var piggie = document.getElementById("piggie");
1189 piggie.style.display = "block";
1190
1191 if (navigator.userAgent.match("Firefox") && Math.random(1) > 0.5) {
1192 piggie2_callback();
1193 } else {
1194 piggie_callback();
1195 }
1196 }
1197 }
1198
1199 function validateOpmlImport() {
1200
1201 var opml_file = document.getElementById("opml_file");
1202
1203 if (opml_file.value.length == 0) {
1204 alert("No OPML file to upload.");
1205 return false;
1206 } else {
1207 return true;
1208 }
1209 }
1210
1211 function updateFilterList() {
1212
1213 if (!xmlhttp_ready(xmlhttp)) {
1214 printLockingError();
1215 return
1216 }
1217
1218 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1219
1220 p_notify("Loading, please wait...");
1221
1222 xmlhttp.open("GET", "backend.php?op=pref-filters", true);
1223 xmlhttp.onreadystatechange=filterlist_callback;
1224 xmlhttp.send(null);
1225
1226 }
1227
1228 function updateLabelList() {
1229
1230 if (!xmlhttp_ready(xmlhttp)) {
1231 printLockingError();
1232 return
1233 }
1234
1235 p_notify("Loading, please wait...");
1236
1237 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1238
1239 xmlhttp.open("GET", "backend.php?op=pref-labels", true);
1240 xmlhttp.onreadystatechange=labellist_callback;
1241 xmlhttp.send(null);
1242 }
1243
1244 function updatePrefsList() {
1245
1246 if (!xmlhttp_ready(xmlhttp)) {
1247 printLockingError();
1248 return
1249 }
1250
1251 p_notify("Loading, please wait...");
1252
1253 xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
1254 xmlhttp.onreadystatechange=prefslist_callback;
1255 xmlhttp.send(null);
1256
1257 }
1258
1259 function selectTab(id, noupdate) {
1260
1261 // alert(id);
1262
1263 if (!xmlhttp_ready(xmlhttp)) {
1264 printLockingError();
1265 return
1266 }
1267
1268 if (!noupdate) {
1269
1270 if (id == "feedConfig") {
1271 updateFeedList();
1272 } else if (id == "filterConfig") {
1273 updateFilterList();
1274 } else if (id == "labelConfig") {
1275 updateLabelList();
1276 } else if (id == "genConfig") {
1277 updatePrefsList();
1278 } else if (id == "userConfig") {
1279 updateUsersList();
1280 } else if (id == "feedBrowser") {
1281 updateBigFeedBrowser();
1282 }
1283 }
1284
1285 var tab = document.getElementById(active_tab + "Tab");
1286
1287 if (tab) {
1288 if (tab.className.match("Selected")) {
1289 tab.className = "prefsTab";
1290 }
1291 }
1292
1293 tab = document.getElementById(id + "Tab");
1294
1295 if (tab) {
1296 if (!tab.className.match("Selected")) {
1297 tab.className = tab.className + "Selected";
1298 }
1299 }
1300
1301 active_tab = id;
1302
1303 setCookie('ttrss_pref_acttab', active_tab);
1304
1305 }
1306
1307 function init() {
1308
1309 try {
1310
1311 if (arguments.callee.done) return;
1312 arguments.callee.done = true;
1313
1314 // IE kludge
1315 if (!xmlhttp) {
1316 document.getElementById("prefContent").innerHTML =
1317 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1318 "to function properly. Your browser doesn't seem to support it.";
1319 return;
1320 }
1321
1322 active_tab = getCookie("ttrss_pref_acttab");
1323 if (!active_tab) active_tab = "genConfig";
1324 selectTab(active_tab);
1325
1326 document.onkeydown = hotkey_handler;
1327 notify("");
1328 } catch (e) {
1329 exception_error("init", e);
1330 }
1331 }
1332
1333 function categorizeSelectedFeeds() {
1334
1335 if (!xmlhttp_ready(xmlhttp)) {
1336 printLockingError();
1337 return
1338 }
1339
1340 var sel_rows = getSelectedFeeds();
1341
1342 var cat_sel = document.getElementById("sfeed_set_fcat");
1343 var cat_id = cat_sel[cat_sel.selectedIndex].id;
1344
1345 if (sel_rows.length > 0) {
1346
1347 notify("Changing category of selected feeds...");
1348
1349 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1350 param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
1351 xmlhttp.onreadystatechange=feedlist_callback;
1352 xmlhttp.send(null);
1353
1354 } else {
1355
1356 alert("No feeds are selected.");
1357
1358 }
1359
1360 }
1361
1362 function validatePrefsReset() {
1363 return confirm("Reset to defaults?");
1364 }
1365
1366 function browseFeeds(limit) {
1367
1368 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1369 xmlhttp.onreadystatechange=infobox_callback;
1370 xmlhttp.send(null);
1371
1372 }
1373
1374 function feedBrowserSubscribe() {
1375 try {
1376 var list = document.getElementById("browseFeedList");
1377
1378 if (!list) list = document.getElementById("browseBigFeedList");
1379
1380 var selected = new Array();
1381
1382 for (i = 0; i < list.childNodes.length; i++) {
1383 var child = list.childNodes[i];
1384 if (child.id && child.id.match("FBROW-")) {
1385 var id = child.id.replace("FBROW-", "");
1386
1387 var cb = document.getElementById("FBCHK-" + id);
1388
1389 if (cb.checked) {
1390 selected.push(id);
1391 }
1392 }
1393 }
1394
1395 if (selected.length > 0) {
1396 closeInfoBox();
1397 xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1398 param_escape(selected.toString()), true);
1399 xmlhttp.onreadystatechange=feedlist_callback;
1400 xmlhttp.send(null);
1401 } else {
1402 alert("No feeds are selected.");
1403 }
1404
1405 } catch (e) {
1406 exception_error("feedBrowserSubscribe", e);
1407 }
1408 }
1409
1410 function updateBigFeedBrowser(limit) {
1411
1412 if (!xmlhttp_ready(xmlhttp)) {
1413 printLockingError();
1414 return
1415 }
1416
1417 p_notify("Loading, please wait...");
1418
1419 var query = "backend.php?op=pref-feed-browser";
1420
1421 var limit_sel = document.getElementById("feedBrowserLimit");
1422
1423 if (limit_sel) {
1424 var limit = limit_sel[limit_sel.selectedIndex].value;
1425 query = query + "&limit=" + param_escape(limit);
1426 }
1427
1428 xmlhttp.open("GET", query, true);
1429 xmlhttp.onreadystatechange=feed_browser_callback;
1430 xmlhttp.send(null);
1431 }
1432
1433 function browserToggleExpand(id) {
1434 try {
1435 /* if (feed_to_expand && feed_to_expand != id) {
1436 var d = document.getElementById("BRDET-" + feed_to_expand);
1437 d.style.display = "none";
1438 } */
1439
1440 var d = document.getElementById("BRDET-" + id);
1441
1442 if (d.style.display == "block") {
1443 d.style.display = "none";
1444
1445 } else {
1446
1447 feed_to_expand = id;
1448
1449 xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1450 + param_escape(id), true);
1451 xmlhttp.onreadystatechange=expand_feed_callback;
1452 xmlhttp.send(null);
1453 }
1454
1455 } catch (e) {
1456 exception_error("browserExpand", e);
1457 }
1458 }
1459
1460 function validateNewPassword(form) {
1461 if (form.OLD_PASSWORD.value == "") {
1462 alert("Current password cannot be blank");
1463 return false;
1464 }
1465 if (form.NEW_PASSWORD.value == "") {
1466 alert("New password cannot be blank");
1467 return false;
1468 }
1469 return true;
1470 }