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
)) {
791 document
.getElementById("subscribe_to_feed_btn").disabled
= false;
792 document
.getElementById("top25_feeds_btn").disabled
= false;
794 // this button is not always available, no-op if not found
799 selectPrefRows('feed', false); // cleanup feed selection
804 function feedCatEditCancel() {
806 if (!xmlhttp_ready(xmlhttp
)) {
811 active_feed_cat
= false;
813 // notify("Operation cancelled.");
815 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
816 xmlhttp
.onreadystatechange
=infobox_callback
;
822 function feedEditSave() {
826 if (!xmlhttp_ready(xmlhttp
)) {
831 // FIXME: add parameter validation
833 var query
= Form
.serialize("edit_feed_form");
835 notify_progress("Saving feed...");
837 xmlhttp
.open("POST", "backend.php", true);
838 xmlhttp
.onreadystatechange
=feedlist_callback
;
839 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
847 exception_error("feedEditSave", e
);
851 function feedCatEditSave() {
853 if (!xmlhttp_ready(xmlhttp
)) {
858 notify_progress("Saving category...");
860 var query
= Form
.serialize("feed_cat_edit_form");
862 xmlhttp
.open("GET", "backend.php?" + query
, true);
863 xmlhttp
.onreadystatechange
=infobox_callback
;
866 active_feed_cat
= false;
871 function labelEditCancel() {
873 if (!xmlhttp_ready(xmlhttp
)) {
879 document
.getElementById("label_create_btn").disabled
= false;
880 selectPrefRows('label', false); // cleanup feed selection
883 active_label
= false;
890 function userEditCancel() {
892 if (!xmlhttp_ready(xmlhttp
)) {
897 selectPrefRows('user', false); // cleanup feed selection
903 function filterEditCancel() {
905 if (!xmlhttp_ready(xmlhttp
)) {
911 document
.getElementById("create_filter_btn").disabled
= false;
912 selectPrefRows('filter', false); // cleanup feed selection
920 function labelEditSave() {
922 var label
= active_label
;
924 if (!xmlhttp_ready(xmlhttp
)) {
929 /* if (!is_opera()) {
931 var sql_exp = document.forms["label_edit_form"].sql_exp.value;
932 var description = document.forms["label_edit_form"].description.value;
934 if (sql_exp.length == 0) {
935 alert("SQL Expression cannot be blank.");
939 if (description.length == 0) {
940 alert("Caption field cannot be blank.");
947 notify_progress("Saving label...");
949 active_label
= false;
951 query
= Form
.serialize("label_edit_form");
953 xmlhttp
.open("GET", "backend.php?" + query
, true);
954 xmlhttp
.onreadystatechange
=labellist_callback
;
960 function userEditSave() {
962 if (!xmlhttp_ready(xmlhttp
)) {
967 var login
= document
.forms
["user_edit_form"].login
.value
;
969 if (login
.length
== 0) {
970 alert(__("Login field cannot be blank."));
974 notify_progress("Saving user...");
978 var query
= Form
.serialize("user_edit_form");
980 xmlhttp
.open("GET", "backend.php?" + query
, true);
981 xmlhttp
.onreadystatechange
=userlist_callback
;
988 function filterEditSave() {
990 if (!xmlhttp_ready(xmlhttp
)) {
995 /* if (!is_opera()) {
996 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
998 if (reg_exp.length == 0) {
999 alert("Filter expression field cannot be blank.");
1004 notify_progress("Saving filter...");
1006 var query
= Form
.serialize("filter_edit_form");
1010 document
.getElementById("create_filter_btn").disabled
= false;
1012 xmlhttp
.open("GET", "backend.php?" + query
, true);
1013 xmlhttp
.onreadystatechange
=filterlist_callback
;
1019 function editSelectedLabel() {
1020 var rows
= getSelectedLabels();
1022 if (rows
.length
== 0) {
1023 alert(__("No labels are selected."));
1027 if (rows
.length
> 1) {
1028 alert(__("Please select only one label."));
1038 function editSelectedUser() {
1039 var rows
= getSelectedUsers();
1041 if (rows
.length
== 0) {
1042 alert(__("No users are selected."));
1046 if (rows
.length
> 1) {
1047 alert(__("Please select only one user."));
1056 function resetSelectedUserPass() {
1057 var rows
= getSelectedUsers();
1059 if (rows
.length
== 0) {
1060 alert(__("No users are selected."));
1064 if (rows
.length
> 1) {
1065 alert(__("Please select only one user."));
1069 var ok
= confirm(__("Reset password of selected user?"));
1072 notify_progress("Resetting password for selected user...");
1076 xmlhttp
.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
1077 param_escape(id
), true);
1078 xmlhttp
.onreadystatechange
=userlist_callback
;
1083 function selectedUserDetails() {
1085 if (!xmlhttp_ready(xmlhttp
)) {
1086 printLockingError();
1090 var rows
= getSelectedUsers();
1092 if (rows
.length
== 0) {
1093 alert(__("No users are selected."));
1097 if (rows
.length
> 1) {
1098 alert(__("Please select only one user."));
1102 notify_progress("Loading, please wait...");
1106 xmlhttp
.open("GET", "backend.php?op=user-details&id=" + id
, true);
1107 xmlhttp
.onreadystatechange
=infobox_callback
;
1112 function selectedFeedDetails() {
1114 if (!xmlhttp_ready(xmlhttp
)) {
1115 printLockingError();
1119 var rows
= getSelectedFeeds();
1121 if (rows
.length
== 0) {
1122 alert(__("No feeds are selected."));
1126 if (rows
.length
> 1) {
1127 alert(__("Please select only one feed."));
1131 // var id = rows[0];
1135 xmlhttp
.open("GET", "backend.php?op=feed-details&id=" +
1136 param_escape(rows
.toString()), true);
1137 xmlhttp
.onreadystatechange
=infobox_callback
;
1142 function editSelectedFilter() {
1143 var rows
= getSelectedFilters();
1145 if (rows
.length
== 0) {
1146 alert(__("No filters are selected."));
1150 if (rows
.length
> 1) {
1151 alert(__("Please select only one filter."));
1157 editFilter(rows
[0]);
1162 function editSelectedFeed() {
1163 var rows
= getSelectedFeeds();
1165 if (rows
.length
== 0) {
1166 alert(__("No feeds are selected."));
1170 if (rows
.length
> 1) {
1171 alert(__("Please select one feed."));
1181 function editSelectedFeedCat() {
1182 var rows
= getSelectedFeedCats();
1184 if (rows
.length
== 0) {
1185 alert(__("No categories are selected."));
1189 if (rows
.length
> 1) {
1190 alert(__("Please select only one category."));
1196 editFeedCat(rows
[0]);
1200 function localPiggieFunction(enable
) {
1202 debug("I LOVEDED IT!");
1203 var piggie
= document
.getElementById("piggie");
1205 Element
.show(piggie
);
1206 Position
.Center(piggie
);
1207 Effect
.Puff(piggie
);
1212 function validateOpmlImport() {
1214 var opml_file
= document
.getElementById("opml_file");
1216 if (opml_file
.value
.length
== 0) {
1217 alert(__("No OPML file to upload."));
1224 function updateFilterList(sort_key
) {
1226 if (!xmlhttp_ready(xmlhttp
)) {
1227 printLockingError();
1231 var filter_search
= document
.getElementById("filter_search");
1233 if (filter_search
) { search
= filter_search
.value
; }
1235 xmlhttp
.open("GET", "backend.php?op=pref-filters&sort=" +
1236 param_escape(sort_key
) +
1237 "&search=" + param_escape(search
), true);
1238 xmlhttp
.onreadystatechange
=filterlist_callback
;
1243 function updateLabelList(sort_key
) {
1245 if (!xmlhttp_ready(xmlhttp
)) {
1246 printLockingError();
1250 var label_search
= document
.getElementById("label_search");
1252 if (label_search
) { search
= label_search
.value
; }
1254 xmlhttp
.open("GET", "backend.php?op=pref-labels&sort=" +
1255 param_escape(sort_key
) +
1256 "&search=" + param_escape(search
), true);
1257 xmlhttp
.onreadystatechange
=labellist_callback
;
1261 function updatePrefsList() {
1263 if (!xmlhttp_ready(xmlhttp
)) {
1264 printLockingError();
1268 xmlhttp
.open("GET", "backend.php?op=pref-prefs", true);
1269 xmlhttp
.onreadystatechange
=prefslist_callback
;
1274 function selectTab(id
, noupdate
, subop
) {
1278 if (!id
) id
= active_tab
;
1282 if (!xmlhttp_ready(xmlhttp
)) {
1283 printLockingError();
1288 var c
= document
.getElementById('prefContent');
1294 debug("selectTab: " + id
+ "(NU: " + noupdate
+ ")");
1296 notify_progress("Loading, please wait...");
1298 // close active infobox if needed
1301 // clean up all current selections, just in case
1302 active_feed_cat
= false;
1303 active_label
= false;
1305 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1306 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1308 if (id
== "feedConfig") {
1310 } else if (id
== "filterConfig") {
1312 } else if (id
== "labelConfig") {
1314 } else if (id
== "genConfig") {
1316 } else if (id
== "userConfig") {
1318 } else if (id
== "feedBrowser") {
1319 updateBigFeedBrowser();
1323 /* clean selection from all tabs */
1325 var tabs_holder
= document
.getElementById("prefTabs");
1326 var tab
= tabs_holder
.firstChild
;
1329 if (tab
.className
&& tab
.className
.match("prefsTabSelected")) {
1330 tab
.className
= "prefsTab";
1332 tab
= tab
.nextSibling
;
1335 /* mark new tab as selected */
1337 tab
= document
.getElementById(id
+ "Tab");
1340 if (!tab
.className
.match("Selected")) {
1341 tab
.className
= tab
.className
+ "Selected";
1348 exception_error("selectTab", e
);
1352 function backend_sanity_check_callback() {
1354 if (xmlhttp
.readyState
== 4) {
1358 if (sanity_check_done
) {
1359 fatalError(11, "Sanity check request received twice. This can indicate "+
1360 "presence of Firebug or some other disrupting extension. "+
1361 "Please disable it and try again.");
1365 if (!xmlhttp
.responseXML
) {
1366 fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp
.responseText
);
1370 var reply
= xmlhttp
.responseXML
.firstChild
.firstChild
;
1373 fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp
.responseText
);
1377 var error_code
= reply
.getAttribute("error-code");
1379 if (error_code
&& error_code
!= 0) {
1380 return fatalError(error_code
, reply
.getAttribute("error-msg"));
1383 debug("sanity check ok");
1385 var params
= reply
.nextSibling
;
1388 debug('reading init-params...');
1389 var param
= params
.firstChild
;
1392 var k
= param
.getAttribute("key");
1393 var v
= param
.getAttribute("value");
1394 debug(k
+ " => " + v
);
1396 param
= param
.nextSibling
;
1400 sanity_check_done
= true;
1402 init_second_stage();
1405 exception_error("backend_sanity_check_callback", e
);
1410 function init_second_stage() {
1413 active_tab
= getInitParam("prefs_active_tab");
1414 if (!active_tab
|| active_tab
== '0') active_tab
= "genConfig";
1416 document
.onkeydown
= pref_hotkey_handler
;
1418 var tab
= getURLParam('tab');
1420 caller_subop
= getURLParam('subop');
1426 if (navigator
.userAgent
.match("Opera")) {
1427 setTimeout("selectTab()", 500);
1429 selectTab(active_tab
);
1433 exception_error("init_second_stage", e
);
1441 if (arguments
.callee
.done
) return;
1442 arguments
.callee
.done
= true;
1444 if (getURLParam('debug')) {
1445 document
.getElementById('debug_output').style
.display
= 'block';
1446 debug('debug mode activated');
1451 document
.getElementById("prefContent").innerHTML
=
1452 "<b>Fatal error:</b> This program needs XmlHttpRequest " +
1453 "to function properly. Your browser doesn't seem to support it.";
1457 xmlhttp
.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
1458 xmlhttp
.onreadystatechange
=backend_sanity_check_callback
;
1462 exception_error("init", e
);
1466 function categorizeSelectedFeeds() {
1468 if (!xmlhttp_ready(xmlhttp
)) {
1469 printLockingError();
1473 var sel_rows
= getSelectedFeeds();
1475 var cat_sel
= document
.getElementById("sfeed_set_fcat");
1476 var cat_id
= cat_sel
[cat_sel
.selectedIndex
].value
;
1478 if (sel_rows
.length
> 0) {
1480 notify_progress("Changing category of selected feeds...");
1482 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
1483 param_escape(sel_rows
.toString()) + "&cat_id=" + param_escape(cat_id
), true);
1484 xmlhttp
.onreadystatechange
=feedlist_callback
;
1489 alert(__("No feeds are selected."));
1495 function validatePrefsReset() {
1497 var ok
= confirm(__("Reset to defaults?"));
1501 var query
= Form
.serialize("pref_prefs_form");
1502 query
= query
+ "&subop=reset-config";
1505 xmlhttp
.open("POST", "backend.php", true);
1506 xmlhttp
.onreadystatechange
=prefs_reset_callback
;
1507 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1508 xmlhttp
.send(query
);
1512 exception_error("validatePrefsSave", e
);
1519 function browseFeeds(limit
) {
1521 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
1522 xmlhttp
.onreadystatechange
=infobox_callback
;
1527 function feedBrowserSubscribe() {
1530 var selected
= getSelectedFeedsFromBrowser();
1532 if (selected
.length
> 0) {
1534 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=massSubscribe&ids="+
1535 param_escape(selected
.toString()), true);
1536 xmlhttp
.onreadystatechange
=feedlist_callback
;
1539 alert(__("No feeds are selected."));
1543 exception_error("feedBrowserSubscribe", e
);
1547 function updateBigFeedBrowser(limit
) {
1549 if (!xmlhttp_ready(xmlhttp
)) {
1550 printLockingError();
1554 var query
= "backend.php?op=pref-feed-browser";
1556 var limit_sel
= document
.getElementById("feedBrowserLimit");
1559 var limit
= limit_sel
[limit_sel
.selectedIndex
].value
;
1560 query
= query
+ "&limit=" + param_escape(limit
);
1563 xmlhttp
.open("GET", query
, true);
1564 xmlhttp
.onreadystatechange
=feed_browser_callback
;
1568 function browserToggleExpand(id
) {
1570 /* if (feed_to_expand && feed_to_expand != id) {
1571 var d = document.getElementById("BRDET-" + feed_to_expand);
1572 d.style.display = "none";
1575 if (!xmlhttp_ready(xmlhttp
)) {
1576 printLockingError();
1580 /* if (feed_to_expand && id != feed_to_expand) {
1581 Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
1584 var d
= document
.getElementById("BRDET-" + id
);
1586 if (Element
.visible(d
)) {
1587 Effect
.Fade(d
, {duration
: 0.5});
1589 feed_to_expand
= id
;
1591 xmlhttp
.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
1592 + param_escape(id
), true);
1593 xmlhttp
.onreadystatechange
=expand_feed_callback
;
1598 exception_error("browserToggleExpand", e
);
1602 function selectPrefRows(kind
, select
) {
1605 var opbarid
= false;
1610 if (kind
== "feed") {
1611 opbarid
= "feedOpToolbar";
1614 lname
= "prefFeedList";
1615 } else if (kind
== "fcat") {
1616 opbarid
= "catOpToolbar";
1619 lname
= "prefFeedCatList";
1620 } else if (kind
== "filter") {
1621 opbarid
= "filterOpToolbar";
1624 lname
= "prefFilterList";
1625 } else if (kind
== "label") {
1626 opbarid
= "labelOpToolbar";
1629 lname
= "prefLabelList";
1630 } else if (kind
== "user") {
1631 opbarid
= "userOpToolbar";
1634 lname
= "prefUserList";
1638 selectTableRowsByIdPrefix(lname
, nrow
, nchk
, select
);
1639 disableContainerChildren(opbarid
, !select
);
1646 function toggleSelectPrefRow(sender
, kind
) {
1648 toggleSelectRow(sender
);
1651 var opbarid
= false;
1654 if (kind
== "feed") {
1655 opbarid
= "feedOpToolbar";
1656 nsel
= getSelectedFeeds();
1657 } else if (kind
== "fcat") {
1658 opbarid
= "catOpToolbar";
1659 nsel
= getSelectedFeedCats();
1660 } else if (kind
== "filter") {
1661 opbarid
= "filterOpToolbar";
1662 nsel
= getSelectedFilters();
1663 } else if (kind
== "label") {
1664 opbarid
= "labelOpToolbar";
1665 nsel
= getSelectedLabels();
1666 } else if (kind
== "user") {
1667 opbarid
= "userOpToolbar";
1668 nsel
= getSelectedUsers();
1671 if (opbarid
&& nsel
!= -1) {
1672 disableContainerChildren(opbarid
, nsel
== false);
1678 function toggleSelectFBListRow(sender
) {
1679 toggleSelectListRow(sender
);
1680 disableContainerChildren("fbrOpToolbar", getSelectedFeedsFromBrowser() == 0);
1685 function pref_hotkey_handler(e
) {
1689 var shift_key
= false;
1692 shift_key
= e
.shiftKey
;
1698 keycode
= window
.event
.keyCode
;
1703 if (keycode
== 27) { // escape
1704 if (Element
.visible("hotkey_help_overlay")) {
1705 Element
.hide("hotkey_help_overlay");
1707 hotkey_prefix
= false;
1711 if (!hotkeys_enabled
) {
1712 debug("hotkeys disabled");
1716 if (keycode
== 16) return; // ignore lone shift
1718 if ((keycode
== 67 || keycode
== 71) && !hotkey_prefix
) {
1719 hotkey_prefix
= keycode
;
1720 debug("KP: PREFIX=" + keycode
);
1724 if (Element
.visible("hotkey_help_overlay")) {
1725 Element
.hide("hotkey_help_overlay");
1728 if (keycode
== 13 || keycode
== 27) {
1731 seq
= seq
+ "" + keycode
;
1734 /* Global hotkeys */
1736 if (!hotkey_prefix
) {
1738 if (keycode
== 68 && shift_key
) { // d
1739 if (!debug_mode_enabled
) {
1740 document
.getElementById('debug_output').style
.display
= 'block';
1741 debug('debug mode activated');
1743 document
.getElementById('debug_output').style
.display
= 'none';
1746 debug_mode_enabled
= !debug_mode_enabled
;
1750 if (keycode
== 191 && shift_key
) { // ?
1751 if (!Element
.visible("hotkey_help_overlay")) {
1752 Element
.show("hotkey_help_overlay");
1754 Element
.hide("hotkey_help_overlay");
1763 if (hotkey_prefix
== 67) { // c
1764 hotkey_prefix
= false;
1766 if (keycode
== 70) { // f
1767 return displayDlg("quickAddFilter");
1770 if (keycode
== 83) { // s
1771 return displayDlg("quickAddFeed");
1774 if (keycode
== 76) { // l
1775 return displayDlg("quickAddLabel");
1778 if (keycode
== 85) { // u
1782 if (keycode
== 67) { // c
1783 return editFeedCats();
1786 if (keycode
== 84 && shift_key
) { // T
1787 return browseFeeds();
1790 if (keycode
== 69) { // e
1791 return editCurrentEntryDispatcher();
1798 if (hotkey_prefix
== 71) { // g
1800 hotkey_prefix
= false;
1802 if (keycode
== 49 && document
.getElementById("genConfigTab")) { // 1
1803 selectTab("genConfig");
1806 if (keycode
== 50 && document
.getElementById("feedConfigTab")) { // 2
1807 return selectTab("feedConfig");
1810 if (keycode
== 51 && document
.getElementById("feedBrowserTab")) { // 3
1811 return selectTab("feedBrowser");
1814 if (keycode
== 52 && document
.getElementById("filterConfigTab")) { // 4
1815 return selectTab("filterConfig");
1818 if (keycode
== 53 && document
.getElementById("labelConfigTab")) { // 5
1819 return selectTab("labelConfig");
1822 if (keycode
== 54 && document
.getElementById("userConfigTab")) { // 6
1823 return selectTab("userConfig");
1826 if (keycode
== 88) { // x
1832 if (document
.getElementById("piggie")) {
1834 if (seq
.match("807371717369")) {
1836 localPiggieFunction(true);
1838 localPiggieFunction(false);
1842 if (hotkey_prefix
) {
1843 debug("KP: PREFIX=" + hotkey_prefix
+ " CODE=" + keycode
);
1845 debug("KP: CODE=" + keycode
);
1849 exception_error("pref_hotkey_handler", e
);
1853 function editFeedCats() {
1854 if (!xmlhttp_ready(xmlhttp
)) {
1855 printLockingError();
1859 document
.getElementById("subscribe_to_feed_btn").disabled
= true;
1862 document
.getElementById("top25_feeds_btn").disabled
= true;
1864 // this button is not always available, no-op if not found
1867 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
1868 xmlhttp
.onreadystatechange
=infobox_feed_cat_callback
;
1872 function showFeedsWithErrors() {
1873 displayDlg('feedUpdateErrors');
1876 function changeUserPassword() {
1880 if (!xmlhttp_ready(xmlhttp
)) {
1881 printLockingError();
1885 var f
= document
.forms
["change_pass_form"];
1888 if (f
.OLD_PASSWORD
.value
== "") {
1889 new Effect
.Highlight(f
.OLD_PASSWORD
);
1890 notify_error("Old password cannot be blank.");
1894 if (f
.NEW_PASSWORD
.value
== "") {
1895 new Effect
.Highlight(f
.NEW_PASSWORD
);
1896 notify_error("New password cannot be blank.");
1900 if (f
.CONFIRM_PASSWORD
.value
== "") {
1901 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1902 notify_error("Entered passwords do not match.");
1906 if (f
.CONFIRM_PASSWORD
.value
!= f
.NEW_PASSWORD
.value
) {
1907 new Effect
.Highlight(f
.CONFIRM_PASSWORD
);
1908 new Effect
.Highlight(f
.NEW_PASSWORD
);
1909 notify_error("Entered passwords do not match.");
1915 var query
= Form
.serialize("change_pass_form");
1917 notify_progress("Trying to change password...");
1919 xmlhttp
.open("POST", "backend.php", true);
1920 xmlhttp
.onreadystatechange
=changepass_callback
;
1921 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1922 xmlhttp
.send(query
);
1925 exception_error("changeUserPassword", e
);
1931 function changeUserEmail() {
1935 if (!xmlhttp_ready(xmlhttp
)) {
1936 printLockingError();
1940 var query
= Form
.serialize("change_email_form");
1942 notify_progress("Trying to change e-mail...");
1944 xmlhttp
.open("POST", "backend.php", true);
1945 xmlhttp
.onreadystatechange
=notify_callback
;
1946 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
1947 xmlhttp
.send(query
);
1950 exception_error("changeUserPassword", e
);
1957 function feedlistToggleSLAT() {
1958 notify_progress("Loading, please wait...");
1962 function pubRegenKey() {
1964 if (!xmlhttp_ready(xmlhttp
)) {
1965 printLockingError();
1969 var ok
= confirm(__("Replace current publishing address with a new one?"));
1973 notify_progress("Trying to change address...");
1975 xmlhttp
.open("GET", "backend.php?op=rpc&subop=regenPubKey");
1976 xmlhttp
.onreadystatechange
=replace_pubkey_callback
;
1983 function pubToClipboard() {
1987 if (!xmlhttp_ready(xmlhttp
)) {
1988 printLockingError();
1992 var link
= document
.getElementById("pubGenAddress");
1996 exception_error("pubToClipboard", e
);
2002 function validatePrefsSave() {
2005 var ok
= confirm(__("Save current configuration?"));
2009 var query
= Form
.serialize("pref_prefs_form");
2010 query
= query
+ "&subop=save-config";
2013 xmlhttp
.open("POST", "backend.php", true);
2014 xmlhttp
.onreadystatechange
=notify_callback
;
2015 xmlhttp
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
2016 xmlhttp
.send(query
);
2020 exception_error("validatePrefsSave", e
);
2026 function feedActionChange() {
2028 var chooser
= document
.getElementById("feedActionChooser");
2029 var opid
= chooser
[chooser
.selectedIndex
].value
;
2031 chooser
.selectedIndex
= 0;
2034 exception_error("feedActionChange", e
);
2038 function feedActionGo(op
) {
2040 if (op
== "facEdit") {
2044 if (op
== "facClear") {
2045 clearSelectedFeeds();
2048 if (op
== "facPurge") {
2049 purgeSelectedFeeds();
2052 if (op
== "facEditCats") {
2056 if (op
== "facRescore") {
2057 rescoreSelectedFeeds();
2060 if (op
== "facUnsubscribe") {
2061 removeSelectedFeeds();
2065 exception_error("feedActionGo", e
);
2070 function clearFeedArticles(feed_id
) {
2072 notify_progress("Clearing feed...");
2074 var query
= "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id
;
2076 new Ajax
.Request(query
, {
2077 onComplete: function(transport
) {
2084 function rescoreSelectedFeeds() {
2086 if (!xmlhttp_ready(xmlhttp
)) {
2087 printLockingError();
2091 var sel_rows
= getSelectedFeeds();
2093 if (sel_rows
.length
> 0) {
2095 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
2096 var ok
= confirm(__("Rescore articles in selected feeds?"));
2099 notify_progress("Rescoring selected feeds...");
2101 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
2102 param_escape(sel_rows
.toString()), true);
2103 xmlhttp
.onreadystatechange
=notify_callback
;
2107 alert(__("No feeds are selected."));
2113 function rescore_all_feeds() {
2114 var ok
= confirm(__("Rescore all articles? This operation may take a lot of time."));
2117 notify_progress("Rescoring feeds...");
2119 xmlhttp
.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
2120 xmlhttp
.onreadystatechange
=notify_callback
;
2125 function editCurrentEntryDispatcher() {