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