3 var active_feed_cat
= false;
4 var active_label
= false;
5 var active_tab
= false;
6 var feed_to_expand
= false;
8 var xmlhttp
= Ajax
.getTransport();
10 var init_params
= new Array();
12 var caller_subop
= false;
14 var sanity_check_done
= false;
16 function replace_pubkey_callback() {
17 if (xmlhttp
.readyState
== 4) {
19 var link
= document
.getElementById("pubGenAddress");
21 if (xmlhttp
.responseXML
) {
23 var new_link
= xmlhttp
.responseXML
.getElementsByTagName("link")[0];
26 link
.href
= new_link
.firstChild
.nodeValue
;
27 link
.innerHTML
= new_link
.firstChild
.nodeValue
;
29 notify_info("Address changed.");
31 notify_error("Could not change address.");
35 notify_error("Could not change address.");
38 exception_error("replace_pubkey_callback", e
);
43 function expand_feed_callback() {
44 if (xmlhttp
.readyState
== 4) {
46 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
47 container
.innerHTML
=xmlhttp
.responseText
;
48 // container.style.display = "block";
50 Effect
.Appear(container
, {duration
: 0.5});
52 exception_error("expand_feed_callback", e
);
57 function feedlist_callback() {
58 if (xmlhttp
.readyState
== 4) {
60 var container
= document
.getElementById('prefContent');
61 container
.innerHTML
=xmlhttp
.responseText
;
62 selectTab("feedConfig", true);
65 var tuple
= caller_subop
.split(":");
66 if (tuple
[0] == 'editFeed') {
67 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
72 if (typeof correctPNG
!= 'undefined') {
77 exception_error("feedlist_callback", e
);
82 /* stub for subscription dialog */
84 function dlg_frefresh_callback() {
85 if (xmlhttp
.readyState
== 4) {
86 // setTimeout("updateFeedList()", 500);
89 var container
= document
.getElementById('prefContent');
90 container
.innerHTML
=xmlhttp
.responseText
;
91 selectTab("feedConfig", true);
94 var tuple
= caller_subop
.split(":");
95 if (tuple
[0] == 'editFeed') {
96 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
101 if (typeof correctPNG
!= 'undefined') {
106 exception_error("feedlist_callback", e
);
111 function filterlist_callback() {
112 var container
= document
.getElementById('prefContent');
113 if (xmlhttp
.readyState
== 4) {
114 container
.innerHTML
=xmlhttp
.responseText
;
115 if (typeof correctPNG
!= 'undefined') {
122 function labellist_callback() {
123 var container
= document
.getElementById('prefContent');
124 if (xmlhttp
.readyState
== 4) {
126 container
.innerHTML
=xmlhttp
.responseText
;
128 var row
= document
.getElementById("LILRR-" + active_label
);
130 if (!row
.className
.match("Selected")) {
131 row
.className
= row
.className
+ "Selected";
134 var checkbox
= document
.getElementById("LICHK-" + active_label
);
137 checkbox
.checked
= true;
140 if (typeof correctPNG
!= 'undefined') {
147 function feed_browser_callback() {
148 var container
= document
.getElementById('prefContent');
149 if (xmlhttp
.readyState
== 4) {
150 container
.innerHTML
=xmlhttp
.responseText
;
155 function userlist_callback() {
156 var container
= document
.getElementById('prefContent');
157 if (xmlhttp
.readyState
== 4) {
158 container
.innerHTML
=xmlhttp
.responseText
;
163 function prefslist_callback() {
164 var container
= document
.getElementById('prefContent');
165 if (xmlhttp
.readyState
== 4) {
167 container
.innerHTML
=xmlhttp
.responseText
;
173 function gethelp_callback() {
174 var container
= document
.getElementById('prefHelpBox');
175 if (xmlhttp
.readyState
== 4) {
177 container
.innerHTML
= xmlhttp
.responseText
;
178 container
.style
.display
= "block";
183 function notify_callback() {
184 if (xmlhttp
.readyState
== 4) {
185 notify_info(xmlhttp
.responseText
);
190 function changepass_callback() {
192 if (xmlhttp
.readyState
== 4) {
194 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
195 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
197 notify_info(xmlhttp
.responseText
);
198 var warn
= document
.getElementById("default_pass_warning");
199 if (warn
) warn
.style
.display
= "none";
202 document
.forms
['change_pass_form'].reset();
206 exception_error("changepass_callback", e
);
210 function updateFeedList(sort_key
) {
212 if (!xmlhttp_ready(xmlhttp
)) {
217 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
219 // p_notify("Loading, please wait...");
221 var feed_search
= document
.getElementById("feed_search");
223 if (feed_search
) { search
= feed_search
.value
; }
225 var slat
= document
.getElementById("show_last_article_times");
227 var slat_checked
= false;
229 slat_checked
= slat
.checked
;
232 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
233 "&sort=" + param_escape(sort_key
) +
234 "&slat=" + param_escape(slat_checked
) +
235 "&search=" + param_escape(search
), true);
236 xmlhttp
.onreadystatechange
=feedlist_callback
;
241 function updateUsersList(sort_key
) {
243 if (!xmlhttp_ready(xmlhttp
)) {
248 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
250 // p_notify("Loading, please wait...");
252 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
253 + param_escape(sort_key
), true);
254 xmlhttp
.onreadystatechange
=userlist_callback
;
259 function addLabel() {
261 if (!xmlhttp_ready(xmlhttp
)) {
266 var form
= document
.forms
['label_edit_form'];
268 var sql_exp
= form
.sql_exp
.value
;
269 var description
= form
.description
.value
;
272 alert(__("Can't create label: missing SQL expression."));
276 if (description
== "") {
277 alert(__("Can't create label: missing caption."));
281 var query
= Form
.serialize("label_edit_form");
283 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
284 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
290 if (!xmlhttp_ready(xmlhttp
)) {
295 var link
= document
.getElementById("fadd_link");
297 if (link
.value
.length
== 0) {
298 alert(__("Error: No feed URL given."));
299 } else if (!isValidURL(link
.value
)) {
300 alert(__("Error: Invalid feed URL."));
302 notify_progress("Adding feed...");
304 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
305 param_escape(link
.value
), true);
306 xmlhttp
.onreadystatechange
=feedlist_callback
;
315 function addFeedCat() {
317 if (!xmlhttp_ready(xmlhttp
)) {
322 var cat
= document
.getElementById("fadd_cat");
324 if (cat
.value
.length
== 0) {
325 alert(__("Can't add category: no name specified."));
327 notify_progress("Adding feed category...");
329 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
330 param_escape(cat
.value
), true);
331 xmlhttp
.onreadystatechange
=infobox_callback
;
341 if (!xmlhttp_ready(xmlhttp
)) {
346 var sqlexp
= document
.getElementById("uadd_box");
348 if (sqlexp
.value
.length
== 0) {
349 alert(__("Can't add user: no login specified."));
351 notify_progress("Adding user...");
353 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
354 param_escape(sqlexp
.value
), true);
356 xmlhttp
.onreadystatechange
=userlist_callback
;
364 function editLabel(id
) {
366 if (!xmlhttp_ready(xmlhttp
)) {
371 notify_progress("Loading, please wait...");
373 document
.getElementById("label_create_btn").disabled
= true;
377 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
378 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
380 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
381 param_escape(id
), true);
382 xmlhttp
.onreadystatechange
=infobox_callback
;
387 function editUser(id
) {
389 if (!xmlhttp_ready(xmlhttp
)) {
394 notify_progress("Loading, please wait...");
396 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
397 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
399 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
400 param_escape(id
), true);
401 xmlhttp
.onreadystatechange
=infobox_callback
;
406 function editFilter(id
) {
408 if (!xmlhttp_ready(xmlhttp
)) {
413 notify_progress("Loading, please wait...");
415 document
.getElementById("create_filter_btn").disabled
= true;
417 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
418 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
420 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
421 xmlhttp
.onreadystatechange
=infobox_callback
;
425 function editFeed(feed
) {
427 // notify("Editing feed...");
429 if (!xmlhttp_ready(xmlhttp
)) {
434 notify_progress("Loading, please wait...");
436 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
439 document
.getElementById("top25_feeds_btn").disabled
= true;
441 // this button is not always available, no-op if not found
444 // clean selection from all rows & select row being edited
445 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
446 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
448 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
449 param_escape(feed
), true);
451 xmlhttp
.onreadystatechange
=infobox_callback
;
456 function editFeedCat(cat
) {
458 if (!xmlhttp_ready(xmlhttp
)) {
463 notify_progress("Loading, please wait...");
465 active_feed_cat
= cat
;
467 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
468 param_escape(cat
), true);
469 xmlhttp
.onreadystatechange
=infobox_callback
;
474 function getSelectedLabels() {
475 return getSelectedTableRowIds("prefLabelList", "LILRR");
478 function getSelectedUsers() {
479 return getSelectedTableRowIds("prefUserList", "UMRR");
482 function getSelectedFeeds() {
483 return getSelectedTableRowIds("prefFeedList", "FEEDR");
486 function getSelectedFilters() {
487 return getSelectedTableRowIds("prefFilterList", "FILRR");
490 function getSelectedFeedCats() {
491 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
494 function getSelectedFeedsFromBrowser() {
496 var list
= document
.getElementById("browseFeedList");
497 if (!list
) list
= document
.getElementById("browseBigFeedList");
499 var selected
= new Array();
501 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
502 var child
= list
.childNodes
[i
];
503 if (child
.id
&& child
.id
.match("FBROW-")) {
504 var id
= child
.id
.replace("FBROW-", "");
506 var cb
= document
.getElementById("FBCHK-" + id
);
517 function removeSelectedLabels() {
519 if (!xmlhttp_ready(xmlhttp
)) {
524 var sel_rows
= getSelectedLabels();
526 if (sel_rows
.length
> 0) {
528 var ok
= confirm(__("Remove selected labels?"));
531 notify_progress("Removing selected labels...");
533 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
534 param_escape(sel_rows
.toString()), true);
535 xmlhttp
.onreadystatechange
=labellist_callback
;
539 alert(__("No labels are selected."));
545 function removeSelectedUsers() {
547 if (!xmlhttp_ready(xmlhttp
)) {
552 var sel_rows
= getSelectedUsers();
554 if (sel_rows
.length
> 0) {
556 var ok
= confirm(__("Remove selected users?"));
559 notify_progress("Removing selected users...");
561 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
562 param_escape(sel_rows
.toString()), true);
563 xmlhttp
.onreadystatechange
=userlist_callback
;
568 alert(__("No users are selected."));
574 function removeSelectedFilters() {
576 if (!xmlhttp_ready(xmlhttp
)) {
581 var sel_rows
= getSelectedFilters();
583 if (sel_rows
.length
> 0) {
585 var ok
= confirm(__("Remove selected filters?"));
588 notify_progress("Removing selected filters...");
590 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
591 param_escape(sel_rows
.toString()), true);
592 xmlhttp
.onreadystatechange
=filterlist_callback
;
596 alert(__("No filters are selected."));
603 function removeSelectedFeeds() {
605 if (!xmlhttp_ready(xmlhttp
)) {
610 var sel_rows
= getSelectedFeeds();
612 if (sel_rows
.length
> 0) {
614 var ok
= confirm(__("Unsubscribe from selected feeds?"));
618 notify_progress("Unsubscribing from selected feeds...");
620 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
621 param_escape(sel_rows
.toString()), true);
622 xmlhttp
.onreadystatechange
=feedlist_callback
;
628 alert(__("No feeds are selected."));
635 function removeSelectedFeedCats() {
637 if (!xmlhttp_ready(xmlhttp
)) {
642 var sel_rows
= getSelectedFeedCats();
644 if (sel_rows
.length
> 0) {
646 var ok
= confirm(__("Remove selected categories?"));
649 notify_progress("Removing selected categories...");
651 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
652 param_escape(sel_rows
.toString()), true);
653 xmlhttp
.onreadystatechange
=infobox_callback
;
659 alert(__("No categories are selected."));
666 function feedEditCancel() {
668 if (!xmlhttp_ready(xmlhttp
)) {
673 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
676 document
.getElementById("top25_feeds_btn").disabled
= false;
678 // this button is not always available, no-op if not found
683 selectPrefRows('feed', false); // cleanup feed selection
688 function feedCatEditCancel() {
690 if (!xmlhttp_ready(xmlhttp
)) {
695 active_feed_cat
= false;
697 // notify("Operation cancelled.");
699 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
700 xmlhttp
.onreadystatechange
=infobox_callback
;
706 function feedEditSave() {
710 if (!xmlhttp_ready(xmlhttp
)) {
715 // FIXME: add parameter validation
717 var query
= Form
.serialize("edit_feed_form");
719 notify_progress("Saving feed...");
721 xmlhttp
.open("POST", "backend.php", true);
722 xmlhttp
.onreadystatechange
=feedlist_callback
;
723 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
731 exception_error("feedEditSave", e
);
735 function feedCatEditSave() {
737 if (!xmlhttp_ready(xmlhttp
)) {
742 notify_progress("Saving category...");
744 var query
= Form
.serialize("feed_cat_edit_form");
746 xmlhttp
.open("GET", "backend.php?" + query
, true);
747 xmlhttp
.onreadystatechange
=infobox_callback
;
750 active_feed_cat
= false;
757 function displayHelpInfobox(topic_id
) {
759 /* if (!xmlhttp_ready(xmlhttp)) {
764 notify_progress("Loading help...");
766 xmlhttp.open("GET", "backend.php?op=help&tid=" +
767 param_escape(topic_id), true);
769 xmlhttp.onreadystatechange=helpbox_callback;
770 xmlhttp.send(null); */
772 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
774 var w
= window
.open(url
, "ttrss_help",
775 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
779 function labelEditCancel() {
781 if (!xmlhttp_ready(xmlhttp
)) {
786 document
.getElementById("label_create_btn").disabled
= false;
788 active_label
= false;
790 selectPrefRows('label', false); // cleanup feed selection
796 function userEditCancel() {
798 if (!xmlhttp_ready(xmlhttp
)) {
803 selectPrefRows('user', false); // cleanup feed selection
809 function filterEditCancel() {
811 if (!xmlhttp_ready(xmlhttp
)) {
816 document
.getElementById("create_filter_btn").disabled
= false;
818 selectPrefRows('filter', false); // cleanup feed selection
824 function labelEditSave() {
826 var label
= active_label
;
828 if (!xmlhttp_ready(xmlhttp
)) {
833 /* if (!is_opera()) {
835 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
836 var description = document.forms["label_edit_form"].description.value;
838 if (sql_exp.length == 0) {
839 alert("SQL Expression cannot be blank.");
843 if (description.length == 0) {
844 alert("Caption field cannot be blank.");
851 notify_progress("Saving label...");
853 active_label
= false;
855 query
= Form
.serialize("label_edit_form");
857 xmlhttp
.open("GET", "backend.php?" + query
, true);
858 xmlhttp
.onreadystatechange
=labellist_callback
;
864 function userEditSave() {
866 if (!xmlhttp_ready(xmlhttp
)) {
871 var login
= document
.forms
["user_edit_form"].login
.value
;
873 if (login
.length
== 0) {
874 alert(__("Login field cannot be blank."));
878 notify_progress("Saving user...");
882 var query
= Form
.serialize("user_edit_form");
884 xmlhttp
.open("GET", "backend.php?" + query
, true);
885 xmlhttp
.onreadystatechange
=userlist_callback
;
892 function filterEditSave() {
894 if (!xmlhttp_ready(xmlhttp
)) {
899 /* if (!is_opera()) {
900 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
902 if (reg_exp.length == 0) {
903 alert("Filter expression field cannot be blank.");
908 notify_progress("Saving filter...");
910 var query
= Form
.serialize("filter_edit_form");
914 document
.getElementById("create_filter_btn").disabled
= false;
916 xmlhttp
.open("GET", "backend.php?" + query
, true);
917 xmlhttp
.onreadystatechange
=filterlist_callback
;
923 function editSelectedLabel() {
924 var rows
= getSelectedLabels();
926 if (rows
.length
== 0) {
927 alert(__("No labels are selected."));
931 if (rows
.length
> 1) {
932 alert(__("Please select only one label."));
942 function editSelectedUser() {
943 var rows
= getSelectedUsers();
945 if (rows
.length
== 0) {
946 alert(__("No users are selected."));
950 if (rows
.length
> 1) {
951 alert(__("Please select only one user."));
960 function resetSelectedUserPass() {
961 var rows
= getSelectedUsers();
963 if (rows
.length
== 0) {
964 alert(__("No users are selected."));
968 if (rows
.length
> 1) {
969 alert(__("Please select only one user."));
973 var ok
= confirm(__("Reset password of selected user?"));
976 notify_progress("Resetting password for selected user...");
980 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
981 param_escape(id
), true);
982 xmlhttp
.onreadystatechange
=userlist_callback
;
987 function selectedUserDetails() {
989 if (!xmlhttp_ready(xmlhttp
)) {
994 var rows
= getSelectedUsers();
996 if (rows
.length
== 0) {
997 alert(__("No users are selected."));
1001 if (rows
.length
> 1) {
1002 alert(__("Please select only one user."));
1006 notify_progress("Loading, please wait...");
1010 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1011 xmlhttp
.onreadystatechange
=infobox_callback
;
1016 function selectedFeedDetails() {
1018 if (!xmlhttp_ready(xmlhttp
)) {
1019 printLockingError();
1023 var rows
= getSelectedFeeds();
1025 if (rows
.length
== 0) {
1026 alert(__("No feeds are selected."));
1030 if (rows
.length
> 1) {
1031 alert(__("Please select only one feed."));
1035 // var id = rows[0];
1039 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1040 param_escape(rows
.toString()), true);
1041 xmlhttp
.onreadystatechange
=infobox_callback
;
1046 function editSelectedFilter() {
1047 var rows
= getSelectedFilters();
1049 if (rows
.length
== 0) {
1050 alert(__("No filters are selected."));
1054 if (rows
.length
> 1) {
1055 alert(__("Please select only one filter."));
1061 editFilter(rows
[0]);
1066 function editSelectedFeed() {
1067 var rows
= getSelectedFeeds();
1069 if (rows
.length
== 0) {
1070 alert(__("No feeds are selected."));
1074 if (rows
.length
> 1) {
1075 alert(__("Please select one feed."));
1085 function editSelectedFeedCat() {
1086 var rows
= getSelectedFeedCats();
1088 if (rows
.length
== 0) {
1089 alert(__("No categories are selected."));
1093 if (rows
.length
> 1) {
1094 alert(__("Please select only one category."));
1100 editFeedCat(rows
[0]);
1104 function localPiggieFunction(enable
) {
1106 debug("I LOVEDED IT!");
1107 var piggie
= document
.getElementById("piggie");
1109 Element
.show(piggie
);
1110 Position
.Center(piggie
);
1111 Effect
.Puff(piggie
);
1116 function validateOpmlImport() {
1118 var opml_file
= document
.getElementById("opml_file");
1120 if (opml_file
.value
.length
== 0) {
1121 alert(__("No OPML file to upload."));
1128 function updateFilterList(sort_key
) {
1130 if (!xmlhttp_ready(xmlhttp
)) {
1131 printLockingError();
1135 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1137 // p_notify("Loading, please wait...");
1139 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1140 param_escape(sort_key
), true);
1141 xmlhttp
.onreadystatechange
=filterlist_callback
;
1146 function updateLabelList(sort_key
) {
1148 if (!xmlhttp_ready(xmlhttp
)) {
1149 printLockingError();
1153 // p_notify("Loading, please wait...");
1155 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1157 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1158 param_escape(sort_key
), true);
1159 xmlhttp
.onreadystatechange
=labellist_callback
;
1163 function updatePrefsList() {
1165 if (!xmlhttp_ready(xmlhttp
)) {
1166 printLockingError();
1170 // p_notify("Loading, please wait...");
1172 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1173 xmlhttp
.onreadystatechange
=prefslist_callback
;
1178 function selectTab(id
, noupdate
, subop
) {
1182 if (!id
) id
= active_tab
;
1186 if (!xmlhttp_ready(xmlhttp
)) {
1187 printLockingError();
1192 var c
= document
.getElementById('prefContent');
1198 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1200 notify_progress("Loading, please wait...");
1202 // close active infobox if needed
1205 // clean up all current selections, just in case
1206 active_feed_cat
= false;
1207 active_label
= false;
1209 if (id
== "feedConfig") {
1211 } else if (id
== "filterConfig") {
1213 } else if (id
== "labelConfig") {
1215 } else if (id
== "genConfig") {
1217 } else if (id
== "userConfig") {
1219 } else if (id
== "feedBrowser") {
1220 updateBigFeedBrowser();
1224 var tab
= document
.getElementById(active_tab
+ "Tab");
1227 if (tab
.className
.match("Selected")) {
1228 tab
.className
= "prefsTab";
1232 tab
= document
.getElementById(id
+ "Tab");
1235 if (!tab
.className
.match("Selected")) {
1236 tab
.className
= tab
.className
+ "Selected";
1243 exception_error("selectTab", e
);
1247 function backend_sanity_check_callback() {
1249 if (xmlhttp
.readyState
== 4) {
1253 if (sanity_check_done
) {
1254 fatalError(11, "Sanity check request received twice. This can indicate "+
1255 "presence of Firebug or some other disrupting extension. "+
1256 "Please disable it and try again.");
1260 if (!xmlhttp
.responseXML
) {
1261 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1265 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1268 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1272 var error_code
= reply
.getAttribute("error-code");
1274 if (error_code
&& error_code
!= 0) {
1275 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1278 debug("sanity check ok");
1280 var params
= reply
.nextSibling
;
1283 debug('reading init-params...');
1284 var param
= params
.firstChild
;
1287 var k
= param
.getAttribute("key");
1288 var v
= param
.getAttribute("value");
1289 debug(k
+ " => " + v
);
1291 param
= param
.nextSibling
;
1295 sanity_check_done
= true;
1297 init_second_stage();
1300 exception_error("backend_sanity_check_callback", e
);
1305 function init_second_stage() {
1308 active_tab
= getInitParam("prefs_active_tab");
1309 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1311 document
.onkeydown
= pref_hotkey_handler
;
1313 var tab
= getURLParam('tab');
1315 caller_subop
= getURLParam('subop');
1321 if (navigator
.userAgent
.match("Opera")) {
1322 setTimeout("selectTab()", 500);
1324 selectTab(active_tab
);
1328 exception_error("init_second_stage", e
);
1336 if (arguments
.callee
.done
) return;
1337 arguments
.callee
.done
= true;
1339 if (getURLParam('debug')) {
1340 document
.getElementById('debug_output').style
.display
= 'block';
1341 debug('debug mode activated');
1346 document
.getElementById("prefContent").innerHTML
=
1347 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1348 "to function properly. Your browser doesn't seem to support it.";
1352 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1353 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1357 exception_error("init", e
);
1361 function categorizeSelectedFeeds() {
1363 if (!xmlhttp_ready(xmlhttp
)) {
1364 printLockingError();
1368 var sel_rows
= getSelectedFeeds();
1370 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1371 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1373 if (sel_rows
.length
> 0) {
1375 notify_progress("Changing category of selected feeds...");
1377 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1378 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1379 xmlhttp
.onreadystatechange
=feedlist_callback
;
1384 alert(__("No feeds are selected."));
1390 function validatePrefsReset() {
1391 return confirm(__("Reset to defaults?"));
1394 function browseFeeds(limit
) {
1396 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1397 xmlhttp
.onreadystatechange
=infobox_callback
;
1402 function feedBrowserSubscribe() {
1405 var selected
= getSelectedFeedsFromBrowser();
1407 if (selected
.length
> 0) {
1409 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1410 param_escape(selected
.toString()), true);
1411 xmlhttp
.onreadystatechange
=feedlist_callback
;
1414 alert(__("No feeds are selected."));
1418 exception_error("feedBrowserSubscribe", e
);
1422 function updateBigFeedBrowser(limit
) {
1424 if (!xmlhttp_ready(xmlhttp
)) {
1425 printLockingError();
1429 // p_notify("Loading, please wait...");
1431 var query
= "backend.php?op=pref-feed-browser";
1433 var limit_sel
= document
.getElementById("feedBrowserLimit");
1436 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1437 query
= query
+ "&limit=" + param_escape(limit
);
1440 xmlhttp
.open("GET", query
, true);
1441 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1445 function browserToggleExpand(id
) {
1447 /* if (feed_to_expand && feed_to_expand != id) {
1448 var d = document.getElementById("BRDET-" + feed_to_expand);
1449 d.style.display = "none";
1452 if (!xmlhttp_ready(xmlhttp
)) {
1453 printLockingError();
1457 /* if (feed_to_expand && id != feed_to_expand) {
1458 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1461 var d
= document
.getElementById("BRDET-" + id
);
1463 if (Element
.visible(d
)) {
1464 Effect
.Fade(d
, {duration
: 0.5});
1466 feed_to_expand
= id
;
1468 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1469 + param_escape(id
), true);
1470 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1475 exception_error("browserToggleExpand", e
);
1479 function selectPrefRows(kind
, select
) {
1482 var opbarid
= false;
1487 if (kind
== "feed") {
1488 opbarid
= "feedOpToolbar";
1491 lname
= "prefFeedList";
1492 } else if (kind
== "fcat") {
1493 opbarid
= "catOpToolbar";
1496 lname
= "prefFeedCatList";
1497 } else if (kind
== "filter") {
1498 opbarid
= "filterOpToolbar";
1501 lname
= "prefFilterList";
1502 } else if (kind
== "label") {
1503 opbarid
= "labelOpToolbar";
1506 lname
= "prefLabelList";
1507 } else if (kind
== "user") {
1508 opbarid
= "userOpToolbar";
1511 lname
= "prefUserList";
1515 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1516 disableContainerChildren(opbarid
, !select
);
1523 function toggleSelectPrefRow(sender
, kind
) {
1525 toggleSelectRow(sender
);
1528 var opbarid
= false;
1531 if (kind
== "feed") {
1532 opbarid
= "feedOpToolbar";
1533 nsel
= getSelectedFeeds();
1534 } else if (kind
== "fcat") {
1535 opbarid
= "catOpToolbar";
1536 nsel
= getSelectedFeedCats();
1537 } else if (kind
== "filter") {
1538 opbarid
= "filterOpToolbar";
1539 nsel
= getSelectedFilters();
1540 } else if (kind
== "label") {
1541 opbarid
= "labelOpToolbar";
1542 nsel
= getSelectedLabels();
1543 } else if (kind
== "user") {
1544 opbarid
= "userOpToolbar";
1545 nsel
= getSelectedUsers();
1548 if (opbarid
&& nsel
!= -1) {
1549 disableContainerChildren(opbarid
, nsel
== false);
1555 function toggleSelectFBListRow(sender
) {
1556 toggleSelectListRow(sender
);
1557 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1562 function pref_hotkey_handler(e
) {
1567 if (!hotkeys_enabled
) return;
1570 keycode
= window
.event
.keyCode
;
1575 if (keycode
== 13 || keycode
== 27) {
1578 seq
= seq
+ "" + keycode
;
1582 if (document
.getElementById("piggie")) {
1584 if (seq
.match("807371717369")) {
1586 localPiggieFunction(true);
1588 localPiggieFunction(false);
1593 exception_error("pref_hotkey_handler", e
);
1597 function userSwitch() {
1598 var chooser
= document
.getElementById("userSwitch");
1599 var user
= chooser
[chooser
.selectedIndex
].value
;
1600 window
.location
= "prefs.php?swu=" + user
;
1603 function editFeedCats() {
1604 if (!xmlhttp_ready(xmlhttp
)) {
1605 printLockingError();
1609 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1612 document
.getElementById("top25_feeds_btn").disabled
= true;
1614 // this button is not always available, no-op if not found
1617 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1618 xmlhttp
.onreadystatechange
=infobox_callback
;
1622 function showFeedsWithErrors() {
1623 displayDlg('feedUpdateErrors');
1626 function changeUserPassword() {
1630 if (!xmlhttp_ready(xmlhttp
)) {
1631 printLockingError();
1635 var query
= Form
.serialize("change_pass_form");
1637 notify_progress("Trying to change password...");
1639 xmlhttp
.open("POST", "backend.php", true);
1640 xmlhttp
.onreadystatechange
=changepass_callback
;
1641 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1642 xmlhttp
.send(query
);
1645 exception_error("changeUserPassword", e
);
1651 function changeUserEmail() {
1655 if (!xmlhttp_ready(xmlhttp
)) {
1656 printLockingError();
1660 var query
= Form
.serialize("change_email_form");
1662 notify_progress("Trying to change e-mail...");
1664 xmlhttp
.open("POST", "backend.php", true);
1665 xmlhttp
.onreadystatechange
=notify_callback
;
1666 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1667 xmlhttp
.send(query
);
1670 exception_error("changeUserPassword", e
);
1677 function feedlistToggleSLAT() {
1678 notify_progress("Loading, please wait...");
1682 function pubRegenKey() {
1684 if (!xmlhttp_ready(xmlhttp
)) {
1685 printLockingError();
1689 var ok
= confirm(__("Replace current publishing address with a new one?"));
1693 notify_progress("Trying to change address...");
1695 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1696 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;