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
);
189 function prefs_reset_callback() {
190 if (xmlhttp
.readyState
== 4) {
191 notify_info(xmlhttp
.responseText
);
197 function changepass_callback() {
199 if (xmlhttp
.readyState
== 4) {
201 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
202 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
204 notify_info(xmlhttp
.responseText
);
205 var warn
= document
.getElementById("default_pass_warning");
206 if (warn
) warn
.style
.display
= "none";
209 document
.forms
['change_pass_form'].reset();
213 exception_error("changepass_callback", e
);
217 function infobox_feed_cat_callback() {
218 if (xmlhttp
.readyState
== 4) {
223 if (document
.getElementById("prefFeedCatList")) {
224 var elems
= document
.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
226 for (var i
= 0; i
< elems
.length
; i
++) {
227 if (elems
[i
].id
&& elems
[i
].id
.match("FCATT-")) {
228 var cat_id
= elems
[i
].id
.replace("FCATT-", "");
230 new Ajax
.InPlaceEditor(elems
[i
],
231 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id
);
237 exception_error("infobox_feed_cat_callback", e
);
242 function updateFeedList(sort_key
) {
244 if (!xmlhttp_ready(xmlhttp
)) {
249 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
251 // p_notify("Loading, please wait...");
253 var feed_search
= document
.getElementById("feed_search");
255 if (feed_search
) { search
= feed_search
.value
; }
257 var slat
= document
.getElementById("show_last_article_times");
259 var slat_checked
= false;
261 slat_checked
= slat
.checked
;
264 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
265 "&sort=" + param_escape(sort_key
) +
266 "&slat=" + param_escape(slat_checked
) +
267 "&search=" + param_escape(search
), true);
268 xmlhttp
.onreadystatechange
=feedlist_callback
;
273 function updateUsersList(sort_key
) {
275 if (!xmlhttp_ready(xmlhttp
)) {
280 // document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
282 // p_notify("Loading, please wait...");
284 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
285 + param_escape(sort_key
), true);
286 xmlhttp
.onreadystatechange
=userlist_callback
;
291 function addLabel() {
293 if (!xmlhttp_ready(xmlhttp
)) {
298 var form
= document
.forms
['label_edit_form'];
300 var sql_exp
= form
.sql_exp
.value
;
301 var description
= form
.description
.value
;
304 alert(__("Can't create label: missing SQL expression."));
308 if (description
== "") {
309 alert(__("Can't create label: missing caption."));
313 var query
= Form
.serialize("label_edit_form");
315 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
316 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
322 if (!xmlhttp_ready(xmlhttp
)) {
327 var link
= document
.getElementById("fadd_link");
329 if (link
.value
.length
== 0) {
330 alert(__("Error: No feed URL given."));
331 } else if (!isValidURL(link
.value
)) {
332 alert(__("Error: Invalid feed URL."));
334 notify_progress("Adding feed...");
336 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
337 param_escape(link
.value
), true);
338 xmlhttp
.onreadystatechange
=feedlist_callback
;
347 function addFeedCat() {
349 if (!xmlhttp_ready(xmlhttp
)) {
354 var cat
= document
.getElementById("fadd_cat");
356 if (cat
.value
.length
== 0) {
357 alert(__("Can't add category: no name specified."));
359 notify_progress("Adding feed category...");
361 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
362 param_escape(cat
.value
), true);
363 xmlhttp
.onreadystatechange
=infobox_callback
;
373 if (!xmlhttp_ready(xmlhttp
)) {
378 var sqlexp
= document
.getElementById("uadd_box");
380 if (sqlexp
.value
.length
== 0) {
381 alert(__("Can't add user: no login specified."));
383 notify_progress("Adding user...");
385 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
386 param_escape(sqlexp
.value
), true);
388 xmlhttp
.onreadystatechange
=userlist_callback
;
396 function editLabel(id
) {
398 if (!xmlhttp_ready(xmlhttp
)) {
403 notify_progress("Loading, please wait...");
405 document
.getElementById("label_create_btn").disabled
= true;
409 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
410 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
412 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
413 param_escape(id
), true);
414 xmlhttp
.onreadystatechange
=infobox_callback
;
419 function editUser(id
) {
421 if (!xmlhttp_ready(xmlhttp
)) {
426 notify_progress("Loading, please wait...");
428 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
429 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
431 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
432 param_escape(id
), true);
433 xmlhttp
.onreadystatechange
=infobox_callback
;
438 function editFilter(id
) {
440 if (!xmlhttp_ready(xmlhttp
)) {
445 notify_progress("Loading, please wait...");
447 document
.getElementById("create_filter_btn").disabled
= true;
449 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
450 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
452 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
453 xmlhttp
.onreadystatechange
=infobox_callback
;
457 function editFeed(feed
) {
459 // notify("Editing feed...");
461 if (!xmlhttp_ready(xmlhttp
)) {
466 notify_progress("Loading, please wait...");
468 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
471 document
.getElementById("top25_feeds_btn").disabled
= true;
473 // this button is not always available, no-op if not found
476 // clean selection from all rows & select row being edited
477 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
478 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
480 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
481 param_escape(feed
), true);
483 xmlhttp
.onreadystatechange
=infobox_callback
;
488 function editFeedCat(cat
) {
490 if (!xmlhttp_ready(xmlhttp
)) {
495 notify_progress("Loading, please wait...");
497 active_feed_cat
= cat
;
499 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
500 param_escape(cat
), true);
501 xmlhttp
.onreadystatechange
=infobox_callback
;
506 function getSelectedLabels() {
507 return getSelectedTableRowIds("prefLabelList", "LILRR");
510 function getSelectedUsers() {
511 return getSelectedTableRowIds("prefUserList", "UMRR");
514 function getSelectedFeeds() {
515 return getSelectedTableRowIds("prefFeedList", "FEEDR");
518 function getSelectedFilters() {
519 return getSelectedTableRowIds("prefFilterList", "FILRR");
522 function getSelectedFeedCats() {
523 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
526 function getSelectedFeedsFromBrowser() {
528 var list
= document
.getElementById("browseFeedList");
529 if (!list
) list
= document
.getElementById("browseBigFeedList");
531 var selected
= new Array();
533 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
534 var child
= list
.childNodes
[i
];
535 if (child
.id
&& child
.id
.match("FBROW-")) {
536 var id
= child
.id
.replace("FBROW-", "");
538 var cb
= document
.getElementById("FBCHK-" + id
);
549 function removeSelectedLabels() {
551 if (!xmlhttp_ready(xmlhttp
)) {
556 var sel_rows
= getSelectedLabels();
558 if (sel_rows
.length
> 0) {
560 var ok
= confirm(__("Remove selected labels?"));
563 notify_progress("Removing selected labels...");
565 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
566 param_escape(sel_rows
.toString()), true);
567 xmlhttp
.onreadystatechange
=labellist_callback
;
571 alert(__("No labels are selected."));
577 function removeSelectedUsers() {
579 if (!xmlhttp_ready(xmlhttp
)) {
584 var sel_rows
= getSelectedUsers();
586 if (sel_rows
.length
> 0) {
588 var ok
= confirm(__("Remove selected users?"));
591 notify_progress("Removing selected users...");
593 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
594 param_escape(sel_rows
.toString()), true);
595 xmlhttp
.onreadystatechange
=userlist_callback
;
600 alert(__("No users are selected."));
606 function removeSelectedFilters() {
608 if (!xmlhttp_ready(xmlhttp
)) {
613 var sel_rows
= getSelectedFilters();
615 if (sel_rows
.length
> 0) {
617 var ok
= confirm(__("Remove selected filters?"));
620 notify_progress("Removing selected filters...");
622 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
623 param_escape(sel_rows
.toString()), true);
624 xmlhttp
.onreadystatechange
=filterlist_callback
;
628 alert(__("No filters are selected."));
635 function removeSelectedFeeds() {
637 if (!xmlhttp_ready(xmlhttp
)) {
642 var sel_rows
= getSelectedFeeds();
644 if (sel_rows
.length
> 0) {
646 var ok
= confirm(__("Unsubscribe from selected feeds?"));
650 notify_progress("Unsubscribing from selected feeds...");
652 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
653 param_escape(sel_rows
.toString()), true);
654 xmlhttp
.onreadystatechange
=feedlist_callback
;
660 alert(__("No feeds are selected."));
667 function removeSelectedFeedCats() {
669 if (!xmlhttp_ready(xmlhttp
)) {
674 var sel_rows
= getSelectedFeedCats();
676 if (sel_rows
.length
> 0) {
678 var ok
= confirm(__("Remove selected categories?"));
681 notify_progress("Removing selected categories...");
683 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
684 param_escape(sel_rows
.toString()), true);
685 xmlhttp
.onreadystatechange
=infobox_callback
;
691 alert(__("No categories are selected."));
698 function feedEditCancel() {
700 if (!xmlhttp_ready(xmlhttp
)) {
705 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
708 document
.getElementById("top25_feeds_btn").disabled
= false;
710 // this button is not always available, no-op if not found
715 selectPrefRows('feed', false); // cleanup feed selection
720 function feedCatEditCancel() {
722 if (!xmlhttp_ready(xmlhttp
)) {
727 active_feed_cat
= false;
729 // notify("Operation cancelled.");
731 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
732 xmlhttp
.onreadystatechange
=infobox_callback
;
738 function feedEditSave() {
742 if (!xmlhttp_ready(xmlhttp
)) {
747 // FIXME: add parameter validation
749 var query
= Form
.serialize("edit_feed_form");
751 notify_progress("Saving feed...");
753 xmlhttp
.open("POST", "backend.php", true);
754 xmlhttp
.onreadystatechange
=feedlist_callback
;
755 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
763 exception_error("feedEditSave", e
);
767 function feedCatEditSave() {
769 if (!xmlhttp_ready(xmlhttp
)) {
774 notify_progress("Saving category...");
776 var query
= Form
.serialize("feed_cat_edit_form");
778 xmlhttp
.open("GET", "backend.php?" + query
, true);
779 xmlhttp
.onreadystatechange
=infobox_callback
;
782 active_feed_cat
= false;
789 function displayHelpInfobox(topic_id
) {
791 /* if (!xmlhttp_ready(xmlhttp)) {
796 notify_progress("Loading help...");
798 xmlhttp.open("GET", "backend.php?op=help&tid=" +
799 param_escape(topic_id), true);
801 xmlhttp.onreadystatechange=helpbox_callback;
802 xmlhttp.send(null); */
804 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
806 var w
= window
.open(url
, "ttrss_help",
807 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
811 function labelEditCancel() {
813 if (!xmlhttp_ready(xmlhttp
)) {
818 document
.getElementById("label_create_btn").disabled
= false;
820 active_label
= false;
822 selectPrefRows('label', false); // cleanup feed selection
828 function userEditCancel() {
830 if (!xmlhttp_ready(xmlhttp
)) {
835 selectPrefRows('user', false); // cleanup feed selection
841 function filterEditCancel() {
843 if (!xmlhttp_ready(xmlhttp
)) {
848 document
.getElementById("create_filter_btn").disabled
= false;
850 selectPrefRows('filter', false); // cleanup feed selection
856 function labelEditSave() {
858 var label
= active_label
;
860 if (!xmlhttp_ready(xmlhttp
)) {
865 /* if (!is_opera()) {
867 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
868 var description = document.forms["label_edit_form"].description.value;
870 if (sql_exp.length == 0) {
871 alert("SQL Expression cannot be blank.");
875 if (description.length == 0) {
876 alert("Caption field cannot be blank.");
883 notify_progress("Saving label...");
885 active_label
= false;
887 query
= Form
.serialize("label_edit_form");
889 xmlhttp
.open("GET", "backend.php?" + query
, true);
890 xmlhttp
.onreadystatechange
=labellist_callback
;
896 function userEditSave() {
898 if (!xmlhttp_ready(xmlhttp
)) {
903 var login
= document
.forms
["user_edit_form"].login
.value
;
905 if (login
.length
== 0) {
906 alert(__("Login field cannot be blank."));
910 notify_progress("Saving user...");
914 var query
= Form
.serialize("user_edit_form");
916 xmlhttp
.open("GET", "backend.php?" + query
, true);
917 xmlhttp
.onreadystatechange
=userlist_callback
;
924 function filterEditSave() {
926 if (!xmlhttp_ready(xmlhttp
)) {
931 /* if (!is_opera()) {
932 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
934 if (reg_exp.length == 0) {
935 alert("Filter expression field cannot be blank.");
940 notify_progress("Saving filter...");
942 var query
= Form
.serialize("filter_edit_form");
946 document
.getElementById("create_filter_btn").disabled
= false;
948 xmlhttp
.open("GET", "backend.php?" + query
, true);
949 xmlhttp
.onreadystatechange
=filterlist_callback
;
955 function editSelectedLabel() {
956 var rows
= getSelectedLabels();
958 if (rows
.length
== 0) {
959 alert(__("No labels are selected."));
963 if (rows
.length
> 1) {
964 alert(__("Please select only one label."));
974 function editSelectedUser() {
975 var rows
= getSelectedUsers();
977 if (rows
.length
== 0) {
978 alert(__("No users are selected."));
982 if (rows
.length
> 1) {
983 alert(__("Please select only one user."));
992 function resetSelectedUserPass() {
993 var rows
= getSelectedUsers();
995 if (rows
.length
== 0) {
996 alert(__("No users are selected."));
1000 if (rows
.length
> 1) {
1001 alert(__("Please select only one user."));
1005 var ok
= confirm(__("Reset password of selected user?"));
1008 notify_progress("Resetting password for selected user...");
1012 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1013 param_escape(id
), true);
1014 xmlhttp
.onreadystatechange
=userlist_callback
;
1019 function selectedUserDetails() {
1021 if (!xmlhttp_ready(xmlhttp
)) {
1022 printLockingError();
1026 var rows
= getSelectedUsers();
1028 if (rows
.length
== 0) {
1029 alert(__("No users are selected."));
1033 if (rows
.length
> 1) {
1034 alert(__("Please select only one user."));
1038 notify_progress("Loading, please wait...");
1042 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1043 xmlhttp
.onreadystatechange
=infobox_callback
;
1048 function selectedFeedDetails() {
1050 if (!xmlhttp_ready(xmlhttp
)) {
1051 printLockingError();
1055 var rows
= getSelectedFeeds();
1057 if (rows
.length
== 0) {
1058 alert(__("No feeds are selected."));
1062 if (rows
.length
> 1) {
1063 alert(__("Please select only one feed."));
1067 // var id = rows[0];
1071 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1072 param_escape(rows
.toString()), true);
1073 xmlhttp
.onreadystatechange
=infobox_callback
;
1078 function editSelectedFilter() {
1079 var rows
= getSelectedFilters();
1081 if (rows
.length
== 0) {
1082 alert(__("No filters are selected."));
1086 if (rows
.length
> 1) {
1087 alert(__("Please select only one filter."));
1093 editFilter(rows
[0]);
1098 function editSelectedFeed() {
1099 var rows
= getSelectedFeeds();
1101 if (rows
.length
== 0) {
1102 alert(__("No feeds are selected."));
1106 if (rows
.length
> 1) {
1107 alert(__("Please select one feed."));
1117 function editSelectedFeedCat() {
1118 var rows
= getSelectedFeedCats();
1120 if (rows
.length
== 0) {
1121 alert(__("No categories are selected."));
1125 if (rows
.length
> 1) {
1126 alert(__("Please select only one category."));
1132 editFeedCat(rows
[0]);
1136 function localPiggieFunction(enable
) {
1138 debug("I LOVEDED IT!");
1139 var piggie
= document
.getElementById("piggie");
1141 Element
.show(piggie
);
1142 Position
.Center(piggie
);
1143 Effect
.Puff(piggie
);
1148 function validateOpmlImport() {
1150 var opml_file
= document
.getElementById("opml_file");
1152 if (opml_file
.value
.length
== 0) {
1153 alert(__("No OPML file to upload."));
1160 function updateFilterList(sort_key
) {
1162 if (!xmlhttp_ready(xmlhttp
)) {
1163 printLockingError();
1167 // document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
1169 // p_notify("Loading, please wait...");
1171 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1172 param_escape(sort_key
), true);
1173 xmlhttp
.onreadystatechange
=filterlist_callback
;
1178 function updateLabelList(sort_key
) {
1180 if (!xmlhttp_ready(xmlhttp
)) {
1181 printLockingError();
1185 // p_notify("Loading, please wait...");
1187 // document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
1189 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1190 param_escape(sort_key
), true);
1191 xmlhttp
.onreadystatechange
=labellist_callback
;
1195 function updatePrefsList() {
1197 if (!xmlhttp_ready(xmlhttp
)) {
1198 printLockingError();
1202 // p_notify("Loading, please wait...");
1204 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1205 xmlhttp
.onreadystatechange
=prefslist_callback
;
1210 function selectTab(id
, noupdate
, subop
) {
1214 if (!id
) id
= active_tab
;
1218 if (!xmlhttp_ready(xmlhttp
)) {
1219 printLockingError();
1224 var c
= document
.getElementById('prefContent');
1230 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1232 notify_progress("Loading, please wait...");
1234 // close active infobox if needed
1237 // clean up all current selections, just in case
1238 active_feed_cat
= false;
1239 active_label
= false;
1241 if (id
== "feedConfig") {
1243 } else if (id
== "filterConfig") {
1245 } else if (id
== "labelConfig") {
1247 } else if (id
== "genConfig") {
1249 } else if (id
== "userConfig") {
1251 } else if (id
== "feedBrowser") {
1252 updateBigFeedBrowser();
1256 var tab
= document
.getElementById(active_tab
+ "Tab");
1259 if (tab
.className
.match("Selected")) {
1260 tab
.className
= "prefsTab";
1264 tab
= document
.getElementById(id
+ "Tab");
1267 if (!tab
.className
.match("Selected")) {
1268 tab
.className
= tab
.className
+ "Selected";
1275 exception_error("selectTab", e
);
1279 function backend_sanity_check_callback() {
1281 if (xmlhttp
.readyState
== 4) {
1285 if (sanity_check_done
) {
1286 fatalError(11, "Sanity check request received twice. This can indicate "+
1287 "presence of Firebug or some other disrupting extension. "+
1288 "Please disable it and try again.");
1292 if (!xmlhttp
.responseXML
) {
1293 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1297 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1300 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1304 var error_code
= reply
.getAttribute("error-code");
1306 if (error_code
&& error_code
!= 0) {
1307 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1310 debug("sanity check ok");
1312 var params
= reply
.nextSibling
;
1315 debug('reading init-params...');
1316 var param
= params
.firstChild
;
1319 var k
= param
.getAttribute("key");
1320 var v
= param
.getAttribute("value");
1321 debug(k
+ " => " + v
);
1323 param
= param
.nextSibling
;
1327 sanity_check_done
= true;
1329 init_second_stage();
1332 exception_error("backend_sanity_check_callback", e
);
1337 function init_second_stage() {
1340 active_tab
= getInitParam("prefs_active_tab");
1341 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1343 document
.onkeydown
= pref_hotkey_handler
;
1345 var tab
= getURLParam('tab');
1347 caller_subop
= getURLParam('subop');
1353 if (navigator
.userAgent
.match("Opera")) {
1354 setTimeout("selectTab()", 500);
1356 selectTab(active_tab
);
1360 exception_error("init_second_stage", e
);
1368 if (arguments
.callee
.done
) return;
1369 arguments
.callee
.done
= true;
1371 if (getURLParam('debug')) {
1372 document
.getElementById('debug_output').style
.display
= 'block';
1373 debug('debug mode activated');
1378 document
.getElementById("prefContent").innerHTML
=
1379 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1380 "to function properly. Your browser doesn't seem to support it.";
1384 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1385 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1389 exception_error("init", e
);
1393 function categorizeSelectedFeeds() {
1395 if (!xmlhttp_ready(xmlhttp
)) {
1396 printLockingError();
1400 var sel_rows
= getSelectedFeeds();
1402 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1403 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1405 if (sel_rows
.length
> 0) {
1407 notify_progress("Changing category of selected feeds...");
1409 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1410 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1411 xmlhttp
.onreadystatechange
=feedlist_callback
;
1416 alert(__("No feeds are selected."));
1422 function validatePrefsReset() {
1424 var ok
= confirm(__("Reset to defaults?"));
1428 var query
= Form
.serialize("pref_prefs_form");
1429 query
= query
+ "&subop=reset-config";
1432 xmlhttp
.open("POST", "backend.php", true);
1433 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1434 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1435 xmlhttp
.send(query
);
1439 exception_error("validatePrefsSave", e
);
1446 function browseFeeds(limit
) {
1448 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1449 xmlhttp
.onreadystatechange
=infobox_callback
;
1454 function feedBrowserSubscribe() {
1457 var selected
= getSelectedFeedsFromBrowser();
1459 if (selected
.length
> 0) {
1461 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1462 param_escape(selected
.toString()), true);
1463 xmlhttp
.onreadystatechange
=feedlist_callback
;
1466 alert(__("No feeds are selected."));
1470 exception_error("feedBrowserSubscribe", e
);
1474 function updateBigFeedBrowser(limit
) {
1476 if (!xmlhttp_ready(xmlhttp
)) {
1477 printLockingError();
1481 // p_notify("Loading, please wait...");
1483 var query
= "backend.php?op=pref-feed-browser";
1485 var limit_sel
= document
.getElementById("feedBrowserLimit");
1488 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1489 query
= query
+ "&limit=" + param_escape(limit
);
1492 xmlhttp
.open("GET", query
, true);
1493 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1497 function browserToggleExpand(id
) {
1499 /* if (feed_to_expand && feed_to_expand != id) {
1500 var d = document.getElementById("BRDET-" + feed_to_expand);
1501 d.style.display = "none";
1504 if (!xmlhttp_ready(xmlhttp
)) {
1505 printLockingError();
1509 /* if (feed_to_expand && id != feed_to_expand) {
1510 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1513 var d
= document
.getElementById("BRDET-" + id
);
1515 if (Element
.visible(d
)) {
1516 Effect
.Fade(d
, {duration
: 0.5});
1518 feed_to_expand
= id
;
1520 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1521 + param_escape(id
), true);
1522 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1527 exception_error("browserToggleExpand", e
);
1531 function selectPrefRows(kind
, select
) {
1534 var opbarid
= false;
1539 if (kind
== "feed") {
1540 opbarid
= "feedOpToolbar";
1543 lname
= "prefFeedList";
1544 } else if (kind
== "fcat") {
1545 opbarid
= "catOpToolbar";
1548 lname
= "prefFeedCatList";
1549 } else if (kind
== "filter") {
1550 opbarid
= "filterOpToolbar";
1553 lname
= "prefFilterList";
1554 } else if (kind
== "label") {
1555 opbarid
= "labelOpToolbar";
1558 lname
= "prefLabelList";
1559 } else if (kind
== "user") {
1560 opbarid
= "userOpToolbar";
1563 lname
= "prefUserList";
1567 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1568 disableContainerChildren(opbarid
, !select
);
1575 function toggleSelectPrefRow(sender
, kind
) {
1577 toggleSelectRow(sender
);
1580 var opbarid
= false;
1583 if (kind
== "feed") {
1584 opbarid
= "feedOpToolbar";
1585 nsel
= getSelectedFeeds();
1586 } else if (kind
== "fcat") {
1587 opbarid
= "catOpToolbar";
1588 nsel
= getSelectedFeedCats();
1589 } else if (kind
== "filter") {
1590 opbarid
= "filterOpToolbar";
1591 nsel
= getSelectedFilters();
1592 } else if (kind
== "label") {
1593 opbarid
= "labelOpToolbar";
1594 nsel
= getSelectedLabels();
1595 } else if (kind
== "user") {
1596 opbarid
= "userOpToolbar";
1597 nsel
= getSelectedUsers();
1600 if (opbarid
&& nsel
!= -1) {
1601 disableContainerChildren(opbarid
, nsel
== false);
1607 function toggleSelectFBListRow(sender
) {
1608 toggleSelectListRow(sender
);
1609 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1614 function pref_hotkey_handler(e
) {
1619 if (!hotkeys_enabled
) return;
1622 keycode
= window
.event
.keyCode
;
1627 if (keycode
== 13 || keycode
== 27) {
1630 seq
= seq
+ "" + keycode
;
1634 if (document
.getElementById("piggie")) {
1636 if (seq
.match("807371717369")) {
1638 localPiggieFunction(true);
1640 localPiggieFunction(false);
1645 exception_error("pref_hotkey_handler", e
);
1649 function userSwitch() {
1650 var chooser
= document
.getElementById("userSwitch");
1651 var user
= chooser
[chooser
.selectedIndex
].value
;
1652 window
.location
= "prefs.php?swu=" + user
;
1655 function editFeedCats() {
1656 if (!xmlhttp_ready(xmlhttp
)) {
1657 printLockingError();
1661 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1664 document
.getElementById("top25_feeds_btn").disabled
= true;
1666 // this button is not always available, no-op if not found
1669 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1670 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1674 function showFeedsWithErrors() {
1675 displayDlg('feedUpdateErrors');
1678 function changeUserPassword() {
1682 if (!xmlhttp_ready(xmlhttp
)) {
1683 printLockingError();
1687 var query
= Form
.serialize("change_pass_form");
1689 notify_progress("Trying to change password...");
1691 xmlhttp
.open("POST", "backend.php", true);
1692 xmlhttp
.onreadystatechange
=changepass_callback
;
1693 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1694 xmlhttp
.send(query
);
1697 exception_error("changeUserPassword", e
);
1703 function changeUserEmail() {
1707 if (!xmlhttp_ready(xmlhttp
)) {
1708 printLockingError();
1712 var query
= Form
.serialize("change_email_form");
1714 notify_progress("Trying to change e-mail...");
1716 xmlhttp
.open("POST", "backend.php", true);
1717 xmlhttp
.onreadystatechange
=notify_callback
;
1718 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1719 xmlhttp
.send(query
);
1722 exception_error("changeUserPassword", e
);
1729 function feedlistToggleSLAT() {
1730 notify_progress("Loading, please wait...");
1734 function pubRegenKey() {
1736 if (!xmlhttp_ready(xmlhttp
)) {
1737 printLockingError();
1741 var ok
= confirm(__("Replace current publishing address with a new one?"));
1745 notify_progress("Trying to change address...");
1747 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1748 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1755 function validatePrefsSave() {
1758 var ok
= confirm(__("Save current configuration?"));
1762 var query
= Form
.serialize("pref_prefs_form");
1763 query
= query
+ "&subop=save-config";
1766 xmlhttp
.open("POST", "backend.php", true);
1767 xmlhttp
.onreadystatechange
=notify_callback
;
1768 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1769 xmlhttp
.send(query
);
1773 exception_error("validatePrefsSave", e
);