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_callback() {
249 if (xmlhttp
.readyState
== 4) {
253 init_cat_inline_editor();
256 exception_error("infobox_feed_cat_callback", e
);
261 function updateFeedList(sort_key
) {
263 if (!xmlhttp_ready(xmlhttp
)) {
268 var feed_search
= document
.getElementById("feed_search");
270 if (feed_search
) { search
= feed_search
.value
; }
272 var slat
= document
.getElementById("show_last_article_times");
274 var slat_checked
= false;
276 slat_checked
= slat
.checked
;
279 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
280 "&sort=" + param_escape(sort_key
) +
281 "&slat=" + param_escape(slat_checked
) +
282 "&search=" + param_escape(search
), true);
283 xmlhttp
.onreadystatechange
=feedlist_callback
;
288 function updateUsersList(sort_key
) {
290 if (!xmlhttp_ready(xmlhttp
)) {
295 var user_search
= document
.getElementById("user_search");
297 if (user_search
) { search
= user_search
.value
; }
299 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
300 + param_escape(sort_key
) +
301 "&search=" + param_escape(search
), true);
302 xmlhttp
.onreadystatechange
=userlist_callback
;
307 function addLabel() {
311 if (!xmlhttp_ready(xmlhttp
)) {
316 var caption
= prompt(__("Please enter label caption:"), "");
318 if (caption
== null) {
323 alert(__("Can't create label: missing caption."));
327 // we can be called from some other tab
328 active_tab
= "labelConfig";
330 var query
= "caption=" + param_escape(caption
);
332 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
333 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
337 exception_error("addLabel", e
);
343 if (!xmlhttp_ready(xmlhttp
)) {
348 var link
= document
.getElementById("fadd_link");
350 if (link
.value
.length
== 0) {
351 alert(__("Error: No feed URL given."));
352 } else if (!isValidURL(link
.value
)) {
353 alert(__("Error: Invalid feed URL."));
355 notify_progress("Adding feed...");
357 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
358 param_escape(link
.value
), true);
359 xmlhttp
.onreadystatechange
=feedlist_callback
;
368 function addFeedCat() {
370 if (!xmlhttp_ready(xmlhttp
)) {
375 var cat
= document
.getElementById("fadd_cat");
377 if (cat
.value
.length
== 0) {
378 alert(__("Can't add category: no name specified."));
380 notify_progress("Adding feed category...");
382 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
383 param_escape(cat
.value
), true);
384 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
394 if (!xmlhttp_ready(xmlhttp
)) {
399 var sqlexp
= document
.getElementById("uadd_box");
401 if (sqlexp
.value
.length
== 0) {
402 alert(__("Can't add user: no login specified."));
404 notify_progress("Adding user...");
406 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
407 param_escape(sqlexp
.value
), true);
409 xmlhttp
.onreadystatechange
=userlist_callback
;
417 function editUser(id
) {
423 notify_progress("Loading, please wait...");
425 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
426 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
428 disableContainerChildren("userOpToolbar", false);
430 var query
= "backend.php?op=pref-users&subop=edit&id=" +
433 new Ajax
.Request(query
, {
434 onComplete: function(transport
) {
435 infobox_callback2(transport
);
439 exception_error("editUser", e
);
444 function editFilter(id
) {
450 notify_progress("Loading, please wait...");
452 disableContainerChildren("filterOpToolbar", false);
454 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
455 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
457 var query
= "backend.php?op=pref-filters&subop=edit&id=" +
460 new Ajax
.Request(query
, {
461 onComplete: function(transport
) {
462 infobox_callback2(transport
);
465 exception_error("editFilter", e
);
469 function editFeed(feed
) {
475 notify_progress("Loading, please wait...");
477 // clean selection from all rows & select row being edited
478 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
479 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
481 disableContainerChildren("feedOpToolbar", false);
483 var query
= "backend.php?op=pref-feeds&subop=editfeed&id=" +
486 new Ajax
.Request(query
, {
487 onComplete: function(transport
) {
488 infobox_callback2(transport
);
492 exception_error("editFeed", e
);
496 function getSelectedLabels() {
497 return getSelectedTableRowIds("prefLabelList", "LILRR");
500 function getSelectedUsers() {
501 return getSelectedTableRowIds("prefUserList", "UMRR");
504 function getSelectedFeeds() {
505 return getSelectedTableRowIds("prefFeedList", "FEEDR");
508 function getSelectedFilters() {
509 return getSelectedTableRowIds("prefFilterList", "FILRR");
512 function getSelectedFeedCats() {
513 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
517 function removeSelectedLabels() {
519 if (!xmlhttp_ready(xmlhttp
)) {
524 var sel_rows
= getSelectedLabels();
526 if (sel_rows
.length
> 0) {
528 var ok
= confirm(__("Remove selected labels?"));
531 notify_progress("Removing selected labels...");
533 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
534 param_escape(sel_rows
.toString()), true);
535 xmlhttp
.onreadystatechange
=labellist_callback
;
539 alert(__("No labels are selected."));
545 function removeSelectedUsers() {
547 if (!xmlhttp_ready(xmlhttp
)) {
552 var sel_rows
= getSelectedUsers();
554 if (sel_rows
.length
> 0) {
556 var ok
= confirm(__("Remove selected users?"));
559 notify_progress("Removing selected users...");
561 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
562 param_escape(sel_rows
.toString()), true);
563 xmlhttp
.onreadystatechange
=userlist_callback
;
568 alert(__("No users are selected."));
574 function removeSelectedFilters() {
576 if (!xmlhttp_ready(xmlhttp
)) {
581 var sel_rows
= getSelectedFilters();
583 if (sel_rows
.length
> 0) {
585 var ok
= confirm(__("Remove selected filters?"));
588 notify_progress("Removing selected filters...");
590 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
591 param_escape(sel_rows
.toString()), true);
592 xmlhttp
.onreadystatechange
=filterlist_callback
;
596 alert(__("No filters are selected."));
603 function removeSelectedFeeds() {
605 if (!xmlhttp_ready(xmlhttp
)) {
610 var sel_rows
= getSelectedFeeds();
612 if (sel_rows
.length
> 0) {
614 var ok
= confirm(__("Unsubscribe from selected feeds?"));
618 notify_progress("Unsubscribing from selected feeds...");
620 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
621 param_escape(sel_rows
.toString()), true);
622 xmlhttp
.onreadystatechange
=feedlist_callback
;
628 alert(__("No feeds are selected."));
635 function clearSelectedFeeds() {
637 if (!xmlhttp_ready(xmlhttp
)) {
642 var sel_rows
= getSelectedFeeds();
644 if (sel_rows
.length
> 1) {
645 alert(__("Please select only one feed."));
649 if (sel_rows
.length
> 0) {
651 var ok
= confirm(__("Erase all non-starred articles in selected feed?"));
654 notify_progress("Clearing selected feed...");
655 clearFeedArticles(sel_rows
[0]);
660 alert(__("No feeds are selected."));
667 function purgeSelectedFeeds() {
669 if (!xmlhttp_ready(xmlhttp
)) {
674 var sel_rows
= getSelectedFeeds();
676 if (sel_rows
.length
> 0) {
678 var pr
= prompt(__("How many days of articles to keep (0 - use default)?"), "0");
680 if (pr
!= undefined) {
681 notify_progress("Purging selected feed...");
683 var query
= "backend.php?op=rpc&subop=purge&ids="+
684 param_escape(sel_rows
.toString()) + "&days=" + pr
;
688 new Ajax
.Request(query
, {
689 onComplete: function(transport
) {
696 alert(__("No feeds are selected."));
703 function removeSelectedFeedCats() {
705 if (!xmlhttp_ready(xmlhttp
)) {
710 var sel_rows
= getSelectedFeedCats();
712 if (sel_rows
.length
> 0) {
714 var ok
= confirm(__("Remove selected categories?"));
717 notify_progress("Removing selected categories...");
719 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
720 param_escape(sel_rows
.toString()), true);
721 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
727 alert(__("No categories are selected."));
734 function feedEditCancel() {
736 if (!xmlhttp_ready(xmlhttp
)) {
742 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
743 document
.getElementById("top25_feeds_btn").disabled
= false;
745 // this button is not always available, no-op if not found
750 selectPrefRows('feed', false); // cleanup feed selection
755 function feedEditSave() {
759 if (!xmlhttp_ready(xmlhttp
)) {
764 // FIXME: add parameter validation
766 var query
= Form
.serialize("edit_feed_form");
768 notify_progress("Saving feed...");
770 xmlhttp
.open("POST", "backend.php", true);
771 xmlhttp
.onreadystatechange
=feedlist_callback
;
772 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
780 exception_error("feedEditSave", e
);
784 function userEditCancel() {
786 if (!xmlhttp_ready(xmlhttp
)) {
791 selectPrefRows('user', false); // cleanup feed selection
797 function filterEditCancel() {
799 if (!xmlhttp_ready(xmlhttp
)) {
805 document
.getElementById("create_filter_btn").disabled
= false;
806 selectPrefRows('filter', false); // cleanup feed selection
814 function userEditSave() {
816 if (!xmlhttp_ready(xmlhttp
)) {
821 var login
= document
.forms
["user_edit_form"].login
.value
;
823 if (login
.length
== 0) {
824 alert(__("Login field cannot be blank."));
828 notify_progress("Saving user...");
832 var query
= Form
.serialize("user_edit_form");
834 xmlhttp
.open("GET", "backend.php?" + query
, true);
835 xmlhttp
.onreadystatechange
=userlist_callback
;
842 function filterEditSave() {
844 if (!xmlhttp_ready(xmlhttp
)) {
849 /* if (!is_opera()) {
850 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
852 if (reg_exp.length == 0) {
853 alert("Filter expression field cannot be blank.");
858 notify_progress("Saving filter...");
860 var query
= Form
.serialize("filter_edit_form");
864 document
.getElementById("create_filter_btn").disabled
= false;
866 xmlhttp
.open("GET", "backend.php?" + query
, true);
867 xmlhttp
.onreadystatechange
=filterlist_callback
;
874 function editSelectedUser() {
875 var rows
= getSelectedUsers();
877 if (rows
.length
== 0) {
878 alert(__("No users are selected."));
882 if (rows
.length
> 1) {
883 alert(__("Please select only one user."));
892 function resetSelectedUserPass() {
893 var rows
= getSelectedUsers();
895 if (rows
.length
== 0) {
896 alert(__("No users are selected."));
900 if (rows
.length
> 1) {
901 alert(__("Please select only one user."));
905 var ok
= confirm(__("Reset password of selected user?"));
908 notify_progress("Resetting password for selected user...");
912 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
913 param_escape(id
), true);
914 xmlhttp
.onreadystatechange
=userlist_callback
;
919 function selectedUserDetails() {
921 if (!xmlhttp_ready(xmlhttp
)) {
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 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=user-details&id=" + id
, true);
943 xmlhttp
.onreadystatechange
=infobox_callback
;
948 function selectedFeedDetails() {
950 if (!xmlhttp_ready(xmlhttp
)) {
955 var rows
= getSelectedFeeds();
957 if (rows
.length
== 0) {
958 alert(__("No feeds are selected."));
962 if (rows
.length
> 1) {
963 alert(__("Please select only one feed."));
971 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
972 param_escape(rows
.toString()), true);
973 xmlhttp
.onreadystatechange
=infobox_callback
;
978 function editSelectedFilter() {
979 var rows
= getSelectedFilters();
981 if (rows
.length
== 0) {
982 alert(__("No filters are selected."));
986 if (rows
.length
> 1) {
987 alert(__("Please select only one filter."));
998 function editSelectedFeed() {
999 var rows
= getSelectedFeeds();
1001 if (rows
.length
== 0) {
1002 alert(__("No feeds are selected."));
1006 if (rows
.length
> 1) {
1007 alert(__("Please select one feed."));
1017 function editSelectedFeeds() {
1019 if (!xmlhttp_ready(xmlhttp
)) {
1020 printLockingError();
1024 var rows
= getSelectedFeeds();
1026 if (rows
.length
== 0) {
1027 alert(__("No feeds are selected."));
1035 notify_progress("Loading, please wait...");
1037 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeeds&ids=" +
1038 param_escape(rows
.toString()), true);
1040 xmlhttp
.onreadystatechange
=infobox_callback
;
1045 function piggie(enable
) {
1047 debug("I LOVEDED IT!");
1048 var piggie
= document
.getElementById("piggie");
1050 Element
.show(piggie
);
1051 Position
.Center(piggie
);
1052 Effect
.Puff(piggie
);
1057 function validateOpmlImport() {
1059 var opml_file
= document
.getElementById("opml_file");
1061 if (opml_file
.value
.length
== 0) {
1062 alert(__("No OPML file to upload."));
1069 function updateFilterList(sort_key
) {
1071 if (!xmlhttp_ready(xmlhttp
)) {
1072 printLockingError();
1076 var filter_search
= document
.getElementById("filter_search");
1078 if (filter_search
) { search
= filter_search
.value
; }
1080 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1081 param_escape(sort_key
) +
1082 "&search=" + param_escape(search
), true);
1083 xmlhttp
.onreadystatechange
=filterlist_callback
;
1088 function updateLabelList(sort_key
) {
1090 if (!xmlhttp_ready(xmlhttp
)) {
1091 printLockingError();
1095 var label_search
= document
.getElementById("label_search");
1097 if (label_search
) { search
= label_search
.value
; }
1099 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1100 param_escape(sort_key
) +
1101 "&search=" + param_escape(search
), true);
1102 xmlhttp
.onreadystatechange
=labellist_callback
;
1106 function updatePrefsList() {
1108 if (!xmlhttp_ready(xmlhttp
)) {
1109 printLockingError();
1113 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1114 xmlhttp
.onreadystatechange
=prefslist_callback
;
1119 function selectTab(id
, noupdate
, subop
) {
1123 if (!id
) id
= active_tab
;
1127 if (!xmlhttp_ready(xmlhttp
)) {
1128 printLockingError();
1133 var c
= document
.getElementById('prefContent');
1139 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1141 notify_progress("Loading, please wait...");
1143 // close active infobox if needed
1146 // clean up all current selections, just in case
1147 active_feed_cat
= false;
1149 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1150 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1152 if (id
== "feedConfig") {
1154 } else if (id
== "filterConfig") {
1156 } else if (id
== "labelConfig") {
1158 } else if (id
== "genConfig") {
1160 } else if (id
== "userConfig") {
1165 /* clean selection from all tabs */
1167 var tabs_holder
= document
.getElementById("prefTabs");
1168 var tab
= tabs_holder
.firstChild
;
1171 if (tab
.className
&& tab
.className
.match("prefsTabSelected")) {
1172 tab
.className
= "prefsTab";
1174 tab
= tab
.nextSibling
;
1177 /* mark new tab as selected */
1179 tab
= document
.getElementById(id
+ "Tab");
1182 if (!tab
.className
.match("Selected")) {
1183 tab
.className
= tab
.className
+ "Selected";
1190 exception_error("selectTab", e
);
1194 function backend_sanity_check_callback() {
1196 if (xmlhttp
.readyState
== 4) {
1200 if (sanity_check_done
) {
1201 fatalError(11, "Sanity check request received twice. This can indicate "+
1202 "presence of Firebug or some other disrupting extension. "+
1203 "Please disable it and try again.");
1207 if (!xmlhttp
.responseXML
) {
1208 fatalError(3, "Sanity Check: Received reply is not XML",
1209 xmlhttp
.responseText
);
1213 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1216 fatalError(3, "Sanity Check: Invalid RPC reply", xmlhttp
.responseText
);
1220 var error_code
= reply
.getAttribute("error-code");
1222 if (error_code
&& error_code
!= 0) {
1223 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1226 debug("sanity check ok");
1228 var params
= reply
.nextSibling
;
1231 debug('reading init-params...');
1232 var param
= params
.firstChild
;
1235 var k
= param
.getAttribute("key");
1236 var v
= param
.getAttribute("value");
1237 debug(k
+ " => " + v
);
1239 param
= param
.nextSibling
;
1243 sanity_check_done
= true;
1245 init_second_stage();
1248 exception_error("backend_sanity_check_callback", e
);
1253 function init_second_stage() {
1256 active_tab
= getInitParam("prefs_active_tab");
1257 if (!document
.getElementById(active_tab
+"Tab")) active_tab
= "genConfig";
1258 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1260 document
.onkeydown
= pref_hotkey_handler
;
1262 var tab
= getURLParam('tab');
1264 caller_subop
= getURLParam('subop');
1266 if (getURLParam("subopparam")) {
1267 caller_subop
= caller_subop
+ ":" + getURLParam("subopparam");
1274 if (navigator
.userAgent
.match("Opera")) {
1275 setTimeout("selectTab()", 500);
1277 selectTab(active_tab
);
1281 loading_set_progress(60);
1284 exception_error("init_second_stage", e
);
1292 if (arguments
.callee
.done
) return;
1293 arguments
.callee
.done
= true;
1295 if (getURLParam('debug')) {
1296 Element
.show("debug_output");
1297 debug('debug mode activated');
1302 document
.getElementById("prefContent").innerHTML
=
1303 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1304 "to function properly. Your browser doesn't seem to support it.";
1308 loading_set_progress(30);
1310 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1311 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1315 exception_error("init", e
);
1319 function categorizeSelectedFeeds() {
1321 if (!xmlhttp_ready(xmlhttp
)) {
1322 printLockingError();
1326 var sel_rows
= getSelectedFeeds();
1328 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1329 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1331 if (sel_rows
.length
> 0) {
1333 notify_progress("Changing category of selected feeds...");
1335 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1336 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1337 xmlhttp
.onreadystatechange
=feedlist_callback
;
1342 alert(__("No feeds are selected."));
1348 function validatePrefsReset() {
1350 var ok
= confirm(__("Reset to defaults?"));
1354 var query
= Form
.serialize("pref_prefs_form");
1355 query
= query
+ "&subop=reset-config";
1358 xmlhttp
.open("POST", "backend.php", true);
1359 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1360 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1361 xmlhttp
.send(query
);
1365 exception_error("validatePrefsSave", e
);
1372 function browseFeeds(limit
) {
1374 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1375 xmlhttp
.onreadystatechange
=infobox_callback
;
1380 function feedBrowserSubscribe() {
1383 var selected
= getSelectedFeedsFromBrowser();
1385 if (selected
.length
> 0) {
1387 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1388 param_escape(selected
.toString()), true);
1389 xmlhttp
.onreadystatechange
=feedlist_callback
;
1392 alert(__("No feeds are selected."));
1396 exception_error("feedBrowserSubscribe", e
);
1400 function updateBigFeedBrowserBtn() {
1401 notify_progress("Loading, please wait...");
1402 return updateBigFeedBrowser();
1405 function selectPrefRows(kind
, select
) {
1408 var opbarid
= false;
1413 if (kind
== "feed") {
1414 opbarid
= "feedOpToolbar";
1417 lname
= "prefFeedList";
1418 } else if (kind
== "fcat") {
1419 opbarid
= "catOpToolbar";
1422 lname
= "prefFeedCatList";
1423 } else if (kind
== "filter") {
1424 opbarid
= "filterOpToolbar";
1427 lname
= "prefFilterList";
1428 } else if (kind
== "label") {
1429 opbarid
= "labelOpToolbar";
1432 lname
= "prefLabelList";
1433 } else if (kind
== "user") {
1434 opbarid
= "userOpToolbar";
1437 lname
= "prefUserList";
1441 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1442 disableContainerChildren(opbarid
, !select
);
1449 function toggleSelectPrefRow(sender
, kind
) {
1451 toggleSelectRow(sender
);
1454 var opbarid
= false;
1457 if (kind
== "feed") {
1458 opbarid
= "feedOpToolbar";
1459 nsel
= getSelectedFeeds();
1460 } else if (kind
== "fcat") {
1461 opbarid
= "catOpToolbar";
1462 nsel
= getSelectedFeedCats();
1463 } else if (kind
== "filter") {
1464 opbarid
= "filterOpToolbar";
1465 nsel
= getSelectedFilters();
1466 } else if (kind
== "label") {
1467 opbarid
= "labelOpToolbar";
1468 nsel
= getSelectedLabels();
1469 } else if (kind
== "user") {
1470 opbarid
= "userOpToolbar";
1471 nsel
= getSelectedUsers();
1474 if (opbarid
&& nsel
!= -1) {
1475 disableContainerChildren(opbarid
, nsel
== false);
1481 function toggleSelectFBListRow(sender
) {
1482 toggleSelectListRow(sender
);
1483 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1488 function pref_hotkey_handler(e
) {
1492 var shift_key
= false;
1495 shift_key
= e
.shiftKey
;
1501 keycode
= window
.event
.keyCode
;
1506 var keychar
= String
.fromCharCode(keycode
);
1508 if (keycode
== 27) { // escape
1509 if (Element
.visible("hotkey_help_overlay")) {
1510 Element
.hide("hotkey_help_overlay");
1512 hotkey_prefix
= false;
1516 if (!hotkeys_enabled
) {
1517 debug("hotkeys disabled");
1521 if (keycode
== 16) return; // ignore lone shift
1523 if ((keycode
== 67 || keycode
== 71) && !hotkey_prefix
) {
1524 hotkey_prefix
= keycode
;
1525 debug("KP: PREFIX=" + keycode
+ " CHAR=" + keychar
);
1529 if (Element
.visible("hotkey_help_overlay")) {
1530 Element
.hide("hotkey_help_overlay");
1533 if (keycode
== 13 || keycode
== 27) {
1536 seq
= seq
+ "" + keycode
;
1539 /* Global hotkeys */
1541 if (!hotkey_prefix
) {
1543 if (keycode
== 68 && shift_key
) { // d
1544 if (!Element
.visible("debug_output")) {
1545 Element
.show("debug_output");
1546 debug('debug mode activated');
1548 Element
.hide("debug_output");
1553 if ((keycode
== 191 || keychar
== '?') && shift_key
) { // ?
1554 if (!Element
.visible("hotkey_help_overlay")) {
1555 //Element.show("hotkey_help_overlay");
1556 Effect
.Appear("hotkey_help_overlay", {duration
: 0.3});
1558 Element
.hide("hotkey_help_overlay");
1563 if (keycode
== 191 || keychar
== '/') { // /
1564 var search_boxes
= new Array("label_search",
1565 "feed_search", "filter_search", "user_search", "feed_browser_search");
1567 for (var i
= 0; i
< search_boxes
.length
; i
++) {
1568 var elem
= document
.getElementById(search_boxes
[i
]);
1570 focus_element(search_boxes
[i
]);
1579 if (hotkey_prefix
== 67) { // c
1580 hotkey_prefix
= false;
1582 if (keycode
== 70) { // f
1583 displayDlg("quickAddFilter");
1587 if (keycode
== 83) { // s
1588 displayDlg("quickAddFeed");
1592 /* if (keycode == 76) { // l
1593 displayDlg("quickAddLabel");
1597 if (keycode
== 85) { // u
1601 if (keycode
== 67) { // c
1606 if (keycode
== 84 && shift_key
) { // T
1615 if (hotkey_prefix
== 71) { // g
1617 hotkey_prefix
= false;
1619 if (keycode
== 49 && document
.getElementById("genConfigTab")) { // 1
1620 selectTab("genConfig");
1624 if (keycode
== 50 && document
.getElementById("feedConfigTab")) { // 2
1625 selectTab("feedConfig");
1629 if (keycode
== 51 && document
.getElementById("filterConfigTab")) { // 4
1630 selectTab("filterConfig");
1634 if (keycode
== 52 && document
.getElementById("labelConfigTab")) { // 5
1635 selectTab("labelConfig");
1639 if (keycode
== 53 && document
.getElementById("userConfigTab")) { // 6
1640 selectTab("userConfig");
1644 if (keycode
== 88) { // x
1650 if (document
.getElementById("piggie")) {
1652 if (seq
.match("807371717369")) {
1660 if (hotkey_prefix
) {
1661 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
+ " CHAR=" + keychar
);
1663 debug("KP: CODE=" + keycode
+ " CHAR=" + keychar
);
1667 exception_error("pref_hotkey_handler", e
);
1671 function editFeedCats() {
1672 if (!xmlhttp_ready(xmlhttp
)) {
1673 printLockingError();
1677 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1680 document
.getElementById("top25_feeds_btn").disabled
= true;
1682 // this button is not always available, no-op if not found
1685 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1686 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1690 function showFeedsWithErrors() {
1691 displayDlg('feedUpdateErrors');
1694 function changeUserPassword() {
1698 if (!xmlhttp_ready(xmlhttp
)) {
1699 printLockingError();
1703 var f
= document
.forms
["change_pass_form"];
1706 if (f
.OLD_PASSWORD
.value
== "") {
1707 new Effect
.Highlight(f
.OLD_PASSWORD
);
1708 notify_error("Old password cannot be blank.");
1712 if (f
.NEW_PASSWORD
.value
== "") {
1713 new Effect
.Highlight(f
.NEW_PASSWORD
);
1714 notify_error("New password cannot be blank.");
1718 if (f
.CONFIRM_PASSWORD
.value
== "") {
1719 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1720 notify_error("Entered passwords do not match.");
1724 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1725 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1726 new Effect
.Highlight(f
.NEW_PASSWORD
);
1727 notify_error("Entered passwords do not match.");
1733 var query
= Form
.serialize("change_pass_form");
1735 notify_progress("Trying to change password...");
1737 xmlhttp
.open("POST", "backend.php", true);
1738 xmlhttp
.onreadystatechange
=changepass_callback
;
1739 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1740 xmlhttp
.send(query
);
1743 exception_error("changeUserPassword", e
);
1749 function changeUserEmail() {
1753 if (!xmlhttp_ready(xmlhttp
)) {
1754 printLockingError();
1758 var query
= Form
.serialize("change_email_form");
1760 notify_progress("Trying to change e-mail...");
1762 xmlhttp
.open("POST", "backend.php", true);
1763 xmlhttp
.onreadystatechange
=notify_callback
;
1764 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1765 xmlhttp
.send(query
);
1768 exception_error("changeUserPassword", e
);
1775 function feedlistToggleSLAT() {
1776 notify_progress("Loading, please wait...");
1780 function pubRegenKey() {
1782 if (!xmlhttp_ready(xmlhttp
)) {
1783 printLockingError();
1787 var ok
= confirm(__("Replace current publishing address with a new one?"));
1791 notify_progress("Trying to change address...");
1793 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1794 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1801 function pubToClipboard() {
1805 if (!xmlhttp_ready(xmlhttp
)) {
1806 printLockingError();
1810 var link
= document
.getElementById("pubGenAddress");
1814 exception_error("pubToClipboard", e
);
1820 function validatePrefsSave() {
1823 var ok
= confirm(__("Save current configuration?"));
1827 var query
= Form
.serialize("pref_prefs_form");
1828 query
= query
+ "&subop=save-config";
1831 xmlhttp
.open("POST", "backend.php", true);
1832 xmlhttp
.onreadystatechange
=notify_callback
;
1833 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1834 xmlhttp
.send(query
);
1838 exception_error("validatePrefsSave", e
);
1844 function feedActionChange() {
1846 var chooser
= document
.getElementById("feedActionChooser");
1847 var opid
= chooser
[chooser
.selectedIndex
].value
;
1849 chooser
.selectedIndex
= 0;
1852 exception_error("feedActionChange", e
);
1856 function feedActionGo(op
) {
1858 if (op
== "facEdit") {
1860 var rows
= getSelectedFeeds();
1862 if (rows
.length
> 1) {
1863 editSelectedFeeds();
1869 if (op
== "facClear") {
1870 clearSelectedFeeds();
1873 if (op
== "facPurge") {
1874 purgeSelectedFeeds();
1877 if (op
== "facEditCats") {
1881 if (op
== "facRescore") {
1882 rescoreSelectedFeeds();
1885 if (op
== "facUnsubscribe") {
1886 removeSelectedFeeds();
1890 exception_error("feedActionGo", e
);
1895 function clearFeedArticles(feed_id
) {
1897 notify_progress("Clearing feed...");
1899 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
1901 new Ajax
.Request(query
, {
1902 onComplete: function(transport
) {
1909 function rescoreSelectedFeeds() {
1911 if (!xmlhttp_ready(xmlhttp
)) {
1912 printLockingError();
1916 var sel_rows
= getSelectedFeeds();
1918 if (sel_rows
.length
> 0) {
1920 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
1921 var ok
= confirm(__("Rescore articles in selected feeds?"));
1924 notify_progress("Rescoring selected feeds...", true);
1926 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
1927 param_escape(sel_rows
.toString()), true);
1928 xmlhttp
.onreadystatechange
=notify_callback
;
1932 alert(__("No feeds are selected."));
1938 function rescore_all_feeds() {
1939 var ok
= confirm(__("Rescore all articles? This operation may take a lot of time."));
1942 notify_progress("Rescoring feeds...", true);
1944 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
1945 xmlhttp
.onreadystatechange
=notify_callback
;
1950 function removeFilter(id
, title
) {
1952 if (!xmlhttp_ready(xmlhttp
)) {
1953 printLockingError();
1957 var msg
= __("Remove filter %s?").replace("%s", title
);
1959 var ok
= confirm(msg
);
1964 notify_progress("Removing filter...");
1966 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
1967 param_escape(id
), true);
1968 xmlhttp
.onreadystatechange
=filterlist_callback
;
1975 function unsubscribeFeed(id
, title
) {
1977 if (!xmlhttp_ready(xmlhttp
)) {
1978 printLockingError();
1982 var msg
= __("Unsubscribe from %s?").replace("%s", title
);
1984 var ok
= confirm(msg
);
1989 notify_progress("Removing feed...");
1991 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
1992 param_escape(id
), true);
1993 xmlhttp
.onreadystatechange
=filterlist_callback
;
2003 function feedsEditSave() {
2006 if (!xmlhttp_ready(xmlhttp
)) {
2007 printLockingError();
2011 var ok
= confirm(__("Save changes to selected feeds?"));
2015 var f
= document
.forms
["batch_edit_feed_form"];
2017 var query
= Form
.serialize("batch_edit_feed_form");
2019 /* Form.serialize ignores unchecked checkboxes */
2021 if (!query
.match("&hidden=") &&
2022 f
.hidden
.disabled
== false) {
2023 query
= query
+ "&hidden=false";
2026 if (!query
.match("&rtl_content=") &&
2027 f
.rtl_content
.disabled
== false) {
2028 query
= query
+ "&rtl_content=false";
2031 if (!query
.match("&private=") &&
2032 f
.private.disabled
== false) {
2033 query
= query
+ "&private=false";
2036 if (!query
.match("&cache_images=") &&
2037 f
.cache_images
.disabled
== false) {
2038 query
= query
+ "&cache_images=false";
2041 if (!query
.match("&include_in_digest=") &&
2042 f
.include_in_digest
.disabled
== false) {
2043 query
= query
+ "&include_in_digest=false";
2048 notify_progress("Saving feeds...");
2050 xmlhttp
.open("POST", "backend.php", true);
2051 xmlhttp
.onreadystatechange
=feedlist_callback
;
2052 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2053 xmlhttp
.send(query
);
2058 exception_error("feedsEditSave", e
);
2062 function batchFeedsToggleField(cb
, elem
, label
) {
2064 var f
= document
.forms
["batch_edit_feed_form"];
2065 var l
= document
.getElementById(label
);
2068 f
[elem
].disabled
= false;
2074 // new Effect.Highlight(f[elem], {duration: 1, startcolor: "#fff7d5",
2075 // queue: { position:'end', scope: 'BPEFQ', limit: 1 } } );
2078 f
[elem
].disabled
= true;
2081 l
.className
= "insensitive";
2086 exception_error("batchFeedsToggleField", e
);