3 var active_feed_cat
= false;
4 var active_label
= false;
5 var active_tab
= false;
6 var feed_to_expand
= false;
11 var xmlhttp
= Ajax
.getTransport();
13 var init_params
= new Array();
15 var caller_subop
= false;
17 function expand_feed_callback() {
18 if (xmlhttp
.readyState
== 4) {
20 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
21 container
.innerHTML
=xmlhttp
.responseText
;
22 container
.style
.display
= "block";
25 exception_error("expand_feed_callback", e
);
30 function feedlist_callback() {
31 if (xmlhttp
.readyState
== 4) {
33 var container
= document
.getElementById('prefContent');
34 container
.innerHTML
=xmlhttp
.responseText
;
35 selectTab("feedConfig", true);
38 var tuple
= caller_subop
.split(":");
39 if (tuple
[0] == 'editFeed') {
40 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
48 exception_error("feedlist_callback", e
);
53 function filterlist_callback() {
54 var container
= document
.getElementById('prefContent');
55 if (xmlhttp
.readyState
== 4) {
56 container
.innerHTML
=xmlhttp
.responseText
;
61 function labellist_callback() {
62 var container
= document
.getElementById('prefContent');
63 if (xmlhttp
.readyState
== 4) {
65 container
.innerHTML
=xmlhttp
.responseText
;
67 var row
= document
.getElementById("LILRR-" + active_label
);
69 if (!row
.className
.match("Selected")) {
70 row
.className
= row
.className
+ "Selected";
73 var checkbox
= document
.getElementById("LICHK-" + active_label
);
76 checkbox
.checked
= true;
83 function labeltest_callback() {
84 var container
= document
.getElementById('label_test_result');
85 if (xmlhttp
.readyState
== 4) {
86 container
.innerHTML
=xmlhttp
.responseText
;
91 function feed_browser_callback() {
92 var container
= document
.getElementById('prefContent');
93 if (xmlhttp
.readyState
== 4) {
94 container
.innerHTML
=xmlhttp
.responseText
;
99 function userlist_callback() {
100 var container
= document
.getElementById('prefContent');
101 if (xmlhttp
.readyState
== 4) {
102 container
.innerHTML
=xmlhttp
.responseText
;
107 function prefslist_callback() {
108 var container
= document
.getElementById('prefContent');
109 if (xmlhttp
.readyState
== 4) {
111 container
.innerHTML
=xmlhttp
.responseText
;
117 function gethelp_callback() {
118 var container
= document
.getElementById('prefHelpBox');
119 if (xmlhttp
.readyState
== 4) {
121 container
.innerHTML
= xmlhttp
.responseText
;
122 container
.style
.display
= "block";
127 function notify_callback() {
128 if (xmlhttp
.readyState
== 4) {
129 notify_info(xmlhttp
.responseText
);
134 function changepass_callback() {
135 if (xmlhttp
.readyState
== 4) {
137 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
138 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
140 notify_info(xmlhttp
.responseText
);
143 document
.forms
['change_pass_form'].reset();
147 function updateFeedList(sort_key
) {
149 if (!xmlhttp_ready(xmlhttp
)) {
154 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
156 // p_notify("Loading, please wait...");
158 var feed_search
= document
.getElementById("feed_search");
160 if (feed_search
) { search
= feed_search
.value
; }
162 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
163 "&sort=" + param_escape(sort_key
) +
164 "&search=" + param_escape(search
), true);
165 xmlhttp
.onreadystatechange
=feedlist_callback
;
170 function updateUsersList(sort_key
) {
172 if (!xmlhttp_ready(xmlhttp
)) {
177 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
179 // p_notify("Loading, please wait...");
181 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
182 + param_escape(sort_key
), true);
183 xmlhttp
.onreadystatechange
=userlist_callback
;
188 function addLabel() {
190 if (!xmlhttp_ready(xmlhttp
)) {
195 var form
= document
.forms
['label_edit_form'];
197 var sql_exp
= form
.sql_exp
.value
;
198 var description
= form
.description
.value
;
201 alert("Can't create label: missing SQL expression.");
205 if (description
== "") {
206 alert("Can't create label: missing caption.");
210 var query
= Form
.serialize("label_edit_form");
212 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
213 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
219 if (!xmlhttp_ready(xmlhttp
)) {
224 var link
= document
.getElementById("fadd_link");
226 if (link
.value
.length
== 0) {
227 alert("Error: No feed URL given.");
228 } else if (!isValidURL(link
.value
)) {
229 alert("Error: Invalid feed URL.");
231 notify_progress("Adding feed...");
233 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
234 param_escape(link
.value
), true);
235 xmlhttp
.onreadystatechange
=feedlist_callback
;
244 function addFeedCat() {
246 if (!xmlhttp_ready(xmlhttp
)) {
251 var cat
= document
.getElementById("fadd_cat");
253 if (cat
.value
.length
== 0) {
254 alert("Can't add category: no name specified.");
256 notify_progress("Adding feed category...");
258 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
259 param_escape(cat
.value
), true);
260 xmlhttp
.onreadystatechange
=infobox_callback
;
270 if (!xmlhttp_ready(xmlhttp
)) {
275 var sqlexp
= document
.getElementById("uadd_box");
277 if (sqlexp
.value
.length
== 0) {
278 alert("Can't add user: no login specified.");
280 notify_progress("Adding user...");
282 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
283 param_escape(sqlexp
.value
), true);
285 xmlhttp
.onreadystatechange
=userlist_callback
;
293 function editLabel(id
) {
295 if (!xmlhttp_ready(xmlhttp
)) {
300 notify_progress("Loading, please wait...");
302 document
.getElementById("label_create_btn").disabled
= true;
306 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
307 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
309 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
310 param_escape(id
), true);
311 xmlhttp
.onreadystatechange
=infobox_callback
;
316 function editUser(id
) {
318 if (!xmlhttp_ready(xmlhttp
)) {
323 notify_progress("Loading, please wait...");
325 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
326 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
328 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
329 param_escape(id
), true);
330 xmlhttp
.onreadystatechange
=infobox_callback
;
335 function editFilter(id
) {
337 if (!xmlhttp_ready(xmlhttp
)) {
342 notify_progress("Loading, please wait...");
344 document
.getElementById("create_filter_btn").disabled
= true;
346 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
347 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
349 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
350 xmlhttp
.onreadystatechange
=infobox_callback
;
354 function editFeed(feed
) {
356 // notify("Editing feed...");
358 if (!xmlhttp_ready(xmlhttp
)) {
363 notify_progress("Loading, please wait...");
365 // clean selection from all rows & select row being edited
366 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
367 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
369 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
370 param_escape(feed
), true);
372 xmlhttp
.onreadystatechange
=infobox_callback
;
377 function editFeedCat(cat
) {
379 if (!xmlhttp_ready(xmlhttp
)) {
384 notify_progress("Loading, please wait...");
386 active_feed_cat
= cat
;
388 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
389 param_escape(cat
), true);
390 xmlhttp
.onreadystatechange
=infobox_callback
;
395 function getSelectedLabels() {
396 return getSelectedTableRowIds("prefLabelList", "LILRR");
399 function getSelectedUsers() {
400 return getSelectedTableRowIds("prefUserList", "UMRR");
403 function getSelectedFeeds() {
404 return getSelectedTableRowIds("prefFeedList", "FEEDR");
407 function getSelectedFilters() {
408 return getSelectedTableRowIds("prefFilterList", "FILRR");
411 function getSelectedFeedCats() {
412 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
415 function getSelectedFeedsFromBrowser() {
417 var list
= document
.getElementById("browseFeedList");
418 if (!list
) list
= document
.getElementById("browseBigFeedList");
420 var selected
= new Array();
422 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
423 var child
= list
.childNodes
[i
];
424 if (child
.id
&& child
.id
.match("FBROW-")) {
425 var id
= child
.id
.replace("FBROW-", "");
427 var cb
= document
.getElementById("FBCHK-" + id
);
438 function removeSelectedLabels() {
440 if (!xmlhttp_ready(xmlhttp
)) {
445 var sel_rows
= getSelectedLabels();
447 if (sel_rows
.length
> 0) {
449 var ok
= confirm("Remove selected labels?");
452 notify_progress("Removing selected labels...");
454 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
455 param_escape(sel_rows
.toString()), true);
456 xmlhttp
.onreadystatechange
=labellist_callback
;
460 alert("No labels are selected.");
466 function removeSelectedUsers() {
468 if (!xmlhttp_ready(xmlhttp
)) {
473 var sel_rows
= getSelectedUsers();
475 if (sel_rows
.length
> 0) {
477 var ok
= confirm("Remove selected users?");
480 notify_progress("Removing selected users...");
482 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
483 param_escape(sel_rows
.toString()), true);
484 xmlhttp
.onreadystatechange
=userlist_callback
;
489 alert("No users are selected.");
495 function removeSelectedFilters() {
497 if (!xmlhttp_ready(xmlhttp
)) {
502 var sel_rows
= getSelectedFilters();
504 if (sel_rows
.length
> 0) {
506 var ok
= confirm("Remove selected filters?");
509 notify_progress("Removing selected filters...");
511 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
512 param_escape(sel_rows
.toString()), true);
513 xmlhttp
.onreadystatechange
=filterlist_callback
;
517 alert("No filters are selected.");
524 function removeSelectedFeeds() {
526 if (!xmlhttp_ready(xmlhttp
)) {
531 var sel_rows
= getSelectedFeeds();
533 if (sel_rows
.length
> 0) {
535 var ok
= confirm("Unsubscribe from selected feeds?");
539 notify_progress("Unsubscribing from selected feeds...");
541 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
542 param_escape(sel_rows
.toString()), true);
543 xmlhttp
.onreadystatechange
=feedlist_callback
;
549 alert("No feeds are selected.");
556 function removeSelectedFeedCats() {
558 if (!xmlhttp_ready(xmlhttp
)) {
563 var sel_rows
= getSelectedFeedCats();
565 if (sel_rows
.length
> 0) {
567 var ok
= confirm("Remove selected categories?");
570 notify_progress("Removing selected categories...");
572 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
573 param_escape(sel_rows
.toString()), true);
574 xmlhttp
.onreadystatechange
=infobox_callback
;
580 alert("No categories are selected.");
587 function feedEditCancel() {
589 if (!xmlhttp_ready(xmlhttp
)) {
596 selectPrefRows('feed', false); // cleanup feed selection
601 function feedCatEditCancel() {
603 if (!xmlhttp_ready(xmlhttp
)) {
608 active_feed_cat
= false;
610 // notify("Operation cancelled.");
612 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
613 xmlhttp
.onreadystatechange
=infobox_callback
;
619 function feedEditSave() {
623 if (!xmlhttp_ready(xmlhttp
)) {
628 // FIXME: add parameter validation
630 var query
= Form
.serialize("edit_feed_form");
632 notify_progress("Saving feed...");
634 xmlhttp
.open("POST", "backend.php", true);
635 xmlhttp
.onreadystatechange
=feedlist_callback
;
636 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
644 exception_error("feedEditSave", e
);
648 function feedCatEditSave() {
650 if (!xmlhttp_ready(xmlhttp
)) {
655 notify_progress("Saving category...");
657 var query
= Form
.serialize("feed_cat_edit_form");
659 xmlhttp
.open("GET", "backend.php?" + query
, true);
660 xmlhttp
.onreadystatechange
=infobox_callback
;
663 active_feed_cat
= false;
669 function labelTest() {
671 var container
= document
.getElementById('label_test_result');
672 container
.style
.display
= "block";
673 container
.innerHTML
= "<p>Loading, please wait...</p>";
675 var form
= document
.forms
['label_edit_form'];
677 var sql_exp
= form
.sql_exp
.value
;
678 var description
= form
.description
.value
;
680 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
681 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
683 xmlhttp
.onreadystatechange
=labeltest_callback
;
689 function displayHelpInfobox(topic_id
) {
691 if (!xmlhttp_ready(xmlhttp
)) {
696 notify_progress("Loading help...");
698 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
699 param_escape(topic_id
) + "&noheaders=1", true);
701 xmlhttp
.onreadystatechange
=infobox_callback
;
706 function labelEditCancel() {
708 if (!xmlhttp_ready(xmlhttp
)) {
713 document
.getElementById("label_create_btn").disabled
= false;
715 active_label
= false;
717 selectPrefRows('label', false); // cleanup feed selection
723 function userEditCancel() {
725 if (!xmlhttp_ready(xmlhttp
)) {
730 selectPrefRows('user', false); // cleanup feed selection
736 function filterEditCancel() {
738 if (!xmlhttp_ready(xmlhttp
)) {
743 document
.getElementById("create_filter_btn").disabled
= false;
745 selectPrefRows('filter', false); // cleanup feed selection
751 function labelEditSave() {
753 var label
= active_label
;
755 if (!xmlhttp_ready(xmlhttp
)) {
760 /* if (!is_opera()) {
762 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
763 var description = document.forms["label_edit_form"].description.value;
765 if (sql_exp.length == 0) {
766 alert("SQL Expression cannot be blank.");
770 if (description.length == 0) {
771 alert("Caption field cannot be blank.");
778 notify_progress("Saving label...");
780 active_label
= false;
782 query
= Form
.serialize("label_edit_form");
784 xmlhttp
.open("GET", "backend.php?" + query
, true);
785 xmlhttp
.onreadystatechange
=labellist_callback
;
791 function userEditSave() {
793 if (!xmlhttp_ready(xmlhttp
)) {
798 var login
= document
.forms
["user_edit_form"].login
.value
;
800 if (login
.length
== 0) {
801 alert("Login field cannot be blank.");
805 notify_progress("Saving user...");
809 var query
= Form
.serialize("user_edit_form");
811 xmlhttp
.open("GET", "backend.php?" + query
, true);
812 xmlhttp
.onreadystatechange
=userlist_callback
;
819 function filterEditSave() {
821 if (!xmlhttp_ready(xmlhttp
)) {
826 /* if (!is_opera()) {
827 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
829 if (reg_exp.length == 0) {
830 alert("Filter expression field cannot be blank.");
835 notify_progress("Saving filter...");
837 var query
= Form
.serialize("filter_edit_form");
841 document
.getElementById("create_filter_btn").disabled
= false;
843 xmlhttp
.open("GET", "backend.php?" + query
, true);
844 xmlhttp
.onreadystatechange
=filterlist_callback
;
850 function editSelectedLabel() {
851 var rows
= getSelectedLabels();
853 if (rows
.length
== 0) {
854 alert("No labels are selected.");
858 if (rows
.length
> 1) {
859 alert("Please select only one label.");
869 function editSelectedUser() {
870 var rows
= getSelectedUsers();
872 if (rows
.length
== 0) {
873 alert("No users are selected.");
877 if (rows
.length
> 1) {
878 alert("Please select only one user.");
887 function resetSelectedUserPass() {
888 var rows
= getSelectedUsers();
890 if (rows
.length
== 0) {
891 alert("No users are selected.");
895 if (rows
.length
> 1) {
896 alert("Please select only one user.");
900 var ok
= confirm("Reset password of selected user?");
903 notify_progress("Resetting password for selected user...");
907 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
908 param_escape(id
), true);
909 xmlhttp
.onreadystatechange
=userlist_callback
;
914 function selectedUserDetails() {
916 if (!xmlhttp_ready(xmlhttp
)) {
921 var rows
= getSelectedUsers();
923 if (rows
.length
== 0) {
924 alert("No users are selected.");
928 if (rows
.length
> 1) {
929 alert("Please select only one user.");
933 notify_progress("Loading, please wait...");
937 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
938 xmlhttp
.onreadystatechange
=infobox_callback
;
943 function selectedFeedDetails() {
945 if (!xmlhttp_ready(xmlhttp
)) {
950 var rows
= getSelectedFeeds();
952 if (rows
.length
== 0) {
953 alert("No feeds are selected.");
957 if (rows
.length
> 1) {
958 alert("Please select only one feed.");
966 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
967 param_escape(rows
.toString()), true);
968 xmlhttp
.onreadystatechange
=infobox_callback
;
973 function editSelectedFilter() {
974 var rows
= getSelectedFilters();
976 if (rows
.length
== 0) {
977 alert("No filters are selected.");
981 if (rows
.length
> 1) {
982 alert("Please select only one filter.");
993 function editSelectedFeed() {
994 var rows
= getSelectedFeeds();
996 if (rows
.length
== 0) {
997 alert("No feeds are selected.");
1001 if (rows
.length
> 1) {
1002 alert("Please select one feed.");
1012 function editSelectedFeedCat() {
1013 var rows
= getSelectedFeedCats();
1015 if (rows
.length
== 0) {
1016 alert("No categories are selected.");
1020 if (rows
.length
> 1) {
1021 alert("Please select only one category.");
1027 editFeedCat(rows
[0]);
1031 function piggie_callback() {
1032 var piggie
= document
.getElementById("piggie");
1034 piggie
.style
.top
= piggie_top
;
1035 piggie
.style
.backgroundColor
= "white";
1036 piggie
.style
.borderWidth
= "1px";
1038 if (piggie_fwd
&& piggie_top
< 0) {
1039 setTimeout("piggie_callback()", 50);
1040 piggie_top
= piggie_top
+ 10;
1041 } else if (piggie_fwd
&& piggie_top
>= 0) {
1043 setTimeout("piggie_callback()", 50);
1044 } else if (!piggie_fwd
&& piggie_top
> -400) {
1045 setTimeout("piggie_callback()", 50);
1046 piggie_top
= piggie_top
- 10;
1047 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1048 piggie
.style
.display
= "none";
1053 var piggie_opacity
= 0;
1055 function piggie2_callback() {
1056 var piggie
= document
.getElementById("piggie");
1057 piggie
.style
.top
= 0;
1058 piggie
.style
.opacity
= piggie_opacity
;
1059 piggie
.style
.backgroundColor
= "transparent";
1060 piggie
.style
.borderWidth
= "0px";
1062 if (piggie_fwd
&& piggie_opacity
< 1) {
1063 setTimeout("piggie2_callback()", 50);
1064 piggie_opacity
= piggie_opacity
+ 0.03;
1065 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1067 setTimeout("piggie2_callback()", 50);
1068 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1069 setTimeout("piggie2_callback()", 50);
1070 piggie_opacity
= piggie_opacity
- 0.03;
1071 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1072 piggie
.style
.display
= "none";
1077 function localPiggieFunction(enable
) {
1079 debug("I LOVEDED IT!");
1080 var piggie
= document
.getElementById("piggie");
1081 piggie
.style
.display
= "block";
1083 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1091 function validateOpmlImport() {
1093 var opml_file
= document
.getElementById("opml_file");
1095 if (opml_file
.value
.length
== 0) {
1096 alert("No OPML file to upload.");
1103 function updateFilterList(sort_key
) {
1105 if (!xmlhttp_ready(xmlhttp
)) {
1106 printLockingError();
1110 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1112 // p_notify("Loading, please wait...");
1114 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1115 param_escape(sort_key
), true);
1116 xmlhttp
.onreadystatechange
=filterlist_callback
;
1121 function updateLabelList(sort_key
) {
1123 if (!xmlhttp_ready(xmlhttp
)) {
1124 printLockingError();
1128 // p_notify("Loading, please wait...");
1130 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1132 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1133 param_escape(sort_key
), true);
1134 xmlhttp
.onreadystatechange
=labellist_callback
;
1138 function updatePrefsList() {
1140 if (!xmlhttp_ready(xmlhttp
)) {
1141 printLockingError();
1145 // p_notify("Loading, please wait...");
1147 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1148 xmlhttp
.onreadystatechange
=prefslist_callback
;
1153 function selectTab(id
, noupdate
, subop
) {
1157 if (!id
) id
= active_tab
;
1161 if (!xmlhttp_ready(xmlhttp
)) {
1162 printLockingError();
1167 var c
= document
.getElementById('prefContent');
1173 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1175 notify_progress("Loading, please wait...");
1177 // close active infobox if needed
1180 // clean up all current selections, just in case
1181 active_feed_cat
= false;
1182 active_label
= false;
1184 if (id
== "feedConfig") {
1186 } else if (id
== "filterConfig") {
1188 } else if (id
== "labelConfig") {
1190 } else if (id
== "genConfig") {
1192 } else if (id
== "userConfig") {
1194 } else if (id
== "feedBrowser") {
1195 updateBigFeedBrowser();
1199 var tab
= document
.getElementById(active_tab
+ "Tab");
1202 if (tab
.className
.match("Selected")) {
1203 tab
.className
= "prefsTab";
1207 tab
= document
.getElementById(id
+ "Tab");
1210 if (!tab
.className
.match("Selected")) {
1211 tab
.className
= tab
.className
+ "Selected";
1215 if (active_tab
!= id
) {
1216 storeInitParam("prefs_active_tab", id
);
1222 exception_error("selectTab", e
);
1226 function backend_sanity_check_callback() {
1228 if (xmlhttp
.readyState
== 4) {
1232 if (!xmlhttp
.responseXML
) {
1233 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1237 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1240 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1244 var error_code
= reply
.getAttribute("error-code");
1246 if (error_code
&& error_code
!= 0) {
1247 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1250 debug("sanity check ok");
1252 var params
= reply
.nextSibling
;
1255 debug('reading init-params...');
1256 var param
= params
.firstChild
;
1259 var k
= param
.getAttribute("key");
1260 var v
= param
.getAttribute("value");
1261 debug(k
+ " => " + v
);
1263 param
= param
.nextSibling
;
1267 init_second_stage();
1270 exception_error("backend_sanity_check_callback", e
);
1275 function init_second_stage() {
1278 active_tab
= getInitParam("prefs_active_tab");
1279 if (!active_tab
) active_tab
= "genConfig";
1281 document
.onkeydown
= pref_hotkey_handler
;
1283 var tab
= getURLParam('tab');
1285 caller_subop
= getURLParam('subop');
1291 if (navigator
.userAgent
.match("Opera")) {
1292 setTimeout("selectTab()", 500);
1294 selectTab(active_tab
);
1298 exception_error("init_second_stage", e
);
1306 if (arguments
.callee
.done
) return;
1307 arguments
.callee
.done
= true;
1309 if (getURLParam('debug')) {
1310 document
.getElementById('debug_output').style
.display
= 'block';
1311 debug('debug mode activated');
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.";
1322 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1323 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1327 exception_error("init", e
);
1331 function categorizeSelectedFeeds() {
1333 if (!xmlhttp_ready(xmlhttp
)) {
1334 printLockingError();
1338 var sel_rows
= getSelectedFeeds();
1340 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1341 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1343 if (sel_rows
.length
> 0) {
1345 notify_progress("Changing category of selected feeds...");
1347 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1348 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1349 xmlhttp
.onreadystatechange
=feedlist_callback
;
1354 alert("No feeds are selected.");
1360 function validatePrefsReset() {
1361 return confirm("Reset to defaults?");
1364 function browseFeeds(limit
) {
1366 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1367 xmlhttp
.onreadystatechange
=infobox_callback
;
1372 function feedBrowserSubscribe() {
1375 var selected
= getSelectedFeedsFromBrowser();
1377 if (selected
.length
> 0) {
1379 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1380 param_escape(selected
.toString()), true);
1381 xmlhttp
.onreadystatechange
=feedlist_callback
;
1384 alert("No feeds are selected.");
1388 exception_error("feedBrowserSubscribe", e
);
1392 function updateBigFeedBrowser(limit
) {
1394 if (!xmlhttp_ready(xmlhttp
)) {
1395 printLockingError();
1399 // p_notify("Loading, please wait...");
1401 var query
= "backend.php?op=pref-feed-browser";
1403 var limit_sel
= document
.getElementById("feedBrowserLimit");
1406 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1407 query
= query
+ "&limit=" + param_escape(limit
);
1410 xmlhttp
.open("GET", query
, true);
1411 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1415 function browserToggleExpand(id
) {
1417 /* if (feed_to_expand && feed_to_expand != id) {
1418 var d = document.getElementById("BRDET-" + feed_to_expand);
1419 d.style.display = "none";
1422 if (!xmlhttp_ready(xmlhttp
)) {
1423 printLockingError();
1427 var d
= document
.getElementById("BRDET-" + id
);
1429 if (d
.style
.display
== "block") {
1430 d
.style
.display
= "none";
1434 feed_to_expand
= id
;
1436 d
.style
.display
= "block";
1437 d
.innerHTML
= "Loading, please wait...";
1439 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1440 + param_escape(id
), true);
1441 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1446 exception_error("browserExpand", e
);
1450 function validateNewPassword(form
) {
1451 if (form
.OLD_PASSWORD
.value
== "") {
1452 alert("Old password cannot be blank");
1455 if (form
.NEW_PASSWORD
.value
== "") {
1456 alert("New password cannot be blank");
1462 function selectPrefRows(kind
, select
) {
1465 var opbarid
= false;
1470 if (kind
== "feed") {
1471 opbarid
= "feedOpToolbar";
1474 lname
= "prefFeedList";
1475 } else if (kind
== "fcat") {
1476 opbarid
= "catOpToolbar";
1479 lname
= "prefFeedCatList";
1480 } else if (kind
== "filter") {
1481 opbarid
= "filterOpToolbar";
1484 lname
= "prefFilterList";
1485 } else if (kind
== "label") {
1486 opbarid
= "labelOpToolbar";
1489 lname
= "prefLabelList";
1490 } else if (kind
== "user") {
1491 opbarid
= "userOpToolbar";
1494 lname
= "prefUserList";
1498 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1499 disableContainerChildren(opbarid
, !select
);
1506 function toggleSelectPrefRow(sender
, kind
) {
1508 toggleSelectRow(sender
);
1511 var opbarid
= false;
1514 if (kind
== "feed") {
1515 opbarid
= "feedOpToolbar";
1516 nsel
= getSelectedFeeds();
1517 } else if (kind
== "fcat") {
1518 opbarid
= "catOpToolbar";
1519 nsel
= getSelectedFeedCats();
1520 } else if (kind
== "filter") {
1521 opbarid
= "filterOpToolbar";
1522 nsel
= getSelectedFilters();
1523 } else if (kind
== "label") {
1524 opbarid
= "labelOpToolbar";
1525 nsel
= getSelectedLabels();
1526 } else if (kind
== "user") {
1527 opbarid
= "userOpToolbar";
1528 nsel
= getSelectedUsers();
1531 if (opbarid
&& nsel
!= -1) {
1532 disableContainerChildren(opbarid
, nsel
== false);
1538 function toggleSelectFBListRow(sender
) {
1539 toggleSelectListRow(sender
);
1540 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1545 function pref_hotkey_handler(e
) {
1550 if (!hotkeys_enabled
) return;
1553 keycode
= window
.event
.keyCode
;
1558 if (keycode
== 13 || keycode
== 27) {
1561 seq
= seq
+ "" + keycode
;
1565 if (document
.getElementById("piggie")) {
1567 if (seq
.match("807371717369")) {
1569 localPiggieFunction(true);
1571 localPiggieFunction(false);
1576 exception_error("pref_hotkey_handler", e
);
1580 function userSwitch() {
1581 var chooser
= document
.getElementById("userSwitch");
1582 var user
= chooser
[chooser
.selectedIndex
].value
;
1583 window
.location
= "prefs.php?swu=" + user
;
1586 function editFeedCats() {
1587 if (!xmlhttp_ready(xmlhttp
)) {
1588 printLockingError();
1592 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1593 xmlhttp
.onreadystatechange
=infobox_callback
;
1597 function showFeedsWithErrors() {
1598 displayDlg('feedUpdateErrors');
1601 function changeUserPassword() {
1605 if (!xmlhttp_ready(xmlhttp
)) {
1606 printLockingError();
1610 var query
= Form
.serialize("change_pass_form");
1612 notify_progress("Trying to change password...");
1614 xmlhttp
.open("POST", "backend.php", true);
1615 xmlhttp
.onreadystatechange
=changepass_callback
;
1616 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1617 xmlhttp
.send(query
);
1620 exception_error("changeUserPassword", e
);