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) {
67 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 labeltest_callback() {
86 var container
= document
.getElementById('label_test_result');
87 if (xmlhttp
.readyState
== 4) {
88 container
.innerHTML
=xmlhttp
.responseText
;
93 function feed_browser_callback() {
94 var container
= document
.getElementById('prefContent');
95 if (xmlhttp
.readyState
== 4) {
96 container
.innerHTML
=xmlhttp
.responseText
;
101 function userlist_callback() {
102 var container
= document
.getElementById('prefContent');
103 if (xmlhttp
.readyState
== 4) {
104 container
.innerHTML
=xmlhttp
.responseText
;
109 function prefslist_callback() {
110 var container
= document
.getElementById('prefContent');
111 if (xmlhttp
.readyState
== 4) {
113 container
.innerHTML
=xmlhttp
.responseText
;
119 function gethelp_callback() {
120 var container
= document
.getElementById('prefHelpBox');
121 if (xmlhttp
.readyState
== 4) {
123 container
.innerHTML
= xmlhttp
.responseText
;
124 container
.style
.display
= "block";
130 function notify_callback() {
131 var container
= document
.getElementById('notify');
132 if (xmlhttp
.readyState
== 4) {
133 container
.innerHTML
=xmlhttp
.responseText
;
137 function updateFeedList(sort_key
) {
139 if (!xmlhttp_ready(xmlhttp
)) {
144 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
146 // p_notify("Loading, please wait...");
148 var feed_search
= document
.getElementById("feed_search");
150 if (feed_search
) { search
= feed_search
.value
; }
152 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
153 "&sort=" + param_escape(sort_key
) +
154 "&search=" + param_escape(search
), true);
155 xmlhttp
.onreadystatechange
=feedlist_callback
;
160 function updateUsersList(sort_key
) {
162 if (!xmlhttp_ready(xmlhttp
)) {
167 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
169 // p_notify("Loading, please wait...");
171 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
172 + param_escape(sort_key
), true);
173 xmlhttp
.onreadystatechange
=userlist_callback
;
178 function addLabel() {
180 if (!xmlhttp_ready(xmlhttp
)) {
185 var form
= document
.forms
['label_edit_form'];
187 var sql_exp
= form
.sql_exp
.value
;
188 var description
= form
.description
.value
;
191 alert("Can't create label: missing SQL expression.");
195 if (description
== "") {
196 alert("Can't create label: missing caption.");
200 var query
= Form
.serialize("label_edit_form");
202 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
203 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
209 if (!xmlhttp_ready(xmlhttp
)) {
214 var link
= document
.getElementById("fadd_link");
216 if (link
.value
.length
== 0) {
217 alert("Error: No feed URL given.");
218 } else if (!isValidURL(link
.value
)) {
219 alert("Error: Invalid feed URL.");
221 notify("Adding feed...");
223 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&feed_url=" +
224 param_escape(link
.value
), true);
225 xmlhttp
.onreadystatechange
=feedlist_callback
;
234 function addFeedCat() {
236 if (!xmlhttp_ready(xmlhttp
)) {
241 var cat
= document
.getElementById("fadd_cat");
243 if (cat
.value
.length
== 0) {
244 alert("Can't add category: no name specified.");
246 notify("Adding feed category...");
248 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
249 param_escape(cat
.value
), true);
250 xmlhttp
.onreadystatechange
=feedlist_callback
;
260 if (!xmlhttp_ready(xmlhttp
)) {
265 var sqlexp
= document
.getElementById("uadd_box");
267 if (sqlexp
.value
.length
== 0) {
268 alert("Can't add user: no login specified.");
270 notify("Adding user...");
272 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
273 param_escape(sqlexp
.value
), true);
275 xmlhttp
.onreadystatechange
=userlist_callback
;
283 function editLabel(id
) {
285 if (!xmlhttp_ready(xmlhttp
)) {
290 document
.getElementById("label_create_btn").disabled
= true;
294 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
295 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
297 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
298 param_escape(id
), true);
299 xmlhttp
.onreadystatechange
=infobox_callback
;
304 function editUser(id
) {
306 if (!xmlhttp_ready(xmlhttp
)) {
311 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
312 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
314 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
315 param_escape(id
), true);
316 xmlhttp
.onreadystatechange
=infobox_callback
;
321 function editFilter(id
) {
323 if (!xmlhttp_ready(xmlhttp
)) {
328 document
.getElementById("create_filter_btn").disabled
= true;
330 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
331 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
333 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
334 xmlhttp
.onreadystatechange
=infobox_callback
;
338 function editFeed(feed
) {
340 // notify("Editing feed...");
342 if (!xmlhttp_ready(xmlhttp
)) {
347 // clean selection from all rows & select row being edited
348 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
349 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
351 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
352 param_escape(feed
), true);
354 xmlhttp
.onreadystatechange
=infobox_callback
;
359 function editFeedCat(cat
) {
361 if (!xmlhttp_ready(xmlhttp
)) {
366 active_feed_cat
= cat
;
368 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
369 param_escape(cat
), true);
370 xmlhttp
.onreadystatechange
=feedlist_callback
;
375 function getSelectedLabels() {
376 return getSelectedTableRowIds("prefLabelList", "LILRR");
379 function getSelectedUsers() {
380 return getSelectedTableRowIds("prefUserList", "UMRR");
383 function getSelectedFeeds() {
384 return getSelectedTableRowIds("prefFeedList", "FEEDR");
387 function getSelectedFilters() {
388 return getSelectedTableRowIds("prefFilterList", "FILRR");
391 function getSelectedFeedCats() {
392 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
395 function getSelectedFeedsFromBrowser() {
397 var list
= document
.getElementById("browseFeedList");
398 if (!list
) list
= document
.getElementById("browseBigFeedList");
400 var selected
= new Array();
402 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
403 var child
= list
.childNodes
[i
];
404 if (child
.id
&& child
.id
.match("FBROW-")) {
405 var id
= child
.id
.replace("FBROW-", "");
407 var cb
= document
.getElementById("FBCHK-" + id
);
418 function removeSelectedLabels() {
420 if (!xmlhttp_ready(xmlhttp
)) {
425 var sel_rows
= getSelectedLabels();
427 if (sel_rows
.length
> 0) {
429 var ok
= confirm("Remove selected labels?");
432 notify("Removing selected labels...");
434 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
435 param_escape(sel_rows
.toString()), true);
436 xmlhttp
.onreadystatechange
=labellist_callback
;
440 alert("No labels are selected.");
446 function removeSelectedUsers() {
448 if (!xmlhttp_ready(xmlhttp
)) {
453 var sel_rows
= getSelectedUsers();
455 if (sel_rows
.length
> 0) {
457 var ok
= confirm("Remove selected users?");
460 notify("Removing selected users...");
462 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
463 param_escape(sel_rows
.toString()), true);
464 xmlhttp
.onreadystatechange
=userlist_callback
;
469 alert("No users are selected.");
475 function removeSelectedFilters() {
477 if (!xmlhttp_ready(xmlhttp
)) {
482 var sel_rows
= getSelectedFilters();
484 if (sel_rows
.length
> 0) {
486 var ok
= confirm("Remove selected filters?");
489 notify("Removing selected filters...");
491 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
492 param_escape(sel_rows
.toString()), true);
493 xmlhttp
.onreadystatechange
=filterlist_callback
;
497 alert("No filters are selected.");
504 function removeSelectedFeeds() {
506 if (!xmlhttp_ready(xmlhttp
)) {
511 var sel_rows
= getSelectedFeeds();
513 if (sel_rows
.length
> 0) {
515 var ok
= confirm("Unsubscribe from selected feeds?");
519 notify("Unsubscribing from selected feeds...");
521 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
522 param_escape(sel_rows
.toString()), true);
523 xmlhttp
.onreadystatechange
=feedlist_callback
;
529 alert("No feeds are selected.");
536 function removeSelectedFeedCats() {
538 if (!xmlhttp_ready(xmlhttp
)) {
543 var sel_rows
= getSelectedFeedCats();
545 if (sel_rows
.length
> 0) {
547 var ok
= confirm("Remove selected categories?");
550 notify("Removing selected categories...");
552 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
553 param_escape(sel_rows
.toString()), true);
554 xmlhttp
.onreadystatechange
=feedlist_callback
;
560 alert("No categories are selected.");
567 function feedEditCancel() {
569 if (!xmlhttp_ready(xmlhttp
)) {
576 selectPrefRows('feed', false); // cleanup feed selection
581 function feedCatEditCancel() {
583 if (!xmlhttp_ready(xmlhttp
)) {
588 active_feed_cat
= false;
590 // notify("Operation cancelled.");
592 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
593 xmlhttp
.onreadystatechange
=feedlist_callback
;
599 function feedEditSave() {
603 if (!xmlhttp_ready(xmlhttp
)) {
608 // FIXME: add parameter validation
610 var query
= Form
.serialize("edit_feed_form");
612 notify("Saving feed...");
614 xmlhttp
.open("POST", "backend.php", true);
615 xmlhttp
.onreadystatechange
=feedlist_callback
;
616 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
624 exception_error("feedEditSave", e
);
628 function feedCatEditSave() {
630 if (!xmlhttp_ready(xmlhttp
)) {
635 notify("Saving category...");
637 var query
= Form
.serialize("feed_cat_edit_form");
639 xmlhttp
.open("GET", "backend.php?" + query
, true);
640 xmlhttp
.onreadystatechange
=feedlist_callback
;
643 active_feed_cat
= false;
649 function labelTest() {
651 var container
= document
.getElementById('label_test_result');
652 container
.style
.display
= "block";
653 container
.innerHTML
= "<p>Loading, please wait...</p>";
655 var form
= document
.forms
['label_edit_form'];
657 var sql_exp
= form
.sql_exp
.value
;
658 var description
= form
.description
.value
;
660 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
661 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
663 xmlhttp
.onreadystatechange
=labeltest_callback
;
669 function displayHelpInfobox(topic_id
) {
671 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
672 param_escape(topic_id
) + "&noheaders=1", true);
674 xmlhttp
.onreadystatechange
=infobox_callback
;
679 function labelEditCancel() {
681 if (!xmlhttp_ready(xmlhttp
)) {
686 document
.getElementById("label_create_btn").disabled
= false;
688 active_label
= false;
690 selectPrefRows('label', false); // cleanup feed selection
696 function userEditCancel() {
698 if (!xmlhttp_ready(xmlhttp
)) {
703 selectPrefRows('user', false); // cleanup feed selection
709 function filterEditCancel() {
711 if (!xmlhttp_ready(xmlhttp
)) {
716 document
.getElementById("create_filter_btn").disabled
= false;
718 selectPrefRows('filter', false); // cleanup feed selection
724 function labelEditSave() {
726 var label
= active_label
;
728 if (!xmlhttp_ready(xmlhttp
)) {
735 var sql_exp
= document
.forms
["label_edit_form"].sql_exp
.value
;
736 var description
= document
.forms
["label_edit_form"].description
.value
;
738 if (sql_exp
.length
== 0) {
739 alert("SQL Expression cannot be blank.");
743 if (description
.length
== 0) {
744 alert("Caption field cannot be blank.");
751 notify("Saving label...");
753 active_label
= false;
755 query
= Form
.serialize("label_edit_form");
757 xmlhttp
.open("GET", "backend.php?" + query
, true);
758 xmlhttp
.onreadystatechange
=labellist_callback
;
764 function userEditSave() {
766 if (!xmlhttp_ready(xmlhttp
)) {
771 var login
= document
.forms
["user_edit_form"].login
.value
;
773 if (login
.length
== 0) {
774 alert("Login field cannot be blank.");
778 notify("Saving user...");
782 var query
= Form
.serialize("user_edit_form");
784 xmlhttp
.open("GET", "backend.php?" + query
, true);
785 xmlhttp
.onreadystatechange
=userlist_callback
;
792 function filterEditSave() {
794 if (!xmlhttp_ready(xmlhttp
)) {
800 var reg_exp
= document
.forms
["filter_edit_form"].reg_exp
.value
;
802 if (reg_exp
.length
== 0) {
803 alert("Filter expression field cannot be blank.");
808 notify("Saving filter...");
810 var query
= Form
.serialize("filter_edit_form");
814 document
.getElementById("create_filter_btn").disabled
= false;
816 xmlhttp
.open("GET", "backend.php?" + query
, true);
817 xmlhttp
.onreadystatechange
=filterlist_callback
;
823 function editSelectedLabel() {
824 var rows
= getSelectedLabels();
826 if (rows
.length
== 0) {
827 alert("No labels are selected.");
831 if (rows
.length
> 1) {
832 alert("Please select only one label.");
842 function editSelectedUser() {
843 var rows
= getSelectedUsers();
845 if (rows
.length
== 0) {
846 alert("No users are selected.");
850 if (rows
.length
> 1) {
851 alert("Please select only one user.");
860 function resetSelectedUserPass() {
861 var rows
= getSelectedUsers();
863 if (rows
.length
== 0) {
864 alert("No users are selected.");
868 if (rows
.length
> 1) {
869 alert("Please select only one user.");
873 var ok
= confirm("Reset password of selected user?");
876 notify("Resetting password for selected user...");
880 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
881 param_escape(id
), true);
882 xmlhttp
.onreadystatechange
=userlist_callback
;
887 function selectedUserDetails() {
889 if (!xmlhttp_ready(xmlhttp
)) {
894 var rows
= getSelectedUsers();
896 if (rows
.length
== 0) {
897 alert("No users are selected.");
901 if (rows
.length
> 1) {
902 alert("Please select only one user.");
910 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
911 xmlhttp
.onreadystatechange
=infobox_callback
;
916 function selectedFeedDetails() {
918 if (!xmlhttp_ready(xmlhttp
)) {
923 var rows
= getSelectedFeeds();
925 if (rows
.length
== 0) {
926 alert("No feeds are selected.");
930 if (rows
.length
> 1) {
931 notify("Please select only one feed.");
939 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
940 param_escape(rows
.toString()), true);
941 xmlhttp
.onreadystatechange
=infobox_callback
;
946 function editSelectedFilter() {
947 var rows
= getSelectedFilters();
949 if (rows
.length
== 0) {
950 alert("No filters are selected.");
954 if (rows
.length
> 1) {
955 alert("Please select only one filter.");
966 function editSelectedFeed() {
967 var rows
= getSelectedFeeds();
969 if (rows
.length
== 0) {
970 notify("No feeds are selected.");
974 if (rows
.length
> 1) {
975 notify("Please select one feed.");
985 function editSelectedFeedCat() {
986 var rows
= getSelectedFeedCats();
988 if (rows
.length
== 0) {
989 alert("No categories are selected.");
993 if (rows
.length
> 1) {
994 alert("Please select only one category.");
1000 editFeedCat(rows
[0]);
1004 function piggie_callback() {
1005 var piggie
= document
.getElementById("piggie");
1007 piggie
.style
.top
= piggie_top
;
1008 piggie
.style
.backgroundColor
= "white";
1009 piggie
.style
.borderWidth
= "1px";
1011 if (piggie_fwd
&& piggie_top
< 0) {
1012 setTimeout("piggie_callback()", 50);
1013 piggie_top
= piggie_top
+ 10;
1014 } else if (piggie_fwd
&& piggie_top
>= 0) {
1016 setTimeout("piggie_callback()", 50);
1017 } else if (!piggie_fwd
&& piggie_top
> -400) {
1018 setTimeout("piggie_callback()", 50);
1019 piggie_top
= piggie_top
- 10;
1020 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1021 piggie
.style
.display
= "none";
1026 var piggie_opacity
= 0;
1028 function piggie2_callback() {
1029 var piggie
= document
.getElementById("piggie");
1030 piggie
.style
.top
= 0;
1031 piggie
.style
.opacity
= piggie_opacity
;
1032 piggie
.style
.backgroundColor
= "transparent";
1033 piggie
.style
.borderWidth
= "0px";
1035 if (piggie_fwd
&& piggie_opacity
< 1) {
1036 setTimeout("piggie2_callback()", 50);
1037 piggie_opacity
= piggie_opacity
+ 0.03;
1038 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1040 setTimeout("piggie2_callback()", 50);
1041 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1042 setTimeout("piggie2_callback()", 50);
1043 piggie_opacity
= piggie_opacity
- 0.03;
1044 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1045 piggie
.style
.display
= "none";
1050 function localPiggieFunction(enable
) {
1052 debug("I LOVEDED IT!");
1053 var piggie
= document
.getElementById("piggie");
1054 piggie
.style
.display
= "block";
1056 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1064 function validateOpmlImport() {
1066 var opml_file
= document
.getElementById("opml_file");
1068 if (opml_file
.value
.length
== 0) {
1069 alert("No OPML file to upload.");
1076 function updateFilterList(sort_key
) {
1078 if (!xmlhttp_ready(xmlhttp
)) {
1079 printLockingError();
1083 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1085 // p_notify("Loading, please wait...");
1087 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1088 param_escape(sort_key
), true);
1089 xmlhttp
.onreadystatechange
=filterlist_callback
;
1094 function updateLabelList(sort_key
) {
1096 if (!xmlhttp_ready(xmlhttp
)) {
1097 printLockingError();
1101 // p_notify("Loading, please wait...");
1103 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1105 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1106 param_escape(sort_key
), true);
1107 xmlhttp
.onreadystatechange
=labellist_callback
;
1111 function updatePrefsList() {
1113 if (!xmlhttp_ready(xmlhttp
)) {
1114 printLockingError();
1118 // p_notify("Loading, please wait...");
1120 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1121 xmlhttp
.onreadystatechange
=prefslist_callback
;
1126 function selectTab(id
, noupdate
) {
1130 if (!id
) id
= active_tab
;
1134 if (!xmlhttp_ready(xmlhttp
)) {
1135 printLockingError();
1141 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1143 // notify("Loading, please wait...", true);
1145 // close active infobox if needed
1148 // clean up all current selections, just in case
1149 active_feed_cat
= false;
1150 active_label
= false;
1152 if (id
== "feedConfig") {
1154 } else if (id
== "filterConfig") {
1156 } else if (id
== "labelConfig") {
1158 } else if (id
== "genConfig") {
1160 } else if (id
== "userConfig") {
1162 } else if (id
== "feedBrowser") {
1163 updateBigFeedBrowser();
1167 var tab
= document
.getElementById(active_tab
+ "Tab");
1170 if (tab
.className
.match("Selected")) {
1171 tab
.className
= "prefsTab";
1175 tab
= document
.getElementById(id
+ "Tab");
1178 if (!tab
.className
.match("Selected")) {
1179 tab
.className
= tab
.className
+ "Selected";
1183 if (active_tab
!= id
) {
1184 storeInitParam("prefs_active_tab", id
);
1190 exception_error("selectTab", e
);
1194 function backend_sanity_check_callback() {
1196 if (xmlhttp
.readyState
== 4) {
1200 if (!xmlhttp
.responseXML
) {
1201 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1205 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1208 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1212 var error_code
= reply
.getAttribute("error-code");
1214 if (error_code
&& error_code
!= 0) {
1215 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1218 debug("sanity check ok");
1220 var params
= reply
.nextSibling
;
1223 debug('reading init-params...');
1224 var param
= params
.firstChild
;
1227 var k
= param
.getAttribute("key");
1228 var v
= param
.getAttribute("value");
1229 debug(k
+ " => " + v
);
1231 param
= param
.nextSibling
;
1235 init_second_stage();
1238 exception_error("backend_sanity_check_callback", e
);
1243 function init_second_stage() {
1246 active_tab
= getInitParam("prefs_active_tab");
1247 if (!active_tab
) active_tab
= "genConfig";
1249 document
.onkeydown
= pref_hotkey_handler
;
1251 if (navigator
.userAgent
.match("Opera")) {
1252 setTimeout("selectTab()", 500);
1254 selectTab(active_tab
);
1258 exception_error("init_second_stage", e
);
1266 if (arguments
.callee
.done
) return;
1267 arguments
.callee
.done
= true;
1269 if (getURLParam('debug')) {
1270 document
.getElementById('debug_output').style
.display
= 'block';
1271 debug('debug mode activated');
1276 document
.getElementById("prefContent").innerHTML
=
1277 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1278 "to function properly. Your browser doesn't seem to support it.";
1282 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1283 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1287 exception_error("init", e
);
1291 function categorizeSelectedFeeds() {
1293 if (!xmlhttp_ready(xmlhttp
)) {
1294 printLockingError();
1298 var sel_rows
= getSelectedFeeds();
1300 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1301 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1303 if (sel_rows
.length
> 0) {
1305 notify("Changing category of selected feeds...");
1307 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1308 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1309 xmlhttp
.onreadystatechange
=feedlist_callback
;
1314 alert("No feeds are selected.");
1320 function validatePrefsReset() {
1321 return confirm("Reset to defaults?");
1324 function browseFeeds(limit
) {
1326 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1327 xmlhttp
.onreadystatechange
=infobox_callback
;
1332 function feedBrowserSubscribe() {
1335 var selected
= getSelectedFeedsFromBrowser();
1337 if (selected
.length
> 0) {
1339 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1340 param_escape(selected
.toString()), true);
1341 xmlhttp
.onreadystatechange
=feedlist_callback
;
1344 alert("No feeds are selected.");
1348 exception_error("feedBrowserSubscribe", e
);
1352 function updateBigFeedBrowser(limit
) {
1354 if (!xmlhttp_ready(xmlhttp
)) {
1355 printLockingError();
1359 // p_notify("Loading, please wait...");
1361 var query
= "backend.php?op=pref-feed-browser";
1363 var limit_sel
= document
.getElementById("feedBrowserLimit");
1366 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1367 query
= query
+ "&limit=" + param_escape(limit
);
1370 xmlhttp
.open("GET", query
, true);
1371 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1375 function browserToggleExpand(id
) {
1377 /* if (feed_to_expand && feed_to_expand != id) {
1378 var d = document.getElementById("BRDET-" + feed_to_expand);
1379 d.style.display = "none";
1382 if (!xmlhttp_ready(xmlhttp
)) {
1383 printLockingError();
1387 var d
= document
.getElementById("BRDET-" + id
);
1389 if (d
.style
.display
== "block") {
1390 d
.style
.display
= "none";
1394 feed_to_expand
= id
;
1396 d
.style
.display
= "block";
1397 d
.innerHTML
= "Loading, please wait...";
1399 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1400 + param_escape(id
), true);
1401 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1406 exception_error("browserExpand", e
);
1410 function validateNewPassword(form
) {
1411 if (form
.OLD_PASSWORD
.value
== "") {
1412 alert("Old password cannot be blank");
1415 if (form
.NEW_PASSWORD
.value
== "") {
1416 alert("New password cannot be blank");
1422 function selectPrefRows(kind
, select
) {
1425 var opbarid
= false;
1430 if (kind
== "feed") {
1431 opbarid
= "feedOpToolbar";
1434 lname
= "prefFeedList";
1435 } else if (kind
== "fcat") {
1436 opbarid
= "catOpToolbar";
1439 lname
= "prefFeedCatList";
1440 } else if (kind
== "filter") {
1441 opbarid
= "filterOpToolbar";
1444 lname
= "prefFilterList";
1445 } else if (kind
== "label") {
1446 opbarid
= "labelOpToolbar";
1449 lname
= "prefLabelList";
1450 } else if (kind
== "user") {
1451 opbarid
= "userOpToolbar";
1454 lname
= "prefUserList";
1458 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1459 disableContainerChildren(opbarid
, !select
);
1466 function toggleSelectPrefRow(sender
, kind
) {
1468 toggleSelectRow(sender
);
1471 var opbarid
= false;
1474 if (kind
== "feed") {
1475 opbarid
= "feedOpToolbar";
1476 nsel
= getSelectedFeeds();
1477 } else if (kind
== "fcat") {
1478 opbarid
= "catOpToolbar";
1479 nsel
= getSelectedFeedCats();
1480 } else if (kind
== "filter") {
1481 opbarid
= "filterOpToolbar";
1482 nsel
= getSelectedFilters();
1483 } else if (kind
== "label") {
1484 opbarid
= "labelOpToolbar";
1485 nsel
= getSelectedLabels();
1486 } else if (kind
== "user") {
1487 opbarid
= "userOpToolbar";
1488 nsel
= getSelectedUsers();
1491 if (opbarid
&& nsel
!= -1) {
1492 disableContainerChildren(opbarid
, nsel
== false);
1498 function toggleSelectFBListRow(sender
) {
1499 toggleSelectListRow(sender
);
1500 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1505 function pref_hotkey_handler(e
) {
1510 if (!hotkeys_enabled
) return;
1513 keycode
= window
.event
.keyCode
;
1518 if (keycode
== 13 || keycode
== 27) {
1521 seq
= seq
+ "" + keycode
;
1525 if (document
.getElementById("piggie")) {
1527 if (seq
.match("807371717369")) {
1529 localPiggieFunction(true);
1531 localPiggieFunction(false);
1536 exception_error("pref_hotkey_handler", e
);