]>
git.wh0rd.org - tt-rss.git/blob - prefs.js
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;
9 var active_tab
= false;
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.
16 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
19 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
26 if (!xmlhttp
&& typeof XMLHttpRequest
!='undefined') {
27 xmlhttp
= new XMLHttpRequest();
30 function feedlist_callback() {
31 if (xmlhttp
.readyState
== 4) {
32 var container
= document
.getElementById('prefContent');
33 container
.innerHTML
=xmlhttp
.responseText
;
35 var row
= document
.getElementById("FEEDR-" + active_feed
);
37 if (!row
.className
.match("Selected")) {
38 row
.className
= row
.className
+ "Selected";
41 var checkbox
= document
.getElementById("FRCHK-" + active_feed
);
43 checkbox
.checked
= true;
50 function filterlist_callback() {
51 var container
= document
.getElementById('prefContent');
52 if (xmlhttp
.readyState
== 4) {
54 container
.innerHTML
=xmlhttp
.responseText
;
57 var row
= document
.getElementById("FILRR-" + active_filter
);
59 if (!row
.className
.match("Selected")) {
60 row
.className
= row
.className
+ "Selected";
63 var checkbox
= document
.getElementById("FICHK-" + active_filter
);
66 checkbox
.checked
= true;
73 function labellist_callback() {
74 var container
= document
.getElementById('prefContent');
75 if (xmlhttp
.readyState
== 4) {
76 container
.innerHTML
=xmlhttp
.responseText
;
79 var row
= document
.getElementById("LILRR-" + active_label
);
81 if (!row
.className
.match("Selected")) {
82 row
.className
= row
.className
+ "Selected";
85 var checkbox
= document
.getElementById("LICHK-" + active_label
);
88 checkbox
.checked
= true;
95 function userlist_callback() {
96 var container
= document
.getElementById('prefContent');
97 if (xmlhttp
.readyState
== 4) {
98 container
.innerHTML
=xmlhttp
.responseText
;
101 var row
= document
.getElementById("UMRR-" + active_user
);
103 if (!row
.className
.match("Selected")) {
104 row
.className
= row
.className
+ "Selected";
107 var checkbox
= document
.getElementById("UMCHK-" + active_user
);
110 checkbox
.checked
= true;
118 function infobox_callback() {
119 if (xmlhttp
.readyState
== 4) {
120 var box
= document
.getElementById('infoBox');
121 var shadow
= document
.getElementById('infoBoxShadow');
124 box
.innerHTML
=xmlhttp
.responseText
;
126 shadow
.style
.display
= "block";
128 box
.style
.display
= "block";
135 function prefslist_callback() {
136 var container
= document
.getElementById('prefContent');
137 if (xmlhttp
.readyState
== 4) {
139 container
.innerHTML
=xmlhttp
.responseText
;
145 function gethelp_callback() {
146 var container
= document
.getElementById('prefHelpBox');
147 if (xmlhttp
.readyState
== 4) {
149 container
.innerHTML
= xmlhttp
.responseText
;
150 container
.style
.display
= "block";
156 function notify_callback() {
157 var container
= document
.getElementById('notify');
158 if (xmlhttp
.readyState
== 4) {
159 container
.innerHTML
=xmlhttp
.responseText
;
163 function updateFeedList(sort_key
) {
165 if (!xmlhttp_ready(xmlhttp
)) {
170 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
172 p_notify("Loading, please wait...");
174 var feed_search
= document
.getElementById("feed_search");
176 if (feed_search
) { search
= feed_search
.value
; }
178 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
179 "&sort=" + param_escape(sort_key
) +
180 "&search=" + param_escape(search
), true);
181 xmlhttp
.onreadystatechange
=feedlist_callback
;
186 function updateUsersList() {
188 if (!xmlhttp_ready(xmlhttp
)) {
193 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
195 p_notify("Loading, please wait...");
197 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
198 xmlhttp
.onreadystatechange
=userlist_callback
;
203 function addLabel() {
205 if (!xmlhttp_ready(xmlhttp
)) {
210 var sqlexp
= document
.getElementById("ladd_expr");
212 if (sqlexp
.value
.length
== 0) {
213 notify("Missing SQL expression.");
215 notify("Adding label...");
217 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
218 param_escape(sqlexp
.value
), true);
220 xmlhttp
.onreadystatechange
=labellist_callback
;
228 function addFilter() {
230 if (!xmlhttp_ready(xmlhttp
)) {
235 var regexp
= document
.getElementById("fadd_regexp");
236 var match
= document
.getElementById("fadd_match");
237 var feed
= document
.getElementById("fadd_feed");
239 if (regexp
.value
.length
== 0) {
240 notify("Missing filter expression.");
242 notify("Adding filter...");
244 var v_match
= match
[match
.selectedIndex
].text
;
246 var feed_id
= feed
[feed
.selectedIndex
].id
;
248 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
249 param_escape(regexp
.value
) + "&match=" + v_match
+
250 "&fid=" + param_escape(feed_id
), true);
252 xmlhttp
.onreadystatechange
=filterlist_callback
;
262 if (!xmlhttp_ready(xmlhttp
)) {
267 var link
= document
.getElementById("fadd_link");
269 if (link
.value
.length
== 0) {
270 notify("Missing feed URL.");
272 notify("Adding feed...");
274 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
275 param_escape(link
.value
), true);
276 xmlhttp
.onreadystatechange
=feedlist_callback
;
285 function addFeedCat() {
287 if (!xmlhttp_ready(xmlhttp
)) {
292 var cat
= document
.getElementById("fadd_cat");
294 if (cat
.value
.length
== 0) {
295 notify("Missing feed category.");
297 notify("Adding feed category...");
299 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
300 param_escape(cat
.value
), true);
301 xmlhttp
.onreadystatechange
=feedlist_callback
;
311 if (!xmlhttp_ready(xmlhttp
)) {
316 var sqlexp
= document
.getElementById("uadd_box");
318 if (sqlexp
.value
.length
== 0) {
319 notify("Missing user login.");
321 notify("Adding user...");
323 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
324 param_escape(sqlexp
.value
), true);
326 xmlhttp
.onreadystatechange
=userlist_callback
;
334 function editLabel(id
) {
336 if (!xmlhttp_ready(xmlhttp
)) {
343 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
344 param_escape(id
), true);
345 xmlhttp
.onreadystatechange
=labellist_callback
;
350 function editUser(id
) {
352 if (!xmlhttp_ready(xmlhttp
)) {
359 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
360 param_escape(id
), true);
361 xmlhttp
.onreadystatechange
=userlist_callback
;
366 function editFilter(id
) {
368 if (!xmlhttp_ready(xmlhttp
)) {
375 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
376 param_escape(id
), true);
377 xmlhttp
.onreadystatechange
=filterlist_callback
;
382 function editFeed(feed
) {
384 // notify("Editing feed...");
386 if (!xmlhttp_ready(xmlhttp
)) {
393 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
394 param_escape(feed
), true);
395 xmlhttp
.onreadystatechange
=feedlist_callback
;
400 function editFeedCat(cat
) {
402 if (!xmlhttp_ready(xmlhttp
)) {
407 active_feed_cat
= cat
;
409 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
410 param_escape(cat
), true);
411 xmlhttp
.onreadystatechange
=feedlist_callback
;
416 function getSelectedLabels() {
417 return getSelectedTableRowIds("prefLabelList", "LILRR");
420 function getSelectedUsers() {
421 return getSelectedTableRowIds("prefUserList", "UMRR");
424 function getSelectedFeeds() {
425 return getSelectedTableRowIds("prefFeedList", "FEEDR");
428 function getSelectedFilters() {
429 return getSelectedTableRowIds("prefFilterList", "FILRR");
432 function getSelectedFeedCats() {
433 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
437 function readSelectedFeeds(read
) {
439 if (!xmlhttp_ready(xmlhttp
)) {
444 var sel_rows
= getSelectedFeeds();
446 if (sel_rows
.length
> 0) {
454 notify("Marking selected feeds as " + op
+ "...");
456 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=" + op
+ "&ids="+
457 param_escape(sel_rows
.toString()), true);
458 xmlhttp
.onreadystatechange
=notify_callback
;
463 notify("Please select some feeds first.");
468 function removeSelectedLabels() {
470 if (!xmlhttp_ready(xmlhttp
)) {
475 var sel_rows
= getSelectedLabels();
477 if (sel_rows
.length
> 0) {
479 notify("Removing selected labels...");
481 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
482 param_escape(sel_rows
.toString()), true);
483 xmlhttp
.onreadystatechange
=labellist_callback
;
487 notify("Please select some labels first.");
491 function removeSelectedUsers() {
493 if (!xmlhttp_ready(xmlhttp
)) {
498 var sel_rows
= getSelectedUsers();
500 if (sel_rows
.length
> 0) {
502 notify("Removing selected users...");
504 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
505 param_escape(sel_rows
.toString()), true);
506 xmlhttp
.onreadystatechange
=userlist_callback
;
510 notify("Please select some labels first.");
514 function removeSelectedFilters() {
516 if (!xmlhttp_ready(xmlhttp
)) {
521 var sel_rows
= getSelectedFilters();
523 if (sel_rows
.length
> 0) {
525 notify("Removing selected filters...");
527 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
528 param_escape(sel_rows
.toString()), true);
529 xmlhttp
.onreadystatechange
=filterlist_callback
;
533 notify("Please select some filters first.");
538 function removeSelectedFeeds() {
540 if (!xmlhttp_ready(xmlhttp
)) {
545 var sel_rows
= getSelectedFeeds();
547 if (sel_rows
.length
> 0) {
549 notify("Removing selected feeds...");
551 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
552 param_escape(sel_rows
.toString()), true);
553 xmlhttp
.onreadystatechange
=feedlist_callback
;
558 notify("Please select some feeds first.");
564 function removeSelectedFeedCats() {
566 if (!xmlhttp_ready(xmlhttp
)) {
571 var sel_rows
= getSelectedFeedCats();
573 if (sel_rows
.length
> 0) {
575 notify("Removing selected categories...");
577 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
578 param_escape(sel_rows
.toString()), true);
579 xmlhttp
.onreadystatechange
=feedlist_callback
;
584 notify("Please select some feeds first.");
590 function feedEditCancel() {
592 if (!xmlhttp_ready(xmlhttp
)) {
599 notify("Operation cancelled.");
601 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
602 xmlhttp
.onreadystatechange
=feedlist_callback
;
607 function feedCatEditCancel() {
609 if (!xmlhttp_ready(xmlhttp
)) {
614 active_feed_cat
= false;
616 notify("Operation cancelled.");
618 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
619 xmlhttp
.onreadystatechange
=feedlist_callback
;
624 function feedEditSave() {
626 var feed
= active_feed
;
628 if (!xmlhttp_ready(xmlhttp
)) {
633 var link
= document
.getElementById("iedit_link").value
;
634 var title
= document
.getElementById("iedit_title").value
;
635 var upd_intl
= document
.getElementById("iedit_updintl").value
;
636 var purge_intl
= document
.getElementById("iedit_purgintl").value
;
637 var fcat
= document
.getElementById("iedit_fcat");
639 var fcat_id
= fcat
[fcat
.selectedIndex
].id
;
641 // notify("Saving feed.");
643 /* if (upd_intl < 0) {
644 notify("Update interval must be >= 0 (0 = default)");
648 if (purge_intl < 0) {
649 notify("Purge days must be >= 0 (0 = default)");
653 if (link
.length
== 0) {
654 notify("Feed link cannot be blank.");
658 if (title
.length
== 0) {
659 notify("Feed title cannot be blank.");
667 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
668 feed
+ "&l=" + param_escape(link
) + "&t=" + param_escape(title
) +
669 "&ui=" + param_escape(upd_intl
) + "&pi=" + param_escape(purge_intl
) +
670 "&catid=" + param_escape(fcat_id
), true);
671 xmlhttp
.onreadystatechange
=feedlist_callback
;
676 function labelTest() {
678 var sqlexp
= document
.getElementById("iedit_expr").value
;
679 var descr
= document
.getElementById("iedit_descr").value
;
681 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
682 param_escape(sqlexp
) + "&descr=" + param_escape(descr
), true);
684 xmlhttp
.onreadystatechange
=infobox_callback
;
689 function displayHelpInfobox(topic_id
) {
691 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
692 param_escape(topic_id
) + "&noheaders=1", true);
694 xmlhttp
.onreadystatechange
=infobox_callback
;
699 function labelEditCancel() {
701 if (!xmlhttp_ready(xmlhttp
)) {
706 active_label
= false;
708 notify("Operation cancelled.");
710 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
711 xmlhttp
.onreadystatechange
=labellist_callback
;
716 function userEditCancel() {
718 if (!xmlhttp_ready(xmlhttp
)) {
725 notify("Operation cancelled.");
727 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
728 xmlhttp
.onreadystatechange
=userlist_callback
;
733 function filterEditCancel() {
735 if (!xmlhttp_ready(xmlhttp
)) {
740 active_filter
= false;
742 notify("Operation cancelled.");
744 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
745 xmlhttp
.onreadystatechange
=filterlist_callback
;
750 function labelEditSave() {
752 var label
= active_label
;
754 if (!xmlhttp_ready(xmlhttp
)) {
759 var sqlexp
= document
.getElementById("iedit_expr").value
;
760 var descr
= document
.getElementById("iedit_descr").value
;
762 // notify("Saving label " + sqlexp + ": " + descr);
764 if (sqlexp
.length
== 0) {
765 notify("SQL expression cannot be blank.");
769 if (descr
.length
== 0) {
770 notify("Caption cannot be blank.");
776 active_label
= false;
778 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
779 label
+ "&s=" + param_escape(sqlexp
) + "&d=" + param_escape(descr
),
782 xmlhttp
.onreadystatechange
=labellist_callback
;
787 function userEditSave() {
789 var user
= active_user
;
791 if (!xmlhttp_ready(xmlhttp
)) {
796 var login
= document
.getElementById("iedit_ulogin").value
;
797 var level
= document
.getElementById("iedit_ulevel").value
;
799 if (login
.length
== 0) {
800 notify("Login cannot be blank.");
804 if (level
.length
== 0) {
805 notify("User level cannot be blank.");
813 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
814 user
+ "&l=" + param_escape(login
) + "&al=" + param_escape(level
),
817 xmlhttp
.onreadystatechange
=userlist_callback
;
823 function filterEditSave() {
825 var filter
= active_filter
;
827 if (!xmlhttp_ready(xmlhttp
)) {
832 var regexp
= document
.getElementById("iedit_regexp").value
;
833 var descr
= document
.getElementById("iedit_descr").value
;
834 var match
= document
.getElementById("iedit_match");
836 var v_match
= match
[match
.selectedIndex
].text
;
838 var feed
= document
.getElementById("iedit_feed");
839 var feed_id
= feed
[feed
.selectedIndex
].id
;
841 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
843 if (regexp
.length
== 0) {
844 notify("Filter expression cannot be blank.");
848 active_filter
= false;
850 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
851 filter
+ "&r=" + param_escape(regexp
) + "&d=" + param_escape(descr
) +
852 "&m=" + param_escape(v_match
) + "&fid=" + param_escape(feed_id
), true);
856 xmlhttp
.onreadystatechange
=filterlist_callback
;
861 function editSelectedLabel() {
862 var rows
= getSelectedLabels();
864 if (rows
.length
== 0) {
865 notify("No labels are selected.");
869 if (rows
.length
> 1) {
870 notify("Please select one label.");
880 function editSelectedUser() {
881 var rows
= getSelectedUsers();
883 if (rows
.length
== 0) {
884 notify("No users are selected.");
888 if (rows
.length
> 1) {
889 notify("Please select one user.");
898 function resetSelectedUserPass() {
899 var rows
= getSelectedUsers();
901 if (rows
.length
== 0) {
902 notify("No users are selected.");
906 if (rows
.length
> 1) {
907 notify("Please select one user.");
911 notify("Resetting password for selected user...");
915 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
916 param_escape(id
), true);
917 xmlhttp
.onreadystatechange
=userlist_callback
;
922 function selectedUserDetails() {
924 if (!xmlhttp_ready(xmlhttp
)) {
929 var rows
= getSelectedUsers();
931 if (rows
.length
== 0) {
932 notify("No users are selected.");
936 if (rows
.length
> 1) {
937 notify("Please select one user.");
945 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
946 xmlhttp
.onreadystatechange
=infobox_callback
;
951 function selectedFeedDetails() {
953 if (!xmlhttp_ready(xmlhttp
)) {
958 var rows
= getSelectedFeeds();
960 if (rows
.length
== 0) {
961 notify("No feeds are selected.");
965 if (rows
.length
> 1) {
966 notify("Please select one feed.");
974 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" + id
, true);
975 xmlhttp
.onreadystatechange
=infobox_callback
;
980 function editSelectedFilter() {
981 var rows
= getSelectedFilters();
983 if (rows
.length
== 0) {
984 notify("No filters are selected.");
988 if (rows
.length
> 1) {
989 notify("Please select one filter.");
1000 function editSelectedFeed() {
1001 var rows
= getSelectedFeeds();
1003 if (rows
.length
== 0) {
1004 notify("No feeds are selected.");
1008 if (rows
.length
> 1) {
1009 notify("Please select one feed.");
1019 function editSelectedFeedCat() {
1020 var rows
= getSelectedFeedCats();
1022 if (rows
.length
== 0) {
1023 notify("No categories are selected.");
1027 if (rows
.length
> 1) {
1028 notify("Please select one category.");
1034 editFeedCat(rows
[0]);
1038 function localPiggieFunction(enable
) {
1040 piggie
.style
.display
= "block";
1042 notify("I loveded it!!!");
1044 piggie
.style
.display
= "none";
1049 function validateOpmlImport() {
1051 var opml_file
= document
.getElementById("opml_file");
1053 if (opml_file
.value
.length
== 0) {
1054 notify("Please select OPML file to upload.");
1061 function updateFilterList() {
1063 if (!xmlhttp_ready(xmlhttp
)) {
1064 printLockingError();
1068 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1070 p_notify("Loading, please wait...");
1072 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
1073 xmlhttp
.onreadystatechange
=filterlist_callback
;
1078 function updateLabelList() {
1080 if (!xmlhttp_ready(xmlhttp
)) {
1081 printLockingError();
1085 p_notify("Loading, please wait...");
1087 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1089 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
1090 xmlhttp
.onreadystatechange
=labellist_callback
;
1094 function updatePrefsList() {
1096 if (!xmlhttp_ready(xmlhttp
)) {
1097 printLockingError();
1101 p_notify("Loading, please wait...");
1103 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1104 xmlhttp
.onreadystatechange
=prefslist_callback
;
1109 function selectTab(id
) {
1111 if (!xmlhttp_ready(xmlhttp
)) {
1112 printLockingError();
1116 if (id
== "feedConfig") {
1118 } else if (id
== "filterConfig") {
1120 } else if (id
== "labelConfig") {
1122 } else if (id
== "genConfig") {
1124 } else if (id
== "userConfig") {
1128 var tab
= document
.getElementById(active_tab
+ "Tab");
1131 if (tab
.className
.match("Selected")) {
1132 tab
.className
= "prefsTab";
1136 tab
= document
.getElementById(id
+ "Tab");
1139 if (!tab
.className
.match("Selected")) {
1140 tab
.className
= tab
.className
+ "Selected";
1154 document
.getElementById("prefContent").innerHTML
=
1155 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1156 "to function properly. Your browser doesn't seem to support it.";
1160 selectTab("genConfig");
1162 document
.onkeydown
= hotkey_handler
;
1165 exception_error("init", e
);
1169 function closeInfoBox() {
1170 var box
= document
.getElementById('infoBox');
1171 var shadow
= document
.getElementById('infoBoxShadow');
1174 shadow
.style
.display
= "none";
1176 box
.style
.display
= "none";
1180 function categorizeSelectedFeeds() {
1182 if (!xmlhttp_ready(xmlhttp
)) {
1183 printLockingError();
1187 var sel_rows
= getSelectedFeeds();
1189 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1190 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].id
;
1192 if (sel_rows
.length
> 0) {
1194 notify("Changing category of selected feeds...");
1196 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1197 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1198 xmlhttp
.onreadystatechange
=feedlist_callback
;
1203 notify("Please select some feeds first.");