3 var active_feed_cat
= false;
4 var active_label
= false;
5 var active_tab
= false;
6 var feed_to_expand
= false;
8 var xmlhttp
= Ajax
.getTransport();
10 var init_params
= new Array();
12 var caller_subop
= false;
13 var sanity_check_done
= false;
14 var hotkey_prefix
= false;
16 function infobox_callback() {
17 if (xmlhttp
.readyState
== 4) {
18 infobox_callback2(xmlhttp
);
22 function infobox_submit_callback() {
23 if (xmlhttp
.readyState
== 4) {
24 infobox_submit_callback2(xmlhttp
);
29 function replace_pubkey_callback() {
30 if (xmlhttp
.readyState
== 4) {
32 var link
= document
.getElementById("pubGenAddress");
34 if (xmlhttp
.responseXML
) {
36 var new_link
= xmlhttp
.responseXML
.getElementsByTagName("link")[0];
39 link
.href
= new_link
.firstChild
.nodeValue
;
40 //link.innerHTML = new_link.firstChild.nodeValue;
42 new Effect
.Highlight(link
);
44 notify_info("Published feed URL changed.");
46 notify_error("Could not change feed URL.");
50 notify_error("Could not change feed URL.");
53 exception_error("replace_pubkey_callback", e
);
58 function expand_feed_callback() {
59 if (xmlhttp
.readyState
== 4) {
61 var container
= document
.getElementById("BRDET-" + feed_to_expand
);
62 container
.innerHTML
=xmlhttp
.responseText
;
63 // container.style.display = "block";
64 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') {
91 exception_error("feedlist_callback", e
);
96 /* stub for subscription dialog */
98 function dlg_frefresh_callback(transport
) {
101 var container
= document
.getElementById('prefContent');
102 container
.innerHTML
=transport
.responseText
;
103 selectTab("feedConfig", true);
106 var tuple
= caller_subop
.split(":");
107 if (tuple
[0] == 'editFeed') {
108 window
.setTimeout('editFeed('+tuple
[1]+')', 100);
111 caller_subop
= false;
113 if (typeof correctPNG
!= 'undefined') {
118 exception_error("feedlist_callback", e
);
123 function filterlist_callback() {
124 var container
= document
.getElementById('prefContent');
125 if (xmlhttp
.readyState
== 4) {
126 container
.innerHTML
=xmlhttp
.responseText
;
127 if (typeof correctPNG
!= 'undefined') {
134 function labellist_callback() {
135 var container
= document
.getElementById('prefContent');
136 if (xmlhttp
.readyState
== 4) {
138 container
.innerHTML
=xmlhttp
.responseText
;
140 var row
= document
.getElementById("LILRR-" + active_label
);
142 if (!row
.className
.match("Selected")) {
143 row
.className
= row
.className
+ "Selected";
146 var checkbox
= document
.getElementById("LICHK-" + active_label
);
149 checkbox
.checked
= true;
152 if (typeof correctPNG
!= 'undefined') {
159 function feed_browser_callback() {
160 var container
= document
.getElementById('prefContent');
161 if (xmlhttp
.readyState
== 4) {
162 container
.innerHTML
=xmlhttp
.responseText
;
167 function userlist_callback() {
168 var container
= document
.getElementById('prefContent');
169 if (xmlhttp
.readyState
== 4) {
170 container
.innerHTML
=xmlhttp
.responseText
;
175 function prefslist_callback() {
176 var container
= document
.getElementById('prefContent');
177 if (xmlhttp
.readyState
== 4) {
179 container
.innerHTML
=xmlhttp
.responseText
;
185 function gethelp_callback() {
186 var container
= document
.getElementById('prefHelpBox');
187 if (xmlhttp
.readyState
== 4) {
189 container
.innerHTML
= xmlhttp
.responseText
;
190 container
.style
.display
= "block";
195 function notify_callback() {
196 if (xmlhttp
.readyState
== 4) {
197 notify_info(xmlhttp
.responseText
);
201 function prefs_reset_callback() {
202 if (xmlhttp
.readyState
== 4) {
203 notify_info(xmlhttp
.responseText
);
209 function changepass_callback() {
211 if (xmlhttp
.readyState
== 4) {
213 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
214 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
216 notify_info(xmlhttp
.responseText
);
217 var warn
= document
.getElementById("default_pass_warning");
218 if (warn
) warn
.style
.display
= "none";
221 document
.forms
['change_pass_form'].reset();
225 exception_error("changepass_callback", e
);
229 function infobox_feed_cat_callback() {
230 if (xmlhttp
.readyState
== 4) {
235 if (document
.getElementById("prefFeedCatList")) {
236 var elems
= document
.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
238 for (var i
= 0; i
< elems
.length
; i
++) {
239 if (elems
[i
].id
&& elems
[i
].id
.match("FCATT-")) {
240 var cat_id
= elems
[i
].id
.replace("FCATT-", "");
242 new Ajax
.InPlaceEditor(elems
[i
],
243 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id
);
249 exception_error("infobox_feed_cat_callback", e
);
254 function updateFeedList(sort_key
) {
256 if (!xmlhttp_ready(xmlhttp
)) {
261 var feed_search
= document
.getElementById("feed_search");
263 if (feed_search
) { search
= feed_search
.value
; }
265 var slat
= document
.getElementById("show_last_article_times");
267 var slat_checked
= false;
269 slat_checked
= slat
.checked
;
272 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
273 "&sort=" + param_escape(sort_key
) +
274 "&slat=" + param_escape(slat_checked
) +
275 "&search=" + param_escape(search
), true);
276 xmlhttp
.onreadystatechange
=feedlist_callback
;
281 function updateUsersList(sort_key
) {
283 if (!xmlhttp_ready(xmlhttp
)) {
288 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
289 + param_escape(sort_key
), true);
290 xmlhttp
.onreadystatechange
=userlist_callback
;
295 function addLabel() {
297 if (!xmlhttp_ready(xmlhttp
)) {
302 var form
= document
.forms
['label_edit_form'];
304 var sql_exp
= form
.sql_exp
.value
;
305 var description
= form
.description
.value
;
308 alert(__("Can't create label: missing SQL expression."));
312 if (description
== "") {
313 alert(__("Can't create label: missing caption."));
317 var query
= Form
.serialize("label_edit_form");
319 // we can be called from some other tab
320 active_tab
= "labelConfig";
322 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
323 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
329 if (!xmlhttp_ready(xmlhttp
)) {
334 var link
= document
.getElementById("fadd_link");
336 if (link
.value
.length
== 0) {
337 alert(__("Error: No feed URL given."));
338 } else if (!isValidURL(link
.value
)) {
339 alert(__("Error: Invalid feed URL."));
341 notify_progress("Adding feed...");
343 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
344 param_escape(link
.value
), true);
345 xmlhttp
.onreadystatechange
=feedlist_callback
;
354 function addFeedCat() {
356 if (!xmlhttp_ready(xmlhttp
)) {
361 var cat
= document
.getElementById("fadd_cat");
363 if (cat
.value
.length
== 0) {
364 alert(__("Can't add category: no name specified."));
366 notify_progress("Adding feed category...");
368 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
369 param_escape(cat
.value
), true);
370 xmlhttp
.onreadystatechange
=infobox_callback
;
380 if (!xmlhttp_ready(xmlhttp
)) {
385 var sqlexp
= document
.getElementById("uadd_box");
387 if (sqlexp
.value
.length
== 0) {
388 alert(__("Can't add user: no login specified."));
390 notify_progress("Adding user...");
392 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
393 param_escape(sqlexp
.value
), true);
395 xmlhttp
.onreadystatechange
=userlist_callback
;
403 function editLabel(id
) {
405 if (!xmlhttp_ready(xmlhttp
)) {
412 notify_progress("Loading, please wait...");
414 document
.getElementById("label_create_btn").disabled
= true;
418 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
419 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
421 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
422 param_escape(id
), true);
423 xmlhttp
.onreadystatechange
=infobox_callback
;
428 function editUser(id
) {
430 if (!xmlhttp_ready(xmlhttp
)) {
437 notify_progress("Loading, please wait...");
439 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
440 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
442 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
443 param_escape(id
), true);
444 xmlhttp
.onreadystatechange
=infobox_callback
;
449 function editFilter(id
) {
451 if (!xmlhttp_ready(xmlhttp
)) {
458 notify_progress("Loading, please wait...");
460 document
.getElementById("create_filter_btn").disabled
= true;
462 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
463 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
465 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
466 xmlhttp
.onreadystatechange
=infobox_callback
;
470 function editFeed(feed
) {
472 // notify("Editing feed...");
474 if (!xmlhttp_ready(xmlhttp
)) {
481 notify_progress("Loading, please wait...");
483 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
486 document
.getElementById("top25_feeds_btn").disabled
= true;
488 // this button is not always available, no-op if not found
491 // clean selection from all rows & select row being edited
492 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
493 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
495 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
496 param_escape(feed
), true);
498 xmlhttp
.onreadystatechange
=infobox_callback
;
503 function editFeedCat(cat
) {
505 if (!xmlhttp_ready(xmlhttp
)) {
512 notify_progress("Loading, please wait...");
514 active_feed_cat
= cat
;
516 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
517 param_escape(cat
), true);
518 xmlhttp
.onreadystatechange
=infobox_callback
;
523 function getSelectedLabels() {
524 return getSelectedTableRowIds("prefLabelList", "LILRR");
527 function getSelectedUsers() {
528 return getSelectedTableRowIds("prefUserList", "UMRR");
531 function getSelectedFeeds() {
532 return getSelectedTableRowIds("prefFeedList", "FEEDR");
535 function getSelectedFilters() {
536 return getSelectedTableRowIds("prefFilterList", "FILRR");
539 function getSelectedFeedCats() {
540 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
543 function getSelectedFeedsFromBrowser() {
545 var list
= document
.getElementById("browseFeedList");
546 if (!list
) list
= document
.getElementById("browseBigFeedList");
548 var selected
= new Array();
550 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
551 var child
= list
.childNodes
[i
];
552 if (child
.id
&& child
.id
.match("FBROW-")) {
553 var id
= child
.id
.replace("FBROW-", "");
555 var cb
= document
.getElementById("FBCHK-" + id
);
566 function removeSelectedLabels() {
568 if (!xmlhttp_ready(xmlhttp
)) {
573 var sel_rows
= getSelectedLabels();
575 if (sel_rows
.length
> 0) {
577 var ok
= confirm(__("Remove selected labels?"));
580 notify_progress("Removing selected labels...");
582 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
583 param_escape(sel_rows
.toString()), true);
584 xmlhttp
.onreadystatechange
=labellist_callback
;
588 alert(__("No labels are selected."));
594 function removeSelectedUsers() {
596 if (!xmlhttp_ready(xmlhttp
)) {
601 var sel_rows
= getSelectedUsers();
603 if (sel_rows
.length
> 0) {
605 var ok
= confirm(__("Remove selected users?"));
608 notify_progress("Removing selected users...");
610 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
611 param_escape(sel_rows
.toString()), true);
612 xmlhttp
.onreadystatechange
=userlist_callback
;
617 alert(__("No users are selected."));
623 function removeSelectedFilters() {
625 if (!xmlhttp_ready(xmlhttp
)) {
630 var sel_rows
= getSelectedFilters();
632 if (sel_rows
.length
> 0) {
634 var ok
= confirm(__("Remove selected filters?"));
637 notify_progress("Removing selected filters...");
639 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
640 param_escape(sel_rows
.toString()), true);
641 xmlhttp
.onreadystatechange
=filterlist_callback
;
645 alert(__("No filters are selected."));
652 function removeSelectedFeeds() {
654 if (!xmlhttp_ready(xmlhttp
)) {
659 var sel_rows
= getSelectedFeeds();
661 if (sel_rows
.length
> 0) {
663 var ok
= confirm(__("Unsubscribe from selected feeds?"));
667 notify_progress("Unsubscribing from selected feeds...");
669 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
670 param_escape(sel_rows
.toString()), true);
671 xmlhttp
.onreadystatechange
=feedlist_callback
;
677 alert(__("No feeds are selected."));
684 function clearSelectedFeeds() {
686 if (!xmlhttp_ready(xmlhttp
)) {
691 var sel_rows
= getSelectedFeeds();
693 if (sel_rows
.length
> 1) {
694 alert(__("Please select only one feed."));
698 if (sel_rows
.length
> 0) {
700 var ok
= confirm(__("Erase all non-starred articles in selected feed?"));
703 notify_progress("Clearing selected feed...");
704 clearFeedArticles(sel_rows
[0]);
709 alert(__("No feeds are selected."));
716 function purgeSelectedFeeds() {
718 if (!xmlhttp_ready(xmlhttp
)) {
723 var sel_rows
= getSelectedFeeds();
725 if (sel_rows
.length
> 0) {
727 var pr
= prompt(__("How many days of articles to keep (0 - use default)?"), "0");
729 if (pr
!= undefined) {
730 notify_progress("Purging selected feed...");
732 var query
= "backend.php?op=rpc&subop=purge&ids="+
733 param_escape(sel_rows
.toString()) + "&days=" + pr
;
737 new Ajax
.Request(query
, {
738 onComplete: function(transport
) {
745 alert(__("No feeds are selected."));
752 function removeSelectedFeedCats() {
754 if (!xmlhttp_ready(xmlhttp
)) {
759 var sel_rows
= getSelectedFeedCats();
761 if (sel_rows
.length
> 0) {
763 var ok
= confirm(__("Remove selected categories?"));
766 notify_progress("Removing selected categories...");
768 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
769 param_escape(sel_rows
.toString()), true);
770 xmlhttp
.onreadystatechange
=infobox_callback
;
776 alert(__("No categories are selected."));
783 function feedEditCancel() {
785 if (!xmlhttp_ready(xmlhttp
)) {
790 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
793 document
.getElementById("top25_feeds_btn").disabled
= false;
795 // this button is not always available, no-op if not found
800 selectPrefRows('feed', false); // cleanup feed selection
805 function feedCatEditCancel() {
807 if (!xmlhttp_ready(xmlhttp
)) {
812 active_feed_cat
= false;
814 // notify("Operation cancelled.");
816 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
817 xmlhttp
.onreadystatechange
=infobox_callback
;
823 function feedEditSave() {
827 if (!xmlhttp_ready(xmlhttp
)) {
832 // FIXME: add parameter validation
834 var query
= Form
.serialize("edit_feed_form");
836 notify_progress("Saving feed...");
838 xmlhttp
.open("POST", "backend.php", true);
839 xmlhttp
.onreadystatechange
=feedlist_callback
;
840 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
848 exception_error("feedEditSave", e
);
852 function feedCatEditSave() {
854 if (!xmlhttp_ready(xmlhttp
)) {
859 notify_progress("Saving category...");
861 var query
= Form
.serialize("feed_cat_edit_form");
863 xmlhttp
.open("GET", "backend.php?" + query
, true);
864 xmlhttp
.onreadystatechange
=infobox_callback
;
867 active_feed_cat
= false;
872 function labelEditCancel() {
874 if (!xmlhttp_ready(xmlhttp
)) {
879 document
.getElementById("label_create_btn").disabled
= false;
881 active_label
= false;
883 selectPrefRows('label', false); // cleanup feed selection
889 function userEditCancel() {
891 if (!xmlhttp_ready(xmlhttp
)) {
896 selectPrefRows('user', false); // cleanup feed selection
902 function filterEditCancel() {
904 if (!xmlhttp_ready(xmlhttp
)) {
909 document
.getElementById("create_filter_btn").disabled
= false;
911 selectPrefRows('filter', false); // cleanup feed selection
917 function labelEditSave() {
919 var label
= active_label
;
921 if (!xmlhttp_ready(xmlhttp
)) {
926 /* if (!is_opera()) {
928 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
929 var description = document.forms["label_edit_form"].description.value;
931 if (sql_exp.length == 0) {
932 alert("SQL Expression cannot be blank.");
936 if (description.length == 0) {
937 alert("Caption field cannot be blank.");
944 notify_progress("Saving label...");
946 active_label
= false;
948 query
= Form
.serialize("label_edit_form");
950 xmlhttp
.open("GET", "backend.php?" + query
, true);
951 xmlhttp
.onreadystatechange
=labellist_callback
;
957 function userEditSave() {
959 if (!xmlhttp_ready(xmlhttp
)) {
964 var login
= document
.forms
["user_edit_form"].login
.value
;
966 if (login
.length
== 0) {
967 alert(__("Login field cannot be blank."));
971 notify_progress("Saving user...");
975 var query
= Form
.serialize("user_edit_form");
977 xmlhttp
.open("GET", "backend.php?" + query
, true);
978 xmlhttp
.onreadystatechange
=userlist_callback
;
985 function filterEditSave() {
987 if (!xmlhttp_ready(xmlhttp
)) {
992 /* if (!is_opera()) {
993 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
995 if (reg_exp.length == 0) {
996 alert("Filter expression field cannot be blank.");
1001 notify_progress("Saving filter...");
1003 var query
= Form
.serialize("filter_edit_form");
1007 document
.getElementById("create_filter_btn").disabled
= false;
1009 xmlhttp
.open("GET", "backend.php?" + query
, true);
1010 xmlhttp
.onreadystatechange
=filterlist_callback
;
1016 function editSelectedLabel() {
1017 var rows
= getSelectedLabels();
1019 if (rows
.length
== 0) {
1020 alert(__("No labels are selected."));
1024 if (rows
.length
> 1) {
1025 alert(__("Please select only one label."));
1035 function editSelectedUser() {
1036 var rows
= getSelectedUsers();
1038 if (rows
.length
== 0) {
1039 alert(__("No users are selected."));
1043 if (rows
.length
> 1) {
1044 alert(__("Please select only one user."));
1053 function resetSelectedUserPass() {
1054 var rows
= getSelectedUsers();
1056 if (rows
.length
== 0) {
1057 alert(__("No users are selected."));
1061 if (rows
.length
> 1) {
1062 alert(__("Please select only one user."));
1066 var ok
= confirm(__("Reset password of selected user?"));
1069 notify_progress("Resetting password for selected user...");
1073 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1074 param_escape(id
), true);
1075 xmlhttp
.onreadystatechange
=userlist_callback
;
1080 function selectedUserDetails() {
1082 if (!xmlhttp_ready(xmlhttp
)) {
1083 printLockingError();
1087 var rows
= getSelectedUsers();
1089 if (rows
.length
== 0) {
1090 alert(__("No users are selected."));
1094 if (rows
.length
> 1) {
1095 alert(__("Please select only one user."));
1099 notify_progress("Loading, please wait...");
1103 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1104 xmlhttp
.onreadystatechange
=infobox_callback
;
1109 function selectedFeedDetails() {
1111 if (!xmlhttp_ready(xmlhttp
)) {
1112 printLockingError();
1116 var rows
= getSelectedFeeds();
1118 if (rows
.length
== 0) {
1119 alert(__("No feeds are selected."));
1123 if (rows
.length
> 1) {
1124 alert(__("Please select only one feed."));
1128 // var id = rows[0];
1132 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1133 param_escape(rows
.toString()), true);
1134 xmlhttp
.onreadystatechange
=infobox_callback
;
1139 function editSelectedFilter() {
1140 var rows
= getSelectedFilters();
1142 if (rows
.length
== 0) {
1143 alert(__("No filters are selected."));
1147 if (rows
.length
> 1) {
1148 alert(__("Please select only one filter."));
1154 editFilter(rows
[0]);
1159 function editSelectedFeed() {
1160 var rows
= getSelectedFeeds();
1162 if (rows
.length
== 0) {
1163 alert(__("No feeds are selected."));
1167 if (rows
.length
> 1) {
1168 alert(__("Please select one feed."));
1178 function editSelectedFeedCat() {
1179 var rows
= getSelectedFeedCats();
1181 if (rows
.length
== 0) {
1182 alert(__("No categories are selected."));
1186 if (rows
.length
> 1) {
1187 alert(__("Please select only one category."));
1193 editFeedCat(rows
[0]);
1197 function localPiggieFunction(enable
) {
1199 debug("I LOVEDED IT!");
1200 var piggie
= document
.getElementById("piggie");
1202 Element
.show(piggie
);
1203 Position
.Center(piggie
);
1204 Effect
.Puff(piggie
);
1209 function validateOpmlImport() {
1211 var opml_file
= document
.getElementById("opml_file");
1213 if (opml_file
.value
.length
== 0) {
1214 alert(__("No OPML file to upload."));
1221 function updateFilterList(sort_key
) {
1223 if (!xmlhttp_ready(xmlhttp
)) {
1224 printLockingError();
1228 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1229 param_escape(sort_key
), true);
1230 xmlhttp
.onreadystatechange
=filterlist_callback
;
1235 function updateLabelList(sort_key
) {
1237 if (!xmlhttp_ready(xmlhttp
)) {
1238 printLockingError();
1242 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1243 param_escape(sort_key
), true);
1244 xmlhttp
.onreadystatechange
=labellist_callback
;
1248 function updatePrefsList() {
1250 if (!xmlhttp_ready(xmlhttp
)) {
1251 printLockingError();
1255 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1256 xmlhttp
.onreadystatechange
=prefslist_callback
;
1261 function selectTab(id
, noupdate
, subop
) {
1265 if (!id
) id
= active_tab
;
1269 if (!xmlhttp_ready(xmlhttp
)) {
1270 printLockingError();
1275 var c
= document
.getElementById('prefContent');
1281 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1283 notify_progress("Loading, please wait...");
1285 // close active infobox if needed
1288 // clean up all current selections, just in case
1289 active_feed_cat
= false;
1290 active_label
= false;
1292 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1293 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1295 if (id
== "feedConfig") {
1297 } else if (id
== "filterConfig") {
1299 } else if (id
== "labelConfig") {
1301 } else if (id
== "genConfig") {
1303 } else if (id
== "userConfig") {
1305 } else if (id
== "feedBrowser") {
1306 updateBigFeedBrowser();
1310 /* clean selection from all tabs */
1312 var tabs_holder
= document
.getElementById("prefTabs");
1313 var tab
= tabs_holder
.firstChild
;
1316 if (tab
.className
&& tab
.className
.match("prefsTabSelected")) {
1317 tab
.className
= "prefsTab";
1319 tab
= tab
.nextSibling
;
1322 /* mark new tab as selected */
1324 tab
= document
.getElementById(id
+ "Tab");
1327 if (!tab
.className
.match("Selected")) {
1328 tab
.className
= tab
.className
+ "Selected";
1335 exception_error("selectTab", e
);
1339 function backend_sanity_check_callback() {
1341 if (xmlhttp
.readyState
== 4) {
1345 if (sanity_check_done
) {
1346 fatalError(11, "Sanity check request received twice. This can indicate "+
1347 "presence of Firebug or some other disrupting extension. "+
1348 "Please disable it and try again.");
1352 if (!xmlhttp
.responseXML
) {
1353 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1357 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1360 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1364 var error_code
= reply
.getAttribute("error-code");
1366 if (error_code
&& error_code
!= 0) {
1367 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1370 debug("sanity check ok");
1372 var params
= reply
.nextSibling
;
1375 debug('reading init-params...');
1376 var param
= params
.firstChild
;
1379 var k
= param
.getAttribute("key");
1380 var v
= param
.getAttribute("value");
1381 debug(k
+ " => " + v
);
1383 param
= param
.nextSibling
;
1387 sanity_check_done
= true;
1389 init_second_stage();
1392 exception_error("backend_sanity_check_callback", e
);
1397 function init_second_stage() {
1400 active_tab
= getInitParam("prefs_active_tab");
1401 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1403 document
.onkeydown
= pref_hotkey_handler
;
1405 var tab
= getURLParam('tab');
1407 caller_subop
= getURLParam('subop');
1413 if (navigator
.userAgent
.match("Opera")) {
1414 setTimeout("selectTab()", 500);
1416 selectTab(active_tab
);
1420 exception_error("init_second_stage", e
);
1428 if (arguments
.callee
.done
) return;
1429 arguments
.callee
.done
= true;
1431 if (getURLParam('debug')) {
1432 document
.getElementById('debug_output').style
.display
= 'block';
1433 debug('debug mode activated');
1438 document
.getElementById("prefContent").innerHTML
=
1439 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1440 "to function properly. Your browser doesn't seem to support it.";
1444 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1445 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1449 exception_error("init", e
);
1453 function categorizeSelectedFeeds() {
1455 if (!xmlhttp_ready(xmlhttp
)) {
1456 printLockingError();
1460 var sel_rows
= getSelectedFeeds();
1462 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1463 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1465 if (sel_rows
.length
> 0) {
1467 notify_progress("Changing category of selected feeds...");
1469 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1470 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1471 xmlhttp
.onreadystatechange
=feedlist_callback
;
1476 alert(__("No feeds are selected."));
1482 function validatePrefsReset() {
1484 var ok
= confirm(__("Reset to defaults?"));
1488 var query
= Form
.serialize("pref_prefs_form");
1489 query
= query
+ "&subop=reset-config";
1492 xmlhttp
.open("POST", "backend.php", true);
1493 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1494 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1495 xmlhttp
.send(query
);
1499 exception_error("validatePrefsSave", e
);
1506 function browseFeeds(limit
) {
1508 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1509 xmlhttp
.onreadystatechange
=infobox_callback
;
1514 function feedBrowserSubscribe() {
1517 var selected
= getSelectedFeedsFromBrowser();
1519 if (selected
.length
> 0) {
1521 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1522 param_escape(selected
.toString()), true);
1523 xmlhttp
.onreadystatechange
=feedlist_callback
;
1526 alert(__("No feeds are selected."));
1530 exception_error("feedBrowserSubscribe", e
);
1534 function updateBigFeedBrowser(limit
) {
1536 if (!xmlhttp_ready(xmlhttp
)) {
1537 printLockingError();
1541 var query
= "backend.php?op=pref-feed-browser";
1543 var limit_sel
= document
.getElementById("feedBrowserLimit");
1546 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1547 query
= query
+ "&limit=" + param_escape(limit
);
1550 xmlhttp
.open("GET", query
, true);
1551 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1555 function browserToggleExpand(id
) {
1557 /* if (feed_to_expand && feed_to_expand != id) {
1558 var d = document.getElementById("BRDET-" + feed_to_expand);
1559 d.style.display = "none";
1562 if (!xmlhttp_ready(xmlhttp
)) {
1563 printLockingError();
1567 /* if (feed_to_expand && id != feed_to_expand) {
1568 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1571 var d
= document
.getElementById("BRDET-" + id
);
1573 if (Element
.visible(d
)) {
1574 Effect
.Fade(d
, {duration
: 0.5});
1576 feed_to_expand
= id
;
1578 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1579 + param_escape(id
), true);
1580 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1585 exception_error("browserToggleExpand", e
);
1589 function selectPrefRows(kind
, select
) {
1592 var opbarid
= false;
1597 if (kind
== "feed") {
1598 opbarid
= "feedOpToolbar";
1601 lname
= "prefFeedList";
1602 } else if (kind
== "fcat") {
1603 opbarid
= "catOpToolbar";
1606 lname
= "prefFeedCatList";
1607 } else if (kind
== "filter") {
1608 opbarid
= "filterOpToolbar";
1611 lname
= "prefFilterList";
1612 } else if (kind
== "label") {
1613 opbarid
= "labelOpToolbar";
1616 lname
= "prefLabelList";
1617 } else if (kind
== "user") {
1618 opbarid
= "userOpToolbar";
1621 lname
= "prefUserList";
1625 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1626 disableContainerChildren(opbarid
, !select
);
1633 function toggleSelectPrefRow(sender
, kind
) {
1635 toggleSelectRow(sender
);
1638 var opbarid
= false;
1641 if (kind
== "feed") {
1642 opbarid
= "feedOpToolbar";
1643 nsel
= getSelectedFeeds();
1644 } else if (kind
== "fcat") {
1645 opbarid
= "catOpToolbar";
1646 nsel
= getSelectedFeedCats();
1647 } else if (kind
== "filter") {
1648 opbarid
= "filterOpToolbar";
1649 nsel
= getSelectedFilters();
1650 } else if (kind
== "label") {
1651 opbarid
= "labelOpToolbar";
1652 nsel
= getSelectedLabels();
1653 } else if (kind
== "user") {
1654 opbarid
= "userOpToolbar";
1655 nsel
= getSelectedUsers();
1658 if (opbarid
&& nsel
!= -1) {
1659 disableContainerChildren(opbarid
, nsel
== false);
1665 function toggleSelectFBListRow(sender
) {
1666 toggleSelectListRow(sender
);
1667 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1672 function pref_hotkey_handler(e
) {
1676 var shift_key
= false;
1679 shift_key
= e
.shiftKey
;
1685 keycode
= window
.event
.keyCode
;
1690 if (keycode
== 27) { // escape
1691 if (Element
.visible("hotkey_help_overlay")) {
1692 Element
.hide("hotkey_help_overlay");
1694 hotkey_prefix
= false;
1698 if (!hotkeys_enabled
) {
1699 debug("hotkeys disabled");
1703 if (keycode
== 16) return; // ignore lone shift
1705 if ((keycode
== 67 || keycode
== 71) && !hotkey_prefix
) {
1706 hotkey_prefix
= keycode
;
1707 debug("KP: PREFIX=" + keycode
);
1711 if (Element
.visible("hotkey_help_overlay")) {
1712 Element
.hide("hotkey_help_overlay");
1715 if (keycode
== 13 || keycode
== 27) {
1718 seq
= seq
+ "" + keycode
;
1721 /* Global hotkeys */
1723 if (!hotkey_prefix
) {
1725 if (keycode
== 68 && shift_key
) { // d
1726 if (!debug_mode_enabled
) {
1727 document
.getElementById('debug_output').style
.display
= 'block';
1728 debug('debug mode activated');
1730 document
.getElementById('debug_output').style
.display
= 'none';
1733 debug_mode_enabled
= !debug_mode_enabled
;
1737 if (keycode
== 191 && shift_key
) { // ?
1738 if (!Element
.visible("hotkey_help_overlay")) {
1739 Element
.show("hotkey_help_overlay");
1741 Element
.hide("hotkey_help_overlay");
1750 if (hotkey_prefix
== 67) { // c
1751 hotkey_prefix
= false;
1753 if (keycode
== 70) { // f
1754 return displayDlg("quickAddFilter");
1757 if (keycode
== 83) { // s
1758 return displayDlg("quickAddFeed");
1761 if (keycode
== 76) { // l
1762 return displayDlg("quickAddLabel");
1765 if (keycode
== 85) { // u
1773 if (hotkey_prefix
== 71) { // g
1775 hotkey_prefix
= false;
1777 if (keycode
== 49 && document
.getElementById("genConfigTab")) { // 1
1778 selectTab("genConfig");
1781 if (keycode
== 50 && document
.getElementById("feedConfigTab")) { // 2
1782 return selectTab("feedConfig");
1785 if (keycode
== 51 && document
.getElementById("feedBrowserTab")) { // 3
1786 return selectTab("feedBrowser");
1789 if (keycode
== 52 && document
.getElementById("filterConfigTab")) { // 4
1790 return selectTab("filterConfig");
1793 if (keycode
== 53 && document
.getElementById("labelConfigTab")) { // 5
1794 return selectTab("labelConfig");
1797 if (keycode
== 54 && document
.getElementById("userConfigTab")) { // 6
1798 return selectTab("userConfig");
1801 if (keycode
== 88) { // x
1807 if (document
.getElementById("piggie")) {
1809 if (seq
.match("807371717369")) {
1811 localPiggieFunction(true);
1813 localPiggieFunction(false);
1817 if (hotkey_prefix
) {
1818 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
);
1820 debug("KP: CODE=" + keycode
);
1824 exception_error("pref_hotkey_handler", e
);
1828 function editFeedCats() {
1829 if (!xmlhttp_ready(xmlhttp
)) {
1830 printLockingError();
1834 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1837 document
.getElementById("top25_feeds_btn").disabled
= true;
1839 // this button is not always available, no-op if not found
1842 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1843 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1847 function showFeedsWithErrors() {
1848 displayDlg('feedUpdateErrors');
1851 function changeUserPassword() {
1855 if (!xmlhttp_ready(xmlhttp
)) {
1856 printLockingError();
1860 var f
= document
.forms
["change_pass_form"];
1863 if (f
.OLD_PASSWORD
.value
== "") {
1864 new Effect
.Highlight(f
.OLD_PASSWORD
);
1865 notify_error("Old password cannot be blank.");
1869 if (f
.NEW_PASSWORD
.value
== "") {
1870 new Effect
.Highlight(f
.NEW_PASSWORD
);
1871 notify_error("New password cannot be blank.");
1875 if (f
.CONFIRM_PASSWORD
.value
== "") {
1876 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1877 notify_error("Entered passwords do not match.");
1881 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1882 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1883 new Effect
.Highlight(f
.NEW_PASSWORD
);
1884 notify_error("Entered passwords do not match.");
1890 var query
= Form
.serialize("change_pass_form");
1892 notify_progress("Trying to change password...");
1894 xmlhttp
.open("POST", "backend.php", true);
1895 xmlhttp
.onreadystatechange
=changepass_callback
;
1896 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1897 xmlhttp
.send(query
);
1900 exception_error("changeUserPassword", e
);
1906 function changeUserEmail() {
1910 if (!xmlhttp_ready(xmlhttp
)) {
1911 printLockingError();
1915 var query
= Form
.serialize("change_email_form");
1917 notify_progress("Trying to change e-mail...");
1919 xmlhttp
.open("POST", "backend.php", true);
1920 xmlhttp
.onreadystatechange
=notify_callback
;
1921 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1922 xmlhttp
.send(query
);
1925 exception_error("changeUserPassword", e
);
1932 function feedlistToggleSLAT() {
1933 notify_progress("Loading, please wait...");
1937 function pubRegenKey() {
1939 if (!xmlhttp_ready(xmlhttp
)) {
1940 printLockingError();
1944 var ok
= confirm(__("Replace current publishing address with a new one?"));
1948 notify_progress("Trying to change address...");
1950 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1951 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1958 function pubToClipboard() {
1962 if (!xmlhttp_ready(xmlhttp
)) {
1963 printLockingError();
1967 var link
= document
.getElementById("pubGenAddress");
1971 exception_error("pubToClipboard", e
);
1977 function validatePrefsSave() {
1980 var ok
= confirm(__("Save current configuration?"));
1984 var query
= Form
.serialize("pref_prefs_form");
1985 query
= query
+ "&subop=save-config";
1988 xmlhttp
.open("POST", "backend.php", true);
1989 xmlhttp
.onreadystatechange
=notify_callback
;
1990 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1991 xmlhttp
.send(query
);
1995 exception_error("validatePrefsSave", e
);
2001 function feedActionChange() {
2003 var chooser
= document
.getElementById("feedActionChooser");
2004 var opid
= chooser
[chooser
.selectedIndex
].value
;
2006 chooser
.selectedIndex
= 0;
2009 exception_error("feedActionChange", e
);
2013 function feedActionGo(op
) {
2015 if (op
== "facEdit") {
2019 if (op
== "facClear") {
2020 clearSelectedFeeds();
2023 if (op
== "facPurge") {
2024 purgeSelectedFeeds();
2027 if (op
== "facEditCats") {
2031 if (op
== "facRescore") {
2032 rescoreSelectedFeeds();
2035 if (op
== "facUnsubscribe") {
2036 removeSelectedFeeds();
2040 exception_error("feedActionGo", e
);
2045 function clearFeedArticles(feed_id
) {
2047 notify_progress("Clearing feed...");
2049 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
2051 new Ajax
.Request(query
, {
2052 onComplete: function(transport
) {
2059 function rescoreSelectedFeeds() {
2061 if (!xmlhttp_ready(xmlhttp
)) {
2062 printLockingError();
2066 var sel_rows
= getSelectedFeeds();
2068 if (sel_rows
.length
> 0) {
2070 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
2071 var ok
= confirm(__("Rescore articles in selected feeds?"));
2074 notify_progress("Rescoring selected feeds...");
2076 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
2077 param_escape(sel_rows
.toString()), true);
2078 xmlhttp
.onreadystatechange
=notify_callback
;
2082 alert(__("No feeds are selected."));
2088 function rescore_all_feeds() {
2089 var ok
= confirm(__("Rescore all articles? This operation may take a lot of time."));
2092 notify_progress("Rescoring feeds...");
2094 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
2095 xmlhttp
.onreadystatechange
=notify_callback
;