]>
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 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
175 "&sort=" + param_escape(sort_key
), true);
176 xmlhttp
.onreadystatechange
=feedlist_callback
;
181 function updateUsersList() {
183 if (!xmlhttp_ready(xmlhttp
)) {
188 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
190 p_notify("Loading, please wait...");
192 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
193 xmlhttp
.onreadystatechange
=userlist_callback
;
198 function addLabel() {
200 if (!xmlhttp_ready(xmlhttp
)) {
205 var sqlexp
= document
.getElementById("ladd_expr");
207 if (sqlexp
.value
.length
== 0) {
208 notify("Missing SQL expression.");
210 notify("Adding label...");
212 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
213 param_escape(sqlexp
.value
), true);
215 xmlhttp
.onreadystatechange
=labellist_callback
;
223 function addFilter() {
225 if (!xmlhttp_ready(xmlhttp
)) {
230 var regexp
= document
.getElementById("fadd_regexp");
231 var match
= document
.getElementById("fadd_match");
232 var feed
= document
.getElementById("fadd_feed");
234 if (regexp
.value
.length
== 0) {
235 notify("Missing filter expression.");
237 notify("Adding filter...");
239 var v_match
= match
[match
.selectedIndex
].text
;
241 var feed_id
= feed
[feed
.selectedIndex
].id
;
243 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
244 param_escape(regexp
.value
) + "&match=" + v_match
+
245 "&fid=" + param_escape(feed_id
), true);
247 xmlhttp
.onreadystatechange
=filterlist_callback
;
257 if (!xmlhttp_ready(xmlhttp
)) {
262 var link
= document
.getElementById("fadd_link");
264 if (link
.value
.length
== 0) {
265 notify("Missing feed URL.");
267 notify("Adding feed...");
269 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
270 param_escape(link
.value
), true);
271 xmlhttp
.onreadystatechange
=feedlist_callback
;
280 function addFeedCat() {
282 if (!xmlhttp_ready(xmlhttp
)) {
287 var cat
= document
.getElementById("fadd_cat");
289 if (cat
.value
.length
== 0) {
290 notify("Missing feed category.");
292 notify("Adding feed category...");
294 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
295 param_escape(cat
.value
), true);
296 xmlhttp
.onreadystatechange
=feedlist_callback
;
306 if (!xmlhttp_ready(xmlhttp
)) {
311 var sqlexp
= document
.getElementById("uadd_box");
313 if (sqlexp
.value
.length
== 0) {
314 notify("Missing user login.");
316 notify("Adding user...");
318 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
319 param_escape(sqlexp
.value
), true);
321 xmlhttp
.onreadystatechange
=userlist_callback
;
329 function editLabel(id
) {
331 if (!xmlhttp_ready(xmlhttp
)) {
338 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
339 param_escape(id
), true);
340 xmlhttp
.onreadystatechange
=labellist_callback
;
345 function editUser(id
) {
347 if (!xmlhttp_ready(xmlhttp
)) {
354 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
355 param_escape(id
), true);
356 xmlhttp
.onreadystatechange
=userlist_callback
;
361 function editFilter(id
) {
363 if (!xmlhttp_ready(xmlhttp
)) {
370 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
371 param_escape(id
), true);
372 xmlhttp
.onreadystatechange
=filterlist_callback
;
377 function editFeed(feed
) {
379 // notify("Editing feed...");
381 if (!xmlhttp_ready(xmlhttp
)) {
388 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
389 param_escape(feed
), true);
390 xmlhttp
.onreadystatechange
=feedlist_callback
;
395 function editFeedCat(cat
) {
397 if (!xmlhttp_ready(xmlhttp
)) {
402 active_feed_cat
= cat
;
404 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
405 param_escape(cat
), true);
406 xmlhttp
.onreadystatechange
=feedlist_callback
;
411 function getSelectedLabels() {
412 return getSelectedTableRowIds("prefLabelList", "LILRR");
415 function getSelectedUsers() {
416 return getSelectedTableRowIds("prefUserList", "UMRR");
419 function getSelectedFeeds() {
420 return getSelectedTableRowIds("prefFeedList", "FEEDR");
423 function getSelectedFilters() {
424 return getSelectedTableRowIds("prefFilterList", "FILRR");
427 function getSelectedFeedCats() {
428 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
432 function readSelectedFeeds(read
) {
434 if (!xmlhttp_ready(xmlhttp
)) {
439 var sel_rows
= getSelectedFeeds();
441 if (sel_rows
.length
> 0) {
449 notify("Marking selected feeds as " + op
+ "...");
451 xmlhttp
.open("GET", "backend.php?op=pref-rpc&subop=" + op
+ "&ids="+
452 param_escape(sel_rows
.toString()), true);
453 xmlhttp
.onreadystatechange
=notify_callback
;
458 notify("Please select some feeds first.");
463 function removeSelectedLabels() {
465 if (!xmlhttp_ready(xmlhttp
)) {
470 var sel_rows
= getSelectedLabels();
472 if (sel_rows
.length
> 0) {
474 notify("Removing selected labels...");
476 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
477 param_escape(sel_rows
.toString()), true);
478 xmlhttp
.onreadystatechange
=labellist_callback
;
482 notify("Please select some labels first.");
486 function removeSelectedUsers() {
488 if (!xmlhttp_ready(xmlhttp
)) {
493 var sel_rows
= getSelectedUsers();
495 if (sel_rows
.length
> 0) {
497 notify("Removing selected users...");
499 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
500 param_escape(sel_rows
.toString()), true);
501 xmlhttp
.onreadystatechange
=userlist_callback
;
505 notify("Please select some labels first.");
509 function removeSelectedFilters() {
511 if (!xmlhttp_ready(xmlhttp
)) {
516 var sel_rows
= getSelectedFilters();
518 if (sel_rows
.length
> 0) {
520 notify("Removing selected filters...");
522 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
523 param_escape(sel_rows
.toString()), true);
524 xmlhttp
.onreadystatechange
=filterlist_callback
;
528 notify("Please select some filters first.");
533 function removeSelectedFeeds() {
535 if (!xmlhttp_ready(xmlhttp
)) {
540 var sel_rows
= getSelectedFeeds();
542 if (sel_rows
.length
> 0) {
544 notify("Removing selected feeds...");
546 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
547 param_escape(sel_rows
.toString()), true);
548 xmlhttp
.onreadystatechange
=feedlist_callback
;
553 notify("Please select some feeds first.");
559 function removeSelectedFeedCats() {
561 if (!xmlhttp_ready(xmlhttp
)) {
566 var sel_rows
= getSelectedFeedCats();
568 if (sel_rows
.length
> 0) {
570 notify("Removing selected categories...");
572 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
573 param_escape(sel_rows
.toString()), true);
574 xmlhttp
.onreadystatechange
=feedlist_callback
;
579 notify("Please select some feeds first.");
585 function feedEditCancel() {
587 if (!xmlhttp_ready(xmlhttp
)) {
594 notify("Operation cancelled.");
596 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
597 xmlhttp
.onreadystatechange
=feedlist_callback
;
602 function feedCatEditCancel() {
604 if (!xmlhttp_ready(xmlhttp
)) {
609 active_feed_cat
= false;
611 notify("Operation cancelled.");
613 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
614 xmlhttp
.onreadystatechange
=feedlist_callback
;
619 function feedEditSave() {
621 var feed
= active_feed
;
623 if (!xmlhttp_ready(xmlhttp
)) {
628 var link
= document
.getElementById("iedit_link").value
;
629 var title
= document
.getElementById("iedit_title").value
;
630 var upd_intl
= document
.getElementById("iedit_updintl").value
;
631 var purge_intl
= document
.getElementById("iedit_purgintl").value
;
632 var fcat
= document
.getElementById("iedit_fcat");
634 var fcat_id
= fcat
[fcat
.selectedIndex
].id
;
636 // notify("Saving feed.");
638 /* if (upd_intl < 0) {
639 notify("Update interval must be >= 0 (0 = default)");
643 if (purge_intl < 0) {
644 notify("Purge days must be >= 0 (0 = default)");
648 if (link
.length
== 0) {
649 notify("Feed link cannot be blank.");
653 if (title
.length
== 0) {
654 notify("Feed title cannot be blank.");
662 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editSave&id=" +
663 feed
+ "&l=" + param_escape(link
) + "&t=" + param_escape(title
) +
664 "&ui=" + param_escape(upd_intl
) + "&pi=" + param_escape(purge_intl
) +
665 "&catid=" + param_escape(fcat_id
), true);
666 xmlhttp
.onreadystatechange
=feedlist_callback
;
671 function labelTest() {
673 var sqlexp
= document
.getElementById("iedit_expr").value
;
674 var descr
= document
.getElementById("iedit_descr").value
;
676 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
677 param_escape(sqlexp
) + "&descr=" + param_escape(descr
), true);
679 xmlhttp
.onreadystatechange
=infobox_callback
;
684 function displayHelpInfobox(topic_id
) {
686 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
687 param_escape(topic_id
) + "&noheaders=1", true);
689 xmlhttp
.onreadystatechange
=infobox_callback
;
694 function labelEditCancel() {
696 if (!xmlhttp_ready(xmlhttp
)) {
701 active_label
= false;
703 notify("Operation cancelled.");
705 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
706 xmlhttp
.onreadystatechange
=labellist_callback
;
711 function userEditCancel() {
713 if (!xmlhttp_ready(xmlhttp
)) {
720 notify("Operation cancelled.");
722 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
723 xmlhttp
.onreadystatechange
=userlist_callback
;
728 function filterEditCancel() {
730 if (!xmlhttp_ready(xmlhttp
)) {
735 active_filter
= false;
737 notify("Operation cancelled.");
739 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
740 xmlhttp
.onreadystatechange
=filterlist_callback
;
745 function labelEditSave() {
747 var label
= active_label
;
749 if (!xmlhttp_ready(xmlhttp
)) {
754 var sqlexp
= document
.getElementById("iedit_expr").value
;
755 var descr
= document
.getElementById("iedit_descr").value
;
757 // notify("Saving label " + sqlexp + ": " + descr);
759 if (sqlexp
.length
== 0) {
760 notify("SQL expression cannot be blank.");
764 if (descr
.length
== 0) {
765 notify("Caption cannot be blank.");
771 active_label
= false;
773 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=editSave&id=" +
774 label
+ "&s=" + param_escape(sqlexp
) + "&d=" + param_escape(descr
),
777 xmlhttp
.onreadystatechange
=labellist_callback
;
782 function userEditSave() {
784 var user
= active_user
;
786 if (!xmlhttp_ready(xmlhttp
)) {
791 var login
= document
.getElementById("iedit_ulogin").value
;
792 var level
= document
.getElementById("iedit_ulevel").value
;
794 if (login
.length
== 0) {
795 notify("Login cannot be blank.");
799 if (level
.length
== 0) {
800 notify("User level cannot be blank.");
808 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=editSave&id=" +
809 user
+ "&l=" + param_escape(login
) + "&al=" + param_escape(level
),
812 xmlhttp
.onreadystatechange
=userlist_callback
;
818 function filterEditSave() {
820 var filter
= active_filter
;
822 if (!xmlhttp_ready(xmlhttp
)) {
827 var regexp
= document
.getElementById("iedit_regexp").value
;
828 var descr
= document
.getElementById("iedit_descr").value
;
829 var match
= document
.getElementById("iedit_match");
831 var v_match
= match
[match
.selectedIndex
].text
;
833 var feed
= document
.getElementById("iedit_feed");
834 var feed_id
= feed
[feed
.selectedIndex
].id
;
836 // notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
838 if (regexp
.length
== 0) {
839 notify("Filter expression cannot be blank.");
843 active_filter
= false;
845 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
846 filter
+ "&r=" + param_escape(regexp
) + "&d=" + param_escape(descr
) +
847 "&m=" + param_escape(v_match
) + "&fid=" + param_escape(feed_id
), true);
851 xmlhttp
.onreadystatechange
=filterlist_callback
;
856 function editSelectedLabel() {
857 var rows
= getSelectedLabels();
859 if (rows
.length
== 0) {
860 notify("No labels are selected.");
864 if (rows
.length
> 1) {
865 notify("Please select one label.");
875 function editSelectedUser() {
876 var rows
= getSelectedUsers();
878 if (rows
.length
== 0) {
879 notify("No users are selected.");
883 if (rows
.length
> 1) {
884 notify("Please select one user.");
893 function resetSelectedUserPass() {
894 var rows
= getSelectedUsers();
896 if (rows
.length
== 0) {
897 notify("No users are selected.");
901 if (rows
.length
> 1) {
902 notify("Please select one user.");
906 notify("Resetting password for selected user...");
910 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
911 param_escape(id
), true);
912 xmlhttp
.onreadystatechange
=userlist_callback
;
917 function selectedUserDetails() {
919 if (!xmlhttp_ready(xmlhttp
)) {
924 var rows
= getSelectedUsers();
926 if (rows
.length
== 0) {
927 notify("No users are selected.");
931 if (rows
.length
> 1) {
932 notify("Please select one user.");
940 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
941 xmlhttp
.onreadystatechange
=infobox_callback
;
946 function selectedFeedDetails() {
948 if (!xmlhttp_ready(xmlhttp
)) {
953 var rows
= getSelectedFeeds();
955 if (rows
.length
== 0) {
956 notify("No feeds are selected.");
960 if (rows
.length
> 1) {
961 notify("Please select one feed.");
969 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" + id
, true);
970 xmlhttp
.onreadystatechange
=infobox_callback
;
975 function editSelectedFilter() {
976 var rows
= getSelectedFilters();
978 if (rows
.length
== 0) {
979 notify("No filters are selected.");
983 if (rows
.length
> 1) {
984 notify("Please select one filter.");
995 function editSelectedFeed() {
996 var rows
= getSelectedFeeds();
998 if (rows
.length
== 0) {
999 notify("No feeds are selected.");
1003 if (rows
.length
> 1) {
1004 notify("Please select one feed.");
1014 function editSelectedFeedCat() {
1015 var rows
= getSelectedFeedCats();
1017 if (rows
.length
== 0) {
1018 notify("No categories are selected.");
1022 if (rows
.length
> 1) {
1023 notify("Please select one category.");
1029 editFeedCat(rows
[0]);
1033 function localPiggieFunction(enable
) {
1035 piggie
.style
.display
= "block";
1037 notify("I loveded it!!!");
1039 piggie
.style
.display
= "none";
1044 function validateOpmlImport() {
1046 var opml_file
= document
.getElementById("opml_file");
1048 if (opml_file
.value
.length
== 0) {
1049 notify("Please select OPML file to upload.");
1056 function updateFilterList() {
1058 if (!xmlhttp_ready(xmlhttp
)) {
1059 printLockingError();
1063 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1065 p_notify("Loading, please wait...");
1067 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
1068 xmlhttp
.onreadystatechange
=filterlist_callback
;
1073 function updateLabelList() {
1075 if (!xmlhttp_ready(xmlhttp
)) {
1076 printLockingError();
1080 p_notify("Loading, please wait...");
1082 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1084 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
1085 xmlhttp
.onreadystatechange
=labellist_callback
;
1089 function updatePrefsList() {
1091 if (!xmlhttp_ready(xmlhttp
)) {
1092 printLockingError();
1096 p_notify("Loading, please wait...");
1098 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1099 xmlhttp
.onreadystatechange
=prefslist_callback
;
1104 function selectTab(id
) {
1106 if (!xmlhttp_ready(xmlhttp
)) {
1107 printLockingError();
1111 if (id
== "feedConfig") {
1113 } else if (id
== "filterConfig") {
1115 } else if (id
== "labelConfig") {
1117 } else if (id
== "genConfig") {
1119 } else if (id
== "userConfig") {
1123 var tab
= document
.getElementById(active_tab
+ "Tab");
1126 if (tab
.className
.match("Selected")) {
1127 tab
.className
= "prefsTab";
1131 tab
= document
.getElementById(id
+ "Tab");
1134 if (!tab
.className
.match("Selected")) {
1135 tab
.className
= tab
.className
+ "Selected";
1149 document
.getElementById("prefContent").innerHTML
=
1150 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1151 "to function properly. Your browser doesn't seem to support it.";
1155 selectTab("genConfig");
1157 document
.onkeydown
= hotkey_handler
;
1160 exception_error("init", e
);
1164 function closeInfoBox() {
1165 var box
= document
.getElementById('infoBox');
1166 var shadow
= document
.getElementById('infoBoxShadow');
1169 shadow
.style
.display
= "none";
1171 box
.style
.display
= "none";