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 new Effect
.Highlight(link
);
31 notify_info("Address changed.");
33 notify_error("Could not change address.");
37 notify_error("Could not change address.");
40 exception_error("replace_pubkey_callback", e
);
45 function expand_feed_callback() {
46 if (xmlhttp
.readyState
== 4) {
48 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
49 container
.innerHTML
=xmlhttp
.responseText
;
50 // container.style.display = "block";
52 Effect
.Appear(container
, {duration
: 0.5});
54 exception_error("expand_feed_callback", e
);
59 function feedlist_callback() {
60 if (xmlhttp
.readyState
== 4) {
62 var container
= document
.getElementById('prefContent');
63 container
.innerHTML
=xmlhttp
.responseText
;
64 selectTab("feedConfig", true);
67 var tuple
= caller_subop
.split(":");
68 if (tuple
[0] == 'editFeed') {
69 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
74 if (typeof correctPNG
!= 'undefined') {
79 exception_error("feedlist_callback", e
);
84 /* stub for subscription dialog */
86 function dlg_frefresh_callback() {
87 if (xmlhttp
.readyState
== 4) {
88 // setTimeout("updateFeedList()", 500);
91 var container
= document
.getElementById('prefContent');
92 container
.innerHTML
=xmlhttp
.responseText
;
93 selectTab("feedConfig", true);
96 var tuple
= caller_subop
.split(":");
97 if (tuple
[0] == 'editFeed') {
98 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
101 caller_subop
= false;
103 if (typeof correctPNG
!= 'undefined') {
108 exception_error("feedlist_callback", e
);
113 function filterlist_callback() {
114 var container
= document
.getElementById('prefContent');
115 if (xmlhttp
.readyState
== 4) {
116 container
.innerHTML
=xmlhttp
.responseText
;
117 if (typeof correctPNG
!= 'undefined') {
124 function labellist_callback() {
125 var container
= document
.getElementById('prefContent');
126 if (xmlhttp
.readyState
== 4) {
128 container
.innerHTML
=xmlhttp
.responseText
;
130 var row
= document
.getElementById("LILRR-" + active_label
);
132 if (!row
.className
.match("Selected")) {
133 row
.className
= row
.className
+ "Selected";
136 var checkbox
= document
.getElementById("LICHK-" + active_label
);
139 checkbox
.checked
= true;
142 if (typeof correctPNG
!= 'undefined') {
149 function feed_browser_callback() {
150 var container
= document
.getElementById('prefContent');
151 if (xmlhttp
.readyState
== 4) {
152 container
.innerHTML
=xmlhttp
.responseText
;
157 function userlist_callback() {
158 var container
= document
.getElementById('prefContent');
159 if (xmlhttp
.readyState
== 4) {
160 container
.innerHTML
=xmlhttp
.responseText
;
165 function prefslist_callback() {
166 var container
= document
.getElementById('prefContent');
167 if (xmlhttp
.readyState
== 4) {
169 container
.innerHTML
=xmlhttp
.responseText
;
175 function gethelp_callback() {
176 var container
= document
.getElementById('prefHelpBox');
177 if (xmlhttp
.readyState
== 4) {
179 container
.innerHTML
= xmlhttp
.responseText
;
180 container
.style
.display
= "block";
185 function notify_callback() {
186 if (xmlhttp
.readyState
== 4) {
187 notify_info(xmlhttp
.responseText
);
191 function prefs_reset_callback() {
192 if (xmlhttp
.readyState
== 4) {
193 notify_info(xmlhttp
.responseText
);
199 function changepass_callback() {
201 if (xmlhttp
.readyState
== 4) {
203 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
204 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
206 notify_info(xmlhttp
.responseText
);
207 var warn
= document
.getElementById("default_pass_warning");
208 if (warn
) warn
.style
.display
= "none";
211 document
.forms
['change_pass_form'].reset();
215 exception_error("changepass_callback", e
);
219 function infobox_feed_cat_callback() {
220 if (xmlhttp
.readyState
== 4) {
225 if (document
.getElementById("prefFeedCatList")) {
226 var elems
= document
.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
228 for (var i
= 0; i
< elems
.length
; i
++) {
229 if (elems
[i
].id
&& elems
[i
].id
.match("FCATT-")) {
230 var cat_id
= elems
[i
].id
.replace("FCATT-", "");
232 new Ajax
.InPlaceEditor(elems
[i
],
233 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id
);
239 exception_error("infobox_feed_cat_callback", e
);
244 function updateFeedList(sort_key
) {
246 if (!xmlhttp_ready(xmlhttp
)) {
251 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
253 // p_notify("Loading, please wait...");
255 var feed_search
= document
.getElementById("feed_search");
257 if (feed_search
) { search
= feed_search
.value
; }
259 var slat
= document
.getElementById("show_last_article_times");
261 var slat_checked
= false;
263 slat_checked
= slat
.checked
;
266 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
267 "&sort=" + param_escape(sort_key
) +
268 "&slat=" + param_escape(slat_checked
) +
269 "&search=" + param_escape(search
), true);
270 xmlhttp
.onreadystatechange
=feedlist_callback
;
275 function updateUsersList(sort_key
) {
277 if (!xmlhttp_ready(xmlhttp
)) {
282 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
284 // p_notify("Loading, please wait...");
286 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
287 + param_escape(sort_key
), true);
288 xmlhttp
.onreadystatechange
=userlist_callback
;
293 function addLabel() {
295 if (!xmlhttp_ready(xmlhttp
)) {
300 var form
= document
.forms
['label_edit_form'];
302 var sql_exp
= form
.sql_exp
.value
;
303 var description
= form
.description
.value
;
306 alert(__("Can't create label: missing SQL expression."));
310 if (description
== "") {
311 alert(__("Can't create label: missing caption."));
315 var query
= Form
.serialize("label_edit_form");
317 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
318 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
324 if (!xmlhttp_ready(xmlhttp
)) {
329 var link
= document
.getElementById("fadd_link");
331 if (link
.value
.length
== 0) {
332 alert(__("Error: No feed URL given."));
333 } else if (!isValidURL(link
.value
)) {
334 alert(__("Error: Invalid feed URL."));
336 notify_progress("Adding feed...");
338 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
339 param_escape(link
.value
), true);
340 xmlhttp
.onreadystatechange
=feedlist_callback
;
349 function addFeedCat() {
351 if (!xmlhttp_ready(xmlhttp
)) {
356 var cat
= document
.getElementById("fadd_cat");
358 if (cat
.value
.length
== 0) {
359 alert(__("Can't add category: no name specified."));
361 notify_progress("Adding feed category...");
363 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
364 param_escape(cat
.value
), true);
365 xmlhttp
.onreadystatechange
=infobox_callback
;
375 if (!xmlhttp_ready(xmlhttp
)) {
380 var sqlexp
= document
.getElementById("uadd_box");
382 if (sqlexp
.value
.length
== 0) {
383 alert(__("Can't add user: no login specified."));
385 notify_progress("Adding user...");
387 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
388 param_escape(sqlexp
.value
), true);
390 xmlhttp
.onreadystatechange
=userlist_callback
;
398 function editLabel(id
) {
400 if (!xmlhttp_ready(xmlhttp
)) {
405 notify_progress("Loading, please wait...");
407 document
.getElementById("label_create_btn").disabled
= true;
411 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
412 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
414 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
415 param_escape(id
), true);
416 xmlhttp
.onreadystatechange
=infobox_callback
;
421 function editUser(id
) {
423 if (!xmlhttp_ready(xmlhttp
)) {
428 notify_progress("Loading, please wait...");
430 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
431 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
433 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
434 param_escape(id
), true);
435 xmlhttp
.onreadystatechange
=infobox_callback
;
440 function editFilter(id
) {
442 if (!xmlhttp_ready(xmlhttp
)) {
447 notify_progress("Loading, please wait...");
449 document
.getElementById("create_filter_btn").disabled
= true;
451 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
452 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
454 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
455 xmlhttp
.onreadystatechange
=infobox_callback
;
459 function editFeed(feed
) {
461 // notify("Editing feed...");
463 if (!xmlhttp_ready(xmlhttp
)) {
468 notify_progress("Loading, please wait...");
470 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
473 document
.getElementById("top25_feeds_btn").disabled
= true;
475 // this button is not always available, no-op if not found
478 // clean selection from all rows & select row being edited
479 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
480 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
482 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
483 param_escape(feed
), true);
485 xmlhttp
.onreadystatechange
=infobox_callback
;
490 function editFeedCat(cat
) {
492 if (!xmlhttp_ready(xmlhttp
)) {
497 notify_progress("Loading, please wait...");
499 active_feed_cat
= cat
;
501 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
502 param_escape(cat
), true);
503 xmlhttp
.onreadystatechange
=infobox_callback
;
508 function getSelectedLabels() {
509 return getSelectedTableRowIds("prefLabelList", "LILRR");
512 function getSelectedUsers() {
513 return getSelectedTableRowIds("prefUserList", "UMRR");
516 function getSelectedFeeds() {
517 return getSelectedTableRowIds("prefFeedList", "FEEDR");
520 function getSelectedFilters() {
521 return getSelectedTableRowIds("prefFilterList", "FILRR");
524 function getSelectedFeedCats() {
525 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
528 function getSelectedFeedsFromBrowser() {
530 var list
= document
.getElementById("browseFeedList");
531 if (!list
) list
= document
.getElementById("browseBigFeedList");
533 var selected
= new Array();
535 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
536 var child
= list
.childNodes
[i
];
537 if (child
.id
&& child
.id
.match("FBROW-")) {
538 var id
= child
.id
.replace("FBROW-", "");
540 var cb
= document
.getElementById("FBCHK-" + id
);
551 function removeSelectedLabels() {
553 if (!xmlhttp_ready(xmlhttp
)) {
558 var sel_rows
= getSelectedLabels();
560 if (sel_rows
.length
> 0) {
562 var ok
= confirm(__("Remove selected labels?"));
565 notify_progress("Removing selected labels...");
567 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
568 param_escape(sel_rows
.toString()), true);
569 xmlhttp
.onreadystatechange
=labellist_callback
;
573 alert(__("No labels are selected."));
579 function removeSelectedUsers() {
581 if (!xmlhttp_ready(xmlhttp
)) {
586 var sel_rows
= getSelectedUsers();
588 if (sel_rows
.length
> 0) {
590 var ok
= confirm(__("Remove selected users?"));
593 notify_progress("Removing selected users...");
595 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
596 param_escape(sel_rows
.toString()), true);
597 xmlhttp
.onreadystatechange
=userlist_callback
;
602 alert(__("No users are selected."));
608 function removeSelectedFilters() {
610 if (!xmlhttp_ready(xmlhttp
)) {
615 var sel_rows
= getSelectedFilters();
617 if (sel_rows
.length
> 0) {
619 var ok
= confirm(__("Remove selected filters?"));
622 notify_progress("Removing selected filters...");
624 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
625 param_escape(sel_rows
.toString()), true);
626 xmlhttp
.onreadystatechange
=filterlist_callback
;
630 alert(__("No filters are selected."));
637 function removeSelectedFeeds() {
639 if (!xmlhttp_ready(xmlhttp
)) {
644 var sel_rows
= getSelectedFeeds();
646 if (sel_rows
.length
> 0) {
648 var ok
= confirm(__("Unsubscribe from selected feeds?"));
652 notify_progress("Unsubscribing from selected feeds...");
654 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
655 param_escape(sel_rows
.toString()), true);
656 xmlhttp
.onreadystatechange
=feedlist_callback
;
662 alert(__("No feeds are selected."));
669 function removeSelectedFeedCats() {
671 if (!xmlhttp_ready(xmlhttp
)) {
676 var sel_rows
= getSelectedFeedCats();
678 if (sel_rows
.length
> 0) {
680 var ok
= confirm(__("Remove selected categories?"));
683 notify_progress("Removing selected categories...");
685 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
686 param_escape(sel_rows
.toString()), true);
687 xmlhttp
.onreadystatechange
=infobox_callback
;
693 alert(__("No categories are selected."));
700 function feedEditCancel() {
702 if (!xmlhttp_ready(xmlhttp
)) {
707 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
710 document
.getElementById("top25_feeds_btn").disabled
= false;
712 // this button is not always available, no-op if not found
717 selectPrefRows('feed', false); // cleanup feed selection
722 function feedCatEditCancel() {
724 if (!xmlhttp_ready(xmlhttp
)) {
729 active_feed_cat
= false;
731 // notify("Operation cancelled.");
733 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
734 xmlhttp
.onreadystatechange
=infobox_callback
;
740 function feedEditSave() {
744 if (!xmlhttp_ready(xmlhttp
)) {
749 // FIXME: add parameter validation
751 var query
= Form
.serialize("edit_feed_form");
753 notify_progress("Saving feed...");
755 xmlhttp
.open("POST", "backend.php", true);
756 xmlhttp
.onreadystatechange
=feedlist_callback
;
757 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
765 exception_error("feedEditSave", e
);
769 function feedCatEditSave() {
771 if (!xmlhttp_ready(xmlhttp
)) {
776 notify_progress("Saving category...");
778 var query
= Form
.serialize("feed_cat_edit_form");
780 xmlhttp
.open("GET", "backend.php?" + query
, true);
781 xmlhttp
.onreadystatechange
=infobox_callback
;
784 active_feed_cat
= false;
791 function displayHelpInfobox(topic_id
) {
793 /* if (!xmlhttp_ready(xmlhttp)) {
798 notify_progress("Loading help...");
800 xmlhttp.open("GET", "backend.php?op=help&tid=" +
801 param_escape(topic_id), true);
803 xmlhttp.onreadystatechange=helpbox_callback;
804 xmlhttp.send(null); */
806 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
808 var w
= window
.open(url
, "ttrss_help",
809 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
813 function labelEditCancel() {
815 if (!xmlhttp_ready(xmlhttp
)) {
820 document
.getElementById("label_create_btn").disabled
= false;
822 active_label
= false;
824 selectPrefRows('label', false); // cleanup feed selection
830 function userEditCancel() {
832 if (!xmlhttp_ready(xmlhttp
)) {
837 selectPrefRows('user', false); // cleanup feed selection
843 function filterEditCancel() {
845 if (!xmlhttp_ready(xmlhttp
)) {
850 document
.getElementById("create_filter_btn").disabled
= false;
852 selectPrefRows('filter', false); // cleanup feed selection
858 function labelEditSave() {
860 var label
= active_label
;
862 if (!xmlhttp_ready(xmlhttp
)) {
867 /* if (!is_opera()) {
869 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
870 var description = document.forms["label_edit_form"].description.value;
872 if (sql_exp.length == 0) {
873 alert("SQL Expression cannot be blank.");
877 if (description.length == 0) {
878 alert("Caption field cannot be blank.");
885 notify_progress("Saving label...");
887 active_label
= false;
889 query
= Form
.serialize("label_edit_form");
891 xmlhttp
.open("GET", "backend.php?" + query
, true);
892 xmlhttp
.onreadystatechange
=labellist_callback
;
898 function userEditSave() {
900 if (!xmlhttp_ready(xmlhttp
)) {
905 var login
= document
.forms
["user_edit_form"].login
.value
;
907 if (login
.length
== 0) {
908 alert(__("Login field cannot be blank."));
912 notify_progress("Saving user...");
916 var query
= Form
.serialize("user_edit_form");
918 xmlhttp
.open("GET", "backend.php?" + query
, true);
919 xmlhttp
.onreadystatechange
=userlist_callback
;
926 function filterEditSave() {
928 if (!xmlhttp_ready(xmlhttp
)) {
933 /* if (!is_opera()) {
934 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
936 if (reg_exp.length == 0) {
937 alert("Filter expression field cannot be blank.");
942 notify_progress("Saving filter...");
944 var query
= Form
.serialize("filter_edit_form");
948 document
.getElementById("create_filter_btn").disabled
= false;
950 xmlhttp
.open("GET", "backend.php?" + query
, true);
951 xmlhttp
.onreadystatechange
=filterlist_callback
;
957 function editSelectedLabel() {
958 var rows
= getSelectedLabels();
960 if (rows
.length
== 0) {
961 alert(__("No labels are selected."));
965 if (rows
.length
> 1) {
966 alert(__("Please select only one label."));
976 function editSelectedUser() {
977 var rows
= getSelectedUsers();
979 if (rows
.length
== 0) {
980 alert(__("No users are selected."));
984 if (rows
.length
> 1) {
985 alert(__("Please select only one user."));
994 function resetSelectedUserPass() {
995 var rows
= getSelectedUsers();
997 if (rows
.length
== 0) {
998 alert(__("No users are selected."));
1002 if (rows
.length
> 1) {
1003 alert(__("Please select only one user."));
1007 var ok
= confirm(__("Reset password of selected user?"));
1010 notify_progress("Resetting password for selected user...");
1014 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1015 param_escape(id
), true);
1016 xmlhttp
.onreadystatechange
=userlist_callback
;
1021 function selectedUserDetails() {
1023 if (!xmlhttp_ready(xmlhttp
)) {
1024 printLockingError();
1028 var rows
= getSelectedUsers();
1030 if (rows
.length
== 0) {
1031 alert(__("No users are selected."));
1035 if (rows
.length
> 1) {
1036 alert(__("Please select only one user."));
1040 notify_progress("Loading, please wait...");
1044 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1045 xmlhttp
.onreadystatechange
=infobox_callback
;
1050 function selectedFeedDetails() {
1052 if (!xmlhttp_ready(xmlhttp
)) {
1053 printLockingError();
1057 var rows
= getSelectedFeeds();
1059 if (rows
.length
== 0) {
1060 alert(__("No feeds are selected."));
1064 if (rows
.length
> 1) {
1065 alert(__("Please select only one feed."));
1069 // var id = rows[0];
1073 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1074 param_escape(rows
.toString()), true);
1075 xmlhttp
.onreadystatechange
=infobox_callback
;
1080 function editSelectedFilter() {
1081 var rows
= getSelectedFilters();
1083 if (rows
.length
== 0) {
1084 alert(__("No filters are selected."));
1088 if (rows
.length
> 1) {
1089 alert(__("Please select only one filter."));
1095 editFilter(rows
[0]);
1100 function editSelectedFeed() {
1101 var rows
= getSelectedFeeds();
1103 if (rows
.length
== 0) {
1104 alert(__("No feeds are selected."));
1108 if (rows
.length
> 1) {
1109 alert(__("Please select one feed."));
1119 function editSelectedFeedCat() {
1120 var rows
= getSelectedFeedCats();
1122 if (rows
.length
== 0) {
1123 alert(__("No categories are selected."));
1127 if (rows
.length
> 1) {
1128 alert(__("Please select only one category."));
1134 editFeedCat(rows
[0]);
1138 function localPiggieFunction(enable
) {
1140 debug("I LOVEDED IT!");
1141 var piggie
= document
.getElementById("piggie");
1143 Element
.show(piggie
);
1144 Position
.Center(piggie
);
1145 Effect
.Puff(piggie
);
1150 function validateOpmlImport() {
1152 var opml_file
= document
.getElementById("opml_file");
1154 if (opml_file
.value
.length
== 0) {
1155 alert(__("No OPML file to upload."));
1162 function updateFilterList(sort_key
) {
1164 if (!xmlhttp_ready(xmlhttp
)) {
1165 printLockingError();
1169 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1171 // p_notify("Loading, please wait...");
1173 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1174 param_escape(sort_key
), true);
1175 xmlhttp
.onreadystatechange
=filterlist_callback
;
1180 function updateLabelList(sort_key
) {
1182 if (!xmlhttp_ready(xmlhttp
)) {
1183 printLockingError();
1187 // p_notify("Loading, please wait...");
1189 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1191 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1192 param_escape(sort_key
), true);
1193 xmlhttp
.onreadystatechange
=labellist_callback
;
1197 function updatePrefsList() {
1199 if (!xmlhttp_ready(xmlhttp
)) {
1200 printLockingError();
1204 // p_notify("Loading, please wait...");
1206 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1207 xmlhttp
.onreadystatechange
=prefslist_callback
;
1212 function selectTab(id
, noupdate
, subop
) {
1216 if (!id
) id
= active_tab
;
1220 if (!xmlhttp_ready(xmlhttp
)) {
1221 printLockingError();
1226 var c
= document
.getElementById('prefContent');
1232 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1234 notify_progress("Loading, please wait...");
1236 // close active infobox if needed
1239 // clean up all current selections, just in case
1240 active_feed_cat
= false;
1241 active_label
= false;
1243 if (id
== "feedConfig") {
1245 } else if (id
== "filterConfig") {
1247 } else if (id
== "labelConfig") {
1249 } else if (id
== "genConfig") {
1251 } else if (id
== "userConfig") {
1253 } else if (id
== "feedBrowser") {
1254 updateBigFeedBrowser();
1258 var tab
= document
.getElementById(active_tab
+ "Tab");
1261 if (tab
.className
.match("Selected")) {
1262 tab
.className
= "prefsTab";
1266 tab
= document
.getElementById(id
+ "Tab");
1269 if (!tab
.className
.match("Selected")) {
1270 tab
.className
= tab
.className
+ "Selected";
1277 exception_error("selectTab", e
);
1281 function backend_sanity_check_callback() {
1283 if (xmlhttp
.readyState
== 4) {
1287 if (sanity_check_done
) {
1288 fatalError(11, "Sanity check request received twice. This can indicate "+
1289 "presence of Firebug or some other disrupting extension. "+
1290 "Please disable it and try again.");
1294 if (!xmlhttp
.responseXML
) {
1295 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1299 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1302 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1306 var error_code
= reply
.getAttribute("error-code");
1308 if (error_code
&& error_code
!= 0) {
1309 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1312 debug("sanity check ok");
1314 var params
= reply
.nextSibling
;
1317 debug('reading init-params...');
1318 var param
= params
.firstChild
;
1321 var k
= param
.getAttribute("key");
1322 var v
= param
.getAttribute("value");
1323 debug(k
+ " => " + v
);
1325 param
= param
.nextSibling
;
1329 sanity_check_done
= true;
1331 init_second_stage();
1334 exception_error("backend_sanity_check_callback", e
);
1339 function init_second_stage() {
1342 active_tab
= getInitParam("prefs_active_tab");
1343 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1345 document
.onkeydown
= pref_hotkey_handler
;
1347 var tab
= getURLParam('tab');
1349 caller_subop
= getURLParam('subop');
1355 if (navigator
.userAgent
.match("Opera")) {
1356 setTimeout("selectTab()", 500);
1358 selectTab(active_tab
);
1362 exception_error("init_second_stage", e
);
1370 if (arguments
.callee
.done
) return;
1371 arguments
.callee
.done
= true;
1373 if (getURLParam('debug')) {
1374 document
.getElementById('debug_output').style
.display
= 'block';
1375 debug('debug mode activated');
1380 document
.getElementById("prefContent").innerHTML
=
1381 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1382 "to function properly. Your browser doesn't seem to support it.";
1386 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1387 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1391 exception_error("init", e
);
1395 function categorizeSelectedFeeds() {
1397 if (!xmlhttp_ready(xmlhttp
)) {
1398 printLockingError();
1402 var sel_rows
= getSelectedFeeds();
1404 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1405 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1407 if (sel_rows
.length
> 0) {
1409 notify_progress("Changing category of selected feeds...");
1411 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1412 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1413 xmlhttp
.onreadystatechange
=feedlist_callback
;
1418 alert(__("No feeds are selected."));
1424 function validatePrefsReset() {
1426 var ok
= confirm(__("Reset to defaults?"));
1430 var query
= Form
.serialize("pref_prefs_form");
1431 query
= query
+ "&subop=reset-config";
1434 xmlhttp
.open("POST", "backend.php", true);
1435 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1436 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1437 xmlhttp
.send(query
);
1441 exception_error("validatePrefsSave", e
);
1448 function browseFeeds(limit
) {
1450 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1451 xmlhttp
.onreadystatechange
=infobox_callback
;
1456 function feedBrowserSubscribe() {
1459 var selected
= getSelectedFeedsFromBrowser();
1461 if (selected
.length
> 0) {
1463 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1464 param_escape(selected
.toString()), true);
1465 xmlhttp
.onreadystatechange
=feedlist_callback
;
1468 alert(__("No feeds are selected."));
1472 exception_error("feedBrowserSubscribe", e
);
1476 function updateBigFeedBrowser(limit
) {
1478 if (!xmlhttp_ready(xmlhttp
)) {
1479 printLockingError();
1483 // p_notify("Loading, please wait...");
1485 var query
= "backend.php?op=pref-feed-browser";
1487 var limit_sel
= document
.getElementById("feedBrowserLimit");
1490 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1491 query
= query
+ "&limit=" + param_escape(limit
);
1494 xmlhttp
.open("GET", query
, true);
1495 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1499 function browserToggleExpand(id
) {
1501 /* if (feed_to_expand && feed_to_expand != id) {
1502 var d = document.getElementById("BRDET-" + feed_to_expand);
1503 d.style.display = "none";
1506 if (!xmlhttp_ready(xmlhttp
)) {
1507 printLockingError();
1511 /* if (feed_to_expand && id != feed_to_expand) {
1512 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1515 var d
= document
.getElementById("BRDET-" + id
);
1517 if (Element
.visible(d
)) {
1518 Effect
.Fade(d
, {duration
: 0.5});
1520 feed_to_expand
= id
;
1522 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1523 + param_escape(id
), true);
1524 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1529 exception_error("browserToggleExpand", e
);
1533 function selectPrefRows(kind
, select
) {
1536 var opbarid
= false;
1541 if (kind
== "feed") {
1542 opbarid
= "feedOpToolbar";
1545 lname
= "prefFeedList";
1546 } else if (kind
== "fcat") {
1547 opbarid
= "catOpToolbar";
1550 lname
= "prefFeedCatList";
1551 } else if (kind
== "filter") {
1552 opbarid
= "filterOpToolbar";
1555 lname
= "prefFilterList";
1556 } else if (kind
== "label") {
1557 opbarid
= "labelOpToolbar";
1560 lname
= "prefLabelList";
1561 } else if (kind
== "user") {
1562 opbarid
= "userOpToolbar";
1565 lname
= "prefUserList";
1569 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1570 disableContainerChildren(opbarid
, !select
);
1577 function toggleSelectPrefRow(sender
, kind
) {
1579 toggleSelectRow(sender
);
1582 var opbarid
= false;
1585 if (kind
== "feed") {
1586 opbarid
= "feedOpToolbar";
1587 nsel
= getSelectedFeeds();
1588 } else if (kind
== "fcat") {
1589 opbarid
= "catOpToolbar";
1590 nsel
= getSelectedFeedCats();
1591 } else if (kind
== "filter") {
1592 opbarid
= "filterOpToolbar";
1593 nsel
= getSelectedFilters();
1594 } else if (kind
== "label") {
1595 opbarid
= "labelOpToolbar";
1596 nsel
= getSelectedLabels();
1597 } else if (kind
== "user") {
1598 opbarid
= "userOpToolbar";
1599 nsel
= getSelectedUsers();
1602 if (opbarid
&& nsel
!= -1) {
1603 disableContainerChildren(opbarid
, nsel
== false);
1609 function toggleSelectFBListRow(sender
) {
1610 toggleSelectListRow(sender
);
1611 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1616 function pref_hotkey_handler(e
) {
1621 if (!hotkeys_enabled
) return;
1624 keycode
= window
.event
.keyCode
;
1629 if (keycode
== 13 || keycode
== 27) {
1632 seq
= seq
+ "" + keycode
;
1636 if (document
.getElementById("piggie")) {
1638 if (seq
.match("807371717369")) {
1640 localPiggieFunction(true);
1642 localPiggieFunction(false);
1647 exception_error("pref_hotkey_handler", e
);
1651 function userSwitch() {
1652 var chooser
= document
.getElementById("userSwitch");
1653 var user
= chooser
[chooser
.selectedIndex
].value
;
1654 window
.location
= "prefs.php?swu=" + user
;
1657 function editFeedCats() {
1658 if (!xmlhttp_ready(xmlhttp
)) {
1659 printLockingError();
1663 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1666 document
.getElementById("top25_feeds_btn").disabled
= true;
1668 // this button is not always available, no-op if not found
1671 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1672 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1676 function showFeedsWithErrors() {
1677 displayDlg('feedUpdateErrors');
1680 function changeUserPassword() {
1684 if (!xmlhttp_ready(xmlhttp
)) {
1685 printLockingError();
1689 var f
= document
.forms
["change_pass_form"];
1692 if (f
.OLD_PASSWORD
.value
== "") {
1693 new Effect
.Highlight(f
.OLD_PASSWORD
);
1694 notify_error("Old password cannot be blank.");
1698 if (f
.NEW_PASSWORD
.value
== "") {
1699 new Effect
.Highlight(f
.NEW_PASSWORD
);
1700 notify_error("New password cannot be blank.");
1704 if (f
.CONFIRM_PASSWORD
.value
== "") {
1705 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1706 notify_error("Entered passwords do not match.");
1710 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1711 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1712 new Effect
.Highlight(f
.NEW_PASSWORD
);
1713 notify_error("Entered passwords do not match.");
1719 var query
= Form
.serialize("change_pass_form");
1721 notify_progress("Trying to change password...");
1723 xmlhttp
.open("POST", "backend.php", true);
1724 xmlhttp
.onreadystatechange
=changepass_callback
;
1725 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1726 xmlhttp
.send(query
);
1729 exception_error("changeUserPassword", e
);
1735 function changeUserEmail() {
1739 if (!xmlhttp_ready(xmlhttp
)) {
1740 printLockingError();
1744 var query
= Form
.serialize("change_email_form");
1746 notify_progress("Trying to change e-mail...");
1748 xmlhttp
.open("POST", "backend.php", true);
1749 xmlhttp
.onreadystatechange
=notify_callback
;
1750 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1751 xmlhttp
.send(query
);
1754 exception_error("changeUserPassword", e
);
1761 function feedlistToggleSLAT() {
1762 notify_progress("Loading, please wait...");
1766 function pubRegenKey() {
1768 if (!xmlhttp_ready(xmlhttp
)) {
1769 printLockingError();
1773 var ok
= confirm(__("Replace current publishing address with a new one?"));
1777 notify_progress("Trying to change address...");
1779 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1780 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1787 function validatePrefsSave() {
1790 var ok
= confirm(__("Save current configuration?"));
1794 var query
= Form
.serialize("pref_prefs_form");
1795 query
= query
+ "&subop=save-config";
1798 xmlhttp
.open("POST", "backend.php", true);
1799 xmlhttp
.onreadystatechange
=notify_callback
;
1800 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1801 xmlhttp
.send(query
);
1805 exception_error("validatePrefsSave", e
);