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 debug("I LOVEDED IT!");
1062 var piggie
= document
.getElementById("piggie");
1063 piggie
.style
.display
= "block";
1065 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1073 function validateOpmlImport() {
1075 var opml_file
= document
.getElementById("opml_file");
1077 if (opml_file
.value
.length
== 0) {
1078 alert("No OPML file to upload.");
1085 function updateFilterList() {
1087 if (!xmlhttp_ready(xmlhttp
)) {
1088 printLockingError();
1092 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1094 // p_notify("Loading, please wait...");
1096 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
1097 xmlhttp
.onreadystatechange
=filterlist_callback
;
1102 function updateLabelList() {
1104 if (!xmlhttp_ready(xmlhttp
)) {
1105 printLockingError();
1109 // p_notify("Loading, please wait...");
1111 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1113 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
1114 xmlhttp
.onreadystatechange
=labellist_callback
;
1118 function updatePrefsList() {
1120 if (!xmlhttp_ready(xmlhttp
)) {
1121 printLockingError();
1125 // p_notify("Loading, please wait...");
1127 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1128 xmlhttp
.onreadystatechange
=prefslist_callback
;
1133 function selectTab(id
, noupdate
) {
1137 if (!id
) id
= active_tab
;
1141 if (!xmlhttp_ready(xmlhttp
)) {
1142 printLockingError();
1148 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1150 notify("Loading, please wait...", true);
1152 // close active infobox if needed
1155 // clean up all current selections, just in case
1156 active_feed_cat
= false;
1157 active_label
= false;
1159 if (id
== "feedConfig") {
1161 } else if (id
== "filterConfig") {
1163 } else if (id
== "labelConfig") {
1165 } else if (id
== "genConfig") {
1167 } else if (id
== "userConfig") {
1169 } else if (id
== "feedBrowser") {
1170 updateBigFeedBrowser();
1174 var tab
= document
.getElementById(active_tab
+ "Tab");
1177 if (tab
.className
.match("Selected")) {
1178 tab
.className
= "prefsTab";
1182 tab
= document
.getElementById(id
+ "Tab");
1185 if (!tab
.className
.match("Selected")) {
1186 tab
.className
= tab
.className
+ "Selected";
1190 if (active_tab
!= id
) {
1191 storeInitParam("prefs_active_tab", id
);
1197 exception_error("selectTab", e
);
1201 function backend_sanity_check_callback() {
1203 if (xmlhttp
.readyState
== 4) {
1207 if (!xmlhttp
.responseXML
) {
1208 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1212 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1215 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1219 var error_code
= reply
.getAttribute("error-code");
1221 if (error_code
&& error_code
!= 0) {
1222 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1225 debug("sanity check ok");
1227 var params
= reply
.nextSibling
;
1230 debug('reading init-params...');
1231 var param
= params
.firstChild
;
1234 var k
= param
.getAttribute("key");
1235 var v
= param
.getAttribute("value");
1236 debug(k
+ " => " + v
);
1238 param
= param
.nextSibling
;
1242 init_second_stage();
1245 exception_error("backend_sanity_check_callback", e
);
1250 function init_second_stage() {
1253 active_tab
= getInitParam("prefs_active_tab");
1254 if (!active_tab
) active_tab
= "genConfig";
1256 document
.onkeydown
= pref_hotkey_handler
;
1258 if (navigator
.userAgent
.match("Opera")) {
1259 setTimeout("selectTab()", 500);
1261 selectTab(active_tab
);
1265 exception_error("init_second_stage", e
);
1273 if (arguments
.callee
.done
) return;
1274 arguments
.callee
.done
= true;
1276 if (getURLParam('debug')) {
1277 document
.getElementById('debug_output').style
.display
= 'block';
1278 debug('debug mode activated');
1283 document
.getElementById("prefContent").innerHTML
=
1284 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1285 "to function properly. Your browser doesn't seem to support it.";
1289 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1290 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1294 exception_error("init", e
);
1298 function categorizeSelectedFeeds() {
1300 if (!xmlhttp_ready(xmlhttp
)) {
1301 printLockingError();
1305 var sel_rows
= getSelectedFeeds();
1307 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1308 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1310 if (sel_rows
.length
> 0) {
1312 notify("Changing category of selected feeds...");
1314 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1315 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1316 xmlhttp
.onreadystatechange
=feedlist_callback
;
1321 alert("No feeds are selected.");
1327 function validatePrefsReset() {
1328 return confirm("Reset to defaults?");
1331 function browseFeeds(limit
) {
1333 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1334 xmlhttp
.onreadystatechange
=infobox_callback
;
1339 function feedBrowserSubscribe() {
1342 var selected
= getSelectedFeedsFromBrowser();
1344 if (selected
.length
> 0) {
1346 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1347 param_escape(selected
.toString()), true);
1348 xmlhttp
.onreadystatechange
=feedlist_callback
;
1351 alert("No feeds are selected.");
1355 exception_error("feedBrowserSubscribe", e
);
1359 function updateBigFeedBrowser(limit
) {
1361 if (!xmlhttp_ready(xmlhttp
)) {
1362 printLockingError();
1366 // p_notify("Loading, please wait...");
1368 var query
= "backend.php?op=pref-feed-browser";
1370 var limit_sel
= document
.getElementById("feedBrowserLimit");
1373 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1374 query
= query
+ "&limit=" + param_escape(limit
);
1377 xmlhttp
.open("GET", query
, true);
1378 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1382 function browserToggleExpand(id
) {
1384 /* if (feed_to_expand && feed_to_expand != id) {
1385 var d = document.getElementById("BRDET-" + feed_to_expand);
1386 d.style.display = "none";
1389 if (!xmlhttp_ready(xmlhttp
)) {
1390 printLockingError();
1394 var d
= document
.getElementById("BRDET-" + id
);
1396 if (d
.style
.display
== "block") {
1397 d
.style
.display
= "none";
1401 feed_to_expand
= id
;
1403 d
.style
.display
= "block";
1404 d
.innerHTML
= "Loading, please wait...";
1406 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1407 + param_escape(id
), true);
1408 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1413 exception_error("browserExpand", e
);
1417 function validateNewPassword(form
) {
1418 if (form
.OLD_PASSWORD
.value
== "") {
1419 alert("Old password cannot be blank");
1422 if (form
.NEW_PASSWORD
.value
== "") {
1423 alert("New password cannot be blank");
1429 function selectPrefRows(kind
, select
) {
1432 var opbarid
= false;
1437 if (kind
== "feed") {
1438 opbarid
= "feedOpToolbar";
1441 lname
= "prefFeedList";
1442 } else if (kind
== "fcat") {
1443 opbarid
= "catOpToolbar";
1446 lname
= "prefFeedCatList";
1447 } else if (kind
== "filter") {
1448 opbarid
= "filterOpToolbar";
1451 lname
= "prefFilterList";
1452 } else if (kind
== "label") {
1453 opbarid
= "labelOpToolbar";
1456 lname
= "prefLabelList";
1457 } else if (kind
== "user") {
1458 opbarid
= "userOpToolbar";
1461 lname
= "prefUserList";
1465 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1466 disableContainerChildren(opbarid
, !select
);
1473 function toggleSelectPrefRow(sender
, kind
) {
1475 toggleSelectRow(sender
);
1478 var opbarid
= false;
1481 if (kind
== "feed") {
1482 opbarid
= "feedOpToolbar";
1483 nsel
= getSelectedFeeds();
1484 } else if (kind
== "fcat") {
1485 opbarid
= "catOpToolbar";
1486 nsel
= getSelectedFeedCats();
1487 } else if (kind
== "filter") {
1488 opbarid
= "filterOpToolbar";
1489 nsel
= getSelectedFilters();
1490 } else if (kind
== "label") {
1491 opbarid
= "labelOpToolbar";
1492 nsel
= getSelectedLabels();
1493 } else if (kind
== "user") {
1494 opbarid
= "userOpToolbar";
1495 nsel
= getSelectedUsers();
1498 if (opbarid
&& nsel
!= -1) {
1499 disableContainerChildren(opbarid
, nsel
== false);
1505 function toggleSelectFBListRow(sender
) {
1506 toggleSelectListRow(sender
);
1507 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1512 function pref_hotkey_handler(e
) {
1517 if (!hotkeys_enabled
) return;
1520 keycode
= window
.event
.keyCode
;
1525 if (keycode
== 13 || keycode
== 27) {
1528 seq
= seq
+ "" + keycode
;
1532 if (document
.getElementById("piggie")) {
1534 if (seq
.match("807371717369")) {
1536 localPiggieFunction(true);
1538 localPiggieFunction(false);
1543 exception_error("pref_hotkey_handler", e
);