3 var active_feed_cat
= false;
4 var active_tab
= false;
5 var feed_to_expand
= false;
7 var xmlhttp
= Ajax
.getTransport();
9 var init_params
= new Array();
11 var caller_subop
= false;
12 var sanity_check_done
= false;
13 var hotkey_prefix
= false;
15 function infobox_callback() {
16 if (xmlhttp
.readyState
== 4) {
17 infobox_callback2(xmlhttp
);
21 function infobox_submit_callback() {
22 if (xmlhttp
.readyState
== 4) {
23 infobox_submit_callback2(xmlhttp
);
28 function replace_pubkey_callback() {
29 if (xmlhttp
.readyState
== 4) {
31 var link
= document
.getElementById("pubGenAddress");
33 if (xmlhttp
.responseXML
) {
35 var new_link
= xmlhttp
.responseXML
.getElementsByTagName("link")[0];
38 link
.href
= new_link
.firstChild
.nodeValue
;
39 //link.innerHTML = new_link.firstChild.nodeValue;
41 new Effect
.Highlight(link
);
43 notify_info("Published feed URL changed.");
45 notify_error("Could not change feed URL.");
49 notify_error("Could not change feed URL.");
52 exception_error("replace_pubkey_callback", e
);
57 function expand_feed_callback() {
58 if (xmlhttp
.readyState
== 4) {
60 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
61 container
.innerHTML
=xmlhttp
.responseText
;
62 // container.style.display = "block";
63 Effect
.Appear(container
, {duration
: 0.5});
66 exception_error("expand_feed_callback", e
);
71 function feedlist_callback() {
72 if (xmlhttp
.readyState
== 4) {
74 var container
= document
.getElementById('prefContent');
75 container
.innerHTML
=xmlhttp
.responseText
;
76 selectTab("feedConfig", true);
79 var tuple
= caller_subop
.split(":");
80 if (tuple
[0] == 'editFeed') {
81 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
86 if (typeof correctPNG
!= 'undefined') {
93 exception_error("feedlist_callback", e
);
98 /* stub for subscription dialog */
100 function dlg_frefresh_callback(transport
) {
103 var container
= document
.getElementById('prefContent');
104 container
.innerHTML
=transport
.responseText
;
105 selectTab("feedConfig", true);
108 var tuple
= caller_subop
.split(":");
109 if (tuple
[0] == 'editFeed') {
110 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
113 caller_subop
= false;
115 if (typeof correctPNG
!= 'undefined') {
120 exception_error("feedlist_callback", e
);
125 function filterlist_callback() {
126 var container
= document
.getElementById('prefContent');
127 if (xmlhttp
.readyState
== 4) {
128 container
.innerHTML
=xmlhttp
.responseText
;
129 if (typeof correctPNG
!= 'undefined') {
137 function labellist_callback() {
141 var container
= document
.getElementById('prefContent');
142 if (xmlhttp
.readyState
== 4) {
144 container
.innerHTML
=xmlhttp
.responseText
;
146 if (document
.getElementById("prefLabelList")) {
147 var elems
= document
.getElementById("prefLabelList").getElementsByTagName("SPAN");
149 for (var i
= 0; i
< elems
.length
; i
++) {
150 if (elems
[i
].id
&& elems
[i
].id
.match("LILT-")) {
152 var id
= elems
[i
].id
.replace("LILT-", "");
153 new Ajax
.InPlaceEditor(elems
[i
],
154 'backend.php?op=pref-labels&subop=save&id=' + id
,
155 {cols
: 20, rows
: 1});
160 if (typeof correctPNG
!= 'undefined') {
168 exception_error("labellist_callback", e
);
172 function feed_browser_callback() {
173 var container
= document
.getElementById('prefContent');
174 if (xmlhttp
.readyState
== 4) {
175 container
.innerHTML
=xmlhttp
.responseText
;
181 function userlist_callback() {
182 var container
= document
.getElementById('prefContent');
183 if (xmlhttp
.readyState
== 4) {
184 container
.innerHTML
=xmlhttp
.responseText
;
190 function prefslist_callback() {
191 var container
= document
.getElementById('prefContent');
192 if (xmlhttp
.readyState
== 4) {
193 container
.innerHTML
=xmlhttp
.responseText
;
199 function gethelp_callback() {
200 var container
= document
.getElementById('prefHelpBox');
201 if (xmlhttp
.readyState
== 4) {
203 container
.innerHTML
= xmlhttp
.responseText
;
204 container
.style
.display
= "block";
209 function notify_callback() {
210 if (xmlhttp
.readyState
== 4) {
211 notify_info(xmlhttp
.responseText
);
215 function prefs_reset_callback() {
216 if (xmlhttp
.readyState
== 4) {
217 notify_info(xmlhttp
.responseText
);
223 function changepass_callback() {
225 if (xmlhttp
.readyState
== 4) {
227 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
228 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
230 notify_info(xmlhttp
.responseText
);
231 var warn
= document
.getElementById("default_pass_warning");
232 if (warn
) warn
.style
.display
= "none";
235 document
.forms
['change_pass_form'].reset();
239 exception_error("changepass_callback", e
);
243 function init_cat_inline_editor() {
246 if (document
.getElementById("prefFeedCatList")) {
247 var elems
= document
.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
249 for (var i
= 0; i
< elems
.length
; i
++) {
250 if (elems
[i
].id
&& elems
[i
].id
.match("FCATT-")) {
251 var cat_id
= elems
[i
].id
.replace("FCATT-", "");
252 new Ajax
.InPlaceEditor(elems
[i
],
253 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id
);
259 exception_error("init_cat_inline_editor", e
);
263 function infobox_feed_cat_callback() {
264 if (xmlhttp
.readyState
== 4) {
268 init_cat_inline_editor();
271 exception_error("infobox_feed_cat_callback", e
);
276 function updateFeedList(sort_key
) {
278 if (!xmlhttp_ready(xmlhttp
)) {
283 var feed_search
= document
.getElementById("feed_search");
285 if (feed_search
) { search
= feed_search
.value
; }
287 var slat
= document
.getElementById("show_last_article_times");
289 var slat_checked
= false;
291 slat_checked
= slat
.checked
;
294 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
295 "&sort=" + param_escape(sort_key
) +
296 "&slat=" + param_escape(slat_checked
) +
297 "&search=" + param_escape(search
), true);
298 xmlhttp
.onreadystatechange
=feedlist_callback
;
303 function updateUsersList(sort_key
) {
305 if (!xmlhttp_ready(xmlhttp
)) {
310 var user_search
= document
.getElementById("user_search");
312 if (user_search
) { search
= user_search
.value
; }
314 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
315 + param_escape(sort_key
) +
316 "&search=" + param_escape(search
), true);
317 xmlhttp
.onreadystatechange
=userlist_callback
;
322 function addLabel() {
326 if (!xmlhttp_ready(xmlhttp
)) {
331 var caption
= prompt(__("Please enter label caption:"), "");
333 if (caption
== null) {
338 alert(__("Can't create label: missing caption."));
342 // we can be called from some other tab
343 active_tab
= "labelConfig";
345 var query
= "caption=" + param_escape(caption
);
347 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
348 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
352 exception_error("addLabel", e
);
358 if (!xmlhttp_ready(xmlhttp
)) {
363 var link
= document
.getElementById("fadd_link");
365 if (link
.value
.length
== 0) {
366 alert(__("Error: No feed URL given."));
367 } else if (!isValidURL(link
.value
)) {
368 alert(__("Error: Invalid feed URL."));
370 notify_progress("Adding feed...");
372 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
373 param_escape(link
.value
), true);
374 xmlhttp
.onreadystatechange
=feedlist_callback
;
383 function addFeedCat() {
385 if (!xmlhttp_ready(xmlhttp
)) {
390 var cat
= document
.getElementById("fadd_cat");
392 if (cat
.value
.length
== 0) {
393 alert(__("Can't add category: no name specified."));
395 notify_progress("Adding feed category...");
397 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
398 param_escape(cat
.value
), true);
399 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
409 if (!xmlhttp_ready(xmlhttp
)) {
414 var sqlexp
= document
.getElementById("uadd_box");
416 if (sqlexp
.value
.length
== 0) {
417 alert(__("Can't add user: no login specified."));
419 notify_progress("Adding user...");
421 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
422 param_escape(sqlexp
.value
), true);
424 xmlhttp
.onreadystatechange
=userlist_callback
;
432 function editUser(id
) {
434 if (!xmlhttp_ready(xmlhttp
)) {
441 notify_progress("Loading, please wait...");
443 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
444 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
446 disableContainerChildren("userOpToolbar", false);
448 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
449 param_escape(id
), true);
450 xmlhttp
.onreadystatechange
=infobox_callback
;
455 function editFilter(id
) {
457 if (!xmlhttp_ready(xmlhttp
)) {
464 notify_progress("Loading, please wait...");
466 // document.getElementById("create_filter_btn").disabled = true;
468 disableContainerChildren("filterOpToolbar", false);
470 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
471 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
473 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
474 xmlhttp
.onreadystatechange
=infobox_callback
;
478 function editFeed(feed
) {
480 // notify("Editing feed...");
482 if (!xmlhttp_ready(xmlhttp
)) {
489 notify_progress("Loading, please wait...");
491 /* document.getElementById("subscribe_to_feed_btn").disabled = true;
494 document.getElementById("top25_feeds_btn").disabled = true;
496 // this button is not always available, no-op if not found
499 // clean selection from all rows & select row being edited
500 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
501 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
503 disableContainerChildren("feedOpToolbar", false);
505 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
506 param_escape(feed
), true);
508 xmlhttp
.onreadystatechange
=infobox_callback
;
513 function editFeedCat(cat
) {
515 if (!xmlhttp_ready(xmlhttp
)) {
522 notify_progress("Loading, please wait...");
524 active_feed_cat
= cat
;
526 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
527 param_escape(cat
), true);
528 xmlhttp
.onreadystatechange
=infobox_callback
;
533 function getSelectedLabels() {
534 return getSelectedTableRowIds("prefLabelList", "LILRR");
537 function getSelectedUsers() {
538 return getSelectedTableRowIds("prefUserList", "UMRR");
541 function getSelectedFeeds() {
542 return getSelectedTableRowIds("prefFeedList", "FEEDR");
545 function getSelectedFilters() {
546 return getSelectedTableRowIds("prefFilterList", "FILRR");
549 function getSelectedFeedCats() {
550 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
554 function removeSelectedLabels() {
556 if (!xmlhttp_ready(xmlhttp
)) {
561 var sel_rows
= getSelectedLabels();
563 if (sel_rows
.length
> 0) {
565 var ok
= confirm(__("Remove selected labels?"));
568 notify_progress("Removing selected labels...");
570 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
571 param_escape(sel_rows
.toString()), true);
572 xmlhttp
.onreadystatechange
=labellist_callback
;
576 alert(__("No labels are selected."));
582 function removeSelectedUsers() {
584 if (!xmlhttp_ready(xmlhttp
)) {
589 var sel_rows
= getSelectedUsers();
591 if (sel_rows
.length
> 0) {
593 var ok
= confirm(__("Remove selected users?"));
596 notify_progress("Removing selected users...");
598 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
599 param_escape(sel_rows
.toString()), true);
600 xmlhttp
.onreadystatechange
=userlist_callback
;
605 alert(__("No users are selected."));
611 function removeSelectedFilters() {
613 if (!xmlhttp_ready(xmlhttp
)) {
618 var sel_rows
= getSelectedFilters();
620 if (sel_rows
.length
> 0) {
622 var ok
= confirm(__("Remove selected filters?"));
625 notify_progress("Removing selected filters...");
627 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
628 param_escape(sel_rows
.toString()), true);
629 xmlhttp
.onreadystatechange
=filterlist_callback
;
633 alert(__("No filters are selected."));
640 function removeSelectedFeeds() {
642 if (!xmlhttp_ready(xmlhttp
)) {
647 var sel_rows
= getSelectedFeeds();
649 if (sel_rows
.length
> 0) {
651 var ok
= confirm(__("Unsubscribe from selected feeds?"));
655 notify_progress("Unsubscribing from selected feeds...");
657 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
658 param_escape(sel_rows
.toString()), true);
659 xmlhttp
.onreadystatechange
=feedlist_callback
;
665 alert(__("No feeds are selected."));
672 function clearSelectedFeeds() {
674 if (!xmlhttp_ready(xmlhttp
)) {
679 var sel_rows
= getSelectedFeeds();
681 if (sel_rows
.length
> 1) {
682 alert(__("Please select only one feed."));
686 if (sel_rows
.length
> 0) {
688 var ok
= confirm(__("Erase all non-starred articles in selected feed?"));
691 notify_progress("Clearing selected feed...");
692 clearFeedArticles(sel_rows
[0]);
697 alert(__("No feeds are selected."));
704 function purgeSelectedFeeds() {
706 if (!xmlhttp_ready(xmlhttp
)) {
711 var sel_rows
= getSelectedFeeds();
713 if (sel_rows
.length
> 0) {
715 var pr
= prompt(__("How many days of articles to keep (0 - use default)?"), "0");
717 if (pr
!= undefined) {
718 notify_progress("Purging selected feed...");
720 var query
= "backend.php?op=rpc&subop=purge&ids="+
721 param_escape(sel_rows
.toString()) + "&days=" + pr
;
725 new Ajax
.Request(query
, {
726 onComplete: function(transport
) {
733 alert(__("No feeds are selected."));
740 function removeSelectedFeedCats() {
742 if (!xmlhttp_ready(xmlhttp
)) {
747 var sel_rows
= getSelectedFeedCats();
749 if (sel_rows
.length
> 0) {
751 var ok
= confirm(__("Remove selected categories?"));
754 notify_progress("Removing selected categories...");
756 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
757 param_escape(sel_rows
.toString()), true);
758 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
764 alert(__("No categories are selected."));
771 function feedEditCancel() {
773 if (!xmlhttp_ready(xmlhttp
)) {
779 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
780 document
.getElementById("top25_feeds_btn").disabled
= false;
782 // this button is not always available, no-op if not found
787 selectPrefRows('feed', false); // cleanup feed selection
792 function feedCatEditCancel() {
794 if (!xmlhttp_ready(xmlhttp
)) {
799 active_feed_cat
= false;
802 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
803 document
.getElementById("top25_feeds_btn").disabled
= false;
805 // this button is not always available, no-op if not found
808 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
809 xmlhttp
.onreadystatechange
=infobox_callback
;
815 function feedEditSave() {
819 if (!xmlhttp_ready(xmlhttp
)) {
824 // FIXME: add parameter validation
826 var query
= Form
.serialize("edit_feed_form");
828 notify_progress("Saving feed...");
830 xmlhttp
.open("POST", "backend.php", true);
831 xmlhttp
.onreadystatechange
=feedlist_callback
;
832 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
840 exception_error("feedEditSave", e
);
844 function userEditCancel() {
846 if (!xmlhttp_ready(xmlhttp
)) {
851 selectPrefRows('user', false); // cleanup feed selection
857 function filterEditCancel() {
859 if (!xmlhttp_ready(xmlhttp
)) {
865 document
.getElementById("create_filter_btn").disabled
= false;
866 selectPrefRows('filter', false); // cleanup feed selection
874 function userEditSave() {
876 if (!xmlhttp_ready(xmlhttp
)) {
881 var login
= document
.forms
["user_edit_form"].login
.value
;
883 if (login
.length
== 0) {
884 alert(__("Login field cannot be blank."));
888 notify_progress("Saving user...");
892 var query
= Form
.serialize("user_edit_form");
894 xmlhttp
.open("GET", "backend.php?" + query
, true);
895 xmlhttp
.onreadystatechange
=userlist_callback
;
902 function filterEditSave() {
904 if (!xmlhttp_ready(xmlhttp
)) {
909 /* if (!is_opera()) {
910 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
912 if (reg_exp.length == 0) {
913 alert("Filter expression field cannot be blank.");
918 notify_progress("Saving filter...");
920 var query
= Form
.serialize("filter_edit_form");
924 document
.getElementById("create_filter_btn").disabled
= false;
926 xmlhttp
.open("GET", "backend.php?" + query
, true);
927 xmlhttp
.onreadystatechange
=filterlist_callback
;
934 function editSelectedUser() {
935 var rows
= getSelectedUsers();
937 if (rows
.length
== 0) {
938 alert(__("No users are selected."));
942 if (rows
.length
> 1) {
943 alert(__("Please select only one user."));
952 function resetSelectedUserPass() {
953 var rows
= getSelectedUsers();
955 if (rows
.length
== 0) {
956 alert(__("No users are selected."));
960 if (rows
.length
> 1) {
961 alert(__("Please select only one user."));
965 var ok
= confirm(__("Reset password of selected user?"));
968 notify_progress("Resetting password for selected user...");
972 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
973 param_escape(id
), true);
974 xmlhttp
.onreadystatechange
=userlist_callback
;
979 function selectedUserDetails() {
981 if (!xmlhttp_ready(xmlhttp
)) {
986 var rows
= getSelectedUsers();
988 if (rows
.length
== 0) {
989 alert(__("No users are selected."));
993 if (rows
.length
> 1) {
994 alert(__("Please select only one user."));
998 notify_progress("Loading, please wait...");
1002 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=user-details&id=" + id
, true);
1003 xmlhttp
.onreadystatechange
=infobox_callback
;
1008 function selectedFeedDetails() {
1010 if (!xmlhttp_ready(xmlhttp
)) {
1011 printLockingError();
1015 var rows
= getSelectedFeeds();
1017 if (rows
.length
== 0) {
1018 alert(__("No feeds are selected."));
1022 if (rows
.length
> 1) {
1023 alert(__("Please select only one feed."));
1027 // var id = rows[0];
1031 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1032 param_escape(rows
.toString()), true);
1033 xmlhttp
.onreadystatechange
=infobox_callback
;
1038 function editSelectedFilter() {
1039 var rows
= getSelectedFilters();
1041 if (rows
.length
== 0) {
1042 alert(__("No filters are selected."));
1046 if (rows
.length
> 1) {
1047 alert(__("Please select only one filter."));
1053 editFilter(rows
[0]);
1058 function editSelectedFeed() {
1059 var rows
= getSelectedFeeds();
1061 if (rows
.length
== 0) {
1062 alert(__("No feeds are selected."));
1066 if (rows
.length
> 1) {
1067 alert(__("Please select one feed."));
1077 function editSelectedFeeds() {
1079 if (!xmlhttp_ready(xmlhttp
)) {
1080 printLockingError();
1084 var rows
= getSelectedFeeds();
1086 if (rows
.length
== 0) {
1087 alert(__("No feeds are selected."));
1095 notify_progress("Loading, please wait...");
1097 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeeds&ids=" +
1098 param_escape(rows
.toString()), true);
1100 xmlhttp
.onreadystatechange
=infobox_callback
;
1105 function editSelectedFeedCat() {
1106 var rows
= getSelectedFeedCats();
1108 if (rows
.length
== 0) {
1109 alert(__("No categories are selected."));
1113 if (rows
.length
> 1) {
1114 alert(__("Please select only one category."));
1120 editFeedCat(rows
[0]);
1124 function piggie(enable
) {
1126 debug("I LOVEDED IT!");
1127 var piggie
= document
.getElementById("piggie");
1129 Element
.show(piggie
);
1130 Position
.Center(piggie
);
1131 Effect
.Puff(piggie
);
1136 function validateOpmlImport() {
1138 var opml_file
= document
.getElementById("opml_file");
1140 if (opml_file
.value
.length
== 0) {
1141 alert(__("No OPML file to upload."));
1148 function updateFilterList(sort_key
) {
1150 if (!xmlhttp_ready(xmlhttp
)) {
1151 printLockingError();
1155 var filter_search
= document
.getElementById("filter_search");
1157 if (filter_search
) { search
= filter_search
.value
; }
1159 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1160 param_escape(sort_key
) +
1161 "&search=" + param_escape(search
), true);
1162 xmlhttp
.onreadystatechange
=filterlist_callback
;
1167 function updateLabelList(sort_key
) {
1169 if (!xmlhttp_ready(xmlhttp
)) {
1170 printLockingError();
1174 var label_search
= document
.getElementById("label_search");
1176 if (label_search
) { search
= label_search
.value
; }
1178 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1179 param_escape(sort_key
) +
1180 "&search=" + param_escape(search
), true);
1181 xmlhttp
.onreadystatechange
=labellist_callback
;
1185 function updatePrefsList() {
1187 if (!xmlhttp_ready(xmlhttp
)) {
1188 printLockingError();
1192 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1193 xmlhttp
.onreadystatechange
=prefslist_callback
;
1198 function selectTab(id
, noupdate
, subop
) {
1202 if (!id
) id
= active_tab
;
1206 if (!xmlhttp_ready(xmlhttp
)) {
1207 printLockingError();
1212 var c
= document
.getElementById('prefContent');
1218 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1220 notify_progress("Loading, please wait...");
1222 // close active infobox if needed
1225 // clean up all current selections, just in case
1226 active_feed_cat
= false;
1228 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1229 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1231 if (id
== "feedConfig") {
1233 } else if (id
== "filterConfig") {
1235 } else if (id
== "labelConfig") {
1237 } else if (id
== "genConfig") {
1239 } else if (id
== "userConfig") {
1241 } else if (id
== "feedBrowser") {
1242 updateBigFeedBrowser();
1246 /* clean selection from all tabs */
1248 var tabs_holder
= document
.getElementById("prefTabs");
1249 var tab
= tabs_holder
.firstChild
;
1252 if (tab
.className
&& tab
.className
.match("prefsTabSelected")) {
1253 tab
.className
= "prefsTab";
1255 tab
= tab
.nextSibling
;
1258 /* mark new tab as selected */
1260 tab
= document
.getElementById(id
+ "Tab");
1263 if (!tab
.className
.match("Selected")) {
1264 tab
.className
= tab
.className
+ "Selected";
1271 exception_error("selectTab", e
);
1275 function backend_sanity_check_callback() {
1277 if (xmlhttp
.readyState
== 4) {
1281 if (sanity_check_done
) {
1282 fatalError(11, "Sanity check request received twice. This can indicate "+
1283 "presence of Firebug or some other disrupting extension. "+
1284 "Please disable it and try again.");
1288 if (!xmlhttp
.responseXML
) {
1289 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1293 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1296 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1300 var error_code
= reply
.getAttribute("error-code");
1302 if (error_code
&& error_code
!= 0) {
1303 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1306 debug("sanity check ok");
1308 var params
= reply
.nextSibling
;
1311 debug('reading init-params...');
1312 var param
= params
.firstChild
;
1315 var k
= param
.getAttribute("key");
1316 var v
= param
.getAttribute("value");
1317 debug(k
+ " => " + v
);
1319 param
= param
.nextSibling
;
1323 sanity_check_done
= true;
1325 init_second_stage();
1328 exception_error("backend_sanity_check_callback", e
);
1333 function init_second_stage() {
1336 active_tab
= getInitParam("prefs_active_tab");
1337 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1339 document
.onkeydown
= pref_hotkey_handler
;
1341 var tab
= getURLParam('tab');
1343 caller_subop
= getURLParam('subop');
1345 if (getURLParam("subopparam")) {
1346 caller_subop
= caller_subop
+ ":" + getURLParam("subopparam");
1353 if (navigator
.userAgent
.match("Opera")) {
1354 setTimeout("selectTab()", 500);
1356 selectTab(active_tab
);
1360 loading_set_progress(60);
1363 exception_error("init_second_stage", e
);
1371 if (arguments
.callee
.done
) return;
1372 arguments
.callee
.done
= true;
1374 if (getURLParam('debug')) {
1375 Element
.show("debug_output");
1376 debug('debug mode activated');
1381 document
.getElementById("prefContent").innerHTML
=
1382 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1383 "to function properly. Your browser doesn't seem to support it.";
1387 loading_set_progress(30);
1389 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1390 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1394 exception_error("init", e
);
1398 function categorizeSelectedFeeds() {
1400 if (!xmlhttp_ready(xmlhttp
)) {
1401 printLockingError();
1405 var sel_rows
= getSelectedFeeds();
1407 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1408 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1410 if (sel_rows
.length
> 0) {
1412 notify_progress("Changing category of selected feeds...");
1414 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1415 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1416 xmlhttp
.onreadystatechange
=feedlist_callback
;
1421 alert(__("No feeds are selected."));
1427 function validatePrefsReset() {
1429 var ok
= confirm(__("Reset to defaults?"));
1433 var query
= Form
.serialize("pref_prefs_form");
1434 query
= query
+ "&subop=reset-config";
1437 xmlhttp
.open("POST", "backend.php", true);
1438 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1439 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1440 xmlhttp
.send(query
);
1444 exception_error("validatePrefsSave", e
);
1451 function browseFeeds(limit
) {
1453 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1454 xmlhttp
.onreadystatechange
=infobox_callback
;
1459 function feedBrowserSubscribe() {
1462 var selected
= getSelectedFeedsFromBrowser();
1464 if (selected
.length
> 0) {
1466 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1467 param_escape(selected
.toString()), true);
1468 xmlhttp
.onreadystatechange
=feedlist_callback
;
1471 alert(__("No feeds are selected."));
1475 exception_error("feedBrowserSubscribe", e
);
1479 function updateBigFeedBrowserBtn() {
1480 notify_progress("Loading, please wait...");
1481 return updateBigFeedBrowser();
1484 function updateBigFeedBrowser(limit
, from_button
) {
1486 if (!xmlhttp_ready(xmlhttp
)) {
1487 printLockingError();
1491 var query
= "backend.php?op=pref-feed-browser";
1493 var limit_sel
= document
.getElementById("feedBrowserLimit");
1496 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1497 query
= query
+ "&limit=" + param_escape(limit
);
1500 var search
= document
.getElementById("feed_browser_search");
1503 query
= query
+ "&search=" + param_escape(search
.value
);
1506 xmlhttp
.open("GET", query
, true);
1507 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1511 function browserToggleExpand(id
) {
1513 /* if (feed_to_expand && feed_to_expand != id) {
1514 var d = document.getElementById("BRDET-" + feed_to_expand);
1515 d.style.display = "none";
1518 if (!xmlhttp_ready(xmlhttp
)) {
1519 printLockingError();
1523 /* if (feed_to_expand && id != feed_to_expand) {
1524 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1527 var d
= document
.getElementById("BRDET-" + id
);
1529 notify_progress("Loading, please wait...");
1531 if (Element
.visible(d
)) {
1532 Effect
.Fade(d
, {duration
: 0.5});
1534 feed_to_expand
= id
;
1536 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1537 + param_escape(id
), true);
1538 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1543 exception_error("browserToggleExpand", e
);
1547 function selectPrefRows(kind
, select
) {
1550 var opbarid
= false;
1555 if (kind
== "feed") {
1556 opbarid
= "feedOpToolbar";
1559 lname
= "prefFeedList";
1560 } else if (kind
== "fcat") {
1561 opbarid
= "catOpToolbar";
1564 lname
= "prefFeedCatList";
1565 } else if (kind
== "filter") {
1566 opbarid
= "filterOpToolbar";
1569 lname
= "prefFilterList";
1570 } else if (kind
== "label") {
1571 opbarid
= "labelOpToolbar";
1574 lname
= "prefLabelList";
1575 } else if (kind
== "user") {
1576 opbarid
= "userOpToolbar";
1579 lname
= "prefUserList";
1583 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1584 disableContainerChildren(opbarid
, !select
);
1591 function toggleSelectPrefRow(sender
, kind
) {
1593 toggleSelectRow(sender
);
1596 var opbarid
= false;
1599 if (kind
== "feed") {
1600 opbarid
= "feedOpToolbar";
1601 nsel
= getSelectedFeeds();
1602 } else if (kind
== "fcat") {
1603 opbarid
= "catOpToolbar";
1604 nsel
= getSelectedFeedCats();
1605 } else if (kind
== "filter") {
1606 opbarid
= "filterOpToolbar";
1607 nsel
= getSelectedFilters();
1608 } else if (kind
== "label") {
1609 opbarid
= "labelOpToolbar";
1610 nsel
= getSelectedLabels();
1611 } else if (kind
== "user") {
1612 opbarid
= "userOpToolbar";
1613 nsel
= getSelectedUsers();
1616 if (opbarid
&& nsel
!= -1) {
1617 disableContainerChildren(opbarid
, nsel
== false);
1623 function toggleSelectFBListRow(sender
) {
1624 toggleSelectListRow(sender
);
1625 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1630 function pref_hotkey_handler(e
) {
1634 var shift_key
= false;
1637 shift_key
= e
.shiftKey
;
1643 keycode
= window
.event
.keyCode
;
1648 var keychar
= String
.fromCharCode(keycode
);
1650 if (keycode
== 27) { // escape
1651 if (Element
.visible("hotkey_help_overlay")) {
1652 Element
.hide("hotkey_help_overlay");
1654 hotkey_prefix
= false;
1658 if (!hotkeys_enabled
) {
1659 debug("hotkeys disabled");
1663 if (keycode
== 16) return; // ignore lone shift
1665 if ((keycode
== 67 || keycode
== 71) && !hotkey_prefix
) {
1666 hotkey_prefix
= keycode
;
1667 debug("KP: PREFIX=" + keycode
+ " CHAR=" + keychar
);
1671 if (Element
.visible("hotkey_help_overlay")) {
1672 Element
.hide("hotkey_help_overlay");
1675 if (keycode
== 13 || keycode
== 27) {
1678 seq
= seq
+ "" + keycode
;
1681 /* Global hotkeys */
1683 if (!hotkey_prefix
) {
1685 if (keycode
== 68 && shift_key
) { // d
1686 if (!Element
.visible("debug_output")) {
1687 Element
.show("debug_output");
1688 debug('debug mode activated');
1690 Element
.hide("debug_output");
1695 if ((keycode
== 191 || keychar
== '?') && shift_key
) { // ?
1696 if (!Element
.visible("hotkey_help_overlay")) {
1697 //Element.show("hotkey_help_overlay");
1698 Effect
.Appear("hotkey_help_overlay", {duration
: 0.3});
1700 Element
.hide("hotkey_help_overlay");
1705 if (keycode
== 191 || keychar
== '/') { // /
1706 var search_boxes
= new Array("label_search",
1707 "feed_search", "filter_search", "user_search", "feed_browser_search");
1709 for (var i
= 0; i
< search_boxes
.length
; i
++) {
1710 var elem
= document
.getElementById(search_boxes
[i
]);
1712 focus_element(search_boxes
[i
]);
1721 if (hotkey_prefix
== 67) { // c
1722 hotkey_prefix
= false;
1724 if (keycode
== 70) { // f
1725 displayDlg("quickAddFilter");
1729 if (keycode
== 83) { // s
1730 displayDlg("quickAddFeed");
1734 /* if (keycode == 76) { // l
1735 displayDlg("quickAddLabel");
1739 if (keycode
== 85) { // u
1743 if (keycode
== 67) { // c
1748 if (keycode
== 84 && shift_key
) { // T
1757 if (hotkey_prefix
== 71) { // g
1759 hotkey_prefix
= false;
1761 if (keycode
== 49 && document
.getElementById("genConfigTab")) { // 1
1762 selectTab("genConfig");
1766 if (keycode
== 50 && document
.getElementById("feedConfigTab")) { // 2
1767 selectTab("feedConfig");
1771 if (keycode
== 51 && document
.getElementById("feedBrowserTab")) { // 3
1772 selectTab("feedBrowser");
1776 if (keycode
== 52 && document
.getElementById("filterConfigTab")) { // 4
1777 selectTab("filterConfig");
1781 if (keycode
== 53 && document
.getElementById("labelConfigTab")) { // 5
1782 selectTab("labelConfig");
1786 if (keycode
== 54 && document
.getElementById("userConfigTab")) { // 6
1787 selectTab("userConfig");
1791 if (keycode
== 88) { // x
1797 if (document
.getElementById("piggie")) {
1799 if (seq
.match("807371717369")) {
1807 if (hotkey_prefix
) {
1808 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
+ " CHAR=" + keychar
);
1810 debug("KP: CODE=" + keycode
+ " CHAR=" + keychar
);
1814 exception_error("pref_hotkey_handler", e
);
1818 function editFeedCats() {
1819 if (!xmlhttp_ready(xmlhttp
)) {
1820 printLockingError();
1824 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1827 document
.getElementById("top25_feeds_btn").disabled
= true;
1829 // this button is not always available, no-op if not found
1832 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1833 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1837 function showFeedsWithErrors() {
1838 displayDlg('feedUpdateErrors');
1841 function changeUserPassword() {
1845 if (!xmlhttp_ready(xmlhttp
)) {
1846 printLockingError();
1850 var f
= document
.forms
["change_pass_form"];
1853 if (f
.OLD_PASSWORD
.value
== "") {
1854 new Effect
.Highlight(f
.OLD_PASSWORD
);
1855 notify_error("Old password cannot be blank.");
1859 if (f
.NEW_PASSWORD
.value
== "") {
1860 new Effect
.Highlight(f
.NEW_PASSWORD
);
1861 notify_error("New password cannot be blank.");
1865 if (f
.CONFIRM_PASSWORD
.value
== "") {
1866 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1867 notify_error("Entered passwords do not match.");
1871 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1872 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1873 new Effect
.Highlight(f
.NEW_PASSWORD
);
1874 notify_error("Entered passwords do not match.");
1880 var query
= Form
.serialize("change_pass_form");
1882 notify_progress("Trying to change password...");
1884 xmlhttp
.open("POST", "backend.php", true);
1885 xmlhttp
.onreadystatechange
=changepass_callback
;
1886 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1887 xmlhttp
.send(query
);
1890 exception_error("changeUserPassword", e
);
1896 function changeUserEmail() {
1900 if (!xmlhttp_ready(xmlhttp
)) {
1901 printLockingError();
1905 var query
= Form
.serialize("change_email_form");
1907 notify_progress("Trying to change e-mail...");
1909 xmlhttp
.open("POST", "backend.php", true);
1910 xmlhttp
.onreadystatechange
=notify_callback
;
1911 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1912 xmlhttp
.send(query
);
1915 exception_error("changeUserPassword", e
);
1922 function feedlistToggleSLAT() {
1923 notify_progress("Loading, please wait...");
1927 function pubRegenKey() {
1929 if (!xmlhttp_ready(xmlhttp
)) {
1930 printLockingError();
1934 var ok
= confirm(__("Replace current publishing address with a new one?"));
1938 notify_progress("Trying to change address...");
1940 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1941 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1948 function pubToClipboard() {
1952 if (!xmlhttp_ready(xmlhttp
)) {
1953 printLockingError();
1957 var link
= document
.getElementById("pubGenAddress");
1961 exception_error("pubToClipboard", e
);
1967 function validatePrefsSave() {
1970 var ok
= confirm(__("Save current configuration?"));
1974 var query
= Form
.serialize("pref_prefs_form");
1975 query
= query
+ "&subop=save-config";
1978 xmlhttp
.open("POST", "backend.php", true);
1979 xmlhttp
.onreadystatechange
=notify_callback
;
1980 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1981 xmlhttp
.send(query
);
1985 exception_error("validatePrefsSave", e
);
1991 function feedActionChange() {
1993 var chooser
= document
.getElementById("feedActionChooser");
1994 var opid
= chooser
[chooser
.selectedIndex
].value
;
1996 chooser
.selectedIndex
= 0;
1999 exception_error("feedActionChange", e
);
2003 function feedActionGo(op
) {
2005 if (op
== "facEdit") {
2007 var rows
= getSelectedFeeds();
2009 if (rows
.length
> 1) {
2010 editSelectedFeeds();
2016 if (op
== "facClear") {
2017 clearSelectedFeeds();
2020 if (op
== "facPurge") {
2021 purgeSelectedFeeds();
2024 if (op
== "facEditCats") {
2028 if (op
== "facRescore") {
2029 rescoreSelectedFeeds();
2032 if (op
== "facUnsubscribe") {
2033 removeSelectedFeeds();
2037 exception_error("feedActionGo", e
);
2042 function clearFeedArticles(feed_id
) {
2044 notify_progress("Clearing feed...");
2046 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
2048 new Ajax
.Request(query
, {
2049 onComplete: function(transport
) {
2056 function rescoreSelectedFeeds() {
2058 if (!xmlhttp_ready(xmlhttp
)) {
2059 printLockingError();
2063 var sel_rows
= getSelectedFeeds();
2065 if (sel_rows
.length
> 0) {
2067 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
2068 var ok
= confirm(__("Rescore articles in selected feeds?"));
2071 notify_progress("Rescoring selected feeds...", true);
2073 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
2074 param_escape(sel_rows
.toString()), true);
2075 xmlhttp
.onreadystatechange
=notify_callback
;
2079 alert(__("No feeds are selected."));
2085 function rescore_all_feeds() {
2086 var ok
= confirm(__("Rescore all articles? This operation may take a lot of time."));
2089 notify_progress("Rescoring feeds...", true);
2091 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
2092 xmlhttp
.onreadystatechange
=notify_callback
;
2097 function removeFilter(id
, title
) {
2099 if (!xmlhttp_ready(xmlhttp
)) {
2100 printLockingError();
2104 var msg
= __("Remove filter %s?").replace("%s", title
);
2106 var ok
= confirm(msg
);
2111 notify_progress("Removing filter...");
2113 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
2114 param_escape(id
), true);
2115 xmlhttp
.onreadystatechange
=filterlist_callback
;
2122 function unsubscribeFeed(id
, title
) {
2124 if (!xmlhttp_ready(xmlhttp
)) {
2125 printLockingError();
2129 var msg
= __("Unsubscribe from %s?").replace("%s", title
);
2131 var ok
= confirm(msg
);
2136 notify_progress("Removing feed...");
2138 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
2139 param_escape(id
), true);
2140 xmlhttp
.onreadystatechange
=filterlist_callback
;
2150 function feedsEditSave() {
2153 if (!xmlhttp_ready(xmlhttp
)) {
2154 printLockingError();
2158 var ok
= confirm(__("Save changes to selected feeds?"));
2162 var f
= document
.forms
["batch_edit_feed_form"];
2164 var query
= Form
.serialize("batch_edit_feed_form");
2166 /* Form.serialize ignores unchecked checkboxes */
2168 if (!query
.match("&hidden=") &&
2169 f
.hidden
.disabled
== false) {
2170 query
= query
+ "&hidden=false";
2173 if (!query
.match("&rtl_content=") &&
2174 f
.rtl_content
.disabled
== false) {
2175 query
= query
+ "&rtl_content=false";
2178 if (!query
.match("&private=") &&
2179 f
.private.disabled
== false) {
2180 query
= query
+ "&private=false";
2183 if (!query
.match("&cache_images=") &&
2184 f
.cache_images
.disabled
== false) {
2185 query
= query
+ "&cache_images=false";
2188 if (!query
.match("&include_in_digest=") &&
2189 f
.include_in_digest
.disabled
== false) {
2190 query
= query
+ "&include_in_digest=false";
2195 notify_progress("Saving feeds...");
2197 xmlhttp
.open("POST", "backend.php", true);
2198 xmlhttp
.onreadystatechange
=feedlist_callback
;
2199 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2200 xmlhttp
.send(query
);
2205 exception_error("feedsEditSave", e
);
2209 function batchFeedsToggleField(cb
, elem
, label
) {
2211 var f
= document
.forms
["batch_edit_feed_form"];
2212 var l
= document
.getElementById(label
);
2215 f
[elem
].disabled
= false;
2221 // new Effect.Highlight(f[elem], {duration: 1, startcolor: "#fff7d5",
2222 // queue: { position:'end', scope: 'BPEFQ', limit: 1 } } );
2225 f
[elem
].disabled
= true;
2228 l
.className
= "insensitive";
2233 exception_error("batchFeedsToggleField", e
);