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";
51 Effect
.Appear(container
, {duration
: 0.5});
53 exception_error("expand_feed_callback", e
);
58 function feedlist_callback() {
59 if (xmlhttp
.readyState
== 4) {
61 var container
= document
.getElementById('prefContent');
62 container
.innerHTML
=xmlhttp
.responseText
;
63 selectTab("feedConfig", true);
66 var tuple
= caller_subop
.split(":");
67 if (tuple
[0] == 'editFeed') {
68 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
73 if (typeof correctPNG
!= 'undefined') {
78 exception_error("feedlist_callback", e
);
83 /* stub for subscription dialog */
85 function dlg_frefresh_callback() {
86 if (xmlhttp
.readyState
== 4) {
87 // setTimeout("updateFeedList()", 500);
90 var container
= document
.getElementById('prefContent');
91 container
.innerHTML
=xmlhttp
.responseText
;
92 selectTab("feedConfig", true);
95 var tuple
= caller_subop
.split(":");
96 if (tuple
[0] == 'editFeed') {
97 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
100 caller_subop
= false;
102 if (typeof correctPNG
!= 'undefined') {
107 exception_error("feedlist_callback", e
);
112 function filterlist_callback() {
113 var container
= document
.getElementById('prefContent');
114 if (xmlhttp
.readyState
== 4) {
115 container
.innerHTML
=xmlhttp
.responseText
;
116 if (typeof correctPNG
!= 'undefined') {
123 function labellist_callback() {
124 var container
= document
.getElementById('prefContent');
125 if (xmlhttp
.readyState
== 4) {
127 container
.innerHTML
=xmlhttp
.responseText
;
129 var row
= document
.getElementById("LILRR-" + active_label
);
131 if (!row
.className
.match("Selected")) {
132 row
.className
= row
.className
+ "Selected";
135 var checkbox
= document
.getElementById("LICHK-" + active_label
);
138 checkbox
.checked
= true;
141 if (typeof correctPNG
!= 'undefined') {
148 function feed_browser_callback() {
149 var container
= document
.getElementById('prefContent');
150 if (xmlhttp
.readyState
== 4) {
151 container
.innerHTML
=xmlhttp
.responseText
;
156 function userlist_callback() {
157 var container
= document
.getElementById('prefContent');
158 if (xmlhttp
.readyState
== 4) {
159 container
.innerHTML
=xmlhttp
.responseText
;
164 function prefslist_callback() {
165 var container
= document
.getElementById('prefContent');
166 if (xmlhttp
.readyState
== 4) {
168 container
.innerHTML
=xmlhttp
.responseText
;
174 function gethelp_callback() {
175 var container
= document
.getElementById('prefHelpBox');
176 if (xmlhttp
.readyState
== 4) {
178 container
.innerHTML
= xmlhttp
.responseText
;
179 container
.style
.display
= "block";
184 function notify_callback() {
185 if (xmlhttp
.readyState
== 4) {
186 notify_info(xmlhttp
.responseText
);
190 function prefs_reset_callback() {
191 if (xmlhttp
.readyState
== 4) {
192 notify_info(xmlhttp
.responseText
);
198 function changepass_callback() {
200 if (xmlhttp
.readyState
== 4) {
202 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
203 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
205 notify_info(xmlhttp
.responseText
);
206 var warn
= document
.getElementById("default_pass_warning");
207 if (warn
) warn
.style
.display
= "none";
210 document
.forms
['change_pass_form'].reset();
214 exception_error("changepass_callback", e
);
218 function infobox_feed_cat_callback() {
219 if (xmlhttp
.readyState
== 4) {
224 if (document
.getElementById("prefFeedCatList")) {
225 var elems
= document
.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
227 for (var i
= 0; i
< elems
.length
; i
++) {
228 if (elems
[i
].id
&& elems
[i
].id
.match("FCATT-")) {
229 var cat_id
= elems
[i
].id
.replace("FCATT-", "");
231 new Ajax
.InPlaceEditor(elems
[i
],
232 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id
);
238 exception_error("infobox_feed_cat_callback", e
);
243 function updateFeedList(sort_key
) {
245 if (!xmlhttp_ready(xmlhttp
)) {
250 var feed_search
= document
.getElementById("feed_search");
252 if (feed_search
) { search
= feed_search
.value
; }
254 var slat
= document
.getElementById("show_last_article_times");
256 var slat_checked
= false;
258 slat_checked
= slat
.checked
;
261 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
262 "&sort=" + param_escape(sort_key
) +
263 "&slat=" + param_escape(slat_checked
) +
264 "&search=" + param_escape(search
), true);
265 xmlhttp
.onreadystatechange
=feedlist_callback
;
270 function updateUsersList(sort_key
) {
272 if (!xmlhttp_ready(xmlhttp
)) {
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 var url
= "backend.php?op=help&tid=" + param_escape(topic_id
);
786 var w
= window
.open(url
, "ttrss_help",
787 "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
791 function labelEditCancel() {
793 if (!xmlhttp_ready(xmlhttp
)) {
798 document
.getElementById("label_create_btn").disabled
= false;
800 active_label
= false;
802 selectPrefRows('label', false); // cleanup feed selection
808 function userEditCancel() {
810 if (!xmlhttp_ready(xmlhttp
)) {
815 selectPrefRows('user', false); // cleanup feed selection
821 function filterEditCancel() {
823 if (!xmlhttp_ready(xmlhttp
)) {
828 document
.getElementById("create_filter_btn").disabled
= false;
830 selectPrefRows('filter', false); // cleanup feed selection
836 function labelEditSave() {
838 var label
= active_label
;
840 if (!xmlhttp_ready(xmlhttp
)) {
845 /* if (!is_opera()) {
847 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
848 var description = document.forms["label_edit_form"].description.value;
850 if (sql_exp.length == 0) {
851 alert("SQL Expression cannot be blank.");
855 if (description.length == 0) {
856 alert("Caption field cannot be blank.");
863 notify_progress("Saving label...");
865 active_label
= false;
867 query
= Form
.serialize("label_edit_form");
869 xmlhttp
.open("GET", "backend.php?" + query
, true);
870 xmlhttp
.onreadystatechange
=labellist_callback
;
876 function userEditSave() {
878 if (!xmlhttp_ready(xmlhttp
)) {
883 var login
= document
.forms
["user_edit_form"].login
.value
;
885 if (login
.length
== 0) {
886 alert(__("Login field cannot be blank."));
890 notify_progress("Saving user...");
894 var query
= Form
.serialize("user_edit_form");
896 xmlhttp
.open("GET", "backend.php?" + query
, true);
897 xmlhttp
.onreadystatechange
=userlist_callback
;
904 function filterEditSave() {
906 if (!xmlhttp_ready(xmlhttp
)) {
911 /* if (!is_opera()) {
912 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
914 if (reg_exp.length == 0) {
915 alert("Filter expression field cannot be blank.");
920 notify_progress("Saving filter...");
922 var query
= Form
.serialize("filter_edit_form");
926 document
.getElementById("create_filter_btn").disabled
= false;
928 xmlhttp
.open("GET", "backend.php?" + query
, true);
929 xmlhttp
.onreadystatechange
=filterlist_callback
;
935 function editSelectedLabel() {
936 var rows
= getSelectedLabels();
938 if (rows
.length
== 0) {
939 alert(__("No labels are selected."));
943 if (rows
.length
> 1) {
944 alert(__("Please select only one label."));
954 function editSelectedUser() {
955 var rows
= getSelectedUsers();
957 if (rows
.length
== 0) {
958 alert(__("No users are selected."));
962 if (rows
.length
> 1) {
963 alert(__("Please select only one user."));
972 function resetSelectedUserPass() {
973 var rows
= getSelectedUsers();
975 if (rows
.length
== 0) {
976 alert(__("No users are selected."));
980 if (rows
.length
> 1) {
981 alert(__("Please select only one user."));
985 var ok
= confirm(__("Reset password of selected user?"));
988 notify_progress("Resetting password for selected user...");
992 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
993 param_escape(id
), true);
994 xmlhttp
.onreadystatechange
=userlist_callback
;
999 function selectedUserDetails() {
1001 if (!xmlhttp_ready(xmlhttp
)) {
1002 printLockingError();
1006 var rows
= getSelectedUsers();
1008 if (rows
.length
== 0) {
1009 alert(__("No users are selected."));
1013 if (rows
.length
> 1) {
1014 alert(__("Please select only one user."));
1018 notify_progress("Loading, please wait...");
1022 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1023 xmlhttp
.onreadystatechange
=infobox_callback
;
1028 function selectedFeedDetails() {
1030 if (!xmlhttp_ready(xmlhttp
)) {
1031 printLockingError();
1035 var rows
= getSelectedFeeds();
1037 if (rows
.length
== 0) {
1038 alert(__("No feeds are selected."));
1042 if (rows
.length
> 1) {
1043 alert(__("Please select only one feed."));
1047 // var id = rows[0];
1051 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1052 param_escape(rows
.toString()), true);
1053 xmlhttp
.onreadystatechange
=infobox_callback
;
1058 function editSelectedFilter() {
1059 var rows
= getSelectedFilters();
1061 if (rows
.length
== 0) {
1062 alert(__("No filters are selected."));
1066 if (rows
.length
> 1) {
1067 alert(__("Please select only one filter."));
1073 editFilter(rows
[0]);
1078 function editSelectedFeed() {
1079 var rows
= getSelectedFeeds();
1081 if (rows
.length
== 0) {
1082 alert(__("No feeds are selected."));
1086 if (rows
.length
> 1) {
1087 alert(__("Please select one feed."));
1097 function editSelectedFeedCat() {
1098 var rows
= getSelectedFeedCats();
1100 if (rows
.length
== 0) {
1101 alert(__("No categories are selected."));
1105 if (rows
.length
> 1) {
1106 alert(__("Please select only one category."));
1112 editFeedCat(rows
[0]);
1116 function localPiggieFunction(enable
) {
1118 debug("I LOVEDED IT!");
1119 var piggie
= document
.getElementById("piggie");
1121 Element
.show(piggie
);
1122 Position
.Center(piggie
);
1123 Effect
.Puff(piggie
);
1128 function validateOpmlImport() {
1130 var opml_file
= document
.getElementById("opml_file");
1132 if (opml_file
.value
.length
== 0) {
1133 alert(__("No OPML file to upload."));
1140 function updateFilterList(sort_key
) {
1142 if (!xmlhttp_ready(xmlhttp
)) {
1143 printLockingError();
1147 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1148 param_escape(sort_key
), true);
1149 xmlhttp
.onreadystatechange
=filterlist_callback
;
1154 function updateLabelList(sort_key
) {
1156 if (!xmlhttp_ready(xmlhttp
)) {
1157 printLockingError();
1161 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1162 param_escape(sort_key
), true);
1163 xmlhttp
.onreadystatechange
=labellist_callback
;
1167 function updatePrefsList() {
1169 if (!xmlhttp_ready(xmlhttp
)) {
1170 printLockingError();
1174 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1175 xmlhttp
.onreadystatechange
=prefslist_callback
;
1180 function selectTab(id
, noupdate
, subop
) {
1184 if (!id
) id
= active_tab
;
1188 if (!xmlhttp_ready(xmlhttp
)) {
1189 printLockingError();
1194 var c
= document
.getElementById('prefContent');
1200 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1202 notify_progress("Loading, please wait...");
1204 // close active infobox if needed
1207 // clean up all current selections, just in case
1208 active_feed_cat
= false;
1209 active_label
= false;
1211 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1212 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1214 if (id
== "feedConfig") {
1216 } else if (id
== "filterConfig") {
1218 } else if (id
== "labelConfig") {
1220 } else if (id
== "genConfig") {
1222 } else if (id
== "userConfig") {
1224 } else if (id
== "feedBrowser") {
1225 updateBigFeedBrowser();
1229 var tab
= document
.getElementById(active_tab
+ "Tab");
1232 if (tab
.className
.match("Selected")) {
1233 tab
.className
= "prefsTab";
1237 tab
= document
.getElementById(id
+ "Tab");
1240 if (!tab
.className
.match("Selected")) {
1241 tab
.className
= tab
.className
+ "Selected";
1248 exception_error("selectTab", e
);
1252 function backend_sanity_check_callback() {
1254 if (xmlhttp
.readyState
== 4) {
1258 if (sanity_check_done
) {
1259 fatalError(11, "Sanity check request received twice. This can indicate "+
1260 "presence of Firebug or some other disrupting extension. "+
1261 "Please disable it and try again.");
1265 if (!xmlhttp
.responseXML
) {
1266 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1270 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1273 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1277 var error_code
= reply
.getAttribute("error-code");
1279 if (error_code
&& error_code
!= 0) {
1280 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1283 debug("sanity check ok");
1285 var params
= reply
.nextSibling
;
1288 debug('reading init-params...');
1289 var param
= params
.firstChild
;
1292 var k
= param
.getAttribute("key");
1293 var v
= param
.getAttribute("value");
1294 debug(k
+ " => " + v
);
1296 param
= param
.nextSibling
;
1300 sanity_check_done
= true;
1302 init_second_stage();
1305 exception_error("backend_sanity_check_callback", e
);
1310 function init_second_stage() {
1313 active_tab
= getInitParam("prefs_active_tab");
1314 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1316 document
.onkeydown
= pref_hotkey_handler
;
1318 var tab
= getURLParam('tab');
1320 caller_subop
= getURLParam('subop');
1326 if (navigator
.userAgent
.match("Opera")) {
1327 setTimeout("selectTab()", 500);
1329 selectTab(active_tab
);
1333 exception_error("init_second_stage", e
);
1341 if (arguments
.callee
.done
) return;
1342 arguments
.callee
.done
= true;
1344 if (getURLParam('debug')) {
1345 document
.getElementById('debug_output').style
.display
= 'block';
1346 debug('debug mode activated');
1351 document
.getElementById("prefContent").innerHTML
=
1352 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1353 "to function properly. Your browser doesn't seem to support it.";
1357 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1358 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1362 exception_error("init", e
);
1366 function categorizeSelectedFeeds() {
1368 if (!xmlhttp_ready(xmlhttp
)) {
1369 printLockingError();
1373 var sel_rows
= getSelectedFeeds();
1375 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1376 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1378 if (sel_rows
.length
> 0) {
1380 notify_progress("Changing category of selected feeds...");
1382 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1383 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1384 xmlhttp
.onreadystatechange
=feedlist_callback
;
1389 alert(__("No feeds are selected."));
1395 function validatePrefsReset() {
1397 var ok
= confirm(__("Reset to defaults?"));
1401 var query
= Form
.serialize("pref_prefs_form");
1402 query
= query
+ "&subop=reset-config";
1405 xmlhttp
.open("POST", "backend.php", true);
1406 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1407 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1408 xmlhttp
.send(query
);
1412 exception_error("validatePrefsSave", e
);
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 var query
= "backend.php?op=pref-feed-browser";
1456 var limit_sel
= document
.getElementById("feedBrowserLimit");
1459 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1460 query
= query
+ "&limit=" + param_escape(limit
);
1463 xmlhttp
.open("GET", query
, true);
1464 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1468 function browserToggleExpand(id
) {
1470 /* if (feed_to_expand && feed_to_expand != id) {
1471 var d = document.getElementById("BRDET-" + feed_to_expand);
1472 d.style.display = "none";
1475 if (!xmlhttp_ready(xmlhttp
)) {
1476 printLockingError();
1480 /* if (feed_to_expand && id != feed_to_expand) {
1481 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1484 var d
= document
.getElementById("BRDET-" + id
);
1486 if (Element
.visible(d
)) {
1487 Effect
.Fade(d
, {duration
: 0.5});
1489 feed_to_expand
= id
;
1491 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1492 + param_escape(id
), true);
1493 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1498 exception_error("browserToggleExpand", e
);
1502 function selectPrefRows(kind
, select
) {
1505 var opbarid
= false;
1510 if (kind
== "feed") {
1511 opbarid
= "feedOpToolbar";
1514 lname
= "prefFeedList";
1515 } else if (kind
== "fcat") {
1516 opbarid
= "catOpToolbar";
1519 lname
= "prefFeedCatList";
1520 } else if (kind
== "filter") {
1521 opbarid
= "filterOpToolbar";
1524 lname
= "prefFilterList";
1525 } else if (kind
== "label") {
1526 opbarid
= "labelOpToolbar";
1529 lname
= "prefLabelList";
1530 } else if (kind
== "user") {
1531 opbarid
= "userOpToolbar";
1534 lname
= "prefUserList";
1538 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1539 disableContainerChildren(opbarid
, !select
);
1546 function toggleSelectPrefRow(sender
, kind
) {
1548 toggleSelectRow(sender
);
1551 var opbarid
= false;
1554 if (kind
== "feed") {
1555 opbarid
= "feedOpToolbar";
1556 nsel
= getSelectedFeeds();
1557 } else if (kind
== "fcat") {
1558 opbarid
= "catOpToolbar";
1559 nsel
= getSelectedFeedCats();
1560 } else if (kind
== "filter") {
1561 opbarid
= "filterOpToolbar";
1562 nsel
= getSelectedFilters();
1563 } else if (kind
== "label") {
1564 opbarid
= "labelOpToolbar";
1565 nsel
= getSelectedLabels();
1566 } else if (kind
== "user") {
1567 opbarid
= "userOpToolbar";
1568 nsel
= getSelectedUsers();
1571 if (opbarid
&& nsel
!= -1) {
1572 disableContainerChildren(opbarid
, nsel
== false);
1578 function toggleSelectFBListRow(sender
) {
1579 toggleSelectListRow(sender
);
1580 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1585 function pref_hotkey_handler(e
) {
1590 if (!hotkeys_enabled
) return;
1593 keycode
= window
.event
.keyCode
;
1598 if (keycode
== 13 || keycode
== 27) {
1601 seq
= seq
+ "" + keycode
;
1605 if (document
.getElementById("piggie")) {
1607 if (seq
.match("807371717369")) {
1609 localPiggieFunction(true);
1611 localPiggieFunction(false);
1616 exception_error("pref_hotkey_handler", e
);
1620 function editFeedCats() {
1621 if (!xmlhttp_ready(xmlhttp
)) {
1622 printLockingError();
1626 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1629 document
.getElementById("top25_feeds_btn").disabled
= true;
1631 // this button is not always available, no-op if not found
1634 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1635 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1639 function showFeedsWithErrors() {
1640 displayDlg('feedUpdateErrors');
1643 function changeUserPassword() {
1647 if (!xmlhttp_ready(xmlhttp
)) {
1648 printLockingError();
1652 var f
= document
.forms
["change_pass_form"];
1655 if (f
.OLD_PASSWORD
.value
== "") {
1656 new Effect
.Highlight(f
.OLD_PASSWORD
);
1657 notify_error("Old password cannot be blank.");
1661 if (f
.NEW_PASSWORD
.value
== "") {
1662 new Effect
.Highlight(f
.NEW_PASSWORD
);
1663 notify_error("New password cannot be blank.");
1667 if (f
.CONFIRM_PASSWORD
.value
== "") {
1668 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1669 notify_error("Entered passwords do not match.");
1673 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1674 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1675 new Effect
.Highlight(f
.NEW_PASSWORD
);
1676 notify_error("Entered passwords do not match.");
1682 var query
= Form
.serialize("change_pass_form");
1684 notify_progress("Trying to change password...");
1686 xmlhttp
.open("POST", "backend.php", true);
1687 xmlhttp
.onreadystatechange
=changepass_callback
;
1688 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1689 xmlhttp
.send(query
);
1692 exception_error("changeUserPassword", e
);
1698 function changeUserEmail() {
1702 if (!xmlhttp_ready(xmlhttp
)) {
1703 printLockingError();
1707 var query
= Form
.serialize("change_email_form");
1709 notify_progress("Trying to change e-mail...");
1711 xmlhttp
.open("POST", "backend.php", true);
1712 xmlhttp
.onreadystatechange
=notify_callback
;
1713 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1714 xmlhttp
.send(query
);
1717 exception_error("changeUserPassword", e
);
1724 function feedlistToggleSLAT() {
1725 notify_progress("Loading, please wait...");
1729 function pubRegenKey() {
1731 if (!xmlhttp_ready(xmlhttp
)) {
1732 printLockingError();
1736 var ok
= confirm(__("Replace current publishing address with a new one?"));
1740 notify_progress("Trying to change address...");
1742 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1743 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1750 function validatePrefsSave() {
1753 var ok
= confirm(__("Save current configuration?"));
1757 var query
= Form
.serialize("pref_prefs_form");
1758 query
= query
+ "&subop=save-config";
1761 xmlhttp
.open("POST", "backend.php", true);
1762 xmlhttp
.onreadystatechange
=notify_callback
;
1763 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1764 xmlhttp
.send(query
);
1768 exception_error("validatePrefsSave", e
);