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 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
447 param_escape(id
), true);
448 xmlhttp
.onreadystatechange
=infobox_callback
;
453 function editFilter(id
) {
455 if (!xmlhttp_ready(xmlhttp
)) {
462 notify_progress("Loading, please wait...");
464 // document.getElementById("create_filter_btn").disabled = true;
466 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
467 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
469 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
470 xmlhttp
.onreadystatechange
=infobox_callback
;
474 function editFeed(feed
) {
476 // notify("Editing feed...");
478 if (!xmlhttp_ready(xmlhttp
)) {
485 notify_progress("Loading, please wait...");
487 /* document.getElementById("subscribe_to_feed_btn").disabled = true;
490 document.getElementById("top25_feeds_btn").disabled = true;
492 // this button is not always available, no-op if not found
495 // clean selection from all rows & select row being edited
496 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
497 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
499 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
500 param_escape(feed
), true);
502 xmlhttp
.onreadystatechange
=infobox_callback
;
507 function editFeedCat(cat
) {
509 if (!xmlhttp_ready(xmlhttp
)) {
516 notify_progress("Loading, please wait...");
518 active_feed_cat
= cat
;
520 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
521 param_escape(cat
), true);
522 xmlhttp
.onreadystatechange
=infobox_callback
;
527 function getSelectedLabels() {
528 return getSelectedTableRowIds("prefLabelList", "LILRR");
531 function getSelectedUsers() {
532 return getSelectedTableRowIds("prefUserList", "UMRR");
535 function getSelectedFeeds() {
536 return getSelectedTableRowIds("prefFeedList", "FEEDR");
539 function getSelectedFilters() {
540 return getSelectedTableRowIds("prefFilterList", "FILRR");
543 function getSelectedFeedCats() {
544 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
547 function getSelectedFeedsFromBrowser() {
549 var list
= document
.getElementById("browseFeedList");
550 if (!list
) list
= document
.getElementById("browseBigFeedList");
552 var selected
= new Array();
554 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
555 var child
= list
.childNodes
[i
];
556 if (child
.id
&& child
.id
.match("FBROW-")) {
557 var id
= child
.id
.replace("FBROW-", "");
559 var cb
= document
.getElementById("FBCHK-" + id
);
570 function removeSelectedLabels() {
572 if (!xmlhttp_ready(xmlhttp
)) {
577 var sel_rows
= getSelectedLabels();
579 if (sel_rows
.length
> 0) {
581 var ok
= confirm(__("Remove selected labels?"));
584 notify_progress("Removing selected labels...");
586 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
587 param_escape(sel_rows
.toString()), true);
588 xmlhttp
.onreadystatechange
=labellist_callback
;
592 alert(__("No labels are selected."));
598 function removeSelectedUsers() {
600 if (!xmlhttp_ready(xmlhttp
)) {
605 var sel_rows
= getSelectedUsers();
607 if (sel_rows
.length
> 0) {
609 var ok
= confirm(__("Remove selected users?"));
612 notify_progress("Removing selected users...");
614 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
615 param_escape(sel_rows
.toString()), true);
616 xmlhttp
.onreadystatechange
=userlist_callback
;
621 alert(__("No users are selected."));
627 function removeSelectedFilters() {
629 if (!xmlhttp_ready(xmlhttp
)) {
634 var sel_rows
= getSelectedFilters();
636 if (sel_rows
.length
> 0) {
638 var ok
= confirm(__("Remove selected filters?"));
641 notify_progress("Removing selected filters...");
643 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
644 param_escape(sel_rows
.toString()), true);
645 xmlhttp
.onreadystatechange
=filterlist_callback
;
649 alert(__("No filters are selected."));
656 function removeSelectedFeeds() {
658 if (!xmlhttp_ready(xmlhttp
)) {
663 var sel_rows
= getSelectedFeeds();
665 if (sel_rows
.length
> 0) {
667 var ok
= confirm(__("Unsubscribe from selected feeds?"));
671 notify_progress("Unsubscribing from selected feeds...");
673 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
674 param_escape(sel_rows
.toString()), true);
675 xmlhttp
.onreadystatechange
=feedlist_callback
;
681 alert(__("No feeds are selected."));
688 function clearSelectedFeeds() {
690 if (!xmlhttp_ready(xmlhttp
)) {
695 var sel_rows
= getSelectedFeeds();
697 if (sel_rows
.length
> 1) {
698 alert(__("Please select only one feed."));
702 if (sel_rows
.length
> 0) {
704 var ok
= confirm(__("Erase all non-starred articles in selected feed?"));
707 notify_progress("Clearing selected feed...");
708 clearFeedArticles(sel_rows
[0]);
713 alert(__("No feeds are selected."));
720 function purgeSelectedFeeds() {
722 if (!xmlhttp_ready(xmlhttp
)) {
727 var sel_rows
= getSelectedFeeds();
729 if (sel_rows
.length
> 0) {
731 var pr
= prompt(__("How many days of articles to keep (0 - use default)?"), "0");
733 if (pr
!= undefined) {
734 notify_progress("Purging selected feed...");
736 var query
= "backend.php?op=rpc&subop=purge&ids="+
737 param_escape(sel_rows
.toString()) + "&days=" + pr
;
741 new Ajax
.Request(query
, {
742 onComplete: function(transport
) {
749 alert(__("No feeds are selected."));
756 function removeSelectedFeedCats() {
758 if (!xmlhttp_ready(xmlhttp
)) {
763 var sel_rows
= getSelectedFeedCats();
765 if (sel_rows
.length
> 0) {
767 var ok
= confirm(__("Remove selected categories?"));
770 notify_progress("Removing selected categories...");
772 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
773 param_escape(sel_rows
.toString()), true);
774 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
780 alert(__("No categories are selected."));
787 function feedEditCancel() {
789 if (!xmlhttp_ready(xmlhttp
)) {
795 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
796 document
.getElementById("top25_feeds_btn").disabled
= false;
798 // this button is not always available, no-op if not found
803 selectPrefRows('feed', false); // cleanup feed selection
808 function feedCatEditCancel() {
810 if (!xmlhttp_ready(xmlhttp
)) {
815 active_feed_cat
= false;
818 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
819 document
.getElementById("top25_feeds_btn").disabled
= false;
821 // this button is not always available, no-op if not found
824 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
825 xmlhttp
.onreadystatechange
=infobox_callback
;
831 function feedEditSave() {
835 if (!xmlhttp_ready(xmlhttp
)) {
840 // FIXME: add parameter validation
842 var query
= Form
.serialize("edit_feed_form");
844 notify_progress("Saving feed...");
846 xmlhttp
.open("POST", "backend.php", true);
847 xmlhttp
.onreadystatechange
=feedlist_callback
;
848 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
856 exception_error("feedEditSave", e
);
860 function userEditCancel() {
862 if (!xmlhttp_ready(xmlhttp
)) {
867 selectPrefRows('user', false); // cleanup feed selection
873 function filterEditCancel() {
875 if (!xmlhttp_ready(xmlhttp
)) {
881 document
.getElementById("create_filter_btn").disabled
= false;
882 selectPrefRows('filter', false); // cleanup feed selection
890 function userEditSave() {
892 if (!xmlhttp_ready(xmlhttp
)) {
897 var login
= document
.forms
["user_edit_form"].login
.value
;
899 if (login
.length
== 0) {
900 alert(__("Login field cannot be blank."));
904 notify_progress("Saving user...");
908 var query
= Form
.serialize("user_edit_form");
910 xmlhttp
.open("GET", "backend.php?" + query
, true);
911 xmlhttp
.onreadystatechange
=userlist_callback
;
918 function filterEditSave() {
920 if (!xmlhttp_ready(xmlhttp
)) {
925 /* if (!is_opera()) {
926 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
928 if (reg_exp.length == 0) {
929 alert("Filter expression field cannot be blank.");
934 notify_progress("Saving filter...");
936 var query
= Form
.serialize("filter_edit_form");
940 document
.getElementById("create_filter_btn").disabled
= false;
942 xmlhttp
.open("GET", "backend.php?" + query
, true);
943 xmlhttp
.onreadystatechange
=filterlist_callback
;
950 function editSelectedUser() {
951 var rows
= getSelectedUsers();
953 if (rows
.length
== 0) {
954 alert(__("No users are selected."));
958 if (rows
.length
> 1) {
959 alert(__("Please select only one user."));
968 function resetSelectedUserPass() {
969 var rows
= getSelectedUsers();
971 if (rows
.length
== 0) {
972 alert(__("No users are selected."));
976 if (rows
.length
> 1) {
977 alert(__("Please select only one user."));
981 var ok
= confirm(__("Reset password of selected user?"));
984 notify_progress("Resetting password for selected user...");
988 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
989 param_escape(id
), true);
990 xmlhttp
.onreadystatechange
=userlist_callback
;
995 function selectedUserDetails() {
997 if (!xmlhttp_ready(xmlhttp
)) {
1002 var rows
= getSelectedUsers();
1004 if (rows
.length
== 0) {
1005 alert(__("No users are selected."));
1009 if (rows
.length
> 1) {
1010 alert(__("Please select only one user."));
1014 notify_progress("Loading, please wait...");
1018 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=user-details&id=" + id
, true);
1019 xmlhttp
.onreadystatechange
=infobox_callback
;
1024 function selectedFeedDetails() {
1026 if (!xmlhttp_ready(xmlhttp
)) {
1027 printLockingError();
1031 var rows
= getSelectedFeeds();
1033 if (rows
.length
== 0) {
1034 alert(__("No feeds are selected."));
1038 if (rows
.length
> 1) {
1039 alert(__("Please select only one feed."));
1043 // var id = rows[0];
1047 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1048 param_escape(rows
.toString()), true);
1049 xmlhttp
.onreadystatechange
=infobox_callback
;
1054 function editSelectedFilter() {
1055 var rows
= getSelectedFilters();
1057 if (rows
.length
== 0) {
1058 alert(__("No filters are selected."));
1062 if (rows
.length
> 1) {
1063 alert(__("Please select only one filter."));
1069 editFilter(rows
[0]);
1074 function editSelectedFeed() {
1075 var rows
= getSelectedFeeds();
1077 if (rows
.length
== 0) {
1078 alert(__("No feeds are selected."));
1082 if (rows
.length
> 1) {
1083 alert(__("Please select one feed."));
1093 function editSelectedFeeds() {
1095 if (!xmlhttp_ready(xmlhttp
)) {
1096 printLockingError();
1100 var rows
= getSelectedFeeds();
1102 if (rows
.length
== 0) {
1103 alert(__("No feeds are selected."));
1111 notify_progress("Loading, please wait...");
1113 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeeds&ids=" +
1114 param_escape(rows
.toString()), true);
1116 xmlhttp
.onreadystatechange
=infobox_callback
;
1121 function editSelectedFeedCat() {
1122 var rows
= getSelectedFeedCats();
1124 if (rows
.length
== 0) {
1125 alert(__("No categories are selected."));
1129 if (rows
.length
> 1) {
1130 alert(__("Please select only one category."));
1136 editFeedCat(rows
[0]);
1140 function piggie(enable
) {
1142 debug("I LOVEDED IT!");
1143 var piggie
= document
.getElementById("piggie");
1145 Element
.show(piggie
);
1146 Position
.Center(piggie
);
1147 Effect
.Puff(piggie
);
1152 function validateOpmlImport() {
1154 var opml_file
= document
.getElementById("opml_file");
1156 if (opml_file
.value
.length
== 0) {
1157 alert(__("No OPML file to upload."));
1164 function updateFilterList(sort_key
) {
1166 if (!xmlhttp_ready(xmlhttp
)) {
1167 printLockingError();
1171 var filter_search
= document
.getElementById("filter_search");
1173 if (filter_search
) { search
= filter_search
.value
; }
1175 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1176 param_escape(sort_key
) +
1177 "&search=" + param_escape(search
), true);
1178 xmlhttp
.onreadystatechange
=filterlist_callback
;
1183 function updateLabelList(sort_key
) {
1185 if (!xmlhttp_ready(xmlhttp
)) {
1186 printLockingError();
1190 var label_search
= document
.getElementById("label_search");
1192 if (label_search
) { search
= label_search
.value
; }
1194 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1195 param_escape(sort_key
) +
1196 "&search=" + param_escape(search
), true);
1197 xmlhttp
.onreadystatechange
=labellist_callback
;
1201 function updatePrefsList() {
1203 if (!xmlhttp_ready(xmlhttp
)) {
1204 printLockingError();
1208 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1209 xmlhttp
.onreadystatechange
=prefslist_callback
;
1214 function selectTab(id
, noupdate
, subop
) {
1218 if (!id
) id
= active_tab
;
1222 if (!xmlhttp_ready(xmlhttp
)) {
1223 printLockingError();
1228 var c
= document
.getElementById('prefContent');
1234 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1236 notify_progress("Loading, please wait...");
1238 // close active infobox if needed
1241 // clean up all current selections, just in case
1242 active_feed_cat
= false;
1244 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1245 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1247 if (id
== "feedConfig") {
1249 } else if (id
== "filterConfig") {
1251 } else if (id
== "labelConfig") {
1253 } else if (id
== "genConfig") {
1255 } else if (id
== "userConfig") {
1257 } else if (id
== "feedBrowser") {
1258 updateBigFeedBrowser();
1262 /* clean selection from all tabs */
1264 var tabs_holder
= document
.getElementById("prefTabs");
1265 var tab
= tabs_holder
.firstChild
;
1268 if (tab
.className
&& tab
.className
.match("prefsTabSelected")) {
1269 tab
.className
= "prefsTab";
1271 tab
= tab
.nextSibling
;
1274 /* mark new tab as selected */
1276 tab
= document
.getElementById(id
+ "Tab");
1279 if (!tab
.className
.match("Selected")) {
1280 tab
.className
= tab
.className
+ "Selected";
1287 exception_error("selectTab", e
);
1291 function backend_sanity_check_callback() {
1293 if (xmlhttp
.readyState
== 4) {
1297 if (sanity_check_done
) {
1298 fatalError(11, "Sanity check request received twice. This can indicate "+
1299 "presence of Firebug or some other disrupting extension. "+
1300 "Please disable it and try again.");
1304 if (!xmlhttp
.responseXML
) {
1305 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1309 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1312 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1316 var error_code
= reply
.getAttribute("error-code");
1318 if (error_code
&& error_code
!= 0) {
1319 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1322 debug("sanity check ok");
1324 var params
= reply
.nextSibling
;
1327 debug('reading init-params...');
1328 var param
= params
.firstChild
;
1331 var k
= param
.getAttribute("key");
1332 var v
= param
.getAttribute("value");
1333 debug(k
+ " => " + v
);
1335 param
= param
.nextSibling
;
1339 sanity_check_done
= true;
1341 init_second_stage();
1344 exception_error("backend_sanity_check_callback", e
);
1349 function init_second_stage() {
1352 active_tab
= getInitParam("prefs_active_tab");
1353 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1355 document
.onkeydown
= pref_hotkey_handler
;
1357 var tab
= getURLParam('tab');
1359 caller_subop
= getURLParam('subop');
1365 if (navigator
.userAgent
.match("Opera")) {
1366 setTimeout("selectTab()", 500);
1368 selectTab(active_tab
);
1372 loading_set_progress(60);
1375 exception_error("init_second_stage", e
);
1383 if (arguments
.callee
.done
) return;
1384 arguments
.callee
.done
= true;
1386 if (getURLParam('debug')) {
1387 Element
.show("debug_output");
1388 debug('debug mode activated');
1393 document
.getElementById("prefContent").innerHTML
=
1394 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1395 "to function properly. Your browser doesn't seem to support it.";
1399 loading_set_progress(30);
1401 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1402 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1406 exception_error("init", e
);
1410 function categorizeSelectedFeeds() {
1412 if (!xmlhttp_ready(xmlhttp
)) {
1413 printLockingError();
1417 var sel_rows
= getSelectedFeeds();
1419 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1420 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1422 if (sel_rows
.length
> 0) {
1424 notify_progress("Changing category of selected feeds...");
1426 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1427 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1428 xmlhttp
.onreadystatechange
=feedlist_callback
;
1433 alert(__("No feeds are selected."));
1439 function validatePrefsReset() {
1441 var ok
= confirm(__("Reset to defaults?"));
1445 var query
= Form
.serialize("pref_prefs_form");
1446 query
= query
+ "&subop=reset-config";
1449 xmlhttp
.open("POST", "backend.php", true);
1450 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1451 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1452 xmlhttp
.send(query
);
1456 exception_error("validatePrefsSave", e
);
1463 function browseFeeds(limit
) {
1465 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1466 xmlhttp
.onreadystatechange
=infobox_callback
;
1471 function feedBrowserSubscribe() {
1474 var selected
= getSelectedFeedsFromBrowser();
1476 if (selected
.length
> 0) {
1478 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1479 param_escape(selected
.toString()), true);
1480 xmlhttp
.onreadystatechange
=feedlist_callback
;
1483 alert(__("No feeds are selected."));
1487 exception_error("feedBrowserSubscribe", e
);
1491 function updateBigFeedBrowserBtn() {
1492 notify_progress("Loading, please wait...");
1493 return updateBigFeedBrowser();
1496 function updateBigFeedBrowser(limit
, from_button
) {
1498 if (!xmlhttp_ready(xmlhttp
)) {
1499 printLockingError();
1503 var query
= "backend.php?op=pref-feed-browser";
1505 var limit_sel
= document
.getElementById("feedBrowserLimit");
1508 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1509 query
= query
+ "&limit=" + param_escape(limit
);
1512 var search
= document
.getElementById("feed_browser_search");
1515 query
= query
+ "&search=" + param_escape(search
.value
);
1518 xmlhttp
.open("GET", query
, true);
1519 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1523 function browserToggleExpand(id
) {
1525 /* if (feed_to_expand && feed_to_expand != id) {
1526 var d = document.getElementById("BRDET-" + feed_to_expand);
1527 d.style.display = "none";
1530 if (!xmlhttp_ready(xmlhttp
)) {
1531 printLockingError();
1535 /* if (feed_to_expand && id != feed_to_expand) {
1536 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1539 var d
= document
.getElementById("BRDET-" + id
);
1541 notify_progress("Loading, please wait...");
1543 if (Element
.visible(d
)) {
1544 Effect
.Fade(d
, {duration
: 0.5});
1546 feed_to_expand
= id
;
1548 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1549 + param_escape(id
), true);
1550 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1555 exception_error("browserToggleExpand", e
);
1559 function selectPrefRows(kind
, select
) {
1562 var opbarid
= false;
1567 if (kind
== "feed") {
1568 opbarid
= "feedOpToolbar";
1571 lname
= "prefFeedList";
1572 } else if (kind
== "fcat") {
1573 opbarid
= "catOpToolbar";
1576 lname
= "prefFeedCatList";
1577 } else if (kind
== "filter") {
1578 opbarid
= "filterOpToolbar";
1581 lname
= "prefFilterList";
1582 } else if (kind
== "label") {
1583 opbarid
= "labelOpToolbar";
1586 lname
= "prefLabelList";
1587 } else if (kind
== "user") {
1588 opbarid
= "userOpToolbar";
1591 lname
= "prefUserList";
1595 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1596 disableContainerChildren(opbarid
, !select
);
1603 function toggleSelectPrefRow(sender
, kind
) {
1605 toggleSelectRow(sender
);
1608 var opbarid
= false;
1611 if (kind
== "feed") {
1612 opbarid
= "feedOpToolbar";
1613 nsel
= getSelectedFeeds();
1614 } else if (kind
== "fcat") {
1615 opbarid
= "catOpToolbar";
1616 nsel
= getSelectedFeedCats();
1617 } else if (kind
== "filter") {
1618 opbarid
= "filterOpToolbar";
1619 nsel
= getSelectedFilters();
1620 } else if (kind
== "label") {
1621 opbarid
= "labelOpToolbar";
1622 nsel
= getSelectedLabels();
1623 } else if (kind
== "user") {
1624 opbarid
= "userOpToolbar";
1625 nsel
= getSelectedUsers();
1628 if (opbarid
&& nsel
!= -1) {
1629 disableContainerChildren(opbarid
, nsel
== false);
1635 function toggleSelectFBListRow(sender
) {
1636 toggleSelectListRow(sender
);
1637 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1642 function pref_hotkey_handler(e
) {
1646 var shift_key
= false;
1649 shift_key
= e
.shiftKey
;
1655 keycode
= window
.event
.keyCode
;
1660 var keychar
= String
.fromCharCode(keycode
);
1662 if (keycode
== 27) { // escape
1663 if (Element
.visible("hotkey_help_overlay")) {
1664 Element
.hide("hotkey_help_overlay");
1666 hotkey_prefix
= false;
1670 if (!hotkeys_enabled
) {
1671 debug("hotkeys disabled");
1675 if (keycode
== 16) return; // ignore lone shift
1677 if ((keycode
== 67 || keycode
== 71) && !hotkey_prefix
) {
1678 hotkey_prefix
= keycode
;
1679 debug("KP: PREFIX=" + keycode
+ " CHAR=" + keychar
);
1683 if (Element
.visible("hotkey_help_overlay")) {
1684 Element
.hide("hotkey_help_overlay");
1687 if (keycode
== 13 || keycode
== 27) {
1690 seq
= seq
+ "" + keycode
;
1693 /* Global hotkeys */
1695 if (!hotkey_prefix
) {
1697 if (keycode
== 68 && shift_key
) { // d
1698 if (!Element
.visible("debug_output")) {
1699 Element
.show("debug_output");
1700 debug('debug mode activated');
1702 Element
.hide("debug_output");
1707 if ((keycode
== 191 || keychar
== '?') && shift_key
) { // ?
1708 if (!Element
.visible("hotkey_help_overlay")) {
1709 //Element.show("hotkey_help_overlay");
1710 Effect
.Appear("hotkey_help_overlay", {duration
: 0.3});
1712 Element
.hide("hotkey_help_overlay");
1717 if (keycode
== 191 || keychar
== '/') { // /
1718 var search_boxes
= new Array("label_search",
1719 "feed_search", "filter_search", "user_search", "feed_browser_search");
1721 for (var i
= 0; i
< search_boxes
.length
; i
++) {
1722 var elem
= document
.getElementById(search_boxes
[i
]);
1724 focus_element(search_boxes
[i
]);
1733 if (hotkey_prefix
== 67) { // c
1734 hotkey_prefix
= false;
1736 if (keycode
== 70) { // f
1737 displayDlg("quickAddFilter");
1741 if (keycode
== 83) { // s
1742 displayDlg("quickAddFeed");
1746 /* if (keycode == 76) { // l
1747 displayDlg("quickAddLabel");
1751 if (keycode
== 85) { // u
1755 if (keycode
== 67) { // c
1760 if (keycode
== 84 && shift_key
) { // T
1769 if (hotkey_prefix
== 71) { // g
1771 hotkey_prefix
= false;
1773 if (keycode
== 49 && document
.getElementById("genConfigTab")) { // 1
1774 selectTab("genConfig");
1778 if (keycode
== 50 && document
.getElementById("feedConfigTab")) { // 2
1779 selectTab("feedConfig");
1783 if (keycode
== 51 && document
.getElementById("feedBrowserTab")) { // 3
1784 selectTab("feedBrowser");
1788 if (keycode
== 52 && document
.getElementById("filterConfigTab")) { // 4
1789 selectTab("filterConfig");
1793 if (keycode
== 53 && document
.getElementById("labelConfigTab")) { // 5
1794 selectTab("labelConfig");
1798 if (keycode
== 54 && document
.getElementById("userConfigTab")) { // 6
1799 selectTab("userConfig");
1803 if (keycode
== 88) { // x
1809 if (document
.getElementById("piggie")) {
1811 if (seq
.match("807371717369")) {
1819 if (hotkey_prefix
) {
1820 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
+ " CHAR=" + keychar
);
1822 debug("KP: CODE=" + keycode
+ " CHAR=" + keychar
);
1826 exception_error("pref_hotkey_handler", e
);
1830 function editFeedCats() {
1831 if (!xmlhttp_ready(xmlhttp
)) {
1832 printLockingError();
1836 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1839 document
.getElementById("top25_feeds_btn").disabled
= true;
1841 // this button is not always available, no-op if not found
1844 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1845 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1849 function showFeedsWithErrors() {
1850 displayDlg('feedUpdateErrors');
1853 function changeUserPassword() {
1857 if (!xmlhttp_ready(xmlhttp
)) {
1858 printLockingError();
1862 var f
= document
.forms
["change_pass_form"];
1865 if (f
.OLD_PASSWORD
.value
== "") {
1866 new Effect
.Highlight(f
.OLD_PASSWORD
);
1867 notify_error("Old password cannot be blank.");
1871 if (f
.NEW_PASSWORD
.value
== "") {
1872 new Effect
.Highlight(f
.NEW_PASSWORD
);
1873 notify_error("New password cannot be blank.");
1877 if (f
.CONFIRM_PASSWORD
.value
== "") {
1878 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1879 notify_error("Entered passwords do not match.");
1883 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1884 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1885 new Effect
.Highlight(f
.NEW_PASSWORD
);
1886 notify_error("Entered passwords do not match.");
1892 var query
= Form
.serialize("change_pass_form");
1894 notify_progress("Trying to change password...");
1896 xmlhttp
.open("POST", "backend.php", true);
1897 xmlhttp
.onreadystatechange
=changepass_callback
;
1898 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1899 xmlhttp
.send(query
);
1902 exception_error("changeUserPassword", e
);
1908 function changeUserEmail() {
1912 if (!xmlhttp_ready(xmlhttp
)) {
1913 printLockingError();
1917 var query
= Form
.serialize("change_email_form");
1919 notify_progress("Trying to change e-mail...");
1921 xmlhttp
.open("POST", "backend.php", true);
1922 xmlhttp
.onreadystatechange
=notify_callback
;
1923 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1924 xmlhttp
.send(query
);
1927 exception_error("changeUserPassword", e
);
1934 function feedlistToggleSLAT() {
1935 notify_progress("Loading, please wait...");
1939 function pubRegenKey() {
1941 if (!xmlhttp_ready(xmlhttp
)) {
1942 printLockingError();
1946 var ok
= confirm(__("Replace current publishing address with a new one?"));
1950 notify_progress("Trying to change address...");
1952 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1953 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1960 function pubToClipboard() {
1964 if (!xmlhttp_ready(xmlhttp
)) {
1965 printLockingError();
1969 var link
= document
.getElementById("pubGenAddress");
1973 exception_error("pubToClipboard", e
);
1979 function validatePrefsSave() {
1982 var ok
= confirm(__("Save current configuration?"));
1986 var query
= Form
.serialize("pref_prefs_form");
1987 query
= query
+ "&subop=save-config";
1990 xmlhttp
.open("POST", "backend.php", true);
1991 xmlhttp
.onreadystatechange
=notify_callback
;
1992 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1993 xmlhttp
.send(query
);
1997 exception_error("validatePrefsSave", e
);
2003 function feedActionChange() {
2005 var chooser
= document
.getElementById("feedActionChooser");
2006 var opid
= chooser
[chooser
.selectedIndex
].value
;
2008 chooser
.selectedIndex
= 0;
2011 exception_error("feedActionChange", e
);
2015 function feedActionGo(op
) {
2017 if (op
== "facEdit") {
2019 var rows
= getSelectedFeeds();
2021 if (rows
.length
> 1) {
2022 editSelectedFeeds();
2028 if (op
== "facClear") {
2029 clearSelectedFeeds();
2032 if (op
== "facPurge") {
2033 purgeSelectedFeeds();
2036 if (op
== "facEditCats") {
2040 if (op
== "facRescore") {
2041 rescoreSelectedFeeds();
2044 if (op
== "facUnsubscribe") {
2045 removeSelectedFeeds();
2049 exception_error("feedActionGo", e
);
2054 function clearFeedArticles(feed_id
) {
2056 notify_progress("Clearing feed...");
2058 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
2060 new Ajax
.Request(query
, {
2061 onComplete: function(transport
) {
2068 function rescoreSelectedFeeds() {
2070 if (!xmlhttp_ready(xmlhttp
)) {
2071 printLockingError();
2075 var sel_rows
= getSelectedFeeds();
2077 if (sel_rows
.length
> 0) {
2079 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
2080 var ok
= confirm(__("Rescore articles in selected feeds?"));
2083 notify_progress("Rescoring selected feeds...", true);
2085 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
2086 param_escape(sel_rows
.toString()), true);
2087 xmlhttp
.onreadystatechange
=notify_callback
;
2091 alert(__("No feeds are selected."));
2097 function rescore_all_feeds() {
2098 var ok
= confirm(__("Rescore all articles? This operation may take a lot of time."));
2101 notify_progress("Rescoring feeds...", true);
2103 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
2104 xmlhttp
.onreadystatechange
=notify_callback
;
2109 function removeFilter(id
, title
) {
2111 if (!xmlhttp_ready(xmlhttp
)) {
2112 printLockingError();
2116 var msg
= __("Remove filter %s?").replace("%s", title
);
2118 var ok
= confirm(msg
);
2123 notify_progress("Removing filter...");
2125 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
2126 param_escape(id
), true);
2127 xmlhttp
.onreadystatechange
=filterlist_callback
;
2134 function unsubscribeFeed(id
, title
) {
2136 if (!xmlhttp_ready(xmlhttp
)) {
2137 printLockingError();
2141 var msg
= __("Unsubscribe from %s?").replace("%s", title
);
2143 var ok
= confirm(msg
);
2148 notify_progress("Removing feed...");
2150 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
2151 param_escape(id
), true);
2152 xmlhttp
.onreadystatechange
=filterlist_callback
;
2162 function feedsEditSave() {
2165 if (!xmlhttp_ready(xmlhttp
)) {
2166 printLockingError();
2170 var ok
= confirm(__("Save changes to selected feeds?"));
2174 var f
= document
.forms
["batch_edit_feed_form"];
2176 var query
= Form
.serialize("batch_edit_feed_form");
2178 /* Form.serialize ignores unchecked checkboxes */
2180 if (!query
.match("&hidden=") &&
2181 f
.hidden
.disabled
== false) {
2182 query
= query
+ "&hidden=false";
2185 if (!query
.match("&rtl_content=") &&
2186 f
.rtl_content
.disabled
== false) {
2187 query
= query
+ "&rtl_content=false";
2190 if (!query
.match("&private=") &&
2191 f
.private.disabled
== false) {
2192 query
= query
+ "&private=false";
2195 if (!query
.match("&cache_images=") &&
2196 f
.cache_images
.disabled
== false) {
2197 query
= query
+ "&cache_images=false";
2200 if (!query
.match("&include_in_digest=") &&
2201 f
.include_in_digest
.disabled
== false) {
2202 query
= query
+ "&include_in_digest=false";
2207 notify_progress("Saving feeds...");
2209 xmlhttp
.open("POST", "backend.php", true);
2210 xmlhttp
.onreadystatechange
=feedlist_callback
;
2211 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2212 xmlhttp
.send(query
);
2217 exception_error("feedsEditSave", e
);
2221 function batchFeedsToggleField(cb
, elem
, label
) {
2223 var f
= document
.forms
["batch_edit_feed_form"];
2224 var l
= document
.getElementById(label
);
2227 f
[elem
].disabled
= false;
2233 // new Effect.Highlight(f[elem], {duration: 1, startcolor: "#fff7d5",
2234 // queue: { position:'end', scope: 'BPEFQ', limit: 1 } } );
2237 f
[elem
].disabled
= true;
2240 l
.className
= "insensitive";
2245 exception_error("batchFeedsToggleField", e
);