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 function expand_feed_callback() {
16 if (xmlhttp
.readyState
== 4) {
18 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
19 container
.innerHTML
=xmlhttp
.responseText
;
20 container
.style
.display
= "block";
23 exception_error("expand_feed_callback", e
);
28 function feedlist_callback() {
29 if (xmlhttp
.readyState
== 4) {
31 var container
= document
.getElementById('prefContent');
32 container
.innerHTML
=xmlhttp
.responseText
;
33 selectTab("feedConfig", true);
35 if (active_feed_cat
) {
36 var row
= document
.getElementById("FCATR-" + active_feed_cat
);
38 if (!row
.className
.match("Selected")) {
39 row
.className
= row
.className
+ "Selected";
42 var checkbox
= document
.getElementById("FCCHK-" + active_feed_cat
);
44 checkbox
.checked
= true;
50 exception_error("feedlist_callback", e
);
55 function filterlist_callback() {
56 var container
= document
.getElementById('prefContent');
57 if (xmlhttp
.readyState
== 4) {
58 container
.innerHTML
=xmlhttp
.responseText
;
63 function labellist_callback() {
64 var container
= document
.getElementById('prefContent');
65 if (xmlhttp
.readyState
== 4) {
66 container
.innerHTML
=xmlhttp
.responseText
;
69 var row
= document
.getElementById("LILRR-" + active_label
);
71 if (!row
.className
.match("Selected")) {
72 row
.className
= row
.className
+ "Selected";
75 var checkbox
= document
.getElementById("LICHK-" + active_label
);
78 checkbox
.checked
= true;
85 function feed_browser_callback() {
86 var container
= document
.getElementById('prefContent');
87 if (xmlhttp
.readyState
== 4) {
88 container
.innerHTML
=xmlhttp
.responseText
;
93 function userlist_callback() {
94 var container
= document
.getElementById('prefContent');
95 if (xmlhttp
.readyState
== 4) {
96 container
.innerHTML
=xmlhttp
.responseText
;
101 function prefslist_callback() {
102 var container
= document
.getElementById('prefContent');
103 if (xmlhttp
.readyState
== 4) {
105 container
.innerHTML
=xmlhttp
.responseText
;
111 function gethelp_callback() {
112 var container
= document
.getElementById('prefHelpBox');
113 if (xmlhttp
.readyState
== 4) {
115 container
.innerHTML
= xmlhttp
.responseText
;
116 container
.style
.display
= "block";
122 function notify_callback() {
123 var container
= document
.getElementById('notify');
124 if (xmlhttp
.readyState
== 4) {
125 container
.innerHTML
=xmlhttp
.responseText
;
129 function updateFeedList(sort_key
) {
131 if (!xmlhttp_ready(xmlhttp
)) {
136 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
138 // p_notify("Loading, please wait...");
140 var feed_search
= document
.getElementById("feed_search");
142 if (feed_search
) { search
= feed_search
.value
; }
144 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
145 "&sort=" + param_escape(sort_key
) +
146 "&search=" + param_escape(search
), true);
147 xmlhttp
.onreadystatechange
=feedlist_callback
;
152 function updateUsersList() {
154 if (!xmlhttp_ready(xmlhttp
)) {
159 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
161 // p_notify("Loading, please wait...");
163 xmlhttp
.open("GET", "backend.php?op=pref-users", true);
164 xmlhttp
.onreadystatechange
=userlist_callback
;
169 function addLabel() {
171 if (!xmlhttp_ready(xmlhttp
)) {
176 var sqlexp
= document
.getElementById("ladd_expr");
178 if (sqlexp
.value
.length
== 0) {
179 alert("Can't add label: missing SQL expression.");
181 notify("Adding label...");
183 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
184 param_escape(sqlexp
.value
), true);
186 xmlhttp
.onreadystatechange
=labellist_callback
;
194 function addFilter() {
196 if (!xmlhttp_ready(xmlhttp
)) {
201 var regexp
= document
.getElementById("fadd_regexp");
202 var match
= document
.getElementById("fadd_match");
203 var feed
= document
.getElementById("fadd_feed");
204 var action
= document
.getElementById("fadd_action");
206 if (regexp
.value
.length
== 0) {
207 alert("Can't add filter: missing filter expression.");
209 notify("Adding filter...");
211 var v_match
= match
[match
.selectedIndex
].text
;
212 var feed_id
= feed
[feed
.selectedIndex
].id
;
213 var action_id
= action
[action
.selectedIndex
].id
;
215 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=add®exp=" +
216 param_escape(regexp
.value
) + "&match=" + v_match
+
217 "&fid=" + param_escape(feed_id
) + "&aid=" + param_escape(action_id
), true);
219 xmlhttp
.onreadystatechange
=filterlist_callback
;
229 if (!xmlhttp_ready(xmlhttp
)) {
234 var link
= document
.getElementById("fadd_link");
236 if (link
.value
.length
== 0) {
237 alert("Error: No feed URL given.");
238 } else if (!isValidURL(link
.value
)) {
239 alert("Error: Invalid feed URL.");
241 notify("Adding feed...");
243 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&feed_url=" +
244 param_escape(link
.value
), true);
245 xmlhttp
.onreadystatechange
=feedlist_callback
;
254 function addFeedCat() {
256 if (!xmlhttp_ready(xmlhttp
)) {
261 var cat
= document
.getElementById("fadd_cat");
263 if (cat
.value
.length
== 0) {
264 alert("Can't add category: no name specified.");
266 notify("Adding feed category...");
268 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
269 param_escape(cat
.value
), true);
270 xmlhttp
.onreadystatechange
=feedlist_callback
;
280 if (!xmlhttp_ready(xmlhttp
)) {
285 var sqlexp
= document
.getElementById("uadd_box");
287 if (sqlexp
.value
.length
== 0) {
288 alert("Can't add user: no login specified.");
290 notify("Adding user...");
292 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
293 param_escape(sqlexp
.value
), true);
295 xmlhttp
.onreadystatechange
=userlist_callback
;
303 function editLabel(id
) {
305 if (!xmlhttp_ready(xmlhttp
)) {
312 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
313 param_escape(id
), true);
314 xmlhttp
.onreadystatechange
=labellist_callback
;
319 function editUser(id
) {
321 if (!xmlhttp_ready(xmlhttp
)) {
326 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
327 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
329 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
330 param_escape(id
), true);
331 xmlhttp
.onreadystatechange
=infobox_callback
;
336 function editFilter(id
) {
338 if (!xmlhttp_ready(xmlhttp
)) {
343 document
.getElementById("create_filter_btn").disabled
= true;
345 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
346 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
348 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
349 xmlhttp
.onreadystatechange
=infobox_callback
;
353 function editFeed(feed
) {
355 // notify("Editing feed...");
357 if (!xmlhttp_ready(xmlhttp
)) {
362 // clean selection from all rows & select row being edited
363 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
364 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
366 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
367 param_escape(feed
), true);
369 xmlhttp
.onreadystatechange
=infobox_callback
;
374 function editFeedCat(cat
) {
376 if (!xmlhttp_ready(xmlhttp
)) {
381 active_feed_cat
= cat
;
383 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
384 param_escape(cat
), true);
385 xmlhttp
.onreadystatechange
=feedlist_callback
;
390 function getSelectedLabels() {
391 return getSelectedTableRowIds("prefLabelList", "LILRR");
394 function getSelectedUsers() {
395 return getSelectedTableRowIds("prefUserList", "UMRR");
398 function getSelectedFeeds() {
399 return getSelectedTableRowIds("prefFeedList", "FEEDR");
402 function getSelectedFilters() {
403 return getSelectedTableRowIds("prefFilterList", "FILRR");
406 function getSelectedFeedCats() {
407 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
410 function getSelectedFeedsFromBrowser() {
412 var list
= document
.getElementById("browseFeedList");
413 if (!list
) list
= document
.getElementById("browseBigFeedList");
415 var selected
= new Array();
417 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
418 var child
= list
.childNodes
[i
];
419 if (child
.id
&& child
.id
.match("FBROW-")) {
420 var id
= child
.id
.replace("FBROW-", "");
422 var cb
= document
.getElementById("FBCHK-" + id
);
433 function removeSelectedLabels() {
435 if (!xmlhttp_ready(xmlhttp
)) {
440 var sel_rows
= getSelectedLabels();
442 if (sel_rows
.length
> 0) {
444 var ok
= confirm("Remove selected labels?");
447 notify("Removing selected labels...");
449 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
450 param_escape(sel_rows
.toString()), true);
451 xmlhttp
.onreadystatechange
=labellist_callback
;
455 alert("No labels are selected.");
461 function removeSelectedUsers() {
463 if (!xmlhttp_ready(xmlhttp
)) {
468 var sel_rows
= getSelectedUsers();
470 if (sel_rows
.length
> 0) {
472 var ok
= confirm("Remove selected users?");
475 notify("Removing selected users...");
477 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
478 param_escape(sel_rows
.toString()), true);
479 xmlhttp
.onreadystatechange
=userlist_callback
;
484 alert("No users are selected.");
490 function removeSelectedFilters() {
492 if (!xmlhttp_ready(xmlhttp
)) {
497 var sel_rows
= getSelectedFilters();
499 if (sel_rows
.length
> 0) {
501 var ok
= confirm("Remove selected filters?");
504 notify("Removing selected filters...");
506 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
507 param_escape(sel_rows
.toString()), true);
508 xmlhttp
.onreadystatechange
=filterlist_callback
;
512 alert("No filters are selected.");
519 function removeSelectedFeeds() {
521 if (!xmlhttp_ready(xmlhttp
)) {
526 var sel_rows
= getSelectedFeeds();
528 if (sel_rows
.length
> 0) {
530 var ok
= confirm("Unsubscribe from selected feeds?");
534 notify("Unsubscribing from selected feeds...");
536 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
537 param_escape(sel_rows
.toString()), true);
538 xmlhttp
.onreadystatechange
=feedlist_callback
;
544 alert("No feeds are selected.");
551 function removeSelectedFeedCats() {
553 if (!xmlhttp_ready(xmlhttp
)) {
558 var sel_rows
= getSelectedFeedCats();
560 if (sel_rows
.length
> 0) {
562 var ok
= confirm("Remove selected categories?");
565 notify("Removing selected categories...");
567 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
568 param_escape(sel_rows
.toString()), true);
569 xmlhttp
.onreadystatechange
=feedlist_callback
;
575 alert("No categories are selected.");
582 function feedEditCancel() {
584 if (!xmlhttp_ready(xmlhttp
)) {
591 selectPrefRows('feed', false); // cleanup feed selection
596 function feedCatEditCancel() {
598 if (!xmlhttp_ready(xmlhttp
)) {
603 active_feed_cat
= false;
605 // notify("Operation cancelled.");
607 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
608 xmlhttp
.onreadystatechange
=feedlist_callback
;
614 function feedEditSave() {
618 if (!xmlhttp_ready(xmlhttp
)) {
623 // FIXME: add parameter validation
625 var query
= Form
.serialize("edit_feed_form");
627 notify("Saving feed...");
629 xmlhttp
.open("POST", "backend.php", true);
630 xmlhttp
.onreadystatechange
=feedlist_callback
;
631 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
639 exception_error("feedEditSave", e
);
643 function feedCatEditSave() {
645 if (!xmlhttp_ready(xmlhttp
)) {
650 notify("Saving category...");
652 var query
= Form
.serialize("feed_cat_edit_form");
654 xmlhttp
.open("GET", "backend.php?" + query
, true);
655 xmlhttp
.onreadystatechange
=feedlist_callback
;
658 active_feed_cat
= false;
664 function labelTest() {
666 var form
= document
.forms
['label_edit_form'];
668 var sql_exp
= form
.sql_exp
.value
;
669 var description
= form
.description
.value
;
671 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
672 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
674 xmlhttp
.onreadystatechange
=infobox_callback
;
680 function displayHelpInfobox(topic_id
) {
682 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
683 param_escape(topic_id
) + "&noheaders=1", true);
685 xmlhttp
.onreadystatechange
=infobox_callback
;
690 function labelEditCancel() {
692 if (!xmlhttp_ready(xmlhttp
)) {
697 active_label
= false;
699 // notify("Operation cancelled.");
703 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
704 xmlhttp
.onreadystatechange
=labellist_callback
;
710 function userEditCancel() {
712 if (!xmlhttp_ready(xmlhttp
)) {
717 selectPrefRows('user', false); // cleanup feed selection
723 function filterEditCancel() {
725 if (!xmlhttp_ready(xmlhttp
)) {
730 document
.getElementById("create_filter_btn").disabled
= false;
732 selectPrefRows('filter', false); // cleanup feed selection
738 function labelEditSave() {
740 var label
= active_label
;
742 if (!xmlhttp_ready(xmlhttp
)) {
747 var sql_exp
= document
.forms
["label_edit_form"].sql_exp
.value
;
748 var description
= document
.forms
["label_edit_form"].description
.value
;
750 if (sql_exp
.length
== 0) {
751 alert("SQL Expression cannot be blank.");
755 if (description
.length
== 0) {
756 alert("Caption field cannot be blank.");
762 notify("Saving label...");
764 active_label
= false;
766 query
= Form
.serialize("label_edit_form");
768 xmlhttp
.open("GET", "backend.php?" + query
, true);
769 xmlhttp
.onreadystatechange
=labellist_callback
;
775 function userEditSave() {
777 if (!xmlhttp_ready(xmlhttp
)) {
782 var login
= document
.forms
["user_edit_form"].login
.value
;
784 if (login
.length
== 0) {
785 alert("Login field cannot be blank.");
789 notify("Saving user...");
793 var query
= Form
.serialize("user_edit_form");
795 xmlhttp
.open("GET", "backend.php?" + query
, true);
796 xmlhttp
.onreadystatechange
=userlist_callback
;
803 function filterEditSave() {
805 if (!xmlhttp_ready(xmlhttp
)) {
810 var reg_exp
= document
.forms
["filter_edit_form"].reg_exp
.value
;
812 if (reg_exp
.length
== 0) {
813 alert("Filter expression field cannot be blank.");
817 notify("Saving filter...");
819 var query
= Form
.serialize("filter_edit_form");
823 document
.getElementById("create_filter_btn").disabled
= false;
825 xmlhttp
.open("GET", "backend.php?" + query
, true);
826 xmlhttp
.onreadystatechange
=filterlist_callback
;
832 function editSelectedLabel() {
833 var rows
= getSelectedLabels();
835 if (rows
.length
== 0) {
836 alert("No labels are selected.");
840 if (rows
.length
> 1) {
841 alert("Please select only one label.");
851 function editSelectedUser() {
852 var rows
= getSelectedUsers();
854 if (rows
.length
== 0) {
855 alert("No users are selected.");
859 if (rows
.length
> 1) {
860 alert("Please select only one user.");
869 function resetSelectedUserPass() {
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.");
882 var ok
= confirm("Reset password of selected user?");
885 notify("Resetting password for selected user...");
889 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
890 param_escape(id
), true);
891 xmlhttp
.onreadystatechange
=userlist_callback
;
896 function selectedUserDetails() {
898 if (!xmlhttp_ready(xmlhttp
)) {
903 var rows
= getSelectedUsers();
905 if (rows
.length
== 0) {
906 alert("No users are selected.");
910 if (rows
.length
> 1) {
911 alert("Please select only one user.");
919 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
920 xmlhttp
.onreadystatechange
=infobox_callback
;
925 function selectedFeedDetails() {
927 if (!xmlhttp_ready(xmlhttp
)) {
932 var rows
= getSelectedFeeds();
934 if (rows
.length
== 0) {
935 alert("No feeds are selected.");
939 if (rows
.length
> 1) {
940 notify("Please select only one feed.");
948 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
949 param_escape(rows
.toString()), true);
950 xmlhttp
.onreadystatechange
=infobox_callback
;
955 function editSelectedFilter() {
956 var rows
= getSelectedFilters();
958 if (rows
.length
== 0) {
959 alert("No filters are selected.");
963 if (rows
.length
> 1) {
964 alert("Please select only one filter.");
975 function editSelectedFeed() {
976 var rows
= getSelectedFeeds();
978 if (rows
.length
== 0) {
979 notify("No feeds are selected.");
983 if (rows
.length
> 1) {
984 notify("Please select one feed.");
994 function editSelectedFeedCat() {
995 var rows
= getSelectedFeedCats();
997 if (rows
.length
== 0) {
998 alert("No categories are selected.");
1002 if (rows
.length
> 1) {
1003 alert("Please select only one category.");
1009 editFeedCat(rows
[0]);
1013 function piggie_callback() {
1014 var piggie
= document
.getElementById("piggie");
1016 piggie
.style
.top
= piggie_top
;
1017 piggie
.style
.backgroundColor
= "white";
1018 piggie
.style
.borderWidth
= "1px";
1020 if (piggie_fwd
&& piggie_top
< 0) {
1021 setTimeout("piggie_callback()", 50);
1022 piggie_top
= piggie_top
+ 10;
1023 } else if (piggie_fwd
&& piggie_top
>= 0) {
1025 setTimeout("piggie_callback()", 50);
1026 } else if (!piggie_fwd
&& piggie_top
> -400) {
1027 setTimeout("piggie_callback()", 50);
1028 piggie_top
= piggie_top
- 10;
1029 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1030 piggie
.style
.display
= "none";
1035 var piggie_opacity
= 0;
1037 function piggie2_callback() {
1038 var piggie
= document
.getElementById("piggie");
1039 piggie
.style
.top
= 0;
1040 piggie
.style
.opacity
= piggie_opacity
;
1041 piggie
.style
.backgroundColor
= "transparent";
1042 piggie
.style
.borderWidth
= "0px";
1044 if (piggie_fwd
&& piggie_opacity
< 1) {
1045 setTimeout("piggie2_callback()", 50);
1046 piggie_opacity
= piggie_opacity
+ 0.03;
1047 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1049 setTimeout("piggie2_callback()", 50);
1050 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1051 setTimeout("piggie2_callback()", 50);
1052 piggie_opacity
= piggie_opacity
- 0.03;
1053 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1054 piggie
.style
.display
= "none";
1059 function localPiggieFunction(enable
) {
1061 var piggie
= document
.getElementById("piggie");
1062 piggie
.style
.display
= "block";
1064 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1072 function validateOpmlImport() {
1074 var opml_file
= document
.getElementById("opml_file");
1076 if (opml_file
.value
.length
== 0) {
1077 alert("No OPML file to upload.");
1084 function updateFilterList() {
1086 if (!xmlhttp_ready(xmlhttp
)) {
1087 printLockingError();
1091 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1093 // p_notify("Loading, please wait...");
1095 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
1096 xmlhttp
.onreadystatechange
=filterlist_callback
;
1101 function updateLabelList() {
1103 if (!xmlhttp_ready(xmlhttp
)) {
1104 printLockingError();
1108 // p_notify("Loading, please wait...");
1110 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1112 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
1113 xmlhttp
.onreadystatechange
=labellist_callback
;
1117 function updatePrefsList() {
1119 if (!xmlhttp_ready(xmlhttp
)) {
1120 printLockingError();
1124 // p_notify("Loading, please wait...");
1126 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1127 xmlhttp
.onreadystatechange
=prefslist_callback
;
1132 function selectTab(id
, noupdate
) {
1136 if (!id
) id
= active_tab
;
1140 if (!xmlhttp_ready(xmlhttp
)) {
1141 printLockingError();
1147 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1149 notify("Loading, please wait...", true);
1151 // close active infobox if needed
1154 // clean up all current selections, just in case
1155 active_feed_cat
= false;
1156 active_label
= false;
1158 if (id
== "feedConfig") {
1160 } else if (id
== "filterConfig") {
1162 } else if (id
== "labelConfig") {
1164 } else if (id
== "genConfig") {
1166 } else if (id
== "userConfig") {
1168 } else if (id
== "feedBrowser") {
1169 updateBigFeedBrowser();
1173 var tab
= document
.getElementById(active_tab
+ "Tab");
1176 if (tab
.className
.match("Selected")) {
1177 tab
.className
= "prefsTab";
1181 tab
= document
.getElementById(id
+ "Tab");
1184 if (!tab
.className
.match("Selected")) {
1185 tab
.className
= tab
.className
+ "Selected";
1189 if (active_tab
!= id
) {
1190 storeInitParam("prefs_active_tab", id
);
1196 exception_error("selectTab", e
);
1200 function backend_sanity_check_callback() {
1202 if (xmlhttp
.readyState
== 4) {
1206 if (!xmlhttp
.responseXML
) {
1207 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1211 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1214 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1218 var error_code
= reply
.getAttribute("error-code");
1220 if (error_code
&& error_code
!= 0) {
1221 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1224 debug("sanity check ok");
1226 var params
= reply
.nextSibling
;
1229 debug('reading init-params...');
1230 var param
= params
.firstChild
;
1233 var k
= param
.getAttribute("key");
1234 var v
= param
.getAttribute("value");
1235 debug(k
+ " => " + v
);
1237 param
= param
.nextSibling
;
1241 init_second_stage();
1244 exception_error("backend_sanity_check_callback", e
);
1249 function init_second_stage() {
1252 active_tab
= getInitParam("prefs_active_tab");
1253 if (!active_tab
) active_tab
= "genConfig";
1255 if (navigator
.userAgent
.match("Opera")) {
1256 setTimeout("selectTab()", 500);
1258 selectTab(active_tab
);
1262 exception_error("init_second_stage", e
);
1270 if (arguments
.callee
.done
) return;
1271 arguments
.callee
.done
= true;
1273 if (getURLParam('debug')) {
1274 document
.getElementById('debug_output').style
.display
= 'block';
1275 debug('debug mode activated');
1280 document
.getElementById("prefContent").innerHTML
=
1281 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1282 "to function properly. Your browser doesn't seem to support it.";
1286 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1287 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1291 exception_error("init", e
);
1295 function categorizeSelectedFeeds() {
1297 if (!xmlhttp_ready(xmlhttp
)) {
1298 printLockingError();
1302 var sel_rows
= getSelectedFeeds();
1304 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1305 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1307 if (sel_rows
.length
> 0) {
1309 notify("Changing category of selected feeds...");
1311 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1312 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1313 xmlhttp
.onreadystatechange
=feedlist_callback
;
1318 alert("No feeds are selected.");
1324 function validatePrefsReset() {
1325 return confirm("Reset to defaults?");
1328 function browseFeeds(limit
) {
1330 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1331 xmlhttp
.onreadystatechange
=infobox_callback
;
1336 function feedBrowserSubscribe() {
1339 var selected
= getSelectedFeedsFromBrowser();
1341 if (selected
.length
> 0) {
1343 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1344 param_escape(selected
.toString()), true);
1345 xmlhttp
.onreadystatechange
=feedlist_callback
;
1348 alert("No feeds are selected.");
1352 exception_error("feedBrowserSubscribe", e
);
1356 function updateBigFeedBrowser(limit
) {
1358 if (!xmlhttp_ready(xmlhttp
)) {
1359 printLockingError();
1363 // p_notify("Loading, please wait...");
1365 var query
= "backend.php?op=pref-feed-browser";
1367 var limit_sel
= document
.getElementById("feedBrowserLimit");
1370 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1371 query
= query
+ "&limit=" + param_escape(limit
);
1374 xmlhttp
.open("GET", query
, true);
1375 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1379 function browserToggleExpand(id
) {
1381 /* if (feed_to_expand && feed_to_expand != id) {
1382 var d = document.getElementById("BRDET-" + feed_to_expand);
1383 d.style.display = "none";
1386 if (!xmlhttp_ready(xmlhttp
)) {
1387 printLockingError();
1391 var d
= document
.getElementById("BRDET-" + id
);
1393 if (d
.style
.display
== "block") {
1394 d
.style
.display
= "none";
1398 feed_to_expand
= id
;
1400 d
.style
.display
= "block";
1401 d
.innerHTML
= "Loading, please wait...";
1403 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1404 + param_escape(id
), true);
1405 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1410 exception_error("browserExpand", e
);
1414 function validateNewPassword(form
) {
1415 if (form
.OLD_PASSWORD
.value
== "") {
1416 alert("Old password cannot be blank");
1419 if (form
.NEW_PASSWORD
.value
== "") {
1420 alert("New password cannot be blank");
1426 function selectPrefRows(kind
, select
) {
1429 var opbarid
= false;
1434 if (kind
== "feed") {
1435 opbarid
= "feedOpToolbar";
1438 lname
= "prefFeedList";
1439 } else if (kind
== "fcat") {
1440 opbarid
= "catOpToolbar";
1443 lname
= "prefFeedCatList";
1444 } else if (kind
== "filter") {
1445 opbarid
= "filterOpToolbar";
1448 lname
= "prefFilterList";
1449 } else if (kind
== "label") {
1450 opbarid
= "labelOpToolbar";
1453 lname
= "prefLabelList";
1454 } else if (kind
== "user") {
1455 opbarid
= "userOpToolbar";
1458 lname
= "prefUserList";
1462 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1463 disableContainerChildren(opbarid
, !select
);
1470 function toggleSelectPrefRow(sender
, kind
) {
1472 toggleSelectRow(sender
);
1475 var opbarid
= false;
1478 if (kind
== "feed") {
1479 opbarid
= "feedOpToolbar";
1480 nsel
= getSelectedFeeds();
1481 } else if (kind
== "fcat") {
1482 opbarid
= "catOpToolbar";
1483 nsel
= getSelectedFeedCats();
1484 } else if (kind
== "filter") {
1485 opbarid
= "filterOpToolbar";
1486 nsel
= getSelectedFilters();
1487 } else if (kind
== "label") {
1488 opbarid
= "labelOpToolbar";
1489 nsel
= getSelectedLabels();
1490 } else if (kind
== "user") {
1491 opbarid
= "userOpToolbar";
1492 nsel
= getSelectedUsers();
1495 if (opbarid
&& nsel
!= -1) {
1496 disableContainerChildren(opbarid
, nsel
== false);
1502 function toggleSelectFBListRow(sender
) {
1503 toggleSelectListRow(sender
);
1504 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);