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() {
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", true);
172 xmlhttp
.onreadystatechange
=userlist_callback
;
177 function addLabel() {
179 if (!xmlhttp_ready(xmlhttp
)) {
184 var form
= document
.forms
['label_edit_form'];
186 var sql_exp
= form
.sql_exp
.value
;
187 var description
= form
.description
.value
;
190 alert("Can't create label: missing SQL expression.");
194 if (description
== "") {
195 alert("Can't create label: missing caption.");
199 var query
= Form
.serialize("label_edit_form");
201 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
202 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
208 if (!xmlhttp_ready(xmlhttp
)) {
213 var link
= document
.getElementById("fadd_link");
215 if (link
.value
.length
== 0) {
216 alert("Error: No feed URL given.");
217 } else if (!isValidURL(link
.value
)) {
218 alert("Error: Invalid feed URL.");
220 notify("Adding feed...");
222 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&feed_url=" +
223 param_escape(link
.value
), true);
224 xmlhttp
.onreadystatechange
=feedlist_callback
;
233 function addFeedCat() {
235 if (!xmlhttp_ready(xmlhttp
)) {
240 var cat
= document
.getElementById("fadd_cat");
242 if (cat
.value
.length
== 0) {
243 alert("Can't add category: no name specified.");
245 notify("Adding feed category...");
247 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
248 param_escape(cat
.value
), true);
249 xmlhttp
.onreadystatechange
=feedlist_callback
;
259 if (!xmlhttp_ready(xmlhttp
)) {
264 var sqlexp
= document
.getElementById("uadd_box");
266 if (sqlexp
.value
.length
== 0) {
267 alert("Can't add user: no login specified.");
269 notify("Adding user...");
271 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
272 param_escape(sqlexp
.value
), true);
274 xmlhttp
.onreadystatechange
=userlist_callback
;
282 function editLabel(id
) {
284 if (!xmlhttp_ready(xmlhttp
)) {
289 document
.getElementById("label_create_btn").disabled
= true;
293 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
294 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
296 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
297 param_escape(id
), true);
298 xmlhttp
.onreadystatechange
=infobox_callback
;
303 function editUser(id
) {
305 if (!xmlhttp_ready(xmlhttp
)) {
310 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
311 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
313 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
314 param_escape(id
), true);
315 xmlhttp
.onreadystatechange
=infobox_callback
;
320 function editFilter(id
) {
322 if (!xmlhttp_ready(xmlhttp
)) {
327 document
.getElementById("create_filter_btn").disabled
= true;
329 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
330 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
332 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
333 xmlhttp
.onreadystatechange
=infobox_callback
;
337 function editFeed(feed
) {
339 // notify("Editing feed...");
341 if (!xmlhttp_ready(xmlhttp
)) {
346 // clean selection from all rows & select row being edited
347 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
348 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
350 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
351 param_escape(feed
), true);
353 xmlhttp
.onreadystatechange
=infobox_callback
;
358 function editFeedCat(cat
) {
360 if (!xmlhttp_ready(xmlhttp
)) {
365 active_feed_cat
= cat
;
367 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
368 param_escape(cat
), true);
369 xmlhttp
.onreadystatechange
=feedlist_callback
;
374 function getSelectedLabels() {
375 return getSelectedTableRowIds("prefLabelList", "LILRR");
378 function getSelectedUsers() {
379 return getSelectedTableRowIds("prefUserList", "UMRR");
382 function getSelectedFeeds() {
383 return getSelectedTableRowIds("prefFeedList", "FEEDR");
386 function getSelectedFilters() {
387 return getSelectedTableRowIds("prefFilterList", "FILRR");
390 function getSelectedFeedCats() {
391 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
394 function getSelectedFeedsFromBrowser() {
396 var list
= document
.getElementById("browseFeedList");
397 if (!list
) list
= document
.getElementById("browseBigFeedList");
399 var selected
= new Array();
401 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
402 var child
= list
.childNodes
[i
];
403 if (child
.id
&& child
.id
.match("FBROW-")) {
404 var id
= child
.id
.replace("FBROW-", "");
406 var cb
= document
.getElementById("FBCHK-" + id
);
417 function removeSelectedLabels() {
419 if (!xmlhttp_ready(xmlhttp
)) {
424 var sel_rows
= getSelectedLabels();
426 if (sel_rows
.length
> 0) {
428 var ok
= confirm("Remove selected labels?");
431 notify("Removing selected labels...");
433 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
434 param_escape(sel_rows
.toString()), true);
435 xmlhttp
.onreadystatechange
=labellist_callback
;
439 alert("No labels are selected.");
445 function removeSelectedUsers() {
447 if (!xmlhttp_ready(xmlhttp
)) {
452 var sel_rows
= getSelectedUsers();
454 if (sel_rows
.length
> 0) {
456 var ok
= confirm("Remove selected users?");
459 notify("Removing selected users...");
461 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
462 param_escape(sel_rows
.toString()), true);
463 xmlhttp
.onreadystatechange
=userlist_callback
;
468 alert("No users are selected.");
474 function removeSelectedFilters() {
476 if (!xmlhttp_ready(xmlhttp
)) {
481 var sel_rows
= getSelectedFilters();
483 if (sel_rows
.length
> 0) {
485 var ok
= confirm("Remove selected filters?");
488 notify("Removing selected filters...");
490 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
491 param_escape(sel_rows
.toString()), true);
492 xmlhttp
.onreadystatechange
=filterlist_callback
;
496 alert("No filters are selected.");
503 function removeSelectedFeeds() {
505 if (!xmlhttp_ready(xmlhttp
)) {
510 var sel_rows
= getSelectedFeeds();
512 if (sel_rows
.length
> 0) {
514 var ok
= confirm("Unsubscribe from selected feeds?");
518 notify("Unsubscribing from selected feeds...");
520 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
521 param_escape(sel_rows
.toString()), true);
522 xmlhttp
.onreadystatechange
=feedlist_callback
;
528 alert("No feeds are selected.");
535 function removeSelectedFeedCats() {
537 if (!xmlhttp_ready(xmlhttp
)) {
542 var sel_rows
= getSelectedFeedCats();
544 if (sel_rows
.length
> 0) {
546 var ok
= confirm("Remove selected categories?");
549 notify("Removing selected categories...");
551 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
552 param_escape(sel_rows
.toString()), true);
553 xmlhttp
.onreadystatechange
=feedlist_callback
;
559 alert("No categories are selected.");
566 function feedEditCancel() {
568 if (!xmlhttp_ready(xmlhttp
)) {
575 selectPrefRows('feed', false); // cleanup feed selection
580 function feedCatEditCancel() {
582 if (!xmlhttp_ready(xmlhttp
)) {
587 active_feed_cat
= false;
589 // notify("Operation cancelled.");
591 xmlhttp
.open("GET", "backend.php?op=pref-feeds", true);
592 xmlhttp
.onreadystatechange
=feedlist_callback
;
598 function feedEditSave() {
602 if (!xmlhttp_ready(xmlhttp
)) {
607 // FIXME: add parameter validation
609 var query
= Form
.serialize("edit_feed_form");
611 notify("Saving feed...");
613 xmlhttp
.open("POST", "backend.php", true);
614 xmlhttp
.onreadystatechange
=feedlist_callback
;
615 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
623 exception_error("feedEditSave", e
);
627 function feedCatEditSave() {
629 if (!xmlhttp_ready(xmlhttp
)) {
634 notify("Saving category...");
636 var query
= Form
.serialize("feed_cat_edit_form");
638 xmlhttp
.open("GET", "backend.php?" + query
, true);
639 xmlhttp
.onreadystatechange
=feedlist_callback
;
642 active_feed_cat
= false;
648 function labelTest() {
650 var container
= document
.getElementById('label_test_result');
651 container
.style
.display
= "block";
652 container
.innerHTML
= "<p>Loading, please wait...</p>";
654 var form
= document
.forms
['label_edit_form'];
656 var sql_exp
= form
.sql_exp
.value
;
657 var description
= form
.description
.value
;
659 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
660 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
662 xmlhttp
.onreadystatechange
=labeltest_callback
;
668 function displayHelpInfobox(topic_id
) {
670 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
671 param_escape(topic_id
) + "&noheaders=1", true);
673 xmlhttp
.onreadystatechange
=infobox_callback
;
678 function labelEditCancel() {
680 if (!xmlhttp_ready(xmlhttp
)) {
685 document
.getElementById("label_create_btn").disabled
= false;
687 active_label
= false;
689 selectPrefRows('label', false); // cleanup feed selection
695 function userEditCancel() {
697 if (!xmlhttp_ready(xmlhttp
)) {
702 selectPrefRows('user', false); // cleanup feed selection
708 function filterEditCancel() {
710 if (!xmlhttp_ready(xmlhttp
)) {
715 document
.getElementById("create_filter_btn").disabled
= false;
717 selectPrefRows('filter', false); // cleanup feed selection
723 function labelEditSave() {
725 var label
= active_label
;
727 if (!xmlhttp_ready(xmlhttp
)) {
732 var sql_exp
= document
.forms
["label_edit_form"].sql_exp
.value
;
733 var description
= document
.forms
["label_edit_form"].description
.value
;
735 if (sql_exp
.length
== 0) {
736 alert("SQL Expression cannot be blank.");
740 if (description
.length
== 0) {
741 alert("Caption field cannot be blank.");
747 notify("Saving label...");
749 active_label
= false;
751 query
= Form
.serialize("label_edit_form");
753 xmlhttp
.open("GET", "backend.php?" + query
, true);
754 xmlhttp
.onreadystatechange
=labellist_callback
;
760 function userEditSave() {
762 if (!xmlhttp_ready(xmlhttp
)) {
767 var login
= document
.forms
["user_edit_form"].login
.value
;
769 if (login
.length
== 0) {
770 alert("Login field cannot be blank.");
774 notify("Saving user...");
778 var query
= Form
.serialize("user_edit_form");
780 xmlhttp
.open("GET", "backend.php?" + query
, true);
781 xmlhttp
.onreadystatechange
=userlist_callback
;
788 function filterEditSave() {
790 if (!xmlhttp_ready(xmlhttp
)) {
795 var reg_exp
= document
.forms
["filter_edit_form"].reg_exp
.value
;
797 if (reg_exp
.length
== 0) {
798 alert("Filter expression field cannot be blank.");
802 notify("Saving filter...");
804 var query
= Form
.serialize("filter_edit_form");
808 document
.getElementById("create_filter_btn").disabled
= false;
810 xmlhttp
.open("GET", "backend.php?" + query
, true);
811 xmlhttp
.onreadystatechange
=filterlist_callback
;
817 function editSelectedLabel() {
818 var rows
= getSelectedLabels();
820 if (rows
.length
== 0) {
821 alert("No labels are selected.");
825 if (rows
.length
> 1) {
826 alert("Please select only one label.");
836 function editSelectedUser() {
837 var rows
= getSelectedUsers();
839 if (rows
.length
== 0) {
840 alert("No users are selected.");
844 if (rows
.length
> 1) {
845 alert("Please select only one user.");
854 function resetSelectedUserPass() {
855 var rows
= getSelectedUsers();
857 if (rows
.length
== 0) {
858 alert("No users are selected.");
862 if (rows
.length
> 1) {
863 alert("Please select only one user.");
867 var ok
= confirm("Reset password of selected user?");
870 notify("Resetting password for selected user...");
874 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
875 param_escape(id
), true);
876 xmlhttp
.onreadystatechange
=userlist_callback
;
881 function selectedUserDetails() {
883 if (!xmlhttp_ready(xmlhttp
)) {
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.");
904 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
905 xmlhttp
.onreadystatechange
=infobox_callback
;
910 function selectedFeedDetails() {
912 if (!xmlhttp_ready(xmlhttp
)) {
917 var rows
= getSelectedFeeds();
919 if (rows
.length
== 0) {
920 alert("No feeds are selected.");
924 if (rows
.length
> 1) {
925 notify("Please select only one feed.");
933 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
934 param_escape(rows
.toString()), true);
935 xmlhttp
.onreadystatechange
=infobox_callback
;
940 function editSelectedFilter() {
941 var rows
= getSelectedFilters();
943 if (rows
.length
== 0) {
944 alert("No filters are selected.");
948 if (rows
.length
> 1) {
949 alert("Please select only one filter.");
960 function editSelectedFeed() {
961 var rows
= getSelectedFeeds();
963 if (rows
.length
== 0) {
964 notify("No feeds are selected.");
968 if (rows
.length
> 1) {
969 notify("Please select one feed.");
979 function editSelectedFeedCat() {
980 var rows
= getSelectedFeedCats();
982 if (rows
.length
== 0) {
983 alert("No categories are selected.");
987 if (rows
.length
> 1) {
988 alert("Please select only one category.");
994 editFeedCat(rows
[0]);
998 function piggie_callback() {
999 var piggie
= document
.getElementById("piggie");
1001 piggie
.style
.top
= piggie_top
;
1002 piggie
.style
.backgroundColor
= "white";
1003 piggie
.style
.borderWidth
= "1px";
1005 if (piggie_fwd
&& piggie_top
< 0) {
1006 setTimeout("piggie_callback()", 50);
1007 piggie_top
= piggie_top
+ 10;
1008 } else if (piggie_fwd
&& piggie_top
>= 0) {
1010 setTimeout("piggie_callback()", 50);
1011 } else if (!piggie_fwd
&& piggie_top
> -400) {
1012 setTimeout("piggie_callback()", 50);
1013 piggie_top
= piggie_top
- 10;
1014 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1015 piggie
.style
.display
= "none";
1020 var piggie_opacity
= 0;
1022 function piggie2_callback() {
1023 var piggie
= document
.getElementById("piggie");
1024 piggie
.style
.top
= 0;
1025 piggie
.style
.opacity
= piggie_opacity
;
1026 piggie
.style
.backgroundColor
= "transparent";
1027 piggie
.style
.borderWidth
= "0px";
1029 if (piggie_fwd
&& piggie_opacity
< 1) {
1030 setTimeout("piggie2_callback()", 50);
1031 piggie_opacity
= piggie_opacity
+ 0.03;
1032 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1034 setTimeout("piggie2_callback()", 50);
1035 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1036 setTimeout("piggie2_callback()", 50);
1037 piggie_opacity
= piggie_opacity
- 0.03;
1038 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1039 piggie
.style
.display
= "none";
1044 function localPiggieFunction(enable
) {
1046 debug("I LOVEDED IT!");
1047 var piggie
= document
.getElementById("piggie");
1048 piggie
.style
.display
= "block";
1050 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1058 function validateOpmlImport() {
1060 var opml_file
= document
.getElementById("opml_file");
1062 if (opml_file
.value
.length
== 0) {
1063 alert("No OPML file to upload.");
1070 function updateFilterList() {
1072 if (!xmlhttp_ready(xmlhttp
)) {
1073 printLockingError();
1077 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1079 // p_notify("Loading, please wait...");
1081 xmlhttp
.open("GET", "backend.php?op=pref-filters", true);
1082 xmlhttp
.onreadystatechange
=filterlist_callback
;
1087 function updateLabelList() {
1089 if (!xmlhttp_ready(xmlhttp
)) {
1090 printLockingError();
1094 // p_notify("Loading, please wait...");
1096 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1098 xmlhttp
.open("GET", "backend.php?op=pref-labels", true);
1099 xmlhttp
.onreadystatechange
=labellist_callback
;
1103 function updatePrefsList() {
1105 if (!xmlhttp_ready(xmlhttp
)) {
1106 printLockingError();
1110 // p_notify("Loading, please wait...");
1112 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1113 xmlhttp
.onreadystatechange
=prefslist_callback
;
1118 function selectTab(id
, noupdate
) {
1122 if (!id
) id
= active_tab
;
1126 if (!xmlhttp_ready(xmlhttp
)) {
1127 printLockingError();
1133 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1135 notify("Loading, please wait...", true);
1137 // close active infobox if needed
1140 // clean up all current selections, just in case
1141 active_feed_cat
= false;
1142 active_label
= false;
1144 if (id
== "feedConfig") {
1146 } else if (id
== "filterConfig") {
1148 } else if (id
== "labelConfig") {
1150 } else if (id
== "genConfig") {
1152 } else if (id
== "userConfig") {
1154 } else if (id
== "feedBrowser") {
1155 updateBigFeedBrowser();
1159 var tab
= document
.getElementById(active_tab
+ "Tab");
1162 if (tab
.className
.match("Selected")) {
1163 tab
.className
= "prefsTab";
1167 tab
= document
.getElementById(id
+ "Tab");
1170 if (!tab
.className
.match("Selected")) {
1171 tab
.className
= tab
.className
+ "Selected";
1175 if (active_tab
!= id
) {
1176 storeInitParam("prefs_active_tab", id
);
1182 exception_error("selectTab", e
);
1186 function backend_sanity_check_callback() {
1188 if (xmlhttp
.readyState
== 4) {
1192 if (!xmlhttp
.responseXML
) {
1193 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1197 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1200 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1204 var error_code
= reply
.getAttribute("error-code");
1206 if (error_code
&& error_code
!= 0) {
1207 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1210 debug("sanity check ok");
1212 var params
= reply
.nextSibling
;
1215 debug('reading init-params...');
1216 var param
= params
.firstChild
;
1219 var k
= param
.getAttribute("key");
1220 var v
= param
.getAttribute("value");
1221 debug(k
+ " => " + v
);
1223 param
= param
.nextSibling
;
1227 init_second_stage();
1230 exception_error("backend_sanity_check_callback", e
);
1235 function init_second_stage() {
1238 active_tab
= getInitParam("prefs_active_tab");
1239 if (!active_tab
) active_tab
= "genConfig";
1241 document
.onkeydown
= pref_hotkey_handler
;
1243 if (navigator
.userAgent
.match("Opera")) {
1244 setTimeout("selectTab()", 500);
1246 selectTab(active_tab
);
1250 exception_error("init_second_stage", e
);
1258 if (arguments
.callee
.done
) return;
1259 arguments
.callee
.done
= true;
1261 if (getURLParam('debug')) {
1262 document
.getElementById('debug_output').style
.display
= 'block';
1263 debug('debug mode activated');
1268 document
.getElementById("prefContent").innerHTML
=
1269 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1270 "to function properly. Your browser doesn't seem to support it.";
1274 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1275 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1279 exception_error("init", e
);
1283 function categorizeSelectedFeeds() {
1285 if (!xmlhttp_ready(xmlhttp
)) {
1286 printLockingError();
1290 var sel_rows
= getSelectedFeeds();
1292 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1293 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1295 if (sel_rows
.length
> 0) {
1297 notify("Changing category of selected feeds...");
1299 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1300 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1301 xmlhttp
.onreadystatechange
=feedlist_callback
;
1306 alert("No feeds are selected.");
1312 function validatePrefsReset() {
1313 return confirm("Reset to defaults?");
1316 function browseFeeds(limit
) {
1318 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1319 xmlhttp
.onreadystatechange
=infobox_callback
;
1324 function feedBrowserSubscribe() {
1327 var selected
= getSelectedFeedsFromBrowser();
1329 if (selected
.length
> 0) {
1331 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1332 param_escape(selected
.toString()), true);
1333 xmlhttp
.onreadystatechange
=feedlist_callback
;
1336 alert("No feeds are selected.");
1340 exception_error("feedBrowserSubscribe", e
);
1344 function updateBigFeedBrowser(limit
) {
1346 if (!xmlhttp_ready(xmlhttp
)) {
1347 printLockingError();
1351 // p_notify("Loading, please wait...");
1353 var query
= "backend.php?op=pref-feed-browser";
1355 var limit_sel
= document
.getElementById("feedBrowserLimit");
1358 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1359 query
= query
+ "&limit=" + param_escape(limit
);
1362 xmlhttp
.open("GET", query
, true);
1363 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1367 function browserToggleExpand(id
) {
1369 /* if (feed_to_expand && feed_to_expand != id) {
1370 var d = document.getElementById("BRDET-" + feed_to_expand);
1371 d.style.display = "none";
1374 if (!xmlhttp_ready(xmlhttp
)) {
1375 printLockingError();
1379 var d
= document
.getElementById("BRDET-" + id
);
1381 if (d
.style
.display
== "block") {
1382 d
.style
.display
= "none";
1386 feed_to_expand
= id
;
1388 d
.style
.display
= "block";
1389 d
.innerHTML
= "Loading, please wait...";
1391 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1392 + param_escape(id
), true);
1393 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1398 exception_error("browserExpand", e
);
1402 function validateNewPassword(form
) {
1403 if (form
.OLD_PASSWORD
.value
== "") {
1404 alert("Old password cannot be blank");
1407 if (form
.NEW_PASSWORD
.value
== "") {
1408 alert("New password cannot be blank");
1414 function selectPrefRows(kind
, select
) {
1417 var opbarid
= false;
1422 if (kind
== "feed") {
1423 opbarid
= "feedOpToolbar";
1426 lname
= "prefFeedList";
1427 } else if (kind
== "fcat") {
1428 opbarid
= "catOpToolbar";
1431 lname
= "prefFeedCatList";
1432 } else if (kind
== "filter") {
1433 opbarid
= "filterOpToolbar";
1436 lname
= "prefFilterList";
1437 } else if (kind
== "label") {
1438 opbarid
= "labelOpToolbar";
1441 lname
= "prefLabelList";
1442 } else if (kind
== "user") {
1443 opbarid
= "userOpToolbar";
1446 lname
= "prefUserList";
1450 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1451 disableContainerChildren(opbarid
, !select
);
1458 function toggleSelectPrefRow(sender
, kind
) {
1460 toggleSelectRow(sender
);
1463 var opbarid
= false;
1466 if (kind
== "feed") {
1467 opbarid
= "feedOpToolbar";
1468 nsel
= getSelectedFeeds();
1469 } else if (kind
== "fcat") {
1470 opbarid
= "catOpToolbar";
1471 nsel
= getSelectedFeedCats();
1472 } else if (kind
== "filter") {
1473 opbarid
= "filterOpToolbar";
1474 nsel
= getSelectedFilters();
1475 } else if (kind
== "label") {
1476 opbarid
= "labelOpToolbar";
1477 nsel
= getSelectedLabels();
1478 } else if (kind
== "user") {
1479 opbarid
= "userOpToolbar";
1480 nsel
= getSelectedUsers();
1483 if (opbarid
&& nsel
!= -1) {
1484 disableContainerChildren(opbarid
, nsel
== false);
1490 function toggleSelectFBListRow(sender
) {
1491 toggleSelectListRow(sender
);
1492 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1497 function pref_hotkey_handler(e
) {
1502 if (!hotkeys_enabled
) return;
1505 keycode
= window
.event
.keyCode
;
1510 if (keycode
== 13 || keycode
== 27) {
1513 seq
= seq
+ "" + keycode
;
1517 if (document
.getElementById("piggie")) {
1519 if (seq
.match("807371717369")) {
1521 localPiggieFunction(true);
1523 localPiggieFunction(false);
1528 exception_error("pref_hotkey_handler", e
);