3 var active_feed_cat
= false;
4 var active_tab
= false;
6 var xmlhttp
= Ajax
.getTransport();
8 var init_params
= new Array();
10 var caller_subop
= false;
11 var sanity_check_done
= false;
12 var hotkey_prefix
= false;
14 function infobox_callback() {
15 if (xmlhttp
.readyState
== 4) {
16 infobox_callback2(xmlhttp
);
20 function infobox_submit_callback() {
21 if (xmlhttp
.readyState
== 4) {
22 infobox_submit_callback2(xmlhttp
);
27 function replace_pubkey_callback() {
28 if (xmlhttp
.readyState
== 4) {
30 var link
= document
.getElementById("pubGenAddress");
32 if (xmlhttp
.responseXML
) {
34 var new_link
= xmlhttp
.responseXML
.getElementsByTagName("link")[0];
37 link
.href
= new_link
.firstChild
.nodeValue
;
38 //link.innerHTML = new_link.firstChild.nodeValue;
40 new Effect
.Highlight(link
);
42 notify_info("Published feed URL changed.");
44 notify_error("Could not change feed URL.");
48 notify_error("Could not change feed URL.");
51 exception_error("replace_pubkey_callback", e
);
56 function feedlist_callback() {
57 if (xmlhttp
.readyState
== 4) {
59 var container
= document
.getElementById('prefContent');
60 container
.innerHTML
=xmlhttp
.responseText
;
61 selectTab("feedConfig", true);
64 var tuple
= caller_subop
.split(":");
65 if (tuple
[0] == 'editFeed') {
66 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
71 if (typeof correctPNG
!= 'undefined') {
78 exception_error("feedlist_callback", e
);
83 /* stub for subscription dialog */
85 function dlg_frefresh_callback(transport
) {
88 var container
= document
.getElementById('prefContent');
89 container
.innerHTML
=transport
.responseText
;
90 selectTab("feedConfig", true);
93 var tuple
= caller_subop
.split(":");
94 if (tuple
[0] == 'editFeed') {
95 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
100 if (typeof correctPNG
!= 'undefined') {
105 exception_error("feedlist_callback", e
);
110 function filterlist_callback() {
111 var container
= document
.getElementById('prefContent');
112 if (xmlhttp
.readyState
== 4) {
113 container
.innerHTML
=xmlhttp
.responseText
;
114 if (typeof correctPNG
!= 'undefined') {
122 function labellist_callback() {
126 var container
= document
.getElementById('prefContent');
127 if (xmlhttp
.readyState
== 4) {
129 container
.innerHTML
=xmlhttp
.responseText
;
131 if (document
.getElementById("prefLabelList")) {
132 var elems
= document
.getElementById("prefLabelList").getElementsByTagName("SPAN");
134 for (var i
= 0; i
< elems
.length
; i
++) {
135 if (elems
[i
].id
&& elems
[i
].id
.match("LILT-")) {
137 var id
= elems
[i
].id
.replace("LILT-", "");
138 new Ajax
.InPlaceEditor(elems
[i
],
139 'backend.php?op=pref-labels&subop=save&id=' + id
,
140 {cols
: 20, rows
: 1});
145 if (typeof correctPNG
!= 'undefined') {
153 exception_error("labellist_callback", e
);
157 function feed_browser_callback() {
158 var container
= document
.getElementById('prefContent');
159 if (xmlhttp
.readyState
== 4) {
160 container
.innerHTML
=xmlhttp
.responseText
;
166 function userlist_callback() {
167 var container
= document
.getElementById('prefContent');
168 if (xmlhttp
.readyState
== 4) {
169 container
.innerHTML
=xmlhttp
.responseText
;
175 function prefslist_callback() {
176 var container
= document
.getElementById('prefContent');
177 if (xmlhttp
.readyState
== 4) {
178 container
.innerHTML
=xmlhttp
.responseText
;
184 function gethelp_callback() {
185 var container
= document
.getElementById('prefHelpBox');
186 if (xmlhttp
.readyState
== 4) {
188 container
.innerHTML
= xmlhttp
.responseText
;
189 container
.style
.display
= "block";
194 function notify_callback() {
195 if (xmlhttp
.readyState
== 4) {
196 notify_info(xmlhttp
.responseText
);
200 function prefs_reset_callback() {
201 if (xmlhttp
.readyState
== 4) {
202 notify_info(xmlhttp
.responseText
);
208 function changepass_callback() {
210 if (xmlhttp
.readyState
== 4) {
212 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
213 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
215 notify_info(xmlhttp
.responseText
);
216 var warn
= document
.getElementById("default_pass_warning");
217 if (warn
) warn
.style
.display
= "none";
220 document
.forms
['change_pass_form'].reset();
224 exception_error("changepass_callback", e
);
228 function init_cat_inline_editor() {
231 if (document
.getElementById("prefFeedCatList")) {
232 var elems
= document
.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
234 for (var i
= 0; i
< elems
.length
; i
++) {
235 if (elems
[i
].id
&& elems
[i
].id
.match("FCATT-")) {
236 var cat_id
= elems
[i
].id
.replace("FCATT-", "");
237 new Ajax
.InPlaceEditor(elems
[i
],
238 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id
);
244 exception_error("init_cat_inline_editor", e
);
248 function infobox_feed_cat_callback2(transport
) {
250 infobox_callback2(transport
);
251 init_cat_inline_editor();
253 exception_error("infobox_feed_cat_callback2", e
);
257 function updateFeedList(sort_key
) {
259 if (!xmlhttp_ready(xmlhttp
)) {
264 var feed_search
= document
.getElementById("feed_search");
266 if (feed_search
) { search
= feed_search
.value
; }
268 var slat
= document
.getElementById("show_last_article_times");
270 var slat_checked
= false;
272 slat_checked
= slat
.checked
;
275 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
276 "&sort=" + param_escape(sort_key
) +
277 "&slat=" + param_escape(slat_checked
) +
278 "&search=" + param_escape(search
), true);
279 xmlhttp
.onreadystatechange
=feedlist_callback
;
284 function updateUsersList(sort_key
) {
286 if (!xmlhttp_ready(xmlhttp
)) {
291 var user_search
= document
.getElementById("user_search");
293 if (user_search
) { search
= user_search
.value
; }
295 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
296 + param_escape(sort_key
) +
297 "&search=" + param_escape(search
), true);
298 xmlhttp
.onreadystatechange
=userlist_callback
;
303 function addLabel() {
307 if (!xmlhttp_ready(xmlhttp
)) {
312 var caption
= prompt(__("Please enter label caption:"), "");
314 if (caption
== null) {
319 alert(__("Can't create label: missing caption."));
323 // we can be called from some other tab
324 active_tab
= "labelConfig";
326 var query
= "caption=" + param_escape(caption
);
328 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
329 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
333 exception_error("addLabel", e
);
339 if (!xmlhttp_ready(xmlhttp
)) {
344 var link
= document
.getElementById("fadd_link");
346 if (link
.value
.length
== 0) {
347 alert(__("Error: No feed URL given."));
348 } else if (!isValidURL(link
.value
)) {
349 alert(__("Error: Invalid feed URL."));
351 notify_progress("Adding feed...");
353 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
354 param_escape(link
.value
), true);
355 xmlhttp
.onreadystatechange
=feedlist_callback
;
364 function addFeedCat() {
366 if (!xmlhttp_ready(xmlhttp
)) {
371 var cat
= document
.getElementById("fadd_cat");
373 if (cat
.value
.length
== 0) {
374 alert(__("Can't add category: no name specified."));
376 notify_progress("Adding feed category...");
378 var query
= "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
379 param_escape(cat
.value
);
381 new Ajax
.Request(query
, {
382 onComplete: function(transport
) {
383 infobox_feed_cat_callback2(transport
);
393 if (!xmlhttp_ready(xmlhttp
)) {
398 var sqlexp
= document
.getElementById("uadd_box");
400 if (sqlexp
.value
.length
== 0) {
401 alert(__("Can't add user: no login specified."));
403 notify_progress("Adding user...");
405 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
406 param_escape(sqlexp
.value
), true);
408 xmlhttp
.onreadystatechange
=userlist_callback
;
416 function editUser(id
) {
422 notify_progress("Loading, please wait...");
424 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
425 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
427 disableContainerChildren("userOpToolbar", false);
429 var query
= "backend.php?op=pref-users&subop=edit&id=" +
432 new Ajax
.Request(query
, {
433 onComplete: function(transport
) {
434 infobox_callback2(transport
);
438 exception_error("editUser", e
);
443 function editFilter(id
) {
449 notify_progress("Loading, please wait...");
451 disableContainerChildren("filterOpToolbar", false);
453 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
454 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
456 var query
= "backend.php?op=pref-filters&subop=edit&id=" +
459 new Ajax
.Request(query
, {
460 onComplete: function(transport
) {
461 infobox_callback2(transport
);
464 exception_error("editFilter", e
);
468 function editFeed(feed
) {
474 notify_progress("Loading, please wait...");
476 // clean selection from all rows & select row being edited
477 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
478 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
480 disableContainerChildren("feedOpToolbar", false);
482 var query
= "backend.php?op=pref-feeds&subop=editfeed&id=" +
485 new Ajax
.Request(query
, {
486 onComplete: function(transport
) {
487 infobox_callback2(transport
);
491 exception_error("editFeed", e
);
495 function getSelectedLabels() {
496 return getSelectedTableRowIds("prefLabelList", "LILRR");
499 function getSelectedUsers() {
500 return getSelectedTableRowIds("prefUserList", "UMRR");
503 function getSelectedFeeds() {
504 return getSelectedTableRowIds("prefFeedList", "FEEDR");
507 function getSelectedFilters() {
508 return getSelectedTableRowIds("prefFilterList", "FILRR");
511 function getSelectedFeedCats() {
512 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
516 function removeSelectedLabels() {
518 if (!xmlhttp_ready(xmlhttp
)) {
523 var sel_rows
= getSelectedLabels();
525 if (sel_rows
.length
> 0) {
527 var ok
= confirm(__("Remove selected labels?"));
530 notify_progress("Removing selected labels...");
532 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
533 param_escape(sel_rows
.toString()), true);
534 xmlhttp
.onreadystatechange
=labellist_callback
;
538 alert(__("No labels are selected."));
544 function removeSelectedUsers() {
546 if (!xmlhttp_ready(xmlhttp
)) {
551 var sel_rows
= getSelectedUsers();
553 if (sel_rows
.length
> 0) {
555 var ok
= confirm(__("Remove selected users?"));
558 notify_progress("Removing selected users...");
560 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
561 param_escape(sel_rows
.toString()), true);
562 xmlhttp
.onreadystatechange
=userlist_callback
;
567 alert(__("No users are selected."));
573 function removeSelectedFilters() {
575 if (!xmlhttp_ready(xmlhttp
)) {
580 var sel_rows
= getSelectedFilters();
582 if (sel_rows
.length
> 0) {
584 var ok
= confirm(__("Remove selected filters?"));
587 notify_progress("Removing selected filters...");
589 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
590 param_escape(sel_rows
.toString()), true);
591 xmlhttp
.onreadystatechange
=filterlist_callback
;
595 alert(__("No filters are selected."));
602 function removeSelectedFeeds() {
604 if (!xmlhttp_ready(xmlhttp
)) {
609 var sel_rows
= getSelectedFeeds();
611 if (sel_rows
.length
> 0) {
613 var ok
= confirm(__("Unsubscribe from selected feeds?"));
617 notify_progress("Unsubscribing from selected feeds...");
619 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
620 param_escape(sel_rows
.toString()), true);
621 xmlhttp
.onreadystatechange
=feedlist_callback
;
627 alert(__("No feeds are selected."));
634 function clearSelectedFeeds() {
636 if (!xmlhttp_ready(xmlhttp
)) {
641 var sel_rows
= getSelectedFeeds();
643 if (sel_rows
.length
> 1) {
644 alert(__("Please select only one feed."));
648 if (sel_rows
.length
> 0) {
650 var ok
= confirm(__("Erase all non-starred articles in selected feed?"));
653 notify_progress("Clearing selected feed...");
654 clearFeedArticles(sel_rows
[0]);
659 alert(__("No feeds are selected."));
666 function purgeSelectedFeeds() {
668 if (!xmlhttp_ready(xmlhttp
)) {
673 var sel_rows
= getSelectedFeeds();
675 if (sel_rows
.length
> 0) {
677 var pr
= prompt(__("How many days of articles to keep (0 - use default)?"), "0");
679 if (pr
!= undefined) {
680 notify_progress("Purging selected feed...");
682 var query
= "backend.php?op=rpc&subop=purge&ids="+
683 param_escape(sel_rows
.toString()) + "&days=" + pr
;
687 new Ajax
.Request(query
, {
688 onComplete: function(transport
) {
695 alert(__("No feeds are selected."));
702 function removeSelectedFeedCats() {
704 if (!xmlhttp_ready(xmlhttp
)) {
709 var sel_rows
= getSelectedFeedCats();
711 if (sel_rows
.length
> 0) {
713 var ok
= confirm(__("Remove selected categories?"));
716 notify_progress("Removing selected categories...");
718 var query
= "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
719 param_escape(sel_rows
.toString());
721 new Ajax
.Request(query
, {
722 onComplete: function(transport
) {
723 infobox_feed_cat_callback2(transport
);
730 alert(__("No categories are selected."));
737 function feedEditCancel() {
739 if (!xmlhttp_ready(xmlhttp
)) {
745 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
746 document
.getElementById("top25_feeds_btn").disabled
= false;
748 // this button is not always available, no-op if not found
753 selectPrefRows('feed', false); // cleanup feed selection
758 function feedEditSave() {
762 if (!xmlhttp_ready(xmlhttp
)) {
767 // FIXME: add parameter validation
769 var query
= Form
.serialize("edit_feed_form");
771 notify_progress("Saving feed...");
773 xmlhttp
.open("POST", "backend.php", true);
774 xmlhttp
.onreadystatechange
=feedlist_callback
;
775 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
783 exception_error("feedEditSave", e
);
787 function userEditCancel() {
789 if (!xmlhttp_ready(xmlhttp
)) {
794 selectPrefRows('user', false); // cleanup feed selection
800 function filterEditCancel() {
802 if (!xmlhttp_ready(xmlhttp
)) {
808 document
.getElementById("create_filter_btn").disabled
= false;
809 selectPrefRows('filter', false); // cleanup feed selection
817 function userEditSave() {
819 if (!xmlhttp_ready(xmlhttp
)) {
824 var login
= document
.forms
["user_edit_form"].login
.value
;
826 if (login
.length
== 0) {
827 alert(__("Login field cannot be blank."));
831 notify_progress("Saving user...");
835 var query
= Form
.serialize("user_edit_form");
837 xmlhttp
.open("GET", "backend.php?" + query
, true);
838 xmlhttp
.onreadystatechange
=userlist_callback
;
845 function filterEditSave() {
847 if (!xmlhttp_ready(xmlhttp
)) {
852 /* if (!is_opera()) {
853 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
855 if (reg_exp.length == 0) {
856 alert("Filter expression field cannot be blank.");
861 notify_progress("Saving filter...");
863 var query
= Form
.serialize("filter_edit_form");
867 document
.getElementById("create_filter_btn").disabled
= false;
869 xmlhttp
.open("GET", "backend.php?" + query
, true);
870 xmlhttp
.onreadystatechange
=filterlist_callback
;
877 function editSelectedUser() {
878 var rows
= getSelectedUsers();
880 if (rows
.length
== 0) {
881 alert(__("No users are selected."));
885 if (rows
.length
> 1) {
886 alert(__("Please select only one user."));
895 function resetSelectedUserPass() {
896 var rows
= getSelectedUsers();
898 if (rows
.length
== 0) {
899 alert(__("No users are selected."));
903 if (rows
.length
> 1) {
904 alert(__("Please select only one user."));
908 var ok
= confirm(__("Reset password of selected user?"));
911 notify_progress("Resetting password for selected user...");
915 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
916 param_escape(id
), true);
917 xmlhttp
.onreadystatechange
=userlist_callback
;
922 function selectedUserDetails() {
926 var rows
= getSelectedUsers();
928 if (rows
.length
== 0) {
929 alert(__("No users are selected."));
933 if (rows
.length
> 1) {
934 alert(__("Please select only one user."));
938 notify_progress("Loading, please wait...");
942 var query
= "backend.php?op=pref-users&subop=user-details&id=" + id
;
944 new Ajax
.Request(query
, {
945 onComplete: function(transport
) {
946 infobox_callback2(transport
);
949 exception_error("selectedUserDetails", e
);
954 function editSelectedFilter() {
955 var rows
= getSelectedFilters();
957 if (rows
.length
== 0) {
958 alert(__("No filters are selected."));
962 if (rows
.length
> 1) {
963 alert(__("Please select only one filter."));
974 function editSelectedFeed() {
975 var rows
= getSelectedFeeds();
977 if (rows
.length
== 0) {
978 alert(__("No feeds are selected."));
982 if (rows
.length
> 1) {
983 alert(__("Please select one feed."));
993 function editSelectedFeeds() {
996 var rows
= getSelectedFeeds();
998 if (rows
.length
== 0) {
999 alert(__("No feeds are selected."));
1007 notify_progress("Loading, please wait...");
1009 var query
= "backend.php?op=pref-feeds&subop=editfeeds&ids=" +
1010 param_escape(rows
.toString());
1012 new Ajax
.Request(query
, {
1013 onComplete: function(transport
) {
1014 infobox_callback2(transport
);
1018 exception_error("editSelectedFeeds", e
);
1022 function piggie(enable
) {
1024 debug("I LOVEDED IT!");
1025 var piggie
= document
.getElementById("piggie");
1027 Element
.show(piggie
);
1028 Position
.Center(piggie
);
1029 Effect
.Puff(piggie
);
1034 function validateOpmlImport() {
1036 var opml_file
= document
.getElementById("opml_file");
1038 if (opml_file
.value
.length
== 0) {
1039 alert(__("No OPML file to upload."));
1046 function updateFilterList(sort_key
) {
1048 if (!xmlhttp_ready(xmlhttp
)) {
1049 printLockingError();
1053 var filter_search
= document
.getElementById("filter_search");
1055 if (filter_search
) { search
= filter_search
.value
; }
1057 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1058 param_escape(sort_key
) +
1059 "&search=" + param_escape(search
), true);
1060 xmlhttp
.onreadystatechange
=filterlist_callback
;
1065 function updateLabelList(sort_key
) {
1067 if (!xmlhttp_ready(xmlhttp
)) {
1068 printLockingError();
1072 var label_search
= document
.getElementById("label_search");
1074 if (label_search
) { search
= label_search
.value
; }
1076 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1077 param_escape(sort_key
) +
1078 "&search=" + param_escape(search
), true);
1079 xmlhttp
.onreadystatechange
=labellist_callback
;
1083 function updatePrefsList() {
1085 if (!xmlhttp_ready(xmlhttp
)) {
1086 printLockingError();
1090 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1091 xmlhttp
.onreadystatechange
=prefslist_callback
;
1096 function selectTab(id
, noupdate
, subop
) {
1100 if (!id
) id
= active_tab
;
1104 if (!xmlhttp_ready(xmlhttp
)) {
1105 printLockingError();
1110 var c
= document
.getElementById('prefContent');
1116 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1118 notify_progress("Loading, please wait...");
1120 // close active infobox if needed
1123 // clean up all current selections, just in case
1124 active_feed_cat
= false;
1126 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1127 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1129 if (id
== "feedConfig") {
1131 } else if (id
== "filterConfig") {
1133 } else if (id
== "labelConfig") {
1135 } else if (id
== "genConfig") {
1137 } else if (id
== "userConfig") {
1142 /* clean selection from all tabs */
1144 var tabs_holder
= document
.getElementById("prefTabs");
1145 var tab
= tabs_holder
.firstChild
;
1148 if (tab
.className
&& tab
.className
.match("prefsTabSelected")) {
1149 tab
.className
= "prefsTab";
1151 tab
= tab
.nextSibling
;
1154 /* mark new tab as selected */
1156 tab
= document
.getElementById(id
+ "Tab");
1159 if (!tab
.className
.match("Selected")) {
1160 tab
.className
= tab
.className
+ "Selected";
1167 exception_error("selectTab", e
);
1171 function backend_sanity_check_callback() {
1173 if (xmlhttp
.readyState
== 4) {
1177 if (sanity_check_done
) {
1178 fatalError(11, "Sanity check request received twice. This can indicate "+
1179 "presence of Firebug or some other disrupting extension. "+
1180 "Please disable it and try again.");
1184 if (!xmlhttp
.responseXML
) {
1185 fatalError(3, "Sanity Check: Received reply is not XML",
1186 xmlhttp
.responseText
);
1190 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1193 fatalError(3, "Sanity Check: Invalid RPC reply", xmlhttp
.responseText
);
1197 var error_code
= reply
.getAttribute("error-code");
1199 if (error_code
&& error_code
!= 0) {
1200 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1203 debug("sanity check ok");
1205 var params
= reply
.nextSibling
;
1208 debug('reading init-params...');
1209 var param
= params
.firstChild
;
1212 var k
= param
.getAttribute("key");
1213 var v
= param
.getAttribute("value");
1214 debug(k
+ " => " + v
);
1216 param
= param
.nextSibling
;
1220 sanity_check_done
= true;
1222 init_second_stage();
1225 exception_error("backend_sanity_check_callback", e
);
1230 function init_second_stage() {
1233 active_tab
= getInitParam("prefs_active_tab");
1234 if (!document
.getElementById(active_tab
+"Tab")) active_tab
= "genConfig";
1235 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1237 document
.onkeydown
= pref_hotkey_handler
;
1239 var tab
= getURLParam('tab');
1241 caller_subop
= getURLParam('subop');
1243 if (getURLParam("subopparam")) {
1244 caller_subop
= caller_subop
+ ":" + getURLParam("subopparam");
1251 if (navigator
.userAgent
.match("Opera")) {
1252 setTimeout("selectTab()", 500);
1254 selectTab(active_tab
);
1258 loading_set_progress(60);
1261 exception_error("init_second_stage", e
);
1269 if (arguments
.callee
.done
) return;
1270 arguments
.callee
.done
= true;
1272 if (getURLParam('debug')) {
1273 Element
.show("debug_output");
1274 debug('debug mode activated');
1279 document
.getElementById("prefContent").innerHTML
=
1280 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1281 "to function properly. Your browser doesn't seem to support it.";
1285 loading_set_progress(30);
1287 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1288 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1292 exception_error("init", e
);
1296 function categorizeSelectedFeeds() {
1298 if (!xmlhttp_ready(xmlhttp
)) {
1299 printLockingError();
1303 var sel_rows
= getSelectedFeeds();
1305 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1306 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1308 if (sel_rows
.length
> 0) {
1310 notify_progress("Changing category of selected feeds...");
1312 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1313 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1314 xmlhttp
.onreadystatechange
=feedlist_callback
;
1319 alert(__("No feeds are selected."));
1325 function validatePrefsReset() {
1327 var ok
= confirm(__("Reset to defaults?"));
1331 var query
= Form
.serialize("pref_prefs_form");
1332 query
= query
+ "&subop=reset-config";
1335 xmlhttp
.open("POST", "backend.php", true);
1336 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1337 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1338 xmlhttp
.send(query
);
1342 exception_error("validatePrefsSave", e
);
1349 function feedBrowserSubscribe() {
1352 var selected
= getSelectedFeedsFromBrowser();
1354 if (selected
.length
> 0) {
1356 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1357 param_escape(selected
.toString()), true);
1358 xmlhttp
.onreadystatechange
=feedlist_callback
;
1361 alert(__("No feeds are selected."));
1365 exception_error("feedBrowserSubscribe", e
);
1369 function updateBigFeedBrowserBtn() {
1370 notify_progress("Loading, please wait...");
1371 return updateBigFeedBrowser();
1374 function selectPrefRows(kind
, select
) {
1377 var opbarid
= false;
1382 if (kind
== "feed") {
1383 opbarid
= "feedOpToolbar";
1386 lname
= "prefFeedList";
1387 } else if (kind
== "fcat") {
1388 opbarid
= "catOpToolbar";
1391 lname
= "prefFeedCatList";
1392 } else if (kind
== "filter") {
1393 opbarid
= "filterOpToolbar";
1396 lname
= "prefFilterList";
1397 } else if (kind
== "label") {
1398 opbarid
= "labelOpToolbar";
1401 lname
= "prefLabelList";
1402 } else if (kind
== "user") {
1403 opbarid
= "userOpToolbar";
1406 lname
= "prefUserList";
1410 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1411 disableContainerChildren(opbarid
, !select
);
1418 function toggleSelectPrefRow(sender
, kind
) {
1420 toggleSelectRow(sender
);
1423 var opbarid
= false;
1426 if (kind
== "feed") {
1427 opbarid
= "feedOpToolbar";
1428 nsel
= getSelectedFeeds();
1429 } else if (kind
== "fcat") {
1430 opbarid
= "catOpToolbar";
1431 nsel
= getSelectedFeedCats();
1432 } else if (kind
== "filter") {
1433 opbarid
= "filterOpToolbar";
1434 nsel
= getSelectedFilters();
1435 } else if (kind
== "label") {
1436 opbarid
= "labelOpToolbar";
1437 nsel
= getSelectedLabels();
1438 } else if (kind
== "user") {
1439 opbarid
= "userOpToolbar";
1440 nsel
= getSelectedUsers();
1443 if (opbarid
&& nsel
!= -1) {
1444 disableContainerChildren(opbarid
, nsel
== false);
1450 function toggleSelectFBListRow(sender
) {
1451 toggleSelectListRow(sender
);
1452 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1457 function pref_hotkey_handler(e
) {
1461 var shift_key
= false;
1464 shift_key
= e
.shiftKey
;
1470 keycode
= window
.event
.keyCode
;
1475 var keychar
= String
.fromCharCode(keycode
);
1477 if (keycode
== 27) { // escape
1478 if (Element
.visible("hotkey_help_overlay")) {
1479 Element
.hide("hotkey_help_overlay");
1481 hotkey_prefix
= false;
1485 if (!hotkeys_enabled
) {
1486 debug("hotkeys disabled");
1490 if (keycode
== 16) return; // ignore lone shift
1492 if ((keycode
== 67 || keycode
== 71) && !hotkey_prefix
) {
1493 hotkey_prefix
= keycode
;
1494 debug("KP: PREFIX=" + keycode
+ " CHAR=" + keychar
);
1498 if (Element
.visible("hotkey_help_overlay")) {
1499 Element
.hide("hotkey_help_overlay");
1502 if (keycode
== 13 || keycode
== 27) {
1505 seq
= seq
+ "" + keycode
;
1508 /* Global hotkeys */
1510 if (!hotkey_prefix
) {
1512 if (keycode
== 68 && shift_key
) { // d
1513 if (!Element
.visible("debug_output")) {
1514 Element
.show("debug_output");
1515 debug('debug mode activated');
1517 Element
.hide("debug_output");
1522 if ((keycode
== 191 || keychar
== '?') && shift_key
) { // ?
1523 if (!Element
.visible("hotkey_help_overlay")) {
1524 //Element.show("hotkey_help_overlay");
1525 Effect
.Appear("hotkey_help_overlay", {duration
: 0.3});
1527 Element
.hide("hotkey_help_overlay");
1532 if (keycode
== 191 || keychar
== '/') { // /
1533 var search_boxes
= new Array("label_search",
1534 "feed_search", "filter_search", "user_search", "feed_browser_search");
1536 for (var i
= 0; i
< search_boxes
.length
; i
++) {
1537 var elem
= document
.getElementById(search_boxes
[i
]);
1539 focus_element(search_boxes
[i
]);
1548 if (hotkey_prefix
== 67) { // c
1549 hotkey_prefix
= false;
1551 if (keycode
== 70) { // f
1552 displayDlg("quickAddFilter");
1556 if (keycode
== 83) { // s
1557 displayDlg("quickAddFeed");
1561 /* if (keycode == 76) { // l
1562 displayDlg("quickAddLabel");
1566 if (keycode
== 85) { // u
1570 if (keycode
== 67) { // c
1575 if (keycode
== 84 && shift_key
) { // T
1584 if (hotkey_prefix
== 71) { // g
1586 hotkey_prefix
= false;
1588 if (keycode
== 49 && document
.getElementById("genConfigTab")) { // 1
1589 selectTab("genConfig");
1593 if (keycode
== 50 && document
.getElementById("feedConfigTab")) { // 2
1594 selectTab("feedConfig");
1598 if (keycode
== 51 && document
.getElementById("filterConfigTab")) { // 4
1599 selectTab("filterConfig");
1603 if (keycode
== 52 && document
.getElementById("labelConfigTab")) { // 5
1604 selectTab("labelConfig");
1608 if (keycode
== 53 && document
.getElementById("userConfigTab")) { // 6
1609 selectTab("userConfig");
1613 if (keycode
== 88) { // x
1619 if (document
.getElementById("piggie")) {
1621 if (seq
.match("807371717369")) {
1629 if (hotkey_prefix
) {
1630 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
+ " CHAR=" + keychar
);
1632 debug("KP: CODE=" + keycode
+ " CHAR=" + keychar
);
1636 exception_error("pref_hotkey_handler", e
);
1640 function editFeedCats() {
1642 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1645 document
.getElementById("top25_feeds_btn").disabled
= true;
1647 // this button is not always available, no-op if not found
1650 var query
= "backend.php?op=pref-feeds&subop=editCats";
1652 new Ajax
.Request(query
, {
1653 onComplete: function(transport
) {
1654 infobox_feed_cat_callback2(transport
);
1657 exception_error("editFeedCats", e
);
1661 function showFeedsWithErrors() {
1662 displayDlg('feedUpdateErrors');
1665 function changeUserPassword() {
1669 if (!xmlhttp_ready(xmlhttp
)) {
1670 printLockingError();
1674 var f
= document
.forms
["change_pass_form"];
1677 if (f
.OLD_PASSWORD
.value
== "") {
1678 new Effect
.Highlight(f
.OLD_PASSWORD
);
1679 notify_error("Old password cannot be blank.");
1683 if (f
.NEW_PASSWORD
.value
== "") {
1684 new Effect
.Highlight(f
.NEW_PASSWORD
);
1685 notify_error("New password cannot be blank.");
1689 if (f
.CONFIRM_PASSWORD
.value
== "") {
1690 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1691 notify_error("Entered passwords do not match.");
1695 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1696 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1697 new Effect
.Highlight(f
.NEW_PASSWORD
);
1698 notify_error("Entered passwords do not match.");
1704 var query
= Form
.serialize("change_pass_form");
1706 notify_progress("Trying to change password...");
1708 xmlhttp
.open("POST", "backend.php", true);
1709 xmlhttp
.onreadystatechange
=changepass_callback
;
1710 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1711 xmlhttp
.send(query
);
1714 exception_error("changeUserPassword", e
);
1720 function changeUserEmail() {
1724 if (!xmlhttp_ready(xmlhttp
)) {
1725 printLockingError();
1729 var query
= Form
.serialize("change_email_form");
1731 notify_progress("Trying to change e-mail...");
1733 xmlhttp
.open("POST", "backend.php", true);
1734 xmlhttp
.onreadystatechange
=notify_callback
;
1735 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1736 xmlhttp
.send(query
);
1739 exception_error("changeUserPassword", e
);
1746 function feedlistToggleSLAT() {
1747 notify_progress("Loading, please wait...");
1751 function pubRegenKey() {
1753 if (!xmlhttp_ready(xmlhttp
)) {
1754 printLockingError();
1758 var ok
= confirm(__("Replace current publishing address with a new one?"));
1762 notify_progress("Trying to change address...");
1764 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1765 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1772 function pubToClipboard() {
1776 if (!xmlhttp_ready(xmlhttp
)) {
1777 printLockingError();
1781 var link
= document
.getElementById("pubGenAddress");
1785 exception_error("pubToClipboard", e
);
1791 function validatePrefsSave() {
1794 var ok
= confirm(__("Save current configuration?"));
1798 var query
= Form
.serialize("pref_prefs_form");
1799 query
= query
+ "&subop=save-config";
1802 xmlhttp
.open("POST", "backend.php", true);
1803 xmlhttp
.onreadystatechange
=notify_callback
;
1804 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1805 xmlhttp
.send(query
);
1809 exception_error("validatePrefsSave", e
);
1815 function feedActionChange() {
1817 var chooser
= document
.getElementById("feedActionChooser");
1818 var opid
= chooser
[chooser
.selectedIndex
].value
;
1820 chooser
.selectedIndex
= 0;
1823 exception_error("feedActionChange", e
);
1827 function feedActionGo(op
) {
1829 if (op
== "facEdit") {
1831 var rows
= getSelectedFeeds();
1833 if (rows
.length
> 1) {
1834 editSelectedFeeds();
1840 if (op
== "facClear") {
1841 clearSelectedFeeds();
1844 if (op
== "facPurge") {
1845 purgeSelectedFeeds();
1848 if (op
== "facEditCats") {
1852 if (op
== "facRescore") {
1853 rescoreSelectedFeeds();
1856 if (op
== "facUnsubscribe") {
1857 removeSelectedFeeds();
1861 exception_error("feedActionGo", e
);
1866 function clearFeedArticles(feed_id
) {
1868 notify_progress("Clearing feed...");
1870 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
1872 new Ajax
.Request(query
, {
1873 onComplete: function(transport
) {
1880 function rescoreSelectedFeeds() {
1882 if (!xmlhttp_ready(xmlhttp
)) {
1883 printLockingError();
1887 var sel_rows
= getSelectedFeeds();
1889 if (sel_rows
.length
> 0) {
1891 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
1892 var ok
= confirm(__("Rescore articles in selected feeds?"));
1895 notify_progress("Rescoring selected feeds...", true);
1897 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
1898 param_escape(sel_rows
.toString()), true);
1899 xmlhttp
.onreadystatechange
=notify_callback
;
1903 alert(__("No feeds are selected."));
1909 function rescore_all_feeds() {
1910 var ok
= confirm(__("Rescore all articles? This operation may take a lot of time."));
1913 notify_progress("Rescoring feeds...", true);
1915 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
1916 xmlhttp
.onreadystatechange
=notify_callback
;
1921 function removeFilter(id
, title
) {
1923 if (!xmlhttp_ready(xmlhttp
)) {
1924 printLockingError();
1928 var msg
= __("Remove filter %s?").replace("%s", title
);
1930 var ok
= confirm(msg
);
1935 notify_progress("Removing filter...");
1937 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
1938 param_escape(id
), true);
1939 xmlhttp
.onreadystatechange
=filterlist_callback
;
1946 function unsubscribeFeed(id
, title
) {
1948 if (!xmlhttp_ready(xmlhttp
)) {
1949 printLockingError();
1953 var msg
= __("Unsubscribe from %s?").replace("%s", title
);
1955 var ok
= confirm(msg
);
1960 notify_progress("Removing feed...");
1962 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
1963 param_escape(id
), true);
1964 xmlhttp
.onreadystatechange
=filterlist_callback
;
1974 function feedsEditSave() {
1977 if (!xmlhttp_ready(xmlhttp
)) {
1978 printLockingError();
1982 var ok
= confirm(__("Save changes to selected feeds?"));
1986 var f
= document
.forms
["batch_edit_feed_form"];
1988 var query
= Form
.serialize("batch_edit_feed_form");
1990 /* Form.serialize ignores unchecked checkboxes */
1992 if (!query
.match("&hidden=") &&
1993 f
.hidden
.disabled
== false) {
1994 query
= query
+ "&hidden=false";
1997 if (!query
.match("&rtl_content=") &&
1998 f
.rtl_content
.disabled
== false) {
1999 query
= query
+ "&rtl_content=false";
2002 if (!query
.match("&private=") &&
2003 f
.private.disabled
== false) {
2004 query
= query
+ "&private=false";
2007 if (!query
.match("&cache_images=") &&
2008 f
.cache_images
.disabled
== false) {
2009 query
= query
+ "&cache_images=false";
2012 if (!query
.match("&include_in_digest=") &&
2013 f
.include_in_digest
.disabled
== false) {
2014 query
= query
+ "&include_in_digest=false";
2019 notify_progress("Saving feeds...");
2021 xmlhttp
.open("POST", "backend.php", true);
2022 xmlhttp
.onreadystatechange
=feedlist_callback
;
2023 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2024 xmlhttp
.send(query
);
2029 exception_error("feedsEditSave", e
);
2033 function batchFeedsToggleField(cb
, elem
, label
) {
2035 var f
= document
.forms
["batch_edit_feed_form"];
2036 var l
= document
.getElementById(label
);
2039 f
[elem
].disabled
= false;
2045 // new Effect.Highlight(f[elem], {duration: 1, startcolor: "#fff7d5",
2046 // queue: { position:'end', scope: 'BPEFQ', limit: 1 } } );
2049 f
[elem
].disabled
= true;
2052 l
.className
= "insensitive";
2057 exception_error("batchFeedsToggleField", e
);