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') {
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() {
138 var container
= document
.getElementById('prefContent');
139 if (xmlhttp
.readyState
== 4) {
141 container
.innerHTML
=xmlhttp
.responseText
;
143 var row
= document
.getElementById("LILRR-" + active_label
);
145 if (!row
.className
.match("Selected")) {
146 row
.className
= row
.className
+ "Selected";
149 var checkbox
= document
.getElementById("LICHK-" + active_label
);
152 checkbox
.checked
= true;
155 if (typeof correctPNG
!= 'undefined') {
163 function feed_browser_callback() {
164 var container
= document
.getElementById('prefContent');
165 if (xmlhttp
.readyState
== 4) {
166 container
.innerHTML
=xmlhttp
.responseText
;
172 function userlist_callback() {
173 var container
= document
.getElementById('prefContent');
174 if (xmlhttp
.readyState
== 4) {
175 container
.innerHTML
=xmlhttp
.responseText
;
181 function prefslist_callback() {
182 var container
= document
.getElementById('prefContent');
183 if (xmlhttp
.readyState
== 4) {
184 container
.innerHTML
=xmlhttp
.responseText
;
190 function gethelp_callback() {
191 var container
= document
.getElementById('prefHelpBox');
192 if (xmlhttp
.readyState
== 4) {
194 container
.innerHTML
= xmlhttp
.responseText
;
195 container
.style
.display
= "block";
200 function notify_callback() {
201 if (xmlhttp
.readyState
== 4) {
202 notify_info(xmlhttp
.responseText
);
206 function prefs_reset_callback() {
207 if (xmlhttp
.readyState
== 4) {
208 notify_info(xmlhttp
.responseText
);
214 function changepass_callback() {
216 if (xmlhttp
.readyState
== 4) {
218 if (xmlhttp
.responseText
.indexOf("ERROR: ") == 0) {
219 notify_error(xmlhttp
.responseText
.replace("ERROR: ", ""));
221 notify_info(xmlhttp
.responseText
);
222 var warn
= document
.getElementById("default_pass_warning");
223 if (warn
) warn
.style
.display
= "none";
226 document
.forms
['change_pass_form'].reset();
230 exception_error("changepass_callback", e
);
234 function infobox_feed_cat_callback() {
235 if (xmlhttp
.readyState
== 4) {
240 if (document
.getElementById("prefFeedCatList")) {
241 var elems
= document
.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
243 for (var i
= 0; i
< elems
.length
; i
++) {
244 if (elems
[i
].id
&& elems
[i
].id
.match("FCATT-")) {
245 var cat_id
= elems
[i
].id
.replace("FCATT-", "");
247 new Ajax
.InPlaceEditor(elems
[i
],
248 'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id
);
254 exception_error("infobox_feed_cat_callback", e
);
259 function updateFeedList(sort_key
) {
261 if (!xmlhttp_ready(xmlhttp
)) {
266 var feed_search
= document
.getElementById("feed_search");
268 if (feed_search
) { search
= feed_search
.value
; }
270 var slat
= document
.getElementById("show_last_article_times");
272 var slat_checked
= false;
274 slat_checked
= slat
.checked
;
277 xmlhttp
.open("GET", "backend.php?op=pref-feeds" +
278 "&sort=" + param_escape(sort_key
) +
279 "&slat=" + param_escape(slat_checked
) +
280 "&search=" + param_escape(search
), true);
281 xmlhttp
.onreadystatechange
=feedlist_callback
;
286 function updateUsersList(sort_key
) {
288 if (!xmlhttp_ready(xmlhttp
)) {
293 var user_search
= document
.getElementById("user_search");
295 if (user_search
) { search
= user_search
.value
; }
297 xmlhttp
.open("GET", "backend.php?op=pref-users&sort="
298 + param_escape(sort_key
) +
299 "&search=" + param_escape(search
), true);
300 xmlhttp
.onreadystatechange
=userlist_callback
;
305 function addLabel() {
307 if (!xmlhttp_ready(xmlhttp
)) {
312 var form
= document
.forms
['label_edit_form'];
314 var sql_exp
= form
.sql_exp
.value
;
315 var description
= form
.description
.value
;
318 alert(__("Can't create label: missing SQL expression."));
322 if (description
== "") {
323 alert(__("Can't create label: missing caption."));
327 var query
= Form
.serialize("label_edit_form");
329 // we can be called from some other tab
330 active_tab
= "labelConfig";
332 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=add&" + query
, true);
333 xmlhttp
.onreadystatechange
=infobox_submit_callback
;
339 if (!xmlhttp_ready(xmlhttp
)) {
344 var link
= document
.getElementById("fadd_link");
346 if (link
.value
.length
== 0) {
347 alert(__("Error: No feed URL given."));
348 } else if (!isValidURL(link
.value
)) {
349 alert(__("Error: Invalid feed URL."));
351 notify_progress("Adding feed...");
353 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
354 param_escape(link
.value
), true);
355 xmlhttp
.onreadystatechange
=feedlist_callback
;
364 function addFeedCat() {
366 if (!xmlhttp_ready(xmlhttp
)) {
371 var cat
= document
.getElementById("fadd_cat");
373 if (cat
.value
.length
== 0) {
374 alert(__("Can't add category: no name specified."));
376 notify_progress("Adding feed category...");
378 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
379 param_escape(cat
.value
), true);
380 xmlhttp
.onreadystatechange
=infobox_callback
;
390 if (!xmlhttp_ready(xmlhttp
)) {
395 var sqlexp
= document
.getElementById("uadd_box");
397 if (sqlexp
.value
.length
== 0) {
398 alert(__("Can't add user: no login specified."));
400 notify_progress("Adding user...");
402 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=add&login=" +
403 param_escape(sqlexp
.value
), true);
405 xmlhttp
.onreadystatechange
=userlist_callback
;
413 function editLabel(id
) {
415 if (!xmlhttp_ready(xmlhttp
)) {
422 notify_progress("Loading, please wait...");
424 // document.getElementById("label_create_btn").disabled = true;
428 selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
429 selectTableRowById('LILRR-'+id
, 'LICHK-'+id
, true);
431 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
432 param_escape(id
), true);
433 xmlhttp
.onreadystatechange
=infobox_callback
;
438 function editUser(id
) {
440 if (!xmlhttp_ready(xmlhttp
)) {
447 notify_progress("Loading, please wait...");
449 selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
450 selectTableRowById('UMRR-'+id
, 'UMCHK-'+id
, true);
452 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
453 param_escape(id
), true);
454 xmlhttp
.onreadystatechange
=infobox_callback
;
459 function editFilter(id
) {
461 if (!xmlhttp_ready(xmlhttp
)) {
468 notify_progress("Loading, please wait...");
470 // document.getElementById("create_filter_btn").disabled = true;
472 selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
473 selectTableRowById('FILRR-'+id
, 'FICHK-'+id
, true);
475 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id
), true);
476 xmlhttp
.onreadystatechange
=infobox_callback
;
480 function editFeed(feed
) {
482 // notify("Editing feed...");
484 if (!xmlhttp_ready(xmlhttp
)) {
491 notify_progress("Loading, please wait...");
493 /* document.getElementById("subscribe_to_feed_btn").disabled = true;
496 document.getElementById("top25_feeds_btn").disabled = true;
498 // this button is not always available, no-op if not found
501 // clean selection from all rows & select row being edited
502 selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
503 selectTableRowById('FEEDR-'+feed
, 'FRCHK-'+feed
, true);
505 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
506 param_escape(feed
), true);
508 xmlhttp
.onreadystatechange
=infobox_callback
;
514 function editFeedCat(cat
) {
516 if (!xmlhttp_ready(xmlhttp
)) {
523 notify_progress("Loading, please wait...");
525 active_feed_cat
= cat
;
527 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
528 param_escape(cat
), true);
529 xmlhttp
.onreadystatechange
=infobox_callback
;
534 function getSelectedLabels() {
535 return getSelectedTableRowIds("prefLabelList", "LILRR");
538 function getSelectedUsers() {
539 return getSelectedTableRowIds("prefUserList", "UMRR");
542 function getSelectedFeeds() {
543 return getSelectedTableRowIds("prefFeedList", "FEEDR");
546 function getSelectedFilters() {
547 return getSelectedTableRowIds("prefFilterList", "FILRR");
550 function getSelectedFeedCats() {
551 return getSelectedTableRowIds("prefFeedCatList", "FCATR");
554 function getSelectedFeedsFromBrowser() {
556 var list
= document
.getElementById("browseFeedList");
557 if (!list
) list
= document
.getElementById("browseBigFeedList");
559 var selected
= new Array();
561 for (i
= 0; i
< list
.childNodes
.length
; i
++) {
562 var child
= list
.childNodes
[i
];
563 if (child
.id
&& child
.id
.match("FBROW-")) {
564 var id
= child
.id
.replace("FBROW-", "");
566 var cb
= document
.getElementById("FBCHK-" + id
);
577 function removeSelectedLabels() {
579 if (!xmlhttp_ready(xmlhttp
)) {
584 var sel_rows
= getSelectedLabels();
586 if (sel_rows
.length
> 0) {
588 var ok
= confirm(__("Remove selected labels?"));
591 notify_progress("Removing selected labels...");
593 xmlhttp
.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
594 param_escape(sel_rows
.toString()), true);
595 xmlhttp
.onreadystatechange
=labellist_callback
;
599 alert(__("No labels are selected."));
605 function removeSelectedUsers() {
607 if (!xmlhttp_ready(xmlhttp
)) {
612 var sel_rows
= getSelectedUsers();
614 if (sel_rows
.length
> 0) {
616 var ok
= confirm(__("Remove selected users?"));
619 notify_progress("Removing selected users...");
621 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
622 param_escape(sel_rows
.toString()), true);
623 xmlhttp
.onreadystatechange
=userlist_callback
;
628 alert(__("No users are selected."));
634 function removeSelectedFilters() {
636 if (!xmlhttp_ready(xmlhttp
)) {
641 var sel_rows
= getSelectedFilters();
643 if (sel_rows
.length
> 0) {
645 var ok
= confirm(__("Remove selected filters?"));
648 notify_progress("Removing selected filters...");
650 xmlhttp
.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
651 param_escape(sel_rows
.toString()), true);
652 xmlhttp
.onreadystatechange
=filterlist_callback
;
656 alert(__("No filters are selected."));
663 function removeSelectedFeeds() {
665 if (!xmlhttp_ready(xmlhttp
)) {
670 var sel_rows
= getSelectedFeeds();
672 if (sel_rows
.length
> 0) {
674 var ok
= confirm(__("Unsubscribe from selected feeds?"));
678 notify_progress("Unsubscribing from selected feeds...");
680 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
681 param_escape(sel_rows
.toString()), true);
682 xmlhttp
.onreadystatechange
=feedlist_callback
;
688 alert(__("No feeds are selected."));
695 function removeFeed(id
, title
) {
697 if (!xmlhttp_ready(xmlhttp
)) {
704 var msg
= __("Unsubscribe from %s?").replace("%s", title
);
706 var ok
= confirm(msg
);
710 notify_progress("Unsubscribing...");
712 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
713 param_escape(id
), true);
714 xmlhttp
.onreadystatechange
=feedlist_callback
;
722 function clearSelectedFeeds() {
724 if (!xmlhttp_ready(xmlhttp
)) {
729 var sel_rows
= getSelectedFeeds();
731 if (sel_rows
.length
> 1) {
732 alert(__("Please select only one feed."));
736 if (sel_rows
.length
> 0) {
738 var ok
= confirm(__("Erase all non-starred articles in selected feed?"));
741 notify_progress("Clearing selected feed...");
742 clearFeedArticles(sel_rows
[0]);
747 alert(__("No feeds are selected."));
754 function purgeSelectedFeeds() {
756 if (!xmlhttp_ready(xmlhttp
)) {
761 var sel_rows
= getSelectedFeeds();
763 if (sel_rows
.length
> 0) {
765 var pr
= prompt(__("How many days of articles to keep (0 - use default)?"), "0");
767 if (pr
!= undefined) {
768 notify_progress("Purging selected feed...");
770 var query
= "backend.php?op=rpc&subop=purge&ids="+
771 param_escape(sel_rows
.toString()) + "&days=" + pr
;
775 new Ajax
.Request(query
, {
776 onComplete: function(transport
) {
783 alert(__("No feeds are selected."));
790 function removeSelectedFeedCats() {
792 if (!xmlhttp_ready(xmlhttp
)) {
797 var sel_rows
= getSelectedFeedCats();
799 if (sel_rows
.length
> 0) {
801 var ok
= confirm(__("Remove selected categories?"));
804 notify_progress("Removing selected categories...");
806 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
807 param_escape(sel_rows
.toString()), true);
808 xmlhttp
.onreadystatechange
=infobox_callback
;
814 alert(__("No categories are selected."));
821 function feedEditCancel() {
823 if (!xmlhttp_ready(xmlhttp
)) {
829 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
830 document
.getElementById("top25_feeds_btn").disabled
= false;
832 // this button is not always available, no-op if not found
837 selectPrefRows('feed', false); // cleanup feed selection
842 function feedCatEditCancel() {
844 if (!xmlhttp_ready(xmlhttp
)) {
849 active_feed_cat
= false;
851 // notify("Operation cancelled.");
853 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
854 xmlhttp
.onreadystatechange
=infobox_callback
;
860 function feedEditSave() {
864 if (!xmlhttp_ready(xmlhttp
)) {
869 // FIXME: add parameter validation
871 var query
= Form
.serialize("edit_feed_form");
873 notify_progress("Saving feed...");
875 xmlhttp
.open("POST", "backend.php", true);
876 xmlhttp
.onreadystatechange
=feedlist_callback
;
877 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
885 exception_error("feedEditSave", e
);
889 function feedCatEditSave() {
891 if (!xmlhttp_ready(xmlhttp
)) {
896 notify_progress("Saving category...");
898 var query
= Form
.serialize("feed_cat_edit_form");
900 xmlhttp
.open("GET", "backend.php?" + query
, true);
901 xmlhttp
.onreadystatechange
=infobox_callback
;
904 active_feed_cat
= false;
909 function labelEditCancel() {
911 if (!xmlhttp_ready(xmlhttp
)) {
917 document
.getElementById("label_create_btn").disabled
= false;
918 selectPrefRows('label', false); // cleanup feed selection
921 active_label
= false;
928 function userEditCancel() {
930 if (!xmlhttp_ready(xmlhttp
)) {
935 selectPrefRows('user', false); // cleanup feed selection
941 function filterEditCancel() {
943 if (!xmlhttp_ready(xmlhttp
)) {
949 document
.getElementById("create_filter_btn").disabled
= false;
950 selectPrefRows('filter', false); // cleanup feed selection
958 function labelEditSave() {
960 var label
= active_label
;
962 if (!xmlhttp_ready(xmlhttp
)) {
967 /* if (!is_opera()) {
969 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
970 var description = document.forms["label_edit_form"].description.value;
972 if (sql_exp.length == 0) {
973 alert("SQL Expression cannot be blank.");
977 if (description.length == 0) {
978 alert("Caption field cannot be blank.");
985 notify_progress("Saving label...");
987 active_label
= false;
989 query
= Form
.serialize("label_edit_form");
991 xmlhttp
.open("GET", "backend.php?" + query
, true);
992 xmlhttp
.onreadystatechange
=labellist_callback
;
998 function userEditSave() {
1000 if (!xmlhttp_ready(xmlhttp
)) {
1001 printLockingError();
1005 var login
= document
.forms
["user_edit_form"].login
.value
;
1007 if (login
.length
== 0) {
1008 alert(__("Login field cannot be blank."));
1012 notify_progress("Saving user...");
1016 var query
= Form
.serialize("user_edit_form");
1018 xmlhttp
.open("GET", "backend.php?" + query
, true);
1019 xmlhttp
.onreadystatechange
=userlist_callback
;
1026 function filterEditSave() {
1028 if (!xmlhttp_ready(xmlhttp
)) {
1029 printLockingError();
1033 /* if (!is_opera()) {
1034 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
1036 if (reg_exp.length == 0) {
1037 alert("Filter expression field cannot be blank.");
1042 notify_progress("Saving filter...");
1044 var query
= Form
.serialize("filter_edit_form");
1048 document
.getElementById("create_filter_btn").disabled
= false;
1050 xmlhttp
.open("GET", "backend.php?" + query
, true);
1051 xmlhttp
.onreadystatechange
=filterlist_callback
;
1057 function editSelectedLabel() {
1058 var rows
= getSelectedLabels();
1060 if (rows
.length
== 0) {
1061 alert(__("No labels are selected."));
1065 if (rows
.length
> 1) {
1066 alert(__("Please select only one label."));
1076 function editSelectedUser() {
1077 var rows
= getSelectedUsers();
1079 if (rows
.length
== 0) {
1080 alert(__("No users are selected."));
1084 if (rows
.length
> 1) {
1085 alert(__("Please select only one user."));
1094 function resetSelectedUserPass() {
1095 var rows
= getSelectedUsers();
1097 if (rows
.length
== 0) {
1098 alert(__("No users are selected."));
1102 if (rows
.length
> 1) {
1103 alert(__("Please select only one user."));
1107 var ok
= confirm(__("Reset password of selected user?"));
1110 notify_progress("Resetting password for selected user...");
1114 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1115 param_escape(id
), true);
1116 xmlhttp
.onreadystatechange
=userlist_callback
;
1121 function selectedUserDetails() {
1123 if (!xmlhttp_ready(xmlhttp
)) {
1124 printLockingError();
1128 var rows
= getSelectedUsers();
1130 if (rows
.length
== 0) {
1131 alert(__("No users are selected."));
1135 if (rows
.length
> 1) {
1136 alert(__("Please select only one user."));
1140 notify_progress("Loading, please wait...");
1144 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1145 xmlhttp
.onreadystatechange
=infobox_callback
;
1150 function selectedFeedDetails() {
1152 if (!xmlhttp_ready(xmlhttp
)) {
1153 printLockingError();
1157 var rows
= getSelectedFeeds();
1159 if (rows
.length
== 0) {
1160 alert(__("No feeds are selected."));
1164 if (rows
.length
> 1) {
1165 alert(__("Please select only one feed."));
1169 // var id = rows[0];
1173 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1174 param_escape(rows
.toString()), true);
1175 xmlhttp
.onreadystatechange
=infobox_callback
;
1180 function editSelectedFilter() {
1181 var rows
= getSelectedFilters();
1183 if (rows
.length
== 0) {
1184 alert(__("No filters are selected."));
1188 if (rows
.length
> 1) {
1189 alert(__("Please select only one filter."));
1195 editFilter(rows
[0]);
1200 function editSelectedFeed() {
1201 var rows
= getSelectedFeeds();
1203 if (rows
.length
== 0) {
1204 alert(__("No feeds are selected."));
1208 if (rows
.length
> 1) {
1209 alert(__("Please select one feed."));
1219 function editSelectedFeedCat() {
1220 var rows
= getSelectedFeedCats();
1222 if (rows
.length
== 0) {
1223 alert(__("No categories are selected."));
1227 if (rows
.length
> 1) {
1228 alert(__("Please select only one category."));
1234 editFeedCat(rows
[0]);
1238 function piggie(enable
) {
1240 debug("I LOVEDED IT!");
1241 var piggie
= document
.getElementById("piggie");
1243 Element
.show(piggie
);
1244 Position
.Center(piggie
);
1245 Effect
.Puff(piggie
);
1250 function validateOpmlImport() {
1252 var opml_file
= document
.getElementById("opml_file");
1254 if (opml_file
.value
.length
== 0) {
1255 alert(__("No OPML file to upload."));
1262 function updateFilterList(sort_key
) {
1264 if (!xmlhttp_ready(xmlhttp
)) {
1265 printLockingError();
1269 var filter_search
= document
.getElementById("filter_search");
1271 if (filter_search
) { search
= filter_search
.value
; }
1273 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1274 param_escape(sort_key
) +
1275 "&search=" + param_escape(search
), true);
1276 xmlhttp
.onreadystatechange
=filterlist_callback
;
1281 function updateLabelList(sort_key
) {
1283 if (!xmlhttp_ready(xmlhttp
)) {
1284 printLockingError();
1288 var label_search
= document
.getElementById("label_search");
1290 if (label_search
) { search
= label_search
.value
; }
1292 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1293 param_escape(sort_key
) +
1294 "&search=" + param_escape(search
), true);
1295 xmlhttp
.onreadystatechange
=labellist_callback
;
1299 function updatePrefsList() {
1301 if (!xmlhttp_ready(xmlhttp
)) {
1302 printLockingError();
1306 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1307 xmlhttp
.onreadystatechange
=prefslist_callback
;
1312 function selectTab(id
, noupdate
, subop
) {
1316 if (!id
) id
= active_tab
;
1320 if (!xmlhttp_ready(xmlhttp
)) {
1321 printLockingError();
1326 var c
= document
.getElementById('prefContent');
1332 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1334 notify_progress("Loading, please wait...");
1336 // close active infobox if needed
1339 // clean up all current selections, just in case
1340 active_feed_cat
= false;
1341 active_label
= false;
1343 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1344 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1346 if (id
== "feedConfig") {
1348 } else if (id
== "filterConfig") {
1350 } else if (id
== "labelConfig") {
1352 } else if (id
== "genConfig") {
1354 } else if (id
== "userConfig") {
1356 } else if (id
== "feedBrowser") {
1357 updateBigFeedBrowser();
1361 /* clean selection from all tabs */
1363 var tabs_holder
= document
.getElementById("prefTabs");
1364 var tab
= tabs_holder
.firstChild
;
1367 if (tab
.className
&& tab
.className
.match("prefsTabSelected")) {
1368 tab
.className
= "prefsTab";
1370 tab
= tab
.nextSibling
;
1373 /* mark new tab as selected */
1375 tab
= document
.getElementById(id
+ "Tab");
1378 if (!tab
.className
.match("Selected")) {
1379 tab
.className
= tab
.className
+ "Selected";
1386 exception_error("selectTab", e
);
1390 function backend_sanity_check_callback() {
1392 if (xmlhttp
.readyState
== 4) {
1396 if (sanity_check_done
) {
1397 fatalError(11, "Sanity check request received twice. This can indicate "+
1398 "presence of Firebug or some other disrupting extension. "+
1399 "Please disable it and try again.");
1403 if (!xmlhttp
.responseXML
) {
1404 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1408 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1411 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1415 var error_code
= reply
.getAttribute("error-code");
1417 if (error_code
&& error_code
!= 0) {
1418 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1421 debug("sanity check ok");
1423 var params
= reply
.nextSibling
;
1426 debug('reading init-params...');
1427 var param
= params
.firstChild
;
1430 var k
= param
.getAttribute("key");
1431 var v
= param
.getAttribute("value");
1432 debug(k
+ " => " + v
);
1434 param
= param
.nextSibling
;
1438 sanity_check_done
= true;
1440 init_second_stage();
1443 exception_error("backend_sanity_check_callback", e
);
1448 function init_second_stage() {
1451 active_tab
= getInitParam("prefs_active_tab");
1452 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1454 document
.onkeydown
= pref_hotkey_handler
;
1456 var tab
= getURLParam('tab');
1458 caller_subop
= getURLParam('subop');
1464 if (navigator
.userAgent
.match("Opera")) {
1465 setTimeout("selectTab()", 500);
1467 selectTab(active_tab
);
1471 loading_set_progress(60);
1474 exception_error("init_second_stage", e
);
1482 if (arguments
.callee
.done
) return;
1483 arguments
.callee
.done
= true;
1485 if (getURLParam('debug')) {
1486 Element
.show("debug_output");
1487 debug('debug mode activated');
1492 document
.getElementById("prefContent").innerHTML
=
1493 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1494 "to function properly. Your browser doesn't seem to support it.";
1498 loading_set_progress(30);
1500 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1501 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1505 exception_error("init", e
);
1509 function categorizeSelectedFeeds() {
1511 if (!xmlhttp_ready(xmlhttp
)) {
1512 printLockingError();
1516 var sel_rows
= getSelectedFeeds();
1518 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1519 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1521 if (sel_rows
.length
> 0) {
1523 notify_progress("Changing category of selected feeds...");
1525 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1526 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1527 xmlhttp
.onreadystatechange
=feedlist_callback
;
1532 alert(__("No feeds are selected."));
1538 function validatePrefsReset() {
1540 var ok
= confirm(__("Reset to defaults?"));
1544 var query
= Form
.serialize("pref_prefs_form");
1545 query
= query
+ "&subop=reset-config";
1548 xmlhttp
.open("POST", "backend.php", true);
1549 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1550 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1551 xmlhttp
.send(query
);
1555 exception_error("validatePrefsSave", e
);
1562 function browseFeeds(limit
) {
1564 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1565 xmlhttp
.onreadystatechange
=infobox_callback
;
1570 function feedBrowserSubscribe() {
1573 var selected
= getSelectedFeedsFromBrowser();
1575 if (selected
.length
> 0) {
1577 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1578 param_escape(selected
.toString()), true);
1579 xmlhttp
.onreadystatechange
=feedlist_callback
;
1582 alert(__("No feeds are selected."));
1586 exception_error("feedBrowserSubscribe", e
);
1590 function updateBigFeedBrowser(limit
) {
1592 if (!xmlhttp_ready(xmlhttp
)) {
1593 printLockingError();
1597 var query
= "backend.php?op=pref-feed-browser";
1599 var limit_sel
= document
.getElementById("feedBrowserLimit");
1602 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1603 query
= query
+ "&limit=" + param_escape(limit
);
1606 xmlhttp
.open("GET", query
, true);
1607 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1611 function browserToggleExpand(id
) {
1613 /* if (feed_to_expand && feed_to_expand != id) {
1614 var d = document.getElementById("BRDET-" + feed_to_expand);
1615 d.style.display = "none";
1618 if (!xmlhttp_ready(xmlhttp
)) {
1619 printLockingError();
1623 /* if (feed_to_expand && id != feed_to_expand) {
1624 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1627 var d
= document
.getElementById("BRDET-" + id
);
1629 if (Element
.visible(d
)) {
1630 Effect
.Fade(d
, {duration
: 0.5});
1632 feed_to_expand
= id
;
1634 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1635 + param_escape(id
), true);
1636 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1641 exception_error("browserToggleExpand", e
);
1645 function selectPrefRows(kind
, select
) {
1648 var opbarid
= false;
1653 if (kind
== "feed") {
1654 opbarid
= "feedOpToolbar";
1657 lname
= "prefFeedList";
1658 } else if (kind
== "fcat") {
1659 opbarid
= "catOpToolbar";
1662 lname
= "prefFeedCatList";
1663 } else if (kind
== "filter") {
1664 opbarid
= "filterOpToolbar";
1667 lname
= "prefFilterList";
1668 } else if (kind
== "label") {
1669 opbarid
= "labelOpToolbar";
1672 lname
= "prefLabelList";
1673 } else if (kind
== "user") {
1674 opbarid
= "userOpToolbar";
1677 lname
= "prefUserList";
1681 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1682 disableContainerChildren(opbarid
, !select
);
1689 function toggleSelectPrefRow(sender
, kind
) {
1691 toggleSelectRow(sender
);
1694 var opbarid
= false;
1697 if (kind
== "feed") {
1698 opbarid
= "feedOpToolbar";
1699 nsel
= getSelectedFeeds();
1700 } else if (kind
== "fcat") {
1701 opbarid
= "catOpToolbar";
1702 nsel
= getSelectedFeedCats();
1703 } else if (kind
== "filter") {
1704 opbarid
= "filterOpToolbar";
1705 nsel
= getSelectedFilters();
1706 } else if (kind
== "label") {
1707 opbarid
= "labelOpToolbar";
1708 nsel
= getSelectedLabels();
1709 } else if (kind
== "user") {
1710 opbarid
= "userOpToolbar";
1711 nsel
= getSelectedUsers();
1714 if (opbarid
&& nsel
!= -1) {
1715 disableContainerChildren(opbarid
, nsel
== false);
1721 function toggleSelectFBListRow(sender
) {
1722 toggleSelectListRow(sender
);
1723 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1728 function pref_hotkey_handler(e
) {
1732 var shift_key
= false;
1735 shift_key
= e
.shiftKey
;
1741 keycode
= window
.event
.keyCode
;
1746 var keychar
= String
.fromCharCode(keycode
);
1748 if (keycode
== 27) { // escape
1749 if (Element
.visible("hotkey_help_overlay")) {
1750 Element
.hide("hotkey_help_overlay");
1752 hotkey_prefix
= false;
1756 if (!hotkeys_enabled
) {
1757 debug("hotkeys disabled");
1761 if (keycode
== 16) return; // ignore lone shift
1763 if ((keycode
== 67 || keycode
== 71) && !hotkey_prefix
) {
1764 hotkey_prefix
= keycode
;
1765 debug("KP: PREFIX=" + keycode
+ " CHAR=" + keychar
);
1769 if (Element
.visible("hotkey_help_overlay")) {
1770 Element
.hide("hotkey_help_overlay");
1773 if (keycode
== 13 || keycode
== 27) {
1776 seq
= seq
+ "" + keycode
;
1779 /* Global hotkeys */
1781 if (!hotkey_prefix
) {
1783 if (keycode
== 68 && shift_key
) { // d
1784 if (!Element
.visible("debug_output")) {
1785 Element
.show("debug_output");
1786 debug('debug mode activated');
1788 Element
.hide("debug_output");
1793 if ((keycode
== 191 || keychar
== '?') && shift_key
) { // ?
1794 if (!Element
.visible("hotkey_help_overlay")) {
1795 //Element.show("hotkey_help_overlay");
1796 Effect
.Appear("hotkey_help_overlay", {duration
: 0.3});
1798 Element
.hide("hotkey_help_overlay");
1803 if (keycode
== 191 || keychar
== '/') { // /
1804 var search_boxes
= new Array("label_search",
1805 "feed_search", "filter_search", "user_search");
1807 for (var i
= 0; i
< search_boxes
.length
; i
++) {
1808 var elem
= document
.getElementById(search_boxes
[i
]);
1810 focus_element(search_boxes
[i
]);
1819 if (hotkey_prefix
== 67) { // c
1820 hotkey_prefix
= false;
1822 if (keycode
== 70) { // f
1823 displayDlg("quickAddFilter");
1827 if (keycode
== 83) { // s
1828 displayDlg("quickAddFeed");
1832 if (keycode
== 76) { // l
1833 displayDlg("quickAddLabel");
1837 if (keycode
== 85) { // u
1841 if (keycode
== 67) { // c
1846 if (keycode
== 84 && shift_key
) { // T
1855 if (hotkey_prefix
== 71) { // g
1857 hotkey_prefix
= false;
1859 if (keycode
== 49 && document
.getElementById("genConfigTab")) { // 1
1860 selectTab("genConfig");
1864 if (keycode
== 50 && document
.getElementById("feedConfigTab")) { // 2
1865 selectTab("feedConfig");
1869 if (keycode
== 51 && document
.getElementById("feedBrowserTab")) { // 3
1870 selectTab("feedBrowser");
1874 if (keycode
== 52 && document
.getElementById("filterConfigTab")) { // 4
1875 selectTab("filterConfig");
1879 if (keycode
== 53 && document
.getElementById("labelConfigTab")) { // 5
1880 selectTab("labelConfig");
1884 if (keycode
== 54 && document
.getElementById("userConfigTab")) { // 6
1885 selectTab("userConfig");
1889 if (keycode
== 88) { // x
1895 if (document
.getElementById("piggie")) {
1897 if (seq
.match("807371717369")) {
1905 if (hotkey_prefix
) {
1906 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
+ " CHAR=" + keychar
);
1908 debug("KP: CODE=" + keycode
+ " CHAR=" + keychar
);
1912 exception_error("pref_hotkey_handler", e
);
1916 function editFeedCats() {
1917 if (!xmlhttp_ready(xmlhttp
)) {
1918 printLockingError();
1922 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1925 document
.getElementById("top25_feeds_btn").disabled
= true;
1927 // this button is not always available, no-op if not found
1930 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1931 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1935 function showFeedsWithErrors() {
1936 displayDlg('feedUpdateErrors');
1939 function changeUserPassword() {
1943 if (!xmlhttp_ready(xmlhttp
)) {
1944 printLockingError();
1948 var f
= document
.forms
["change_pass_form"];
1951 if (f
.OLD_PASSWORD
.value
== "") {
1952 new Effect
.Highlight(f
.OLD_PASSWORD
);
1953 notify_error("Old password cannot be blank.");
1957 if (f
.NEW_PASSWORD
.value
== "") {
1958 new Effect
.Highlight(f
.NEW_PASSWORD
);
1959 notify_error("New password cannot be blank.");
1963 if (f
.CONFIRM_PASSWORD
.value
== "") {
1964 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1965 notify_error("Entered passwords do not match.");
1969 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1970 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1971 new Effect
.Highlight(f
.NEW_PASSWORD
);
1972 notify_error("Entered passwords do not match.");
1978 var query
= Form
.serialize("change_pass_form");
1980 notify_progress("Trying to change password...");
1982 xmlhttp
.open("POST", "backend.php", true);
1983 xmlhttp
.onreadystatechange
=changepass_callback
;
1984 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1985 xmlhttp
.send(query
);
1988 exception_error("changeUserPassword", e
);
1994 function changeUserEmail() {
1998 if (!xmlhttp_ready(xmlhttp
)) {
1999 printLockingError();
2003 var query
= Form
.serialize("change_email_form");
2005 notify_progress("Trying to change e-mail...");
2007 xmlhttp
.open("POST", "backend.php", true);
2008 xmlhttp
.onreadystatechange
=notify_callback
;
2009 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2010 xmlhttp
.send(query
);
2013 exception_error("changeUserPassword", e
);
2020 function feedlistToggleSLAT() {
2021 notify_progress("Loading, please wait...");
2025 function pubRegenKey() {
2027 if (!xmlhttp_ready(xmlhttp
)) {
2028 printLockingError();
2032 var ok
= confirm(__("Replace current publishing address with a new one?"));
2036 notify_progress("Trying to change address...");
2038 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
2039 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
2046 function pubToClipboard() {
2050 if (!xmlhttp_ready(xmlhttp
)) {
2051 printLockingError();
2055 var link
= document
.getElementById("pubGenAddress");
2059 exception_error("pubToClipboard", e
);
2065 function validatePrefsSave() {
2068 var ok
= confirm(__("Save current configuration?"));
2072 var query
= Form
.serialize("pref_prefs_form");
2073 query
= query
+ "&subop=save-config";
2076 xmlhttp
.open("POST", "backend.php", true);
2077 xmlhttp
.onreadystatechange
=notify_callback
;
2078 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2079 xmlhttp
.send(query
);
2083 exception_error("validatePrefsSave", e
);
2089 function feedActionChange() {
2091 var chooser
= document
.getElementById("feedActionChooser");
2092 var opid
= chooser
[chooser
.selectedIndex
].value
;
2094 chooser
.selectedIndex
= 0;
2097 exception_error("feedActionChange", e
);
2101 function feedActionGo(op
) {
2103 if (op
== "facEdit") {
2107 if (op
== "facClear") {
2108 clearSelectedFeeds();
2111 if (op
== "facPurge") {
2112 purgeSelectedFeeds();
2115 if (op
== "facEditCats") {
2119 if (op
== "facRescore") {
2120 rescoreSelectedFeeds();
2123 if (op
== "facUnsubscribe") {
2124 removeSelectedFeeds();
2128 exception_error("feedActionGo", e
);
2133 function clearFeedArticles(feed_id
) {
2135 notify_progress("Clearing feed...");
2137 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
2139 new Ajax
.Request(query
, {
2140 onComplete: function(transport
) {
2147 function rescoreSelectedFeeds() {
2149 if (!xmlhttp_ready(xmlhttp
)) {
2150 printLockingError();
2154 var sel_rows
= getSelectedFeeds();
2156 if (sel_rows
.length
> 0) {
2158 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
2159 var ok
= confirm(__("Rescore articles in selected feeds?"));
2162 notify_progress("Rescoring selected feeds...");
2164 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
2165 param_escape(sel_rows
.toString()), true);
2166 xmlhttp
.onreadystatechange
=notify_callback
;
2170 alert(__("No feeds are selected."));
2176 function rescore_all_feeds() {
2177 var ok
= confirm(__("Rescore all articles? This operation may take a lot of time."));
2180 notify_progress("Rescoring feeds...");
2182 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
2183 xmlhttp
.onreadystatechange
=notify_callback
;