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 infobox_feed_cat_callback() {
211 if (xmlhttp
.readyState
== 4) {
216 if (document
.getElementById("prefFeedCatList")) {
217 var elems
= document
.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
219 for (var i
= 0; i
< elems
.length
; i
++) {
220 if (elems
[i
].id
&& elems
[i
].id
.match("FCATT-")) {
221 var cat_id
= elems
[i
].id
.replace("FCATT-", "");
223 new Ajax
.InPlaceEditor(elems
[i
],
224 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id
);
230 exception_error("infobox_feed_cat_callback", e
);
235 function updateFeedList(sort_key
) {
237 if (!xmlhttp_ready(xmlhttp
)) {
242 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
244 // p_notify("Loading, please wait...");
246 var feed_search
= document
.getElementById("feed_search");
248 if (feed_search
) { search
= feed_search
.value
; }
250 var slat
= document
.getElementById("show_last_article_times");
252 var slat_checked
= false;
254 slat_checked
= slat
.checked
;
257 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
258 "&sort=" + param_escape(sort_key
) +
259 "&slat=" + param_escape(slat_checked
) +
260 "&search=" + param_escape(search
), true);
261 xmlhttp
.onreadystatechange
=feedlist_callback
;
266 function updateUsersList(sort_key
) {
268 if (!xmlhttp_ready(xmlhttp
)) {
273 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
275 // p_notify("Loading, please wait...");
277 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
278 + param_escape(sort_key
), true);
279 xmlhttp
.onreadystatechange
=userlist_callback
;
284 function addLabel() {
286 if (!xmlhttp_ready(xmlhttp
)) {
291 var form
= document
.forms
['label_edit_form'];
293 var sql_exp
= form
.sql_exp
.value
;
294 var description
= form
.description
.value
;
297 alert(__("Can't create label: missing SQL expression."));
301 if (description
== "") {
302 alert(__("Can't create label: missing caption."));
306 var query
= Form
.serialize("label_edit_form");
308 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
309 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
315 if (!xmlhttp_ready(xmlhttp
)) {
320 var link
= document
.getElementById("fadd_link");
322 if (link
.value
.length
== 0) {
323 alert(__("Error: No feed URL given."));
324 } else if (!isValidURL(link
.value
)) {
325 alert(__("Error: Invalid feed URL."));
327 notify_progress("Adding feed...");
329 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
330 param_escape(link
.value
), true);
331 xmlhttp
.onreadystatechange
=feedlist_callback
;
340 function addFeedCat() {
342 if (!xmlhttp_ready(xmlhttp
)) {
347 var cat
= document
.getElementById("fadd_cat");
349 if (cat
.value
.length
== 0) {
350 alert(__("Can't add category: no name specified."));
352 notify_progress("Adding feed category...");
354 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
355 param_escape(cat
.value
), true);
356 xmlhttp
.onreadystatechange
=infobox_callback
;
366 if (!xmlhttp_ready(xmlhttp
)) {
371 var sqlexp
= document
.getElementById("uadd_box");
373 if (sqlexp
.value
.length
== 0) {
374 alert(__("Can't add user: no login specified."));
376 notify_progress("Adding user...");
378 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
379 param_escape(sqlexp
.value
), true);
381 xmlhttp
.onreadystatechange
=userlist_callback
;
389 function editLabel(id
) {
391 if (!xmlhttp_ready(xmlhttp
)) {
396 notify_progress("Loading, please wait...");
398 document
.getElementById("label_create_btn").disabled
= true;
402 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
403 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
405 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
406 param_escape(id
), true);
407 xmlhttp
.onreadystatechange
=infobox_callback
;
412 function editUser(id
) {
414 if (!xmlhttp_ready(xmlhttp
)) {
419 notify_progress("Loading, please wait...");
421 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
422 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
424 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
425 param_escape(id
), true);
426 xmlhttp
.onreadystatechange
=infobox_callback
;
431 function editFilter(id
) {
433 if (!xmlhttp_ready(xmlhttp
)) {
438 notify_progress("Loading, please wait...");
440 document
.getElementById("create_filter_btn").disabled
= true;
442 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
443 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
445 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
446 xmlhttp
.onreadystatechange
=infobox_callback
;
450 function editFeed(feed
) {
452 // notify("Editing feed...");
454 if (!xmlhttp_ready(xmlhttp
)) {
459 notify_progress("Loading, please wait...");
461 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
464 document
.getElementById("top25_feeds_btn").disabled
= true;
466 // this button is not always available, no-op if not found
469 // clean selection from all rows & select row being edited
470 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
471 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
473 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
474 param_escape(feed
), true);
476 xmlhttp
.onreadystatechange
=infobox_callback
;
481 function editFeedCat(cat
) {
483 if (!xmlhttp_ready(xmlhttp
)) {
488 notify_progress("Loading, please wait...");
490 active_feed_cat
= cat
;
492 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
493 param_escape(cat
), true);
494 xmlhttp
.onreadystatechange
=infobox_callback
;
499 function getSelectedLabels() {
500 return getSelectedTableRowIds("prefLabelList", "LILRR");
503 function getSelectedUsers() {
504 return getSelectedTableRowIds("prefUserList", "UMRR");
507 function getSelectedFeeds() {
508 return getSelectedTableRowIds("prefFeedList", "FEEDR");
511 function getSelectedFilters() {
512 return getSelectedTableRowIds("prefFilterList", "FILRR");
515 function getSelectedFeedCats() {
516 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
519 function getSelectedFeedsFromBrowser() {
521 var list
= document
.getElementById("browseFeedList");
522 if (!list
) list
= document
.getElementById("browseBigFeedList");
524 var selected
= new Array();
526 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
527 var child
= list
.childNodes
[i
];
528 if (child
.id
&& child
.id
.match("FBROW-")) {
529 var id
= child
.id
.replace("FBROW-", "");
531 var cb
= document
.getElementById("FBCHK-" + id
);
542 function removeSelectedLabels() {
544 if (!xmlhttp_ready(xmlhttp
)) {
549 var sel_rows
= getSelectedLabels();
551 if (sel_rows
.length
> 0) {
553 var ok
= confirm(__("Remove selected labels?"));
556 notify_progress("Removing selected labels...");
558 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
559 param_escape(sel_rows
.toString()), true);
560 xmlhttp
.onreadystatechange
=labellist_callback
;
564 alert(__("No labels are selected."));
570 function removeSelectedUsers() {
572 if (!xmlhttp_ready(xmlhttp
)) {
577 var sel_rows
= getSelectedUsers();
579 if (sel_rows
.length
> 0) {
581 var ok
= confirm(__("Remove selected users?"));
584 notify_progress("Removing selected users...");
586 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
587 param_escape(sel_rows
.toString()), true);
588 xmlhttp
.onreadystatechange
=userlist_callback
;
593 alert(__("No users are selected."));
599 function removeSelectedFilters() {
601 if (!xmlhttp_ready(xmlhttp
)) {
606 var sel_rows
= getSelectedFilters();
608 if (sel_rows
.length
> 0) {
610 var ok
= confirm(__("Remove selected filters?"));
613 notify_progress("Removing selected filters...");
615 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
616 param_escape(sel_rows
.toString()), true);
617 xmlhttp
.onreadystatechange
=filterlist_callback
;
621 alert(__("No filters are selected."));
628 function removeSelectedFeeds() {
630 if (!xmlhttp_ready(xmlhttp
)) {
635 var sel_rows
= getSelectedFeeds();
637 if (sel_rows
.length
> 0) {
639 var ok
= confirm(__("Unsubscribe from selected feeds?"));
643 notify_progress("Unsubscribing from selected feeds...");
645 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
646 param_escape(sel_rows
.toString()), true);
647 xmlhttp
.onreadystatechange
=feedlist_callback
;
653 alert(__("No feeds are selected."));
660 function removeSelectedFeedCats() {
662 if (!xmlhttp_ready(xmlhttp
)) {
667 var sel_rows
= getSelectedFeedCats();
669 if (sel_rows
.length
> 0) {
671 var ok
= confirm(__("Remove selected categories?"));
674 notify_progress("Removing selected categories...");
676 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
677 param_escape(sel_rows
.toString()), true);
678 xmlhttp
.onreadystatechange
=infobox_callback
;
684 alert(__("No categories are selected."));
691 function feedEditCancel() {
693 if (!xmlhttp_ready(xmlhttp
)) {
698 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
701 document
.getElementById("top25_feeds_btn").disabled
= false;
703 // this button is not always available, no-op if not found
708 selectPrefRows('feed', false); // cleanup feed selection
713 function feedCatEditCancel() {
715 if (!xmlhttp_ready(xmlhttp
)) {
720 active_feed_cat
= false;
722 // notify("Operation cancelled.");
724 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
725 xmlhttp
.onreadystatechange
=infobox_callback
;
731 function feedEditSave() {
735 if (!xmlhttp_ready(xmlhttp
)) {
740 // FIXME: add parameter validation
742 var query
= Form
.serialize("edit_feed_form");
744 notify_progress("Saving feed...");
746 xmlhttp
.open("POST", "backend.php", true);
747 xmlhttp
.onreadystatechange
=feedlist_callback
;
748 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
756 exception_error("feedEditSave", e
);
760 function feedCatEditSave() {
762 if (!xmlhttp_ready(xmlhttp
)) {
767 notify_progress("Saving category...");
769 var query
= Form
.serialize("feed_cat_edit_form");
771 xmlhttp
.open("GET", "backend.php?" + query
, true);
772 xmlhttp
.onreadystatechange
=infobox_callback
;
775 active_feed_cat
= false;
782 function displayHelpInfobox(topic_id
) {
784 /* if (!xmlhttp_ready(xmlhttp)) {
789 notify_progress("Loading help...");
791 xmlhttp.open("GET", "backend.php?op=help&tid=" +
792 param_escape(topic_id), true);
794 xmlhttp.onreadystatechange=helpbox_callback;
795 xmlhttp.send(null); */
797 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
799 var w
= window
.open(url
, "ttrss_help",
800 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
804 function labelEditCancel() {
806 if (!xmlhttp_ready(xmlhttp
)) {
811 document
.getElementById("label_create_btn").disabled
= false;
813 active_label
= false;
815 selectPrefRows('label', false); // cleanup feed selection
821 function userEditCancel() {
823 if (!xmlhttp_ready(xmlhttp
)) {
828 selectPrefRows('user', false); // cleanup feed selection
834 function filterEditCancel() {
836 if (!xmlhttp_ready(xmlhttp
)) {
841 document
.getElementById("create_filter_btn").disabled
= false;
843 selectPrefRows('filter', false); // cleanup feed selection
849 function labelEditSave() {
851 var label
= active_label
;
853 if (!xmlhttp_ready(xmlhttp
)) {
858 /* if (!is_opera()) {
860 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
861 var description = document.forms["label_edit_form"].description.value;
863 if (sql_exp.length == 0) {
864 alert("SQL Expression cannot be blank.");
868 if (description.length == 0) {
869 alert("Caption field cannot be blank.");
876 notify_progress("Saving label...");
878 active_label
= false;
880 query
= Form
.serialize("label_edit_form");
882 xmlhttp
.open("GET", "backend.php?" + query
, true);
883 xmlhttp
.onreadystatechange
=labellist_callback
;
889 function userEditSave() {
891 if (!xmlhttp_ready(xmlhttp
)) {
896 var login
= document
.forms
["user_edit_form"].login
.value
;
898 if (login
.length
== 0) {
899 alert(__("Login field cannot be blank."));
903 notify_progress("Saving user...");
907 var query
= Form
.serialize("user_edit_form");
909 xmlhttp
.open("GET", "backend.php?" + query
, true);
910 xmlhttp
.onreadystatechange
=userlist_callback
;
917 function filterEditSave() {
919 if (!xmlhttp_ready(xmlhttp
)) {
924 /* if (!is_opera()) {
925 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
927 if (reg_exp.length == 0) {
928 alert("Filter expression field cannot be blank.");
933 notify_progress("Saving filter...");
935 var query
= Form
.serialize("filter_edit_form");
939 document
.getElementById("create_filter_btn").disabled
= false;
941 xmlhttp
.open("GET", "backend.php?" + query
, true);
942 xmlhttp
.onreadystatechange
=filterlist_callback
;
948 function editSelectedLabel() {
949 var rows
= getSelectedLabels();
951 if (rows
.length
== 0) {
952 alert(__("No labels are selected."));
956 if (rows
.length
> 1) {
957 alert(__("Please select only one label."));
967 function editSelectedUser() {
968 var rows
= getSelectedUsers();
970 if (rows
.length
== 0) {
971 alert(__("No users are selected."));
975 if (rows
.length
> 1) {
976 alert(__("Please select only one user."));
985 function resetSelectedUserPass() {
986 var rows
= getSelectedUsers();
988 if (rows
.length
== 0) {
989 alert(__("No users are selected."));
993 if (rows
.length
> 1) {
994 alert(__("Please select only one user."));
998 var ok
= confirm(__("Reset password of selected user?"));
1001 notify_progress("Resetting password for selected user...");
1005 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1006 param_escape(id
), true);
1007 xmlhttp
.onreadystatechange
=userlist_callback
;
1012 function selectedUserDetails() {
1014 if (!xmlhttp_ready(xmlhttp
)) {
1015 printLockingError();
1019 var rows
= getSelectedUsers();
1021 if (rows
.length
== 0) {
1022 alert(__("No users are selected."));
1026 if (rows
.length
> 1) {
1027 alert(__("Please select only one user."));
1031 notify_progress("Loading, please wait...");
1035 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1036 xmlhttp
.onreadystatechange
=infobox_callback
;
1041 function selectedFeedDetails() {
1043 if (!xmlhttp_ready(xmlhttp
)) {
1044 printLockingError();
1048 var rows
= getSelectedFeeds();
1050 if (rows
.length
== 0) {
1051 alert(__("No feeds are selected."));
1055 if (rows
.length
> 1) {
1056 alert(__("Please select only one feed."));
1060 // var id = rows[0];
1064 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1065 param_escape(rows
.toString()), true);
1066 xmlhttp
.onreadystatechange
=infobox_callback
;
1071 function editSelectedFilter() {
1072 var rows
= getSelectedFilters();
1074 if (rows
.length
== 0) {
1075 alert(__("No filters are selected."));
1079 if (rows
.length
> 1) {
1080 alert(__("Please select only one filter."));
1086 editFilter(rows
[0]);
1091 function editSelectedFeed() {
1092 var rows
= getSelectedFeeds();
1094 if (rows
.length
== 0) {
1095 alert(__("No feeds are selected."));
1099 if (rows
.length
> 1) {
1100 alert(__("Please select one feed."));
1110 function editSelectedFeedCat() {
1111 var rows
= getSelectedFeedCats();
1113 if (rows
.length
== 0) {
1114 alert(__("No categories are selected."));
1118 if (rows
.length
> 1) {
1119 alert(__("Please select only one category."));
1125 editFeedCat(rows
[0]);
1129 function localPiggieFunction(enable
) {
1131 debug("I LOVEDED IT!");
1132 var piggie
= document
.getElementById("piggie");
1134 Element
.show(piggie
);
1135 Position
.Center(piggie
);
1136 Effect
.Puff(piggie
);
1141 function validateOpmlImport() {
1143 var opml_file
= document
.getElementById("opml_file");
1145 if (opml_file
.value
.length
== 0) {
1146 alert(__("No OPML file to upload."));
1153 function updateFilterList(sort_key
) {
1155 if (!xmlhttp_ready(xmlhttp
)) {
1156 printLockingError();
1160 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1162 // p_notify("Loading, please wait...");
1164 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1165 param_escape(sort_key
), true);
1166 xmlhttp
.onreadystatechange
=filterlist_callback
;
1171 function updateLabelList(sort_key
) {
1173 if (!xmlhttp_ready(xmlhttp
)) {
1174 printLockingError();
1178 // p_notify("Loading, please wait...");
1180 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1182 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1183 param_escape(sort_key
), true);
1184 xmlhttp
.onreadystatechange
=labellist_callback
;
1188 function updatePrefsList() {
1190 if (!xmlhttp_ready(xmlhttp
)) {
1191 printLockingError();
1195 // p_notify("Loading, please wait...");
1197 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1198 xmlhttp
.onreadystatechange
=prefslist_callback
;
1203 function selectTab(id
, noupdate
, subop
) {
1207 if (!id
) id
= active_tab
;
1211 if (!xmlhttp_ready(xmlhttp
)) {
1212 printLockingError();
1217 var c
= document
.getElementById('prefContent');
1223 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1225 notify_progress("Loading, please wait...");
1227 // close active infobox if needed
1230 // clean up all current selections, just in case
1231 active_feed_cat
= false;
1232 active_label
= false;
1234 if (id
== "feedConfig") {
1236 } else if (id
== "filterConfig") {
1238 } else if (id
== "labelConfig") {
1240 } else if (id
== "genConfig") {
1242 } else if (id
== "userConfig") {
1244 } else if (id
== "feedBrowser") {
1245 updateBigFeedBrowser();
1249 var tab
= document
.getElementById(active_tab
+ "Tab");
1252 if (tab
.className
.match("Selected")) {
1253 tab
.className
= "prefsTab";
1257 tab
= document
.getElementById(id
+ "Tab");
1260 if (!tab
.className
.match("Selected")) {
1261 tab
.className
= tab
.className
+ "Selected";
1268 exception_error("selectTab", e
);
1272 function backend_sanity_check_callback() {
1274 if (xmlhttp
.readyState
== 4) {
1278 if (sanity_check_done
) {
1279 fatalError(11, "Sanity check request received twice. This can indicate "+
1280 "presence of Firebug or some other disrupting extension. "+
1281 "Please disable it and try again.");
1285 if (!xmlhttp
.responseXML
) {
1286 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1290 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1293 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1297 var error_code
= reply
.getAttribute("error-code");
1299 if (error_code
&& error_code
!= 0) {
1300 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1303 debug("sanity check ok");
1305 var params
= reply
.nextSibling
;
1308 debug('reading init-params...');
1309 var param
= params
.firstChild
;
1312 var k
= param
.getAttribute("key");
1313 var v
= param
.getAttribute("value");
1314 debug(k
+ " => " + v
);
1316 param
= param
.nextSibling
;
1320 sanity_check_done
= true;
1322 init_second_stage();
1325 exception_error("backend_sanity_check_callback", e
);
1330 function init_second_stage() {
1333 active_tab
= getInitParam("prefs_active_tab");
1334 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1336 document
.onkeydown
= pref_hotkey_handler
;
1338 var tab
= getURLParam('tab');
1340 caller_subop
= getURLParam('subop');
1346 if (navigator
.userAgent
.match("Opera")) {
1347 setTimeout("selectTab()", 500);
1349 selectTab(active_tab
);
1353 exception_error("init_second_stage", e
);
1361 if (arguments
.callee
.done
) return;
1362 arguments
.callee
.done
= true;
1364 if (getURLParam('debug')) {
1365 document
.getElementById('debug_output').style
.display
= 'block';
1366 debug('debug mode activated');
1371 document
.getElementById("prefContent").innerHTML
=
1372 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1373 "to function properly. Your browser doesn't seem to support it.";
1377 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1378 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1382 exception_error("init", e
);
1386 function categorizeSelectedFeeds() {
1388 if (!xmlhttp_ready(xmlhttp
)) {
1389 printLockingError();
1393 var sel_rows
= getSelectedFeeds();
1395 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1396 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1398 if (sel_rows
.length
> 0) {
1400 notify_progress("Changing category of selected feeds...");
1402 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1403 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1404 xmlhttp
.onreadystatechange
=feedlist_callback
;
1409 alert(__("No feeds are selected."));
1415 function validatePrefsReset() {
1416 return confirm(__("Reset to defaults?"));
1419 function browseFeeds(limit
) {
1421 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1422 xmlhttp
.onreadystatechange
=infobox_callback
;
1427 function feedBrowserSubscribe() {
1430 var selected
= getSelectedFeedsFromBrowser();
1432 if (selected
.length
> 0) {
1434 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1435 param_escape(selected
.toString()), true);
1436 xmlhttp
.onreadystatechange
=feedlist_callback
;
1439 alert(__("No feeds are selected."));
1443 exception_error("feedBrowserSubscribe", e
);
1447 function updateBigFeedBrowser(limit
) {
1449 if (!xmlhttp_ready(xmlhttp
)) {
1450 printLockingError();
1454 // p_notify("Loading, please wait...");
1456 var query
= "backend.php?op=pref-feed-browser";
1458 var limit_sel
= document
.getElementById("feedBrowserLimit");
1461 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1462 query
= query
+ "&limit=" + param_escape(limit
);
1465 xmlhttp
.open("GET", query
, true);
1466 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1470 function browserToggleExpand(id
) {
1472 /* if (feed_to_expand && feed_to_expand != id) {
1473 var d = document.getElementById("BRDET-" + feed_to_expand);
1474 d.style.display = "none";
1477 if (!xmlhttp_ready(xmlhttp
)) {
1478 printLockingError();
1482 /* if (feed_to_expand && id != feed_to_expand) {
1483 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1486 var d
= document
.getElementById("BRDET-" + id
);
1488 if (Element
.visible(d
)) {
1489 Effect
.Fade(d
, {duration
: 0.5});
1491 feed_to_expand
= id
;
1493 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1494 + param_escape(id
), true);
1495 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1500 exception_error("browserToggleExpand", e
);
1504 function selectPrefRows(kind
, select
) {
1507 var opbarid
= false;
1512 if (kind
== "feed") {
1513 opbarid
= "feedOpToolbar";
1516 lname
= "prefFeedList";
1517 } else if (kind
== "fcat") {
1518 opbarid
= "catOpToolbar";
1521 lname
= "prefFeedCatList";
1522 } else if (kind
== "filter") {
1523 opbarid
= "filterOpToolbar";
1526 lname
= "prefFilterList";
1527 } else if (kind
== "label") {
1528 opbarid
= "labelOpToolbar";
1531 lname
= "prefLabelList";
1532 } else if (kind
== "user") {
1533 opbarid
= "userOpToolbar";
1536 lname
= "prefUserList";
1540 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1541 disableContainerChildren(opbarid
, !select
);
1548 function toggleSelectPrefRow(sender
, kind
) {
1550 toggleSelectRow(sender
);
1553 var opbarid
= false;
1556 if (kind
== "feed") {
1557 opbarid
= "feedOpToolbar";
1558 nsel
= getSelectedFeeds();
1559 } else if (kind
== "fcat") {
1560 opbarid
= "catOpToolbar";
1561 nsel
= getSelectedFeedCats();
1562 } else if (kind
== "filter") {
1563 opbarid
= "filterOpToolbar";
1564 nsel
= getSelectedFilters();
1565 } else if (kind
== "label") {
1566 opbarid
= "labelOpToolbar";
1567 nsel
= getSelectedLabels();
1568 } else if (kind
== "user") {
1569 opbarid
= "userOpToolbar";
1570 nsel
= getSelectedUsers();
1573 if (opbarid
&& nsel
!= -1) {
1574 disableContainerChildren(opbarid
, nsel
== false);
1580 function toggleSelectFBListRow(sender
) {
1581 toggleSelectListRow(sender
);
1582 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1587 function pref_hotkey_handler(e
) {
1592 if (!hotkeys_enabled
) return;
1595 keycode
= window
.event
.keyCode
;
1600 if (keycode
== 13 || keycode
== 27) {
1603 seq
= seq
+ "" + keycode
;
1607 if (document
.getElementById("piggie")) {
1609 if (seq
.match("807371717369")) {
1611 localPiggieFunction(true);
1613 localPiggieFunction(false);
1618 exception_error("pref_hotkey_handler", e
);
1622 function userSwitch() {
1623 var chooser
= document
.getElementById("userSwitch");
1624 var user
= chooser
[chooser
.selectedIndex
].value
;
1625 window
.location
= "prefs.php?swu=" + user
;
1628 function editFeedCats() {
1629 if (!xmlhttp_ready(xmlhttp
)) {
1630 printLockingError();
1634 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1637 document
.getElementById("top25_feeds_btn").disabled
= true;
1639 // this button is not always available, no-op if not found
1642 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1643 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1647 function showFeedsWithErrors() {
1648 displayDlg('feedUpdateErrors');
1651 function changeUserPassword() {
1655 if (!xmlhttp_ready(xmlhttp
)) {
1656 printLockingError();
1660 var query
= Form
.serialize("change_pass_form");
1662 notify_progress("Trying to change password...");
1664 xmlhttp
.open("POST", "backend.php", true);
1665 xmlhttp
.onreadystatechange
=changepass_callback
;
1666 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1667 xmlhttp
.send(query
);
1670 exception_error("changeUserPassword", e
);
1676 function changeUserEmail() {
1680 if (!xmlhttp_ready(xmlhttp
)) {
1681 printLockingError();
1685 var query
= Form
.serialize("change_email_form");
1687 notify_progress("Trying to change e-mail...");
1689 xmlhttp
.open("POST", "backend.php", true);
1690 xmlhttp
.onreadystatechange
=notify_callback
;
1691 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1692 xmlhttp
.send(query
);
1695 exception_error("changeUserPassword", e
);
1702 function feedlistToggleSLAT() {
1703 notify_progress("Loading, please wait...");
1707 function pubRegenKey() {
1709 if (!xmlhttp_ready(xmlhttp
)) {
1710 printLockingError();
1714 var ok
= confirm(__("Replace current publishing address with a new one?"));
1718 notify_progress("Trying to change address...");
1720 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1721 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;