1 var active_feed_cat = false;
3 var init_params = new Array();
5 var caller_subop = false;
6 var hotkey_prefix = false;
7 var hotkey_prefix_pressed = false;
9 var color_picker_active = false;
10 var selection_disabled = false;
11 var mouse_is_down = false;
15 function feedlist_callback2(transport) {
19 dijit.byId('feedConfigTab').attr('content', transport.responseText);
21 selectTab("feedConfig", true);
24 var tuple = caller_subop.split(":");
25 if (tuple[0] == 'editFeed') {
26 window.setTimeout('editFeed('+tuple[1]+')', 100);
35 exception_error("feedlist_callback2", e);
39 function filterlist_callback2(transport) {
40 dijit.byId('filterConfigTab').attr('content', transport.responseText);
45 function labellist_callback2(transport) {
49 dijit.byId('labelConfigTab').attr('content', transport.responseText);
56 exception_error("labellist_callback2", e);
60 function userlist_callback2(transport) {
62 dijit.byId('userConfigTab').attr('content', transport.responseText);
67 exception_error("userlist_callback2", e);
71 function prefslist_callback2(transport) {
73 dijit.byId('genConfigTab').attr('content', transport.responseText);
78 exception_error("prefslist_callback2", e);
82 function notify_callback2(transport) {
83 notify_info(transport.responseText);
86 function init_profile_inline_editor() {
89 if ($("prefFeedCatList")) {
90 var elems = $("prefFeedCatList").getElementsByTagName("SPAN");
92 for (var i = 0; i < elems.length; i++) {
93 if (elems[i].id && elems[i].id.match("FCATT-")) {
94 var id = elems[i].id.replace("FCATT-", "");
95 new Ajax.InPlaceEditor(elems[i],
96 'backend.php?op=rpc&subop=saveprofile&id=' + id);
102 exception_error("init_profile_inline_editor", e);
106 function updateFeedList(sort_key) {
110 var feed_search = $("feed_search");
112 if (feed_search) { search = feed_search.value; }
114 var slat = $("show_last_article_times");
116 var slat_checked = false;
118 slat_checked = slat.checked;
121 var query = "?op=pref-feeds" +
122 "&sort=" + param_escape(sort_key) +
123 "&slat=" + param_escape(slat_checked) +
124 "&search=" + param_escape(search);
126 new Ajax.Request("backend.php", {
128 onComplete: function(transport) {
129 feedlist_callback2(transport);
132 exception_error("updateFeedList", e);
136 function updateUsersList(sort_key) {
140 var user_search = $("user_search");
142 if (user_search) { search = user_search.value; }
144 var query = "?op=pref-users&sort="
145 + param_escape(sort_key) +
146 "&search=" + param_escape(search);
148 new Ajax.Request("backend.php", {
150 onComplete: function(transport) {
151 userlist_callback2(transport);
155 exception_error("updateUsersList", e);
163 var link = $("fadd_link");
165 if (link.value.length == 0) {
166 alert(__("Error: No feed URL given."));
167 } else if (!isValidURL(link.value)) {
168 alert(__("Error: Invalid feed URL."));
170 notify_progress("Adding feed...");
172 var query = "?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
173 param_escape(link.value);
175 new Ajax.Request("backend.php", {
177 onComplete: function(transport) {
178 feedlist_callback2(transport);
186 exception_error("addFeed", e);
191 function addPrefProfile() {
193 var profile = $("fadd_profile");
195 if (profile.value.length == 0) {
196 alert(__("Can't add profile: no name specified."));
198 notify_progress("Adding profile...");
200 var query = "?op=rpc&subop=addprofile&title=" +
201 param_escape(profile.value);
203 new Ajax.Request("backend.php", {
205 onComplete: function(transport) {
213 function addFeedCat() {
215 var cat = $("fadd_cat");
217 if (cat.value.length == 0) {
218 alert(__("Can't add category: no name specified."));
220 notify_progress("Adding feed category...");
222 var query = "?op=pref-feeds&subop=editCats&action=add&cat=" +
223 param_escape(cat.value);
225 new Ajax.Request("backend.php", {
227 onComplete: function(transport) {
228 infobox_callback2(transport);
240 var login = prompt(__("Please enter login:"), "");
247 alert(__("Can't create user: no login specified."));
251 notify_progress("Adding user...");
253 var query = "?op=pref-users&subop=add&login=" +
256 new Ajax.Request("backend.php", {
258 onComplete: function(transport) {
259 userlist_callback2(transport);
263 exception_error("addUser", e);
267 function editUser(id, event) {
270 if (!event || !event.ctrlKey) {
272 notify_progress("Loading, please wait...");
274 selectTableRows('prefUserList', 'none');
275 selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true);
277 var query = "?op=pref-users&subop=edit&id=" +
280 new Ajax.Request("backend.php", {
282 onComplete: function(transport) {
283 infobox_callback2(transport);
284 document.forms['user_edit_form'].login.focus();
287 } else if (event.ctrlKey) {
288 var cb = $('UMCHK-' + id);
289 cb.checked = !cb.checked;
294 exception_error("editUser", e);
299 function editFilter(id, event) {
303 if (!event || !event.ctrlKey) {
305 notify_progress("Loading, please wait...", true);
307 var query = "?op=pref-filters&subop=edit&id=" +
310 new Ajax.Request("backend.php", {
312 onComplete: function(transport) {
313 infobox_callback2(transport);
314 document.forms['filter_edit_form'].reg_exp.focus();
316 } else if (event.ctrlKey) {
317 var cb = $('FICHK-' + id);
318 cb.checked = !cb.checked;
323 exception_error("editFilter", e);
327 function editFeed(feed, event) {
331 if (event && !event.ctrlKey) {
333 notify_progress("Loading, please wait...");
335 // selectTableRows('prefFeedList', 'none');
336 // selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
338 var query = "?op=pref-feeds&subop=editfeed&id=" +
341 new Ajax.Request("backend.php", {
343 onComplete: function(transport) {
344 infobox_callback2(transport);
345 document.forms["edit_feed_form"].title.focus();
348 } else if (event.ctrlKey) {
349 // var cb = $('FRCHK-' + feed);
350 // cb.checked = !cb.checked;
351 // toggleSelectRow(cb);
356 exception_error("editFeed", e);
360 function getSelectedLabels() {
361 return getSelectedTableRowIds("prefLabelList");
364 function getSelectedUsers() {
365 return getSelectedTableRowIds("prefUserList");
368 function getSelectedFeeds() {
369 var tree = dijit.byId("feedTree");
370 var items = tree.model.getCheckedItems();
373 items.each(function(item) {
374 rv.push(tree.model.store.getValue(item, 'bare_id'));
380 function getSelectedFilters() {
381 var tree = dijit.byId("filterTree");
382 var items = tree.model.getCheckedItems();
385 items.each(function(item) {
386 rv.push(tree.model.store.getValue(item, 'bare_id'));
393 function getSelectedFeedCats() {
394 return getSelectedTableRowIds("prefFeedCatList");
398 function removeSelectedLabels() {
400 var sel_rows = getSelectedLabels();
402 if (sel_rows.length > 0) {
404 var ok = confirm(__("Remove selected labels?"));
407 notify_progress("Removing selected labels...");
409 var query = "?op=pref-labels&subop=remove&ids="+
410 param_escape(sel_rows.toString());
412 new Ajax.Request("backend.php", {
414 onComplete: function(transport) {
415 labellist_callback2(transport);
420 alert(__("No labels are selected."));
426 function removeSelectedUsers() {
430 var sel_rows = getSelectedUsers();
432 if (sel_rows.length > 0) {
434 var ok = confirm(__("Remove selected users? Neither default admin nor your account will be removed."));
437 notify_progress("Removing selected users...");
439 var query = "?op=pref-users&subop=remove&ids="+
440 param_escape(sel_rows.toString());
442 new Ajax.Request("backend.php", {
444 onComplete: function(transport) {
445 userlist_callback2(transport);
451 alert(__("No users are selected."));
455 exception_error("removeSelectedUsers", e);
461 function removeSelectedFilters() {
465 var sel_rows = getSelectedFilters();
467 if (sel_rows.length > 0) {
469 var ok = confirm(__("Remove selected filters?"));
472 notify_progress("Removing selected filters...");
474 var query = "?op=pref-filters&subop=remove&ids="+
475 param_escape(sel_rows.toString());
477 new Ajax.Request("backend.php", {
479 onComplete: function(transport) {
480 filterlist_callback2(transport);
485 alert(__("No filters are selected."));
489 exception_error("removeSelectedFilters", e);
496 function removeSelectedFeeds() {
500 var sel_rows = getSelectedFeeds();
502 if (sel_rows.length > 0) {
504 var ok = confirm(__("Unsubscribe from selected feeds?"));
508 notify_progress("Unsubscribing from selected feeds...", true);
510 var query = "?op=pref-feeds&subop=remove&ids="+
511 param_escape(sel_rows.toString());
515 new Ajax.Request("backend.php", {
517 onComplete: function(transport) {
523 alert(__("No feeds are selected."));
527 exception_error("removeSelectedFeeds", e);
533 function clearSelectedFeeds() {
535 var sel_rows = getSelectedFeeds();
537 if (sel_rows.length > 1) {
538 alert(__("Please select only one feed."));
542 if (sel_rows.length > 0) {
544 var ok = confirm(__("Erase all non-starred articles in selected feed?"));
547 notify_progress("Clearing selected feed...");
548 clearFeedArticles(sel_rows[0]);
553 alert(__("No feeds are selected."));
560 function purgeSelectedFeeds() {
562 var sel_rows = getSelectedFeeds();
564 if (sel_rows.length > 0) {
566 var pr = prompt(__("How many days of articles to keep (0 - use default)?"), "0");
568 if (pr != undefined) {
569 notify_progress("Purging selected feed...");
571 var query = "?op=rpc&subop=purge&ids="+
572 param_escape(sel_rows.toString()) + "&days=" + pr;
576 new Ajax.Request("prefs.php", {
578 onComplete: function(transport) {
585 alert(__("No feeds are selected."));
592 function removeSelectedPrefProfiles() {
594 var sel_rows = getSelectedFeedCats();
596 if (sel_rows.length > 0) {
598 var ok = confirm(__("Remove selected profiles? Active and default profiles will not be removed."));
601 notify_progress("Removing selected profiles...");
603 var query = "?op=rpc&subop=remprofiles&ids="+
604 param_escape(sel_rows.toString());
606 new Ajax.Request("backend.php", {
608 onComplete: function(transport) {
614 alert(__("No profiles selected."));
620 function removeSelectedFeedCats() {
622 var sel_rows = getSelectedFeedCats();
624 if (sel_rows.length > 0) {
626 var ok = confirm(__("Remove selected categories?"));
629 notify_progress("Removing selected categories...");
631 var query = "?op=pref-feeds&subop=editCats&action=remove&ids="+
632 param_escape(sel_rows.toString());
634 new Ajax.Request("backend.php", {
636 onComplete: function(transport) {
637 infobox_callback2(transport);
644 alert(__("No categories are selected."));
651 function feedEditCancel() {
656 function feedEditSave() {
660 // FIXME: add parameter validation
662 var query = Form.serialize("edit_feed_form");
664 notify_progress("Saving feed...");
666 new Ajax.Request("backend.php", {
668 onComplete: function(transport) {
669 feedlist_callback2(transport);
677 exception_error("feedEditSave", e);
681 function userEditCancel() {
686 function filterEditCancel() {
691 function userEditSave() {
695 var login = document.forms["user_edit_form"].login.value;
697 if (login.length == 0) {
698 alert(__("Login field cannot be blank."));
702 notify_progress("Saving user...");
706 var query = Form.serialize("user_edit_form");
708 new Ajax.Request("backend.php", {
710 onComplete: function(transport) {
711 userlist_callback2(transport);
715 exception_error("userEditSave", e);
723 function filterEditSave() {
725 var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
727 var query = "?op=rpc&subop=verifyRegexp®_exp=" + param_escape(reg_exp);
729 notify_progress("Verifying regular expression...");
731 new Ajax.Request("backend.php", {
733 onComplete: function(transport) {
734 handle_rpc_reply(transport);
736 var response = transport.responseXML;
739 var s = response.getElementsByTagName("status")[0].firstChild.nodeValue;
743 if (s == "INVALID") {
744 alert("Match regular expression seems to be invalid.");
748 var query = "?" + Form.serialize("filter_edit_form");
750 notify_progress("Saving filter...");
752 Form.disable("filter_edit_form");
754 new Ajax.Request("backend.php", {
756 onComplete: function(transport) {
758 filterlist_callback2(transport);
765 exception_error("filterEditSave", e);
772 function editSelectedUser() {
773 var rows = getSelectedUsers();
775 if (rows.length == 0) {
776 alert(__("No users are selected."));
780 if (rows.length > 1) {
781 alert(__("Please select only one user."));
790 function resetSelectedUserPass() {
794 var rows = getSelectedUsers();
796 if (rows.length == 0) {
797 alert(__("No users are selected."));
801 if (rows.length > 1) {
802 alert(__("Please select only one user."));
806 var ok = confirm(__("Reset password of selected user?"));
809 notify_progress("Resetting password for selected user...");
813 var query = "?op=pref-users&subop=resetPass&id=" +
816 new Ajax.Request("backend.php", {
818 onComplete: function(transport) {
819 userlist_callback2(transport);
825 exception_error("resetSelectedUserPass", e);
829 function selectedUserDetails() {
833 var rows = getSelectedUsers();
835 if (rows.length == 0) {
836 alert(__("No users are selected."));
840 if (rows.length > 1) {
841 alert(__("Please select only one user."));
845 notify_progress("Loading, please wait...");
849 var query = "?op=pref-users&subop=user-details&id=" + id;
851 new Ajax.Request("backend.php", {
853 onComplete: function(transport) {
854 infobox_callback2(transport);
857 exception_error("selectedUserDetails", e);
862 function editSelectedFilter() {
863 var rows = getSelectedFilters();
865 if (rows.length == 0) {
866 alert(__("No filters are selected."));
870 if (rows.length > 1) {
871 alert(__("Please select only one filter."));
882 function editSelectedFeed() {
883 var rows = getSelectedFeeds();
885 if (rows.length == 0) {
886 alert(__("No feeds are selected."));
890 if (rows.length > 1) {
891 return editSelectedFeeds();
896 editFeed(rows[0], {});
900 function editSelectedFeeds() {
903 var rows = getSelectedFeeds();
905 if (rows.length == 0) {
906 alert(__("No feeds are selected."));
912 notify_progress("Loading, please wait...", true);
914 var query = "?op=pref-feeds&subop=editfeeds&ids=" +
915 param_escape(rows.toString());
917 new Ajax.Request("backend.php", {
919 onComplete: function(transport) {
920 infobox_callback2(transport);
924 exception_error("editSelectedFeeds", e);
928 function piggie(enable) {
930 console.log("I LOVEDED IT!");
931 var piggie = $("piggie");
933 Element.show(piggie);
934 Position.Center(piggie);
940 function opmlImport() {
942 var opml_file = $("opml_file");
944 if (opml_file.value.length == 0) {
945 alert(__("No OPML file to upload."));
948 notify_progress("Importing, please wait...", true);
953 function updateFilterList(sort_key) {
956 var filter_search = $("filter_search");
958 if (filter_search) { search = filter_search.value; }
960 var query = "?op=pref-filters&sort=" +
961 param_escape(sort_key) +
962 "&search=" + param_escape(search);
964 new Ajax.Request("backend.php", {
966 onComplete: function(transport) {
967 filterlist_callback2(transport);
971 exception_error("updateFilterList", e);
976 function updateLabelList(sort_key) {
980 var label_search = $("label_search");
982 if (label_search) { search = label_search.value; }
984 var query = "?op=pref-labels&sort=" +
985 param_escape(sort_key) +
986 "&search=" + param_escape(search);
988 new Ajax.Request("backend.php", {
990 onComplete: function(transport) {
991 labellist_callback2(transport);
995 exception_error("updateLabelList", e);
999 function updatePrefsList() {
1001 var query = "?op=pref-prefs";
1003 new Ajax.Request("backend.php", {
1005 onComplete: function(transport) {
1006 prefslist_callback2(transport);
1011 function selectTab(id, noupdate, subop) {
1016 console.log("selectTab: " + id + "(NU: " + noupdate + ")");
1018 notify_progress("Loading, please wait...");
1020 // close active infobox if needed
1023 // clean up all current selections, just in case
1024 active_feed_cat = false;
1026 // Effect.Fade("prefContent", {duration: 1, to: 0.01,
1027 // queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
1029 if (id == "feedConfig") {
1031 } else if (id == "filterConfig") {
1033 } else if (id == "labelConfig") {
1035 } else if (id == "genConfig") {
1037 } else if (id == "userConfig") {
1041 var tab = dijit.byId(id + "Tab");
1042 dijit.byId("pref-tabs").selectChild(tab);
1046 /* clean selection from all tabs */
1048 $$("#prefTabs div").invoke('removeClassName', 'Selected');
1050 /* mark new tab as selected */
1052 $(id + "Tab").addClassName("Selected");
1055 exception_error("selectTab", e);
1059 function init_second_stage() {
1063 document.onkeydown = pref_hotkey_handler;
1064 document.onmousedown = mouse_down_handler;
1065 document.onmouseup = mouse_up_handler;
1067 caller_subop = getURLParam('subop');
1069 if (getURLParam("subopparam")) {
1070 caller_subop = caller_subop + ":" + getURLParam("subopparam");
1073 loading_set_progress(60);
1077 dojo.addOnLoad(function() {
1079 var active_tab = getInitParam("prefs_active_tab");
1080 if (!$(active_tab+"Tab")) active_tab = "genConfig";
1081 if (!active_tab || active_tab == '0') active_tab = "genConfig";
1083 var http_tab = getURLParam('tab');
1085 if (http_tab) active_tab = http_tab;
1087 var tab = dijit.byId(active_tab + "Tab");
1089 if (tab) dijit.byId("pref-tabs").selectChild(tab);
1093 setTimeout("hotkey_prefix_timeout()", 5*1000);
1097 exception_error("init_second_stage", e);
1105 dojo.require("dijit.layout.TabContainer");
1106 dojo.require("dijit.layout.BorderContainer");
1107 dojo.require("dijit.layout.AccordionContainer");
1108 dojo.require("dijit.layout.ContentPane");
1109 dojo.require("dijit.Dialog");
1110 dojo.require("dijit.form.Button");
1111 dojo.require("dijit.form.TextBox");
1112 dojo.require("dijit.form.RadioButton");
1113 dojo.require("dijit.form.Select");
1114 dojo.require("dijit.Toolbar");
1115 dojo.require("dojo.data.ItemFileWriteStore");
1116 dojo.require("dijit.Tree");
1117 dojo.require("dijit.form.DropDownButton");
1118 dojo.require("dijit.form.Form");
1119 dojo.require("dijit.Menu");
1120 dojo.require("dijit.tree.dndSource");
1121 dojo.require("dijit.InlineEditBox");
1123 dojo.registerModulePath("lib", "..");
1124 dojo.registerModulePath("fox", "../..");
1126 dojo.require("lib.CheckBoxTree");
1127 dojo.require("fox.PrefFeedTree");
1128 dojo.require("fox.PrefFilterTree");
1130 loading_set_progress(30);
1132 var query = "?op=rpc&subop=sanityCheck";
1134 new Ajax.Request("backend.php", {
1136 onComplete: function(transport) {
1137 backend_sanity_check_callback(transport);
1141 exception_error("init", e);
1145 function validatePrefsReset() {
1147 var ok = confirm(__("Reset to defaults?"));
1151 var query = Form.serialize("pref_prefs_form");
1152 query = query + "&subop=reset-config";
1155 new Ajax.Request("backend.php", {
1157 onComplete: function(transport) {
1158 var msg = transport.responseText;
1159 if (msg.match("PREFS_THEME_CHANGED")) {
1160 window.location.reload();
1170 exception_error("validatePrefsReset", e);
1178 function pref_hotkey_handler(e) {
1182 var shift_key = false;
1184 var cmdline = $('cmdline');
1187 shift_key = e.shiftKey;
1193 keycode = window.event.keyCode;
1198 var keychar = String.fromCharCode(keycode);
1200 if (keycode == 27) { // escape
1201 if (Element.visible("hotkey_help_overlay")) {
1202 Element.hide("hotkey_help_overlay");
1204 colorPickerHideAll();
1205 hotkey_prefix = false;
1209 var dialog = dijit.byId("infoBox");
1210 var dialog_visible = false;
1213 dialog_visible = Element.visible(dialog.domNode);
1215 if (dialog_visible || !hotkeys_enabled) {
1216 console.log("hotkeys disabled");
1220 if (keycode == 16) return; // ignore lone shift
1221 if (keycode == 17) return; // ignore lone ctrl
1223 if ((keycode == 67 || keycode == 71) && !hotkey_prefix) {
1224 hotkey_prefix = keycode;
1226 var date = new Date();
1227 var ts = Math.round(date.getTime() / 1000);
1229 hotkey_prefix_pressed = ts;
1231 cmdline.innerHTML = keychar;
1232 Element.show(cmdline);
1234 console.log("KP: PREFIX=" + keycode + " CHAR=" + keychar);
1238 if (Element.visible("hotkey_help_overlay")) {
1239 Element.hide("hotkey_help_overlay");
1242 if (keycode == 13 || keycode == 27) {
1245 seq = seq + "" + keycode;
1248 /* Global hotkeys */
1250 Element.hide(cmdline);
1252 if (!hotkey_prefix) {
1254 if ((keycode == 191 || keychar == '?') && shift_key) { // ?
1255 if (!Element.visible("hotkey_help_overlay")) {
1256 //Element.show("hotkey_help_overlay");
1257 Effect.Appear("hotkey_help_overlay", {duration : 0.3});
1259 Element.hide("hotkey_help_overlay");
1264 if (keycode == 191 || keychar == '/') { // /
1265 var search_boxes = new Array("label_search",
1266 "feed_search", "filter_search", "user_search", "feed_browser_search");
1268 for (var i = 0; i < search_boxes.length; i++) {
1269 var elem = $(search_boxes[i]);
1271 $(search_boxes[i]).focus();
1280 if (hotkey_prefix == 67) { // c
1281 hotkey_prefix = false;
1283 if (keycode == 70) { // f
1288 if (keycode == 83) { // s
1293 if (keycode == 85) { // u
1297 if (keycode == 67) { // c
1302 if (keycode == 84 && shift_key) { // T
1303 displayDlg('feedBrowser');
1311 if (hotkey_prefix == 71) { // g
1313 hotkey_prefix = false;
1315 if (keycode == 49 && $("genConfigTab")) { // 1
1316 selectTab("genConfig");
1320 if (keycode == 50 && $("feedConfigTab")) { // 2
1321 selectTab("feedConfig");
1325 if (keycode == 51 && $("filterConfigTab")) { // 4
1326 selectTab("filterConfig");
1330 if (keycode == 52 && $("labelConfigTab")) { // 5
1331 selectTab("labelConfig");
1335 if (keycode == 53 && $("userConfigTab")) { // 6
1336 selectTab("userConfig");
1340 if (keycode == 88) { // x
1347 if (seq.match("8073717369")) {
1355 if (hotkey_prefix) {
1356 console.log("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode + " CHAR=" + keychar);
1358 console.log("KP: CODE=" + keycode + " CHAR=" + keychar);
1362 exception_error("pref_hotkey_handler", e);
1366 function editFeedCats() {
1368 var query = "?op=pref-feeds&subop=editCats";
1370 notify_progress("Loading, please wait...");
1372 new Ajax.Request("backend.php", {
1374 onComplete: function(transport) {
1375 infobox_callback2(transport);
1378 exception_error("editFeedCats", e);
1382 function showFeedsWithErrors() {
1383 displayDlg('feedUpdateErrors');
1386 function changeUserPassword() {
1390 var f = document.forms["change_pass_form"];
1393 if (f.OLD_PASSWORD.value == "") {
1394 new Effect.Highlight(f.OLD_PASSWORD);
1395 notify_error("Old password cannot be blank.");
1399 if (f.NEW_PASSWORD.value == "") {
1400 new Effect.Highlight(f.NEW_PASSWORD);
1401 notify_error("New password cannot be blank.");
1405 if (f.CONFIRM_PASSWORD.value == "") {
1406 new Effect.Highlight(f.CONFIRM_PASSWORD);
1407 notify_error("Entered passwords do not match.");
1411 if (f.CONFIRM_PASSWORD.value != f.NEW_PASSWORD.value) {
1412 new Effect.Highlight(f.CONFIRM_PASSWORD);
1413 new Effect.Highlight(f.NEW_PASSWORD);
1414 notify_error("Entered passwords do not match.");
1420 var query = Form.serialize("change_pass_form");
1422 notify_progress("Changing password...");
1424 new Ajax.Request("backend.php", {
1426 onComplete: function(transport) {
1427 if (transport.responseText.indexOf("ERROR: ") == 0) {
1428 notify_error(transport.responseText.replace("ERROR: ", ""));
1430 notify_info(transport.responseText);
1431 var warn = $("default_pass_warning");
1432 if (warn) warn.style.display = "none";
1435 document.forms['change_pass_form'].reset();
1440 exception_error("changeUserPassword", e);
1446 function changeUserEmail() {
1450 var query = Form.serialize("change_email_form");
1452 notify_progress("Saving...");
1454 new Ajax.Request("backend.php", {
1456 onComplete: function(transport) {
1457 notify_callback2(transport);
1461 exception_error("changeUserPassword", e);
1468 function feedlistToggleSLAT() {
1469 notify_progress("Loading, please wait...");
1473 function opmlRegenKey() {
1476 var ok = confirm(__("Replace current OPML publishing address with a new one?"));
1480 notify_progress("Trying to change address...", true);
1482 var query = "?op=rpc&subop=regenOPMLKey";
1484 new Ajax.Request("backend.php", {
1486 onComplete: function(transport) {
1487 var new_link = transport.responseXML.getElementsByTagName("link")[0];
1489 var e = $('pub_opml_url');
1492 e.href = new_link.firstChild.nodeValue;
1493 e.innerHTML = new_link.firstChild.nodeValue;
1495 new Effect.Highlight(e);
1500 notify_error("Could not change feed URL.");
1505 exception_error("opmlRegenKey", e);
1509 function validatePrefsSave() {
1512 var ok = confirm(__("Save current configuration?"));
1516 var query = Form.serialize("pref_prefs_form");
1517 query = query + "&subop=save-config";
1520 new Ajax.Request("backend.php", {
1522 onComplete: function(transport) {
1523 var msg = transport.responseText;
1524 if (msg.match("PREFS_THEME_CHANGED")) {
1525 window.location.reload();
1534 exception_error("validatePrefsSave", e);
1540 function feedActionChange() {
1542 var chooser = $("feedActionChooser");
1543 var opid = chooser[chooser.selectedIndex].value;
1545 chooser.selectedIndex = 0;
1548 exception_error("feedActionChange", e);
1552 function feedActionGo(op) {
1554 if (op == "facEdit") {
1556 var rows = getSelectedFeeds();
1558 if (rows.length > 1) {
1559 editSelectedFeeds();
1565 if (op == "facClear") {
1566 clearSelectedFeeds();
1569 if (op == "facPurge") {
1570 purgeSelectedFeeds();
1573 if (op == "facEditCats") {
1577 if (op == "facRescore") {
1578 rescoreSelectedFeeds();
1581 if (op == "facUnsubscribe") {
1582 removeSelectedFeeds();
1586 exception_error("feedActionGo", e);
1591 function clearFeedArticles(feed_id) {
1593 notify_progress("Clearing feed...");
1595 var query = "?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id;
1597 new Ajax.Request("backend.php", {
1599 onComplete: function(transport) {
1606 function rescoreSelectedFeeds() {
1608 var sel_rows = getSelectedFeeds();
1610 if (sel_rows.length > 0) {
1612 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
1613 var ok = confirm(__("Rescore articles in selected feeds?"));
1616 notify_progress("Rescoring selected feeds...", true);
1618 var query = "?op=pref-feeds&subop=rescore&quiet=1&ids="+
1619 param_escape(sel_rows.toString());
1621 new Ajax.Request("backend.php", {
1623 onComplete: function(transport) {
1624 notify_callback2(transport);
1629 alert(__("No feeds are selected."));
1635 function rescore_all_feeds() {
1636 var ok = confirm(__("Rescore all articles? This operation may take a lot of time."));
1639 notify_progress("Rescoring feeds...", true);
1641 var query = "?op=pref-feeds&subop=rescoreAll&quiet=1";
1643 new Ajax.Request("backend.php", {
1645 onComplete: function(transport) {
1646 notify_callback2(transport);
1651 function removeFilter(id, title) {
1655 var msg = __("Remove filter %s?").replace("%s", title);
1657 var ok = confirm(msg);
1662 notify_progress("Removing filter...");
1664 var query = "?op=pref-filters&subop=remove&ids="+
1667 new Ajax.Request("backend.php", {
1669 onComplete: function(transport) {
1670 filterlist_callback2(transport);
1676 exception_error("removeFilter", e);
1682 function feedsEditSave() {
1685 var ok = confirm(__("Save changes to selected feeds?"));
1689 var f = document.forms["batch_edit_feed_form"];
1691 var query = Form.serialize("batch_edit_feed_form");
1693 /* Form.serialize ignores unchecked checkboxes */
1695 if (!query.match("&rtl_content=") &&
1696 f.rtl_content.disabled == false) {
1697 query = query + "&rtl_content=false";
1700 if (!query.match("&private=") &&
1701 f.private.disabled == false) {
1702 query = query + "&private=false";
1705 if (!query.match("&cache_images=") &&
1706 f.cache_images.disabled == false) {
1707 query = query + "&cache_images=false";
1710 if (!query.match("&include_in_digest=") &&
1711 f.include_in_digest.disabled == false) {
1712 query = query + "&include_in_digest=false";
1717 notify_progress("Saving feeds...");
1719 new Ajax.Request("backend.php", {
1721 onComplete: function(transport) {
1722 feedlist_callback2(transport);
1729 exception_error("feedsEditSave", e);
1733 function batchFeedsToggleField(cb, elem, label) {
1735 var f = document.forms["batch_edit_feed_form"];
1739 f[elem].disabled = false;
1745 // new Effect.Highlight(f[elem], {duration: 1, startcolor: "#fff7d5",
1746 // queue: { position:'end', scope: 'BPEFQ', limit: 1 } } );
1749 f[elem].disabled = true;
1752 l.className = "insensitive";
1757 exception_error("batchFeedsToggleField", e);
1761 function labelColorReset() {
1763 var labels = getSelectedLabels();
1765 var ok = confirm(__("Reset label colors to default?"));
1769 var query = "?op=pref-labels&subop=color-reset&ids="+
1770 param_escape(labels.toString());
1772 new Ajax.Request("backend.php", {
1774 onComplete: function(transport) {
1775 labellist_callback2(transport);
1780 exception_error("labelColorReset", e);
1784 function labelColorAsk(id, kind) {
1790 p = prompt(__("Please enter new label foreground color:"));
1792 p = prompt(__("Please enter new label background color:"));
1797 var query = "?op=pref-labels&subop=color-set&kind=" + kind +
1798 "&ids="+ param_escape(id) + "&color=" + param_escape(p);
1800 selectTableRows('prefLabelList', 'none');
1802 var e = $("LICID-" + id);
1808 e.style.backgroundColor = p;
1812 new Ajax.Request("backend.php", { parameters: query });
1816 exception_error("labelColorReset", e);
1821 function colorPicker(id, fg, bg) {
1823 var picker = $("colorPicker-" + id);
1825 if (picker) Element.show(picker);
1828 exception_error("colorPicker", e);
1832 function colorPickerHideAll() {
1834 if ($("prefLabelList")) {
1836 var elems = $("prefLabelList").getElementsByTagName("DIV");
1838 for (var i = 0; i < elems.length; i++) {
1839 if (elems[i].id && elems[i].id.match("colorPicker-")) {
1840 Element.hide(elems[i]);
1846 exception_error("colorPickerHideAll", e);
1850 function colorPickerDo(id, fg, bg) {
1853 var query = "?op=pref-labels&subop=color-set&kind=both"+
1854 "&ids=" + param_escape(id) + "&fg=" + param_escape(fg) +
1855 "&bg=" + param_escape(bg);
1857 var e = $("LICID-" + id);
1861 e.style.backgroundColor = bg;
1864 new Ajax.Request("backend.php", { parameters: query });
1867 exception_error("colorPickerDo", e);
1871 function colorPickerActive(b) {
1872 color_picker_active = b;
1875 function mouse_down_handler(e) {
1878 /* do not prevent right click */
1879 if (e && e.button && e.button == 2) return;
1881 if (selection_disabled) {
1882 document.onselectstart = function() { return false; };
1887 exception_error("mouse_down_handler", e);
1891 function mouse_up_handler(e) {
1893 mouse_is_down = false;
1895 if (!selection_disabled) {
1896 document.onselectstart = null;
1899 if (!color_picker_active) {
1900 colorPickerHideAll();
1904 exception_error("mouse_up_handler", e);
1908 function inPreferences() {
1912 function editProfiles() {
1913 displayDlg('editPrefProfiles', false, function() {
1914 init_profile_inline_editor();
1918 function activatePrefProfile() {
1920 var sel_rows = getSelectedFeedCats();
1922 if (sel_rows.length == 1) {
1924 var ok = confirm(__("Activate selected profile?"));
1927 notify_progress("Loading, please wait...");
1929 var query = "?op=rpc&subop=setprofile&id="+
1930 param_escape(sel_rows.toString());
1932 new Ajax.Request("backend.php", {
1934 onComplete: function(transport) {
1935 window.location.reload();
1940 alert(__("Please choose a profile to activate."));
1946 function opmlImportDone() {
1951 function opmlImportHandler(iframe) {
1953 var tmp = new Object();
1954 tmp.responseText = iframe.document.body.innerHTML;
1956 infobox_callback2(tmp);
1958 exception_error("opml_import_handler", e);
1962 function clearFeedAccessKeys() {
1964 var ok = confirm(__("This will invalidate all previously generated feed URLs. Continue?"));
1967 notify_progress("Clearing URLs...");
1969 var query = "?op=rpc&subop=clearKeys";
1971 new Ajax.Request("backend.php", {
1973 onComplete: function(transport) {
1974 notify_info("Generated URLs cleared.");
1981 function handle_rpc_reply(transport, scheduled_call) {
1983 if (transport.responseXML) {
1985 if (!transport_error_check(transport)) return false;
1988 notify_error("Error communicating with server.");
1992 exception_error("handle_rpc_reply", e, transport);
1998 function resetFeedOrder() {
2000 notify_progress("Loading, please wait...");
2002 new Ajax.Request("backend.php", {
2003 parameters: "?op=pref-feeds&subop=feedsortreset",
2004 onComplete: function(transport) {
2010 exception_error("resetFeedOrder");
2014 function resetCatOrder() {
2016 notify_progress("Loading, please wait...");
2018 new Ajax.Request("backend.php", {
2019 parameters: "?op=pref-feeds&subop=catsortreset",
2020 onComplete: function(transport) {
2026 exception_error("resetCatOrder");
2030 function editCat(id, item, event) {
2032 var new_name = prompt(__('Rename category to:'), item.name);
2034 if (new_name && new_name != item.name) {
2036 notify_progress("Loading, please wait...");
2038 new Ajax.Request("backend.php", {
2045 onComplete: function(transport) {
2051 exception_error("editCat", e);