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;
817 // notify("Operation cancelled.");
819 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
820 xmlhttp
.onreadystatechange
=infobox_callback
;
826 function feedEditSave() {
830 if (!xmlhttp_ready(xmlhttp
)) {
835 // FIXME: add parameter validation
837 var query
= Form
.serialize("edit_feed_form");
839 notify_progress("Saving feed...");
841 xmlhttp
.open("POST", "backend.php", true);
842 xmlhttp
.onreadystatechange
=feedlist_callback
;
843 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
851 exception_error("feedEditSave", e
);
855 function feedCatEditSave() {
857 if (!xmlhttp_ready(xmlhttp
)) {
862 notify_progress("Saving category...");
864 var query
= Form
.serialize("feed_cat_edit_form");
866 xmlhttp
.open("GET", "backend.php?" + query
, true);
867 xmlhttp
.onreadystatechange
=infobox_callback
;
870 active_feed_cat
= false;
875 function userEditCancel() {
877 if (!xmlhttp_ready(xmlhttp
)) {
882 selectPrefRows('user', false); // cleanup feed selection
888 function filterEditCancel() {
890 if (!xmlhttp_ready(xmlhttp
)) {
896 document
.getElementById("create_filter_btn").disabled
= false;
897 selectPrefRows('filter', false); // cleanup feed selection
905 function userEditSave() {
907 if (!xmlhttp_ready(xmlhttp
)) {
912 var login
= document
.forms
["user_edit_form"].login
.value
;
914 if (login
.length
== 0) {
915 alert(__("Login field cannot be blank."));
919 notify_progress("Saving user...");
923 var query
= Form
.serialize("user_edit_form");
925 xmlhttp
.open("GET", "backend.php?" + query
, true);
926 xmlhttp
.onreadystatechange
=userlist_callback
;
933 function filterEditSave() {
935 if (!xmlhttp_ready(xmlhttp
)) {
940 /* if (!is_opera()) {
941 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
943 if (reg_exp.length == 0) {
944 alert("Filter expression field cannot be blank.");
949 notify_progress("Saving filter...");
951 var query
= Form
.serialize("filter_edit_form");
955 document
.getElementById("create_filter_btn").disabled
= false;
957 xmlhttp
.open("GET", "backend.php?" + query
, true);
958 xmlhttp
.onreadystatechange
=filterlist_callback
;
965 function editSelectedUser() {
966 var rows
= getSelectedUsers();
968 if (rows
.length
== 0) {
969 alert(__("No users are selected."));
973 if (rows
.length
> 1) {
974 alert(__("Please select only one user."));
983 function resetSelectedUserPass() {
984 var rows
= getSelectedUsers();
986 if (rows
.length
== 0) {
987 alert(__("No users are selected."));
991 if (rows
.length
> 1) {
992 alert(__("Please select only one user."));
996 var ok
= confirm(__("Reset password of selected user?"));
999 notify_progress("Resetting password for selected user...");
1003 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1004 param_escape(id
), true);
1005 xmlhttp
.onreadystatechange
=userlist_callback
;
1010 function selectedUserDetails() {
1012 if (!xmlhttp_ready(xmlhttp
)) {
1013 printLockingError();
1017 var rows
= getSelectedUsers();
1019 if (rows
.length
== 0) {
1020 alert(__("No users are selected."));
1024 if (rows
.length
> 1) {
1025 alert(__("Please select only one user."));
1029 notify_progress("Loading, please wait...");
1033 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=user-details&id=" + id
, true);
1034 xmlhttp
.onreadystatechange
=infobox_callback
;
1039 function selectedFeedDetails() {
1041 if (!xmlhttp_ready(xmlhttp
)) {
1042 printLockingError();
1046 var rows
= getSelectedFeeds();
1048 if (rows
.length
== 0) {
1049 alert(__("No feeds are selected."));
1053 if (rows
.length
> 1) {
1054 alert(__("Please select only one feed."));
1058 // var id = rows[0];
1062 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1063 param_escape(rows
.toString()), true);
1064 xmlhttp
.onreadystatechange
=infobox_callback
;
1069 function editSelectedFilter() {
1070 var rows
= getSelectedFilters();
1072 if (rows
.length
== 0) {
1073 alert(__("No filters are selected."));
1077 if (rows
.length
> 1) {
1078 alert(__("Please select only one filter."));
1084 editFilter(rows
[0]);
1089 function editSelectedFeed() {
1090 var rows
= getSelectedFeeds();
1092 if (rows
.length
== 0) {
1093 alert(__("No feeds are selected."));
1097 if (rows
.length
> 1) {
1098 alert(__("Please select one feed."));
1108 function editSelectedFeeds() {
1110 if (!xmlhttp_ready(xmlhttp
)) {
1111 printLockingError();
1115 var rows
= getSelectedFeeds();
1117 if (rows
.length
== 0) {
1118 alert(__("No feeds are selected."));
1126 notify_progress("Loading, please wait...");
1128 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeeds&ids=" +
1129 param_escape(rows
.toString()), true);
1131 xmlhttp
.onreadystatechange
=infobox_callback
;
1136 function editSelectedFeedCat() {
1137 var rows
= getSelectedFeedCats();
1139 if (rows
.length
== 0) {
1140 alert(__("No categories are selected."));
1144 if (rows
.length
> 1) {
1145 alert(__("Please select only one category."));
1151 editFeedCat(rows
[0]);
1155 function piggie(enable
) {
1157 debug("I LOVEDED IT!");
1158 var piggie
= document
.getElementById("piggie");
1160 Element
.show(piggie
);
1161 Position
.Center(piggie
);
1162 Effect
.Puff(piggie
);
1167 function validateOpmlImport() {
1169 var opml_file
= document
.getElementById("opml_file");
1171 if (opml_file
.value
.length
== 0) {
1172 alert(__("No OPML file to upload."));
1179 function updateFilterList(sort_key
) {
1181 if (!xmlhttp_ready(xmlhttp
)) {
1182 printLockingError();
1186 var filter_search
= document
.getElementById("filter_search");
1188 if (filter_search
) { search
= filter_search
.value
; }
1190 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1191 param_escape(sort_key
) +
1192 "&search=" + param_escape(search
), true);
1193 xmlhttp
.onreadystatechange
=filterlist_callback
;
1198 function updateLabelList(sort_key
) {
1200 if (!xmlhttp_ready(xmlhttp
)) {
1201 printLockingError();
1205 var label_search
= document
.getElementById("label_search");
1207 if (label_search
) { search
= label_search
.value
; }
1209 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1210 param_escape(sort_key
) +
1211 "&search=" + param_escape(search
), true);
1212 xmlhttp
.onreadystatechange
=labellist_callback
;
1216 function updatePrefsList() {
1218 if (!xmlhttp_ready(xmlhttp
)) {
1219 printLockingError();
1223 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1224 xmlhttp
.onreadystatechange
=prefslist_callback
;
1229 function selectTab(id
, noupdate
, subop
) {
1233 if (!id
) id
= active_tab
;
1237 if (!xmlhttp_ready(xmlhttp
)) {
1238 printLockingError();
1243 var c
= document
.getElementById('prefContent');
1249 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1251 notify_progress("Loading, please wait...");
1253 // close active infobox if needed
1256 // clean up all current selections, just in case
1257 active_feed_cat
= false;
1259 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1260 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1262 if (id
== "feedConfig") {
1264 } else if (id
== "filterConfig") {
1266 } else if (id
== "labelConfig") {
1268 } else if (id
== "genConfig") {
1270 } else if (id
== "userConfig") {
1272 } else if (id
== "feedBrowser") {
1273 updateBigFeedBrowser();
1277 /* clean selection from all tabs */
1279 var tabs_holder
= document
.getElementById("prefTabs");
1280 var tab
= tabs_holder
.firstChild
;
1283 if (tab
.className
&& tab
.className
.match("prefsTabSelected")) {
1284 tab
.className
= "prefsTab";
1286 tab
= tab
.nextSibling
;
1289 /* mark new tab as selected */
1291 tab
= document
.getElementById(id
+ "Tab");
1294 if (!tab
.className
.match("Selected")) {
1295 tab
.className
= tab
.className
+ "Selected";
1302 exception_error("selectTab", e
);
1306 function backend_sanity_check_callback() {
1308 if (xmlhttp
.readyState
== 4) {
1312 if (sanity_check_done
) {
1313 fatalError(11, "Sanity check request received twice. This can indicate "+
1314 "presence of Firebug or some other disrupting extension. "+
1315 "Please disable it and try again.");
1319 if (!xmlhttp
.responseXML
) {
1320 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1324 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1327 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1331 var error_code
= reply
.getAttribute("error-code");
1333 if (error_code
&& error_code
!= 0) {
1334 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1337 debug("sanity check ok");
1339 var params
= reply
.nextSibling
;
1342 debug('reading init-params...');
1343 var param
= params
.firstChild
;
1346 var k
= param
.getAttribute("key");
1347 var v
= param
.getAttribute("value");
1348 debug(k
+ " => " + v
);
1350 param
= param
.nextSibling
;
1354 sanity_check_done
= true;
1356 init_second_stage();
1359 exception_error("backend_sanity_check_callback", e
);
1364 function init_second_stage() {
1367 active_tab
= getInitParam("prefs_active_tab");
1368 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1370 document
.onkeydown
= pref_hotkey_handler
;
1372 var tab
= getURLParam('tab');
1374 caller_subop
= getURLParam('subop');
1380 if (navigator
.userAgent
.match("Opera")) {
1381 setTimeout("selectTab()", 500);
1383 selectTab(active_tab
);
1387 loading_set_progress(60);
1390 exception_error("init_second_stage", e
);
1398 if (arguments
.callee
.done
) return;
1399 arguments
.callee
.done
= true;
1401 if (getURLParam('debug')) {
1402 Element
.show("debug_output");
1403 debug('debug mode activated');
1408 document
.getElementById("prefContent").innerHTML
=
1409 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1410 "to function properly. Your browser doesn't seem to support it.";
1414 loading_set_progress(30);
1416 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1417 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1421 exception_error("init", e
);
1425 function categorizeSelectedFeeds() {
1427 if (!xmlhttp_ready(xmlhttp
)) {
1428 printLockingError();
1432 var sel_rows
= getSelectedFeeds();
1434 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1435 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1437 if (sel_rows
.length
> 0) {
1439 notify_progress("Changing category of selected feeds...");
1441 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1442 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1443 xmlhttp
.onreadystatechange
=feedlist_callback
;
1448 alert(__("No feeds are selected."));
1454 function validatePrefsReset() {
1456 var ok
= confirm(__("Reset to defaults?"));
1460 var query
= Form
.serialize("pref_prefs_form");
1461 query
= query
+ "&subop=reset-config";
1464 xmlhttp
.open("POST", "backend.php", true);
1465 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1466 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1467 xmlhttp
.send(query
);
1471 exception_error("validatePrefsSave", e
);
1478 function browseFeeds(limit
) {
1480 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1481 xmlhttp
.onreadystatechange
=infobox_callback
;
1486 function feedBrowserSubscribe() {
1489 var selected
= getSelectedFeedsFromBrowser();
1491 if (selected
.length
> 0) {
1493 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1494 param_escape(selected
.toString()), true);
1495 xmlhttp
.onreadystatechange
=feedlist_callback
;
1498 alert(__("No feeds are selected."));
1502 exception_error("feedBrowserSubscribe", e
);
1506 function updateBigFeedBrowserBtn() {
1507 notify_progress("Loading, please wait...");
1508 return updateBigFeedBrowser();
1511 function updateBigFeedBrowser(limit
, from_button
) {
1513 if (!xmlhttp_ready(xmlhttp
)) {
1514 printLockingError();
1518 var query
= "backend.php?op=pref-feed-browser";
1520 var limit_sel
= document
.getElementById("feedBrowserLimit");
1523 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1524 query
= query
+ "&limit=" + param_escape(limit
);
1527 var search
= document
.getElementById("feed_browser_search");
1530 query
= query
+ "&search=" + param_escape(search
.value
);
1533 xmlhttp
.open("GET", query
, true);
1534 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1538 function browserToggleExpand(id
) {
1540 /* if (feed_to_expand && feed_to_expand != id) {
1541 var d = document.getElementById("BRDET-" + feed_to_expand);
1542 d.style.display = "none";
1545 if (!xmlhttp_ready(xmlhttp
)) {
1546 printLockingError();
1550 /* if (feed_to_expand && id != feed_to_expand) {
1551 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1554 var d
= document
.getElementById("BRDET-" + id
);
1556 notify_progress("Loading, please wait...");
1558 if (Element
.visible(d
)) {
1559 Effect
.Fade(d
, {duration
: 0.5});
1561 feed_to_expand
= id
;
1563 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1564 + param_escape(id
), true);
1565 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1570 exception_error("browserToggleExpand", e
);
1574 function selectPrefRows(kind
, select
) {
1577 var opbarid
= false;
1582 if (kind
== "feed") {
1583 opbarid
= "feedOpToolbar";
1586 lname
= "prefFeedList";
1587 } else if (kind
== "fcat") {
1588 opbarid
= "catOpToolbar";
1591 lname
= "prefFeedCatList";
1592 } else if (kind
== "filter") {
1593 opbarid
= "filterOpToolbar";
1596 lname
= "prefFilterList";
1597 } else if (kind
== "label") {
1598 opbarid
= "labelOpToolbar";
1601 lname
= "prefLabelList";
1602 } else if (kind
== "user") {
1603 opbarid
= "userOpToolbar";
1606 lname
= "prefUserList";
1610 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1611 disableContainerChildren(opbarid
, !select
);
1618 function toggleSelectPrefRow(sender
, kind
) {
1620 toggleSelectRow(sender
);
1623 var opbarid
= false;
1626 if (kind
== "feed") {
1627 opbarid
= "feedOpToolbar";
1628 nsel
= getSelectedFeeds();
1629 } else if (kind
== "fcat") {
1630 opbarid
= "catOpToolbar";
1631 nsel
= getSelectedFeedCats();
1632 } else if (kind
== "filter") {
1633 opbarid
= "filterOpToolbar";
1634 nsel
= getSelectedFilters();
1635 } else if (kind
== "label") {
1636 opbarid
= "labelOpToolbar";
1637 nsel
= getSelectedLabels();
1638 } else if (kind
== "user") {
1639 opbarid
= "userOpToolbar";
1640 nsel
= getSelectedUsers();
1643 if (opbarid
&& nsel
!= -1) {
1644 disableContainerChildren(opbarid
, nsel
== false);
1650 function toggleSelectFBListRow(sender
) {
1651 toggleSelectListRow(sender
);
1652 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1657 function pref_hotkey_handler(e
) {
1661 var shift_key
= false;
1664 shift_key
= e
.shiftKey
;
1670 keycode
= window
.event
.keyCode
;
1675 var keychar
= String
.fromCharCode(keycode
);
1677 if (keycode
== 27) { // escape
1678 if (Element
.visible("hotkey_help_overlay")) {
1679 Element
.hide("hotkey_help_overlay");
1681 hotkey_prefix
= false;
1685 if (!hotkeys_enabled
) {
1686 debug("hotkeys disabled");
1690 if (keycode
== 16) return; // ignore lone shift
1692 if ((keycode
== 67 || keycode
== 71) && !hotkey_prefix
) {
1693 hotkey_prefix
= keycode
;
1694 debug("KP: PREFIX=" + keycode
+ " CHAR=" + keychar
);
1698 if (Element
.visible("hotkey_help_overlay")) {
1699 Element
.hide("hotkey_help_overlay");
1702 if (keycode
== 13 || keycode
== 27) {
1705 seq
= seq
+ "" + keycode
;
1708 /* Global hotkeys */
1710 if (!hotkey_prefix
) {
1712 if (keycode
== 68 && shift_key
) { // d
1713 if (!Element
.visible("debug_output")) {
1714 Element
.show("debug_output");
1715 debug('debug mode activated');
1717 Element
.hide("debug_output");
1722 if ((keycode
== 191 || keychar
== '?') && shift_key
) { // ?
1723 if (!Element
.visible("hotkey_help_overlay")) {
1724 //Element.show("hotkey_help_overlay");
1725 Effect
.Appear("hotkey_help_overlay", {duration
: 0.3});
1727 Element
.hide("hotkey_help_overlay");
1732 if (keycode
== 191 || keychar
== '/') { // /
1733 var search_boxes
= new Array("label_search",
1734 "feed_search", "filter_search", "user_search", "feed_browser_search");
1736 for (var i
= 0; i
< search_boxes
.length
; i
++) {
1737 var elem
= document
.getElementById(search_boxes
[i
]);
1739 focus_element(search_boxes
[i
]);
1748 if (hotkey_prefix
== 67) { // c
1749 hotkey_prefix
= false;
1751 if (keycode
== 70) { // f
1752 displayDlg("quickAddFilter");
1756 if (keycode
== 83) { // s
1757 displayDlg("quickAddFeed");
1761 /* if (keycode == 76) { // l
1762 displayDlg("quickAddLabel");
1766 if (keycode
== 85) { // u
1770 if (keycode
== 67) { // c
1775 if (keycode
== 84 && shift_key
) { // T
1784 if (hotkey_prefix
== 71) { // g
1786 hotkey_prefix
= false;
1788 if (keycode
== 49 && document
.getElementById("genConfigTab")) { // 1
1789 selectTab("genConfig");
1793 if (keycode
== 50 && document
.getElementById("feedConfigTab")) { // 2
1794 selectTab("feedConfig");
1798 if (keycode
== 51 && document
.getElementById("feedBrowserTab")) { // 3
1799 selectTab("feedBrowser");
1803 if (keycode
== 52 && document
.getElementById("filterConfigTab")) { // 4
1804 selectTab("filterConfig");
1808 if (keycode
== 53 && document
.getElementById("labelConfigTab")) { // 5
1809 selectTab("labelConfig");
1813 if (keycode
== 54 && document
.getElementById("userConfigTab")) { // 6
1814 selectTab("userConfig");
1818 if (keycode
== 88) { // x
1824 if (document
.getElementById("piggie")) {
1826 if (seq
.match("807371717369")) {
1834 if (hotkey_prefix
) {
1835 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
+ " CHAR=" + keychar
);
1837 debug("KP: CODE=" + keycode
+ " CHAR=" + keychar
);
1841 exception_error("pref_hotkey_handler", e
);
1845 function editFeedCats() {
1846 if (!xmlhttp_ready(xmlhttp
)) {
1847 printLockingError();
1851 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1854 document
.getElementById("top25_feeds_btn").disabled
= true;
1856 // this button is not always available, no-op if not found
1859 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1860 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1864 function showFeedsWithErrors() {
1865 displayDlg('feedUpdateErrors');
1868 function changeUserPassword() {
1872 if (!xmlhttp_ready(xmlhttp
)) {
1873 printLockingError();
1877 var f
= document
.forms
["change_pass_form"];
1880 if (f
.OLD_PASSWORD
.value
== "") {
1881 new Effect
.Highlight(f
.OLD_PASSWORD
);
1882 notify_error("Old password cannot be blank.");
1886 if (f
.NEW_PASSWORD
.value
== "") {
1887 new Effect
.Highlight(f
.NEW_PASSWORD
);
1888 notify_error("New password cannot be blank.");
1892 if (f
.CONFIRM_PASSWORD
.value
== "") {
1893 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1894 notify_error("Entered passwords do not match.");
1898 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1899 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1900 new Effect
.Highlight(f
.NEW_PASSWORD
);
1901 notify_error("Entered passwords do not match.");
1907 var query
= Form
.serialize("change_pass_form");
1909 notify_progress("Trying to change password...");
1911 xmlhttp
.open("POST", "backend.php", true);
1912 xmlhttp
.onreadystatechange
=changepass_callback
;
1913 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1914 xmlhttp
.send(query
);
1917 exception_error("changeUserPassword", e
);
1923 function changeUserEmail() {
1927 if (!xmlhttp_ready(xmlhttp
)) {
1928 printLockingError();
1932 var query
= Form
.serialize("change_email_form");
1934 notify_progress("Trying to change e-mail...");
1936 xmlhttp
.open("POST", "backend.php", true);
1937 xmlhttp
.onreadystatechange
=notify_callback
;
1938 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1939 xmlhttp
.send(query
);
1942 exception_error("changeUserPassword", e
);
1949 function feedlistToggleSLAT() {
1950 notify_progress("Loading, please wait...");
1954 function pubRegenKey() {
1956 if (!xmlhttp_ready(xmlhttp
)) {
1957 printLockingError();
1961 var ok
= confirm(__("Replace current publishing address with a new one?"));
1965 notify_progress("Trying to change address...");
1967 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1968 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1975 function pubToClipboard() {
1979 if (!xmlhttp_ready(xmlhttp
)) {
1980 printLockingError();
1984 var link
= document
.getElementById("pubGenAddress");
1988 exception_error("pubToClipboard", e
);
1994 function validatePrefsSave() {
1997 var ok
= confirm(__("Save current configuration?"));
2001 var query
= Form
.serialize("pref_prefs_form");
2002 query
= query
+ "&subop=save-config";
2005 xmlhttp
.open("POST", "backend.php", true);
2006 xmlhttp
.onreadystatechange
=notify_callback
;
2007 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2008 xmlhttp
.send(query
);
2012 exception_error("validatePrefsSave", e
);
2018 function feedActionChange() {
2020 var chooser
= document
.getElementById("feedActionChooser");
2021 var opid
= chooser
[chooser
.selectedIndex
].value
;
2023 chooser
.selectedIndex
= 0;
2026 exception_error("feedActionChange", e
);
2030 function feedActionGo(op
) {
2032 if (op
== "facEdit") {
2034 var rows
= getSelectedFeeds();
2036 if (rows
.length
> 1) {
2037 editSelectedFeeds();
2043 if (op
== "facClear") {
2044 clearSelectedFeeds();
2047 if (op
== "facPurge") {
2048 purgeSelectedFeeds();
2051 if (op
== "facEditCats") {
2055 if (op
== "facRescore") {
2056 rescoreSelectedFeeds();
2059 if (op
== "facUnsubscribe") {
2060 removeSelectedFeeds();
2064 exception_error("feedActionGo", e
);
2069 function clearFeedArticles(feed_id
) {
2071 notify_progress("Clearing feed...");
2073 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
2075 new Ajax
.Request(query
, {
2076 onComplete: function(transport
) {
2083 function rescoreSelectedFeeds() {
2085 if (!xmlhttp_ready(xmlhttp
)) {
2086 printLockingError();
2090 var sel_rows
= getSelectedFeeds();
2092 if (sel_rows
.length
> 0) {
2094 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
2095 var ok
= confirm(__("Rescore articles in selected feeds?"));
2098 notify_progress("Rescoring selected feeds...", true);
2100 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
2101 param_escape(sel_rows
.toString()), true);
2102 xmlhttp
.onreadystatechange
=notify_callback
;
2106 alert(__("No feeds are selected."));
2112 function rescore_all_feeds() {
2113 var ok
= confirm(__("Rescore all articles? This operation may take a lot of time."));
2116 notify_progress("Rescoring feeds...", true);
2118 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
2119 xmlhttp
.onreadystatechange
=notify_callback
;
2124 function removeFilter(id
, title
) {
2126 if (!xmlhttp_ready(xmlhttp
)) {
2127 printLockingError();
2131 var msg
= __("Remove filter %s?").replace("%s", title
);
2133 var ok
= confirm(msg
);
2138 notify_progress("Removing filter...");
2140 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
2141 param_escape(id
), true);
2142 xmlhttp
.onreadystatechange
=filterlist_callback
;
2149 function unsubscribeFeed(id
, title
) {
2151 if (!xmlhttp_ready(xmlhttp
)) {
2152 printLockingError();
2156 var msg
= __("Unsubscribe from %s?").replace("%s", title
);
2158 var ok
= confirm(msg
);
2163 notify_progress("Removing feed...");
2165 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
2166 param_escape(id
), true);
2167 xmlhttp
.onreadystatechange
=filterlist_callback
;
2177 function feedsEditSave() {
2180 if (!xmlhttp_ready(xmlhttp
)) {
2181 printLockingError();
2185 var ok
= confirm(__("Save changes to selected feeds?"));
2189 var f
= document
.forms
["batch_edit_feed_form"];
2191 var query
= Form
.serialize("batch_edit_feed_form");
2193 /* Form.serialize ignores unchecked checkboxes */
2195 if (!query
.match("&hidden=") &&
2196 f
.hidden
.disabled
== false) {
2197 query
= query
+ "&hidden=false";
2200 if (!query
.match("&rtl_content=") &&
2201 f
.rtl_content
.disabled
== false) {
2202 query
= query
+ "&rtl_content=false";
2205 if (!query
.match("&private=") &&
2206 f
.private.disabled
== false) {
2207 query
= query
+ "&private=false";
2210 if (!query
.match("&cache_images=") &&
2211 f
.cache_images
.disabled
== false) {
2212 query
= query
+ "&cache_images=false";
2215 if (!query
.match("&include_in_digest=") &&
2216 f
.include_in_digest
.disabled
== false) {
2217 query
= query
+ "&include_in_digest=false";
2222 notify_progress("Saving feeds...");
2224 xmlhttp
.open("POST", "backend.php", true);
2225 xmlhttp
.onreadystatechange
=feedlist_callback
;
2226 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2227 xmlhttp
.send(query
);
2232 exception_error("feedsEditSave", e
);
2236 function batchFeedsToggleField(cb
, elem
, label
) {
2238 var f
= document
.forms
["batch_edit_feed_form"];
2239 var l
= document
.getElementById(label
);
2242 f
[elem
].disabled
= false;
2248 // new Effect.Highlight(f[elem], {duration: 1, startcolor: "#fff7d5",
2249 // queue: { position:'end', scope: 'BPEFQ', limit: 1 } } );
2252 f
[elem
].disabled
= true;
2255 l
.className
= "insensitive";
2260 exception_error("batchFeedsToggleField", e
);