3 var active_feed_cat
= false;
4 var active_label
= false;
5 var active_tab
= false;
6 var feed_to_expand
= false;
11 var xmlhttp
= Ajax
.getTransport();
13 var init_params
= new Array();
15 var caller_subop
= false;
17 function expand_feed_callback() {
18 if (xmlhttp
.readyState
== 4) {
20 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
21 container
.innerHTML
=xmlhttp
.responseText
;
22 container
.style
.display
= "block";
25 exception_error("expand_feed_callback", e
);
30 function feedlist_callback() {
31 if (xmlhttp
.readyState
== 4) {
33 var container
= document
.getElementById('prefContent');
34 container
.innerHTML
=xmlhttp
.responseText
;
35 selectTab("feedConfig", true);
38 var tuple
= caller_subop
.split(":");
39 if (tuple
[0] == 'editFeed') {
40 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
48 exception_error("feedlist_callback", e
);
53 function filterlist_callback() {
54 var container
= document
.getElementById('prefContent');
55 if (xmlhttp
.readyState
== 4) {
56 container
.innerHTML
=xmlhttp
.responseText
;
61 function labellist_callback() {
62 var container
= document
.getElementById('prefContent');
63 if (xmlhttp
.readyState
== 4) {
65 container
.innerHTML
=xmlhttp
.responseText
;
67 var row
= document
.getElementById("LILRR-" + active_label
);
69 if (!row
.className
.match("Selected")) {
70 row
.className
= row
.className
+ "Selected";
73 var checkbox
= document
.getElementById("LICHK-" + active_label
);
76 checkbox
.checked
= true;
83 function labeltest_callback() {
84 var container
= document
.getElementById('label_test_result');
85 if (xmlhttp
.readyState
== 4) {
86 container
.innerHTML
=xmlhttp
.responseText
;
91 function feed_browser_callback() {
92 var container
= document
.getElementById('prefContent');
93 if (xmlhttp
.readyState
== 4) {
94 container
.innerHTML
=xmlhttp
.responseText
;
99 function userlist_callback() {
100 var container
= document
.getElementById('prefContent');
101 if (xmlhttp
.readyState
== 4) {
102 container
.innerHTML
=xmlhttp
.responseText
;
107 function prefslist_callback() {
108 var container
= document
.getElementById('prefContent');
109 if (xmlhttp
.readyState
== 4) {
111 container
.innerHTML
=xmlhttp
.responseText
;
117 function gethelp_callback() {
118 var container
= document
.getElementById('prefHelpBox');
119 if (xmlhttp
.readyState
== 4) {
121 container
.innerHTML
= xmlhttp
.responseText
;
122 container
.style
.display
= "block";
128 function notify_callback() {
129 var container
= document
.getElementById('notify');
130 if (xmlhttp
.readyState
== 4) {
131 container
.innerHTML
=xmlhttp
.responseText
;
135 function updateFeedList(sort_key
) {
137 if (!xmlhttp_ready(xmlhttp
)) {
142 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
144 // p_notify("Loading, please wait...");
146 var feed_search
= document
.getElementById("feed_search");
148 if (feed_search
) { search
= feed_search
.value
; }
150 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
151 "&sort=" + param_escape(sort_key
) +
152 "&search=" + param_escape(search
), true);
153 xmlhttp
.onreadystatechange
=feedlist_callback
;
158 function updateUsersList(sort_key
) {
160 if (!xmlhttp_ready(xmlhttp
)) {
165 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
167 // p_notify("Loading, please wait...");
169 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
170 + param_escape(sort_key
), true);
171 xmlhttp
.onreadystatechange
=userlist_callback
;
176 function addLabel() {
178 if (!xmlhttp_ready(xmlhttp
)) {
183 var form
= document
.forms
['label_edit_form'];
185 var sql_exp
= form
.sql_exp
.value
;
186 var description
= form
.description
.value
;
189 alert("Can't create label: missing SQL expression.");
193 if (description
== "") {
194 alert("Can't create label: missing caption.");
198 var query
= Form
.serialize("label_edit_form");
200 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
201 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
207 if (!xmlhttp_ready(xmlhttp
)) {
212 var link
= document
.getElementById("fadd_link");
214 if (link
.value
.length
== 0) {
215 alert("Error: No feed URL given.");
216 } else if (!isValidURL(link
.value
)) {
217 alert("Error: Invalid feed URL.");
219 notify("Adding feed...");
221 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
222 param_escape(link
.value
), true);
223 xmlhttp
.onreadystatechange
=feedlist_callback
;
232 function addFeedCat() {
234 if (!xmlhttp_ready(xmlhttp
)) {
239 var cat
= document
.getElementById("fadd_cat");
241 if (cat
.value
.length
== 0) {
242 alert("Can't add category: no name specified.");
244 notify("Adding feed category...");
246 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
247 param_escape(cat
.value
), true);
248 xmlhttp
.onreadystatechange
=infobox_callback
;
258 if (!xmlhttp_ready(xmlhttp
)) {
263 var sqlexp
= document
.getElementById("uadd_box");
265 if (sqlexp
.value
.length
== 0) {
266 alert("Can't add user: no login specified.");
268 notify("Adding user...");
270 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
271 param_escape(sqlexp
.value
), true);
273 xmlhttp
.onreadystatechange
=userlist_callback
;
281 function editLabel(id
) {
283 if (!xmlhttp_ready(xmlhttp
)) {
288 document
.getElementById("label_create_btn").disabled
= true;
292 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
293 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
295 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
296 param_escape(id
), true);
297 xmlhttp
.onreadystatechange
=infobox_callback
;
302 function editUser(id
) {
304 if (!xmlhttp_ready(xmlhttp
)) {
309 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
310 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
312 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
313 param_escape(id
), true);
314 xmlhttp
.onreadystatechange
=infobox_callback
;
319 function editFilter(id
) {
321 if (!xmlhttp_ready(xmlhttp
)) {
326 document
.getElementById("create_filter_btn").disabled
= true;
328 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
329 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
331 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
332 xmlhttp
.onreadystatechange
=infobox_callback
;
336 function editFeed(feed
) {
338 // notify("Editing feed...");
340 if (!xmlhttp_ready(xmlhttp
)) {
345 // clean selection from all rows & select row being edited
346 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
347 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
349 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
350 param_escape(feed
), true);
352 xmlhttp
.onreadystatechange
=infobox_callback
;
357 function editFeedCat(cat
) {
359 if (!xmlhttp_ready(xmlhttp
)) {
364 active_feed_cat
= cat
;
366 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
367 param_escape(cat
), true);
368 xmlhttp
.onreadystatechange
=infobox_callback
;
373 function getSelectedLabels() {
374 return getSelectedTableRowIds("prefLabelList", "LILRR");
377 function getSelectedUsers() {
378 return getSelectedTableRowIds("prefUserList", "UMRR");
381 function getSelectedFeeds() {
382 return getSelectedTableRowIds("prefFeedList", "FEEDR");
385 function getSelectedFilters() {
386 return getSelectedTableRowIds("prefFilterList", "FILRR");
389 function getSelectedFeedCats() {
390 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
393 function getSelectedFeedsFromBrowser() {
395 var list
= document
.getElementById("browseFeedList");
396 if (!list
) list
= document
.getElementById("browseBigFeedList");
398 var selected
= new Array();
400 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
401 var child
= list
.childNodes
[i
];
402 if (child
.id
&& child
.id
.match("FBROW-")) {
403 var id
= child
.id
.replace("FBROW-", "");
405 var cb
= document
.getElementById("FBCHK-" + id
);
416 function removeSelectedLabels() {
418 if (!xmlhttp_ready(xmlhttp
)) {
423 var sel_rows
= getSelectedLabels();
425 if (sel_rows
.length
> 0) {
427 var ok
= confirm("Remove selected labels?");
430 notify("Removing selected labels...");
432 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
433 param_escape(sel_rows
.toString()), true);
434 xmlhttp
.onreadystatechange
=labellist_callback
;
438 alert("No labels are selected.");
444 function removeSelectedUsers() {
446 if (!xmlhttp_ready(xmlhttp
)) {
451 var sel_rows
= getSelectedUsers();
453 if (sel_rows
.length
> 0) {
455 var ok
= confirm("Remove selected users?");
458 notify("Removing selected users...");
460 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
461 param_escape(sel_rows
.toString()), true);
462 xmlhttp
.onreadystatechange
=userlist_callback
;
467 alert("No users are selected.");
473 function removeSelectedFilters() {
475 if (!xmlhttp_ready(xmlhttp
)) {
480 var sel_rows
= getSelectedFilters();
482 if (sel_rows
.length
> 0) {
484 var ok
= confirm("Remove selected filters?");
487 notify("Removing selected filters...");
489 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
490 param_escape(sel_rows
.toString()), true);
491 xmlhttp
.onreadystatechange
=filterlist_callback
;
495 alert("No filters are selected.");
502 function removeSelectedFeeds() {
504 if (!xmlhttp_ready(xmlhttp
)) {
509 var sel_rows
= getSelectedFeeds();
511 if (sel_rows
.length
> 0) {
513 var ok
= confirm("Unsubscribe from selected feeds?");
517 notify("Unsubscribing from selected feeds...");
519 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
520 param_escape(sel_rows
.toString()), true);
521 xmlhttp
.onreadystatechange
=feedlist_callback
;
527 alert("No feeds are selected.");
534 function removeSelectedFeedCats() {
536 if (!xmlhttp_ready(xmlhttp
)) {
541 var sel_rows
= getSelectedFeedCats();
543 if (sel_rows
.length
> 0) {
545 var ok
= confirm("Remove selected categories?");
548 notify("Removing selected categories...");
550 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
551 param_escape(sel_rows
.toString()), true);
552 xmlhttp
.onreadystatechange
=infobox_callback
;
558 alert("No categories are selected.");
565 function feedEditCancel() {
567 if (!xmlhttp_ready(xmlhttp
)) {
574 selectPrefRows('feed', false); // cleanup feed selection
579 function feedCatEditCancel() {
581 if (!xmlhttp_ready(xmlhttp
)) {
586 active_feed_cat
= false;
588 // notify("Operation cancelled.");
590 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
591 xmlhttp
.onreadystatechange
=infobox_callback
;
597 function feedEditSave() {
601 if (!xmlhttp_ready(xmlhttp
)) {
606 // FIXME: add parameter validation
608 var query
= Form
.serialize("edit_feed_form");
610 notify("Saving feed...");
612 xmlhttp
.open("POST", "backend.php", true);
613 xmlhttp
.onreadystatechange
=feedlist_callback
;
614 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
622 exception_error("feedEditSave", e
);
626 function feedCatEditSave() {
628 if (!xmlhttp_ready(xmlhttp
)) {
633 notify("Saving category...");
635 var query
= Form
.serialize("feed_cat_edit_form");
637 xmlhttp
.open("GET", "backend.php?" + query
, true);
638 xmlhttp
.onreadystatechange
=infobox_callback
;
641 active_feed_cat
= false;
647 function labelTest() {
649 var container
= document
.getElementById('label_test_result');
650 container
.style
.display
= "block";
651 container
.innerHTML
= "<p>Loading, please wait...</p>";
653 var form
= document
.forms
['label_edit_form'];
655 var sql_exp
= form
.sql_exp
.value
;
656 var description
= form
.description
.value
;
658 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
659 param_escape(sql_exp
) + "&descr=" + param_escape(description
), true);
661 xmlhttp
.onreadystatechange
=labeltest_callback
;
667 function displayHelpInfobox(topic_id
) {
669 xmlhttp
.open("GET", "backend.php?op=help&tid=" +
670 param_escape(topic_id
) + "&noheaders=1", true);
672 xmlhttp
.onreadystatechange
=infobox_callback
;
677 function labelEditCancel() {
679 if (!xmlhttp_ready(xmlhttp
)) {
684 document
.getElementById("label_create_btn").disabled
= false;
686 active_label
= false;
688 selectPrefRows('label', false); // cleanup feed selection
694 function userEditCancel() {
696 if (!xmlhttp_ready(xmlhttp
)) {
701 selectPrefRows('user', false); // cleanup feed selection
707 function filterEditCancel() {
709 if (!xmlhttp_ready(xmlhttp
)) {
714 document
.getElementById("create_filter_btn").disabled
= false;
716 selectPrefRows('filter', false); // cleanup feed selection
722 function labelEditSave() {
724 var label
= active_label
;
726 if (!xmlhttp_ready(xmlhttp
)) {
731 /* if (!is_opera()) {
733 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
734 var description = document.forms["label_edit_form"].description.value;
736 if (sql_exp.length == 0) {
737 alert("SQL Expression cannot be blank.");
741 if (description.length == 0) {
742 alert("Caption field cannot be blank.");
749 notify("Saving label...");
751 active_label
= false;
753 query
= Form
.serialize("label_edit_form");
755 xmlhttp
.open("GET", "backend.php?" + query
, true);
756 xmlhttp
.onreadystatechange
=labellist_callback
;
762 function userEditSave() {
764 if (!xmlhttp_ready(xmlhttp
)) {
769 var login
= document
.forms
["user_edit_form"].login
.value
;
771 if (login
.length
== 0) {
772 alert("Login field cannot be blank.");
776 notify("Saving user...");
780 var query
= Form
.serialize("user_edit_form");
782 xmlhttp
.open("GET", "backend.php?" + query
, true);
783 xmlhttp
.onreadystatechange
=userlist_callback
;
790 function filterEditSave() {
792 if (!xmlhttp_ready(xmlhttp
)) {
797 /* if (!is_opera()) {
798 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
800 if (reg_exp.length == 0) {
801 alert("Filter expression field cannot be blank.");
806 notify("Saving filter...");
808 var query
= Form
.serialize("filter_edit_form");
812 document
.getElementById("create_filter_btn").disabled
= false;
814 xmlhttp
.open("GET", "backend.php?" + query
, true);
815 xmlhttp
.onreadystatechange
=filterlist_callback
;
821 function editSelectedLabel() {
822 var rows
= getSelectedLabels();
824 if (rows
.length
== 0) {
825 alert("No labels are selected.");
829 if (rows
.length
> 1) {
830 alert("Please select only one label.");
840 function editSelectedUser() {
841 var rows
= getSelectedUsers();
843 if (rows
.length
== 0) {
844 alert("No users are selected.");
848 if (rows
.length
> 1) {
849 alert("Please select only one user.");
858 function resetSelectedUserPass() {
859 var rows
= getSelectedUsers();
861 if (rows
.length
== 0) {
862 alert("No users are selected.");
866 if (rows
.length
> 1) {
867 alert("Please select only one user.");
871 var ok
= confirm("Reset password of selected user?");
874 notify("Resetting password for selected user...");
878 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
879 param_escape(id
), true);
880 xmlhttp
.onreadystatechange
=userlist_callback
;
885 function selectedUserDetails() {
887 if (!xmlhttp_ready(xmlhttp
)) {
892 var rows
= getSelectedUsers();
894 if (rows
.length
== 0) {
895 alert("No users are selected.");
899 if (rows
.length
> 1) {
900 alert("Please select only one user.");
908 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
909 xmlhttp
.onreadystatechange
=infobox_callback
;
914 function selectedFeedDetails() {
916 if (!xmlhttp_ready(xmlhttp
)) {
921 var rows
= getSelectedFeeds();
923 if (rows
.length
== 0) {
924 alert("No feeds are selected.");
928 if (rows
.length
> 1) {
929 notify("Please select only one feed.");
937 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
938 param_escape(rows
.toString()), true);
939 xmlhttp
.onreadystatechange
=infobox_callback
;
944 function editSelectedFilter() {
945 var rows
= getSelectedFilters();
947 if (rows
.length
== 0) {
948 alert("No filters are selected.");
952 if (rows
.length
> 1) {
953 alert("Please select only one filter.");
964 function editSelectedFeed() {
965 var rows
= getSelectedFeeds();
967 if (rows
.length
== 0) {
968 notify("No feeds are selected.");
972 if (rows
.length
> 1) {
973 notify("Please select one feed.");
983 function editSelectedFeedCat() {
984 var rows
= getSelectedFeedCats();
986 if (rows
.length
== 0) {
987 alert("No categories are selected.");
991 if (rows
.length
> 1) {
992 alert("Please select only one category.");
998 editFeedCat(rows
[0]);
1002 function piggie_callback() {
1003 var piggie
= document
.getElementById("piggie");
1005 piggie
.style
.top
= piggie_top
;
1006 piggie
.style
.backgroundColor
= "white";
1007 piggie
.style
.borderWidth
= "1px";
1009 if (piggie_fwd
&& piggie_top
< 0) {
1010 setTimeout("piggie_callback()", 50);
1011 piggie_top
= piggie_top
+ 10;
1012 } else if (piggie_fwd
&& piggie_top
>= 0) {
1014 setTimeout("piggie_callback()", 50);
1015 } else if (!piggie_fwd
&& piggie_top
> -400) {
1016 setTimeout("piggie_callback()", 50);
1017 piggie_top
= piggie_top
- 10;
1018 } else if (!piggie_fwd
&& piggie_top
<= -400) {
1019 piggie
.style
.display
= "none";
1024 var piggie_opacity
= 0;
1026 function piggie2_callback() {
1027 var piggie
= document
.getElementById("piggie");
1028 piggie
.style
.top
= 0;
1029 piggie
.style
.opacity
= piggie_opacity
;
1030 piggie
.style
.backgroundColor
= "transparent";
1031 piggie
.style
.borderWidth
= "0px";
1033 if (piggie_fwd
&& piggie_opacity
< 1) {
1034 setTimeout("piggie2_callback()", 50);
1035 piggie_opacity
= piggie_opacity
+ 0.03;
1036 } else if (piggie_fwd
&& piggie_opacity
>= 1) {
1038 setTimeout("piggie2_callback()", 50);
1039 } else if (!piggie_fwd
&& piggie_opacity
> 0) {
1040 setTimeout("piggie2_callback()", 50);
1041 piggie_opacity
= piggie_opacity
- 0.03;
1042 } else if (!piggie_fwd
&& piggie_opacity
<= 0) {
1043 piggie
.style
.display
= "none";
1048 function localPiggieFunction(enable
) {
1050 debug("I LOVEDED IT!");
1051 var piggie
= document
.getElementById("piggie");
1052 piggie
.style
.display
= "block";
1054 if (navigator
.userAgent
.match("Gecko") && Math
.random(1) > 0.5) {
1062 function validateOpmlImport() {
1064 var opml_file
= document
.getElementById("opml_file");
1066 if (opml_file
.value
.length
== 0) {
1067 alert("No OPML file to upload.");
1074 function updateFilterList(sort_key
) {
1076 if (!xmlhttp_ready(xmlhttp
)) {
1077 printLockingError();
1081 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1083 // p_notify("Loading, please wait...");
1085 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1086 param_escape(sort_key
), true);
1087 xmlhttp
.onreadystatechange
=filterlist_callback
;
1092 function updateLabelList(sort_key
) {
1094 if (!xmlhttp_ready(xmlhttp
)) {
1095 printLockingError();
1099 // p_notify("Loading, please wait...");
1101 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1103 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1104 param_escape(sort_key
), true);
1105 xmlhttp
.onreadystatechange
=labellist_callback
;
1109 function updatePrefsList() {
1111 if (!xmlhttp_ready(xmlhttp
)) {
1112 printLockingError();
1116 // p_notify("Loading, please wait...");
1118 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1119 xmlhttp
.onreadystatechange
=prefslist_callback
;
1124 function selectTab(id
, noupdate
, subop
) {
1128 if (!id
) id
= active_tab
;
1132 if (!xmlhttp_ready(xmlhttp
)) {
1133 printLockingError();
1138 var c
= document
.getElementById('prefContent');
1144 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1146 // notify("Loading, please wait...", true);
1148 // close active infobox if needed
1151 // clean up all current selections, just in case
1152 active_feed_cat
= false;
1153 active_label
= false;
1155 if (id
== "feedConfig") {
1157 } else if (id
== "filterConfig") {
1159 } else if (id
== "labelConfig") {
1161 } else if (id
== "genConfig") {
1163 } else if (id
== "userConfig") {
1165 } else if (id
== "feedBrowser") {
1166 updateBigFeedBrowser();
1170 var tab
= document
.getElementById(active_tab
+ "Tab");
1173 if (tab
.className
.match("Selected")) {
1174 tab
.className
= "prefsTab";
1178 tab
= document
.getElementById(id
+ "Tab");
1181 if (!tab
.className
.match("Selected")) {
1182 tab
.className
= tab
.className
+ "Selected";
1186 if (active_tab
!= id
) {
1187 storeInitParam("prefs_active_tab", id
);
1193 exception_error("selectTab", e
);
1197 function backend_sanity_check_callback() {
1199 if (xmlhttp
.readyState
== 4) {
1203 if (!xmlhttp
.responseXML
) {
1204 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1208 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1211 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1215 var error_code
= reply
.getAttribute("error-code");
1217 if (error_code
&& error_code
!= 0) {
1218 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1221 debug("sanity check ok");
1223 var params
= reply
.nextSibling
;
1226 debug('reading init-params...');
1227 var param
= params
.firstChild
;
1230 var k
= param
.getAttribute("key");
1231 var v
= param
.getAttribute("value");
1232 debug(k
+ " => " + v
);
1234 param
= param
.nextSibling
;
1238 init_second_stage();
1241 exception_error("backend_sanity_check_callback", e
);
1246 function init_second_stage() {
1249 active_tab
= getInitParam("prefs_active_tab");
1250 if (!active_tab
) active_tab
= "genConfig";
1252 document
.onkeydown
= pref_hotkey_handler
;
1254 var tab
= getURLParam('tab');
1256 caller_subop
= getURLParam('subop');
1262 if (navigator
.userAgent
.match("Opera")) {
1263 setTimeout("selectTab()", 500);
1265 selectTab(active_tab
);
1269 exception_error("init_second_stage", e
);
1277 if (arguments
.callee
.done
) return;
1278 arguments
.callee
.done
= true;
1280 if (getURLParam('debug')) {
1281 document
.getElementById('debug_output').style
.display
= 'block';
1282 debug('debug mode activated');
1287 document
.getElementById("prefContent").innerHTML
=
1288 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1289 "to function properly. Your browser doesn't seem to support it.";
1293 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1294 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1298 exception_error("init", e
);
1302 function categorizeSelectedFeeds() {
1304 if (!xmlhttp_ready(xmlhttp
)) {
1305 printLockingError();
1309 var sel_rows
= getSelectedFeeds();
1311 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1312 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1314 if (sel_rows
.length
> 0) {
1316 notify("Changing category of selected feeds...");
1318 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1319 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1320 xmlhttp
.onreadystatechange
=feedlist_callback
;
1325 alert("No feeds are selected.");
1331 function validatePrefsReset() {
1332 return confirm("Reset to defaults?");
1335 function browseFeeds(limit
) {
1337 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1338 xmlhttp
.onreadystatechange
=infobox_callback
;
1343 function feedBrowserSubscribe() {
1346 var selected
= getSelectedFeedsFromBrowser();
1348 if (selected
.length
> 0) {
1350 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1351 param_escape(selected
.toString()), true);
1352 xmlhttp
.onreadystatechange
=feedlist_callback
;
1355 alert("No feeds are selected.");
1359 exception_error("feedBrowserSubscribe", e
);
1363 function updateBigFeedBrowser(limit
) {
1365 if (!xmlhttp_ready(xmlhttp
)) {
1366 printLockingError();
1370 // p_notify("Loading, please wait...");
1372 var query
= "backend.php?op=pref-feed-browser";
1374 var limit_sel
= document
.getElementById("feedBrowserLimit");
1377 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1378 query
= query
+ "&limit=" + param_escape(limit
);
1381 xmlhttp
.open("GET", query
, true);
1382 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1386 function browserToggleExpand(id
) {
1388 /* if (feed_to_expand && feed_to_expand != id) {
1389 var d = document.getElementById("BRDET-" + feed_to_expand);
1390 d.style.display = "none";
1393 if (!xmlhttp_ready(xmlhttp
)) {
1394 printLockingError();
1398 var d
= document
.getElementById("BRDET-" + id
);
1400 if (d
.style
.display
== "block") {
1401 d
.style
.display
= "none";
1405 feed_to_expand
= id
;
1407 d
.style
.display
= "block";
1408 d
.innerHTML
= "Loading, please wait...";
1410 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1411 + param_escape(id
), true);
1412 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1417 exception_error("browserExpand", e
);
1421 function validateNewPassword(form
) {
1422 if (form
.OLD_PASSWORD
.value
== "") {
1423 alert("Old password cannot be blank");
1426 if (form
.NEW_PASSWORD
.value
== "") {
1427 alert("New password cannot be blank");
1433 function selectPrefRows(kind
, select
) {
1436 var opbarid
= false;
1441 if (kind
== "feed") {
1442 opbarid
= "feedOpToolbar";
1445 lname
= "prefFeedList";
1446 } else if (kind
== "fcat") {
1447 opbarid
= "catOpToolbar";
1450 lname
= "prefFeedCatList";
1451 } else if (kind
== "filter") {
1452 opbarid
= "filterOpToolbar";
1455 lname
= "prefFilterList";
1456 } else if (kind
== "label") {
1457 opbarid
= "labelOpToolbar";
1460 lname
= "prefLabelList";
1461 } else if (kind
== "user") {
1462 opbarid
= "userOpToolbar";
1465 lname
= "prefUserList";
1469 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1470 disableContainerChildren(opbarid
, !select
);
1477 function toggleSelectPrefRow(sender
, kind
) {
1479 toggleSelectRow(sender
);
1482 var opbarid
= false;
1485 if (kind
== "feed") {
1486 opbarid
= "feedOpToolbar";
1487 nsel
= getSelectedFeeds();
1488 } else if (kind
== "fcat") {
1489 opbarid
= "catOpToolbar";
1490 nsel
= getSelectedFeedCats();
1491 } else if (kind
== "filter") {
1492 opbarid
= "filterOpToolbar";
1493 nsel
= getSelectedFilters();
1494 } else if (kind
== "label") {
1495 opbarid
= "labelOpToolbar";
1496 nsel
= getSelectedLabels();
1497 } else if (kind
== "user") {
1498 opbarid
= "userOpToolbar";
1499 nsel
= getSelectedUsers();
1502 if (opbarid
&& nsel
!= -1) {
1503 disableContainerChildren(opbarid
, nsel
== false);
1509 function toggleSelectFBListRow(sender
) {
1510 toggleSelectListRow(sender
);
1511 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1516 function pref_hotkey_handler(e
) {
1521 if (!hotkeys_enabled
) return;
1524 keycode
= window
.event
.keyCode
;
1529 if (keycode
== 13 || keycode
== 27) {
1532 seq
= seq
+ "" + keycode
;
1536 if (document
.getElementById("piggie")) {
1538 if (seq
.match("807371717369")) {
1540 localPiggieFunction(true);
1542 localPiggieFunction(false);
1547 exception_error("pref_hotkey_handler", e
);
1551 function userSwitch() {
1552 var chooser
= document
.getElementById("userSwitch");
1553 var user
= chooser
[chooser
.selectedIndex
].value
;
1554 window
.location
= "prefs.php?swu=" + user
;
1557 function editFeedCats() {
1558 if (!xmlhttp_ready(xmlhttp
)) {
1559 printLockingError();
1563 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1564 xmlhttp
.onreadystatechange
=infobox_callback
;
1568 function showFeedsWithErrors() {
1569 displayDlg('feedUpdateErrors');