1 var init_params = new Array();
3 var hotkey_prefix = false;
4 var hotkey_prefix_pressed = false;
8 function notify_callback2(transport, sticky) {
9 notify_info(transport.responseText, sticky);
12 function updateFeedList(sort_key) {
14 var user_search = $("feed_search");
16 if (user_search) { search = user_search.value; }
18 new Ajax.Request("backend.php", {
19 parameters: "?op=pref-feeds&search=" + param_escape(search),
20 onComplete: function(transport) {
21 dijit.byId('feedConfigTab').attr('content', transport.responseText);
22 selectTab("feedConfig", true);
28 function updateUsersList(sort_key) {
30 var user_search = $("user_search");
32 if (user_search) { search = user_search.value; }
34 var query = "?op=pref-users&sort="
35 + param_escape(sort_key) +
36 "&search=" + param_escape(search);
38 new Ajax.Request("backend.php", {
40 onComplete: function(transport) {
41 dijit.byId('userConfigTab').attr('content', transport.responseText);
42 selectTab("userConfig", true)
47 exception_error("updateUsersList", e);
55 var login = prompt(__("Please enter login:"), "");
62 alert(__("Can't create user: no login specified."));
66 notify_progress("Adding user...");
68 var query = "?op=pref-users&method=add&login=" +
71 new Ajax.Request("backend.php", {
73 onComplete: function(transport) {
74 notify_callback2(transport);
79 exception_error("addUser", e);
83 function editUser(id, event) {
86 notify_progress("Loading, please wait...");
88 var query = "?op=pref-users&method=edit&id=" +
91 new Ajax.Request("backend.php", {
93 onComplete: function(transport) {
94 infobox_callback2(transport, __("User Editor"));
95 document.forms['user_edit_form'].login.focus();
99 exception_error("editUser", e);
104 function editFilter(id) {
107 var query = "backend.php?op=pref-filters&method=edit&id=" + param_escape(id);
109 if (dijit.byId("feedEditDlg"))
110 dijit.byId("feedEditDlg").destroyRecursive();
112 if (dijit.byId("filterEditDlg"))
113 dijit.byId("filterEditDlg").destroyRecursive();
115 dialog = new dijit.Dialog({
117 title: __("Edit Filter"),
118 style: "width: 600px",
120 var query = "backend.php?" + dojo.formToQuery("filter_edit_form") + "&savemode=test";
122 if (dijit.byId("filterTestDlg"))
123 dijit.byId("filterTestDlg").destroyRecursive();
125 var test_dlg = new dijit.Dialog({
127 title: "Test Filter",
128 style: "width: 600px",
133 selectRules: function(select) {
134 $$("#filterDlg_Matches input[type=checkbox]").each(function(e) {
137 e.parentNode.addClassName("Selected");
139 e.parentNode.removeClassName("Selected");
142 selectActions: function(select) {
143 $$("#filterDlg_Actions input[type=checkbox]").each(function(e) {
147 e.parentNode.addClassName("Selected");
149 e.parentNode.removeClassName("Selected");
153 editRule: function(e) {
154 var li = e.parentNode;
155 var rule = li.getElementsByTagName("INPUT")[1].value;
156 addFilterRule(li, rule);
158 editAction: function(e) {
159 var li = e.parentNode;
160 var action = li.getElementsByTagName("INPUT")[1].value;
161 addFilterAction(li, action);
163 removeFilter: function() {
164 var msg = __("Remove filter?");
169 notify_progress("Removing filter...");
171 var id = this.attr('value').id;
173 var query = "?op=pref-filters&method=remove&ids="+
176 new Ajax.Request("backend.php", {
178 onComplete: function(transport) {
183 addAction: function() { addFilterAction(); },
184 addRule: function() { addFilterRule(); },
185 deleteAction: function() {
186 $$("#filterDlg_Actions li.[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) });
188 deleteRule: function() {
189 $$("#filterDlg_Matches li.[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) });
191 execute: function() {
192 if (this.validate()) {
194 notify_progress("Saving data...", true);
196 var query = dojo.formToQuery("filter_edit_form");
200 new Ajax.Request("backend.php", {
202 onComplete: function(transport) {
214 exception_error("editFilter", e);
218 function getSelectedLabels() {
219 var tree = dijit.byId("labelTree");
220 var items = tree.model.getCheckedItems();
223 items.each(function(item) {
224 rv.push(tree.model.store.getValue(item, 'bare_id'));
230 function getSelectedUsers() {
231 return getSelectedTableRowIds("prefUserList");
234 function getSelectedFeeds() {
235 var tree = dijit.byId("feedTree");
236 var items = tree.model.getCheckedItems();
239 items.each(function(item) {
240 if (item.id[0].match("FEED:"))
241 rv.push(tree.model.store.getValue(item, 'bare_id'));
247 function getSelectedCategories() {
248 var tree = dijit.byId("feedTree");
249 var items = tree.model.getCheckedItems();
252 items.each(function(item) {
253 if (item.id[0].match("CAT:"))
254 rv.push(tree.model.store.getValue(item, 'bare_id'));
260 function getSelectedFilters() {
261 var tree = dijit.byId("filterTree");
262 var items = tree.model.getCheckedItems();
265 items.each(function(item) {
266 rv.push(tree.model.store.getValue(item, 'bare_id'));
273 function removeSelectedLabels() {
275 var sel_rows = getSelectedLabels();
277 if (sel_rows.length > 0) {
279 var ok = confirm(__("Remove selected labels?"));
282 notify_progress("Removing selected labels...");
284 var query = "?op=pref-labels&method=remove&ids="+
285 param_escape(sel_rows.toString());
287 new Ajax.Request("backend.php", {
289 onComplete: function(transport) {
295 alert(__("No labels are selected."));
301 function removeSelectedUsers() {
305 var sel_rows = getSelectedUsers();
307 if (sel_rows.length > 0) {
309 var ok = confirm(__("Remove selected users? Neither default admin nor your account will be removed."));
312 notify_progress("Removing selected users...");
314 var query = "?op=pref-users&method=remove&ids="+
315 param_escape(sel_rows.toString());
317 new Ajax.Request("backend.php", {
319 onComplete: function(transport) {
326 alert(__("No users are selected."));
330 exception_error("removeSelectedUsers", e);
336 function removeSelectedFilters() {
340 var sel_rows = getSelectedFilters();
342 if (sel_rows.length > 0) {
344 var ok = confirm(__("Remove selected filters?"));
347 notify_progress("Removing selected filters...");
349 var query = "?op=pref-filters&method=remove&ids="+
350 param_escape(sel_rows.toString());
352 new Ajax.Request("backend.php", {
354 onComplete: function(transport) {
359 alert(__("No filters are selected."));
363 exception_error("removeSelectedFilters", e);
370 function removeSelectedFeeds() {
374 var sel_rows = getSelectedFeeds();
376 if (sel_rows.length > 0) {
378 var ok = confirm(__("Unsubscribe from selected feeds?"));
382 notify_progress("Unsubscribing from selected feeds...", true);
384 var query = "?op=pref-feeds&method=remove&ids="+
385 param_escape(sel_rows.toString());
389 new Ajax.Request("backend.php", {
391 onComplete: function(transport) {
397 alert(__("No feeds are selected."));
401 exception_error("removeSelectedFeeds", e);
407 function clearSelectedFeeds() {
409 var sel_rows = getSelectedFeeds();
411 if (sel_rows.length > 1) {
412 alert(__("Please select only one feed."));
416 if (sel_rows.length > 0) {
418 var ok = confirm(__("Erase all non-starred articles in selected feed?"));
421 notify_progress("Clearing selected feed...");
422 clearFeedArticles(sel_rows[0]);
427 alert(__("No feeds are selected."));
434 function purgeSelectedFeeds() {
436 var sel_rows = getSelectedFeeds();
438 if (sel_rows.length > 0) {
440 var pr = prompt(__("How many days of articles to keep (0 - use default)?"), "0");
442 if (pr != undefined) {
443 notify_progress("Purging selected feed...");
445 var query = "?op=rpc&method=purge&ids="+
446 param_escape(sel_rows.toString()) + "&days=" + pr;
450 new Ajax.Request("prefs.php", {
452 onComplete: function(transport) {
459 alert(__("No feeds are selected."));
466 function userEditCancel() {
471 function userEditSave() {
475 var login = document.forms["user_edit_form"].login.value;
477 if (login.length == 0) {
478 alert(__("Login field cannot be blank."));
482 notify_progress("Saving user...");
486 var query = Form.serialize("user_edit_form");
488 new Ajax.Request("backend.php", {
490 onComplete: function(transport) {
495 exception_error("userEditSave", e);
503 function editSelectedUser() {
504 var rows = getSelectedUsers();
506 if (rows.length == 0) {
507 alert(__("No users are selected."));
511 if (rows.length > 1) {
512 alert(__("Please select only one user."));
521 function resetSelectedUserPass() {
525 var rows = getSelectedUsers();
527 if (rows.length == 0) {
528 alert(__("No users are selected."));
532 if (rows.length > 1) {
533 alert(__("Please select only one user."));
537 var ok = confirm(__("Reset password of selected user?"));
540 notify_progress("Resetting password for selected user...");
544 var query = "?op=pref-users&method=resetPass&id=" +
547 new Ajax.Request("backend.php", {
549 onComplete: function(transport) {
550 notify_info(transport.responseText, true);
556 exception_error("resetSelectedUserPass", e);
560 function selectedUserDetails() {
564 var rows = getSelectedUsers();
566 if (rows.length == 0) {
567 alert(__("No users are selected."));
571 if (rows.length > 1) {
572 alert(__("Please select only one user."));
576 notify_progress("Loading, please wait...");
580 var query = "?op=pref-users&method=userdetails&id=" + id;
582 new Ajax.Request("backend.php", {
584 onComplete: function(transport) {
585 infobox_callback2(transport, __("User details"));
588 exception_error("selectedUserDetails", e);
593 function editSelectedFilter() {
594 var rows = getSelectedFilters();
596 if (rows.length == 0) {
597 alert(__("No filters are selected."));
601 if (rows.length > 1) {
602 alert(__("Please select only one filter."));
612 function joinSelectedFilters() {
613 var rows = getSelectedFilters();
615 if (rows.length == 0) {
616 alert(__("No filters are selected."));
620 var ok = confirm(__("Combine selected filters?"));
623 notify_progress("Joining filters...");
625 var query = "?op=pref-filters&method=join&ids="+
626 param_escape(rows.toString());
630 new Ajax.Request("backend.php", {
632 onComplete: function(transport) {
638 function editSelectedFeed() {
639 var rows = getSelectedFeeds();
641 if (rows.length == 0) {
642 alert(__("No feeds are selected."));
646 if (rows.length > 1) {
647 return editSelectedFeeds();
652 editFeed(rows[0], {});
656 function editSelectedFeeds() {
659 var rows = getSelectedFeeds();
661 if (rows.length == 0) {
662 alert(__("No feeds are selected."));
666 notify_progress("Loading, please wait...");
668 var query = "backend.php?op=pref-feeds&method=editfeeds&ids=" +
669 param_escape(rows.toString());
673 if (dijit.byId("feedEditDlg"))
674 dijit.byId("feedEditDlg").destroyRecursive();
676 new Ajax.Request("backend.php", {
678 onComplete: function(transport) {
682 var dialog = new dijit.Dialog({
684 title: __("Edit Multiple Feeds"),
685 style: "width: 600px",
686 getChildByName: function (name) {
688 this.getChildren().each(
690 if (child.name == name) {
697 toggleField: function (checkbox, elem, label) {
698 this.getChildByName(elem).attr('disabled', !checkbox.checked);
701 if (checkbox.checked)
702 $(label).removeClassName('insensitive');
704 $(label).addClassName('insensitive');
707 execute: function() {
708 if (this.validate() && confirm(__("Save changes to selected feeds?"))) {
709 var query = dojo.objectToQuery(this.attr('value'));
711 /* Form.serialize ignores unchecked checkboxes */
713 if (!query.match("&private=") &&
714 this.getChildByName('private').attr('disabled') == false) {
715 query = query + "&private=false";
719 if (!query.match("&cache_images=") &&
720 this.getChildByName('cache_images').attr('disabled') == false) {
721 query = query + "&cache_images=false";
726 if (!query.match("&hide_images=") &&
727 this.getChildByName('hide_images').attr('disabled') == false) {
728 query = query + "&hide_images=false";
732 if (!query.match("&include_in_digest=") &&
733 this.getChildByName('include_in_digest').attr('disabled') == false) {
734 query = query + "&include_in_digest=false";
737 if (!query.match("&always_display_enclosures=") &&
738 this.getChildByName('always_display_enclosures').attr('disabled') == false) {
739 query = query + "&always_display_enclosures=false";
742 if (!query.match("&mark_unread_on_update=") &&
743 this.getChildByName('mark_unread_on_update').attr('disabled') == false) {
744 query = query + "&mark_unread_on_update=false";
749 notify_progress("Saving data...", true);
751 new Ajax.Request("backend.php", {
753 onComplete: function(transport) {
759 content: transport.responseText});
766 exception_error("editSelectedFeeds", e);
770 function opmlImportComplete(iframe) {
772 if (!iframe.contentDocument.body.innerHTML) return false;
774 Element.show(iframe);
778 if (dijit.byId('opmlImportDlg'))
779 dijit.byId('opmlImportDlg').destroyRecursive();
781 var content = iframe.contentDocument.body.innerHTML;
783 dialog = new dijit.Dialog({
785 title: __("OPML Import"),
786 style: "width: 600px",
787 onCancel: function() {
792 execute: function() {
803 exception_error("opmlImportComplete", e);
807 function opmlImport() {
809 var opml_file = $("opml_file");
811 if (opml_file.value.length == 0) {
812 alert(__("Please choose an OPML file first."));
815 notify_progress("Importing, please wait...", true);
817 Element.show("upload_iframe");
824 function updateFilterList() {
825 var user_search = $("filter_search");
827 if (user_search) { search = user_search.value; }
829 new Ajax.Request("backend.php", {
830 parameters: "?op=pref-filters&search=" + param_escape(search),
831 onComplete: function(transport) {
832 dijit.byId('filterConfigTab').attr('content', transport.responseText);
837 function updateLabelList() {
838 new Ajax.Request("backend.php", {
839 parameters: "?op=pref-labels",
840 onComplete: function(transport) {
841 dijit.byId('labelConfigTab').attr('content', transport.responseText);
846 function updatePrefsList() {
847 new Ajax.Request("backend.php", {
848 parameters: "?op=pref-prefs",
849 onComplete: function(transport) {
850 dijit.byId('genConfigTab').attr('content', transport.responseText);
855 function updateSystemList() {
856 new Ajax.Request("backend.php", {
857 parameters: "?op=pref-system",
858 onComplete: function(transport) {
859 dijit.byId('systemConfigTab').attr('content', transport.responseText);
864 function selectTab(id, noupdate, method) {
867 notify_progress("Loading, please wait...");
869 if (id == "feedConfig") {
871 } else if (id == "filterConfig") {
873 } else if (id == "labelConfig") {
875 } else if (id == "genConfig") {
877 } else if (id == "userConfig") {
879 } else if (id == "systemConfig") {
883 var tab = dijit.byId(id + "Tab");
884 dijit.byId("pref-tabs").selectChild(tab);
889 exception_error("selectTab", e);
893 function init_second_stage() {
896 document.onkeydown = pref_hotkey_handler;
897 loading_set_progress(50);
900 dojo.addOnLoad(function() {
901 var tab = getURLParam('tab');
904 tab = dijit.byId(tab + "Tab");
905 if (tab) dijit.byId("pref-tabs").selectChild(tab);
908 var method = getURLParam('method');
910 if (method == 'editFeed') {
911 var param = getURLParam('methodparam');
913 window.setTimeout('editFeed(' + param + ')', 100);
917 setTimeout("hotkey_prefix_timeout()", 5*1000);
920 exception_error("init_second_stage", e);
927 dojo.registerModulePath("lib", "..");
928 dojo.registerModulePath("fox", "../../js/");
930 dojo.require("dijit.ColorPalette");
931 dojo.require("dijit.Dialog");
932 dojo.require("dijit.form.Button");
933 dojo.require("dijit.form.CheckBox");
934 dojo.require("dijit.form.DropDownButton");
935 dojo.require("dijit.form.FilteringSelect");
936 dojo.require("dijit.form.Form");
937 dojo.require("dijit.form.RadioButton");
938 dojo.require("dijit.form.Select");
939 dojo.require("dijit.form.SimpleTextarea");
940 dojo.require("dijit.form.TextBox");
941 dojo.require("dijit.form.ValidationTextBox");
942 dojo.require("dijit.InlineEditBox");
943 dojo.require("dijit.layout.AccordionContainer");
944 dojo.require("dijit.layout.BorderContainer");
945 dojo.require("dijit.layout.ContentPane");
946 dojo.require("dijit.layout.TabContainer");
947 dojo.require("dijit.Menu");
948 dojo.require("dijit.ProgressBar");
949 dojo.require("dijit.ProgressBar");
950 dojo.require("dijit.Toolbar");
951 dojo.require("dijit.Tree");
952 dojo.require("dijit.tree.dndSource");
953 dojo.require("dojo.data.ItemFileWriteStore");
955 dojo.require("lib.CheckBoxTree");
956 dojo.require("fox.PrefFeedTree");
957 dojo.require("fox.PrefFilterTree");
958 dojo.require("fox.PrefLabelTree");
962 dojo.addOnLoad(function() {
963 loading_set_progress(50);
965 var clientTzOffset = new Date().getTimezoneOffset() * 60;
967 new Ajax.Request("backend.php", {
968 parameters: {op: "rpc", method: "sanityCheck",
969 clientTzOffset: clientTzOffset },
970 onComplete: function(transport) {
971 backend_sanity_check_callback(transport);
976 exception_error("init", e);
980 function validatePrefsReset() {
982 var ok = confirm(__("Reset to defaults?"));
986 query = "?op=pref-prefs&method=resetconfig";
989 new Ajax.Request("backend.php", {
991 onComplete: function(transport) {
993 notify_info(transport.responseText);
999 exception_error("validatePrefsReset", e);
1006 function pref_hotkey_handler(e) {
1009 if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
1011 var keycode = false;
1012 var shift_key = false;
1014 var cmdline = $('cmdline');
1017 shift_key = e.shiftKey;
1023 keycode = window.event.keyCode;
1028 var keychar = String.fromCharCode(keycode);
1030 if (keycode == 27) { // escape
1031 hotkey_prefix = false;
1034 if (keycode == 16) return; // ignore lone shift
1035 if (keycode == 17) return; // ignore lone ctrl
1037 if (!shift_key) keychar = keychar.toLowerCase();
1039 var hotkeys = getInitParam("hotkeys");
1041 if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) {
1043 var date = new Date();
1044 var ts = Math.round(date.getTime() / 1000);
1046 hotkey_prefix = keychar;
1047 hotkey_prefix_pressed = ts;
1049 cmdline.innerHTML = keychar;
1050 Element.show(cmdline);
1055 Element.hide(cmdline);
1057 var hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
1058 hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey;
1059 hotkey_prefix = false;
1061 var hotkey_action = false;
1062 var hotkeys = getInitParam("hotkeys");
1064 for (sequence in hotkeys[1]) {
1065 if (sequence == hotkey) {
1066 hotkey_action = hotkeys[1][sequence];
1071 switch (hotkey_action) {
1072 case "feed_subscribe":
1075 case "create_label":
1078 case "create_filter":
1082 //helpDialog("prefs");
1085 console.log("unhandled action: " + hotkey_action + "; hotkey: " + hotkey);
1089 exception_error("hotkey_handler", e);
1093 function removeCategory(id, item) {
1096 var ok = confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name));
1099 var query = "?op=pref-feeds&method=removeCat&ids="+
1102 notify_progress("Removing category...");
1104 new Ajax.Request("backend.php", {
1106 onComplete: function(transport) {
1113 exception_error("removeCategory", e);
1117 function removeSelectedCategories() {
1119 var sel_rows = getSelectedCategories();
1121 if (sel_rows.length > 0) {
1123 var ok = confirm(__("Remove selected categories?"));
1126 notify_progress("Removing selected categories...");
1128 var query = "?op=pref-feeds&method=removeCat&ids="+
1129 param_escape(sel_rows.toString());
1131 new Ajax.Request("backend.php", {
1133 onComplete: function(transport) {
1139 alert(__("No categories are selected."));
1145 function createCategory() {
1147 var title = prompt(__("Category title:"));
1151 notify_progress("Creating category...");
1153 var query = "?op=pref-feeds&method=addCat&cat=" +
1154 param_escape(title);
1156 new Ajax.Request("backend.php", {
1158 onComplete: function(transport) {
1165 exception_error("createCategory", e);
1169 function showInactiveFeeds() {
1171 var query = "backend.php?op=pref-feeds&method=inactiveFeeds";
1173 if (dijit.byId("inactiveFeedsDlg"))
1174 dijit.byId("inactiveFeedsDlg").destroyRecursive();
1176 dialog = new dijit.Dialog({
1177 id: "inactiveFeedsDlg",
1178 title: __("Feeds without recent updates"),
1179 style: "width: 600px",
1180 getSelectedFeeds: function() {
1181 return getSelectedTableRowIds("prefInactiveFeedList");
1183 removeSelected: function() {
1184 var sel_rows = this.getSelectedFeeds();
1186 console.log(sel_rows);
1188 if (sel_rows.length > 0) {
1189 var ok = confirm(__("Remove selected feeds?"));
1192 notify_progress("Removing selected feeds...", true);
1194 var query = "?op=pref-feeds&method=remove&ids="+
1195 param_escape(sel_rows.toString());
1197 new Ajax.Request("backend.php", {
1199 onComplete: function(transport) {
1207 alert(__("No feeds are selected."));
1210 execute: function() {
1211 if (this.validate()) {
1219 exception_error("showInactiveFeeds", e);
1224 function opmlRegenKey() {
1227 var ok = confirm(__("Replace current OPML publishing address with a new one?"));
1231 notify_progress("Trying to change address...", true);
1233 var query = "?op=pref-feeds&method=regenOPMLKey";
1235 new Ajax.Request("backend.php", {
1237 onComplete: function(transport) {
1238 var reply = JSON.parse(transport.responseText);
1240 var new_link = reply.link;
1242 var e = $('pub_opml_url');
1246 e.innerHTML = new_link;
1248 new Effect.Highlight(e);
1253 notify_error("Could not change feed URL.");
1258 exception_error("opmlRegenKey", e);
1263 function feedActionChange() {
1265 var chooser = $("feedActionChooser");
1266 var opid = chooser[chooser.selectedIndex].value;
1268 chooser.selectedIndex = 0;
1271 exception_error("feedActionChange", e);
1275 function feedActionGo(op) {
1277 if (op == "facEdit") {
1279 var rows = getSelectedFeeds();
1281 if (rows.length > 1) {
1282 editSelectedFeeds();
1288 if (op == "facClear") {
1289 clearSelectedFeeds();
1292 if (op == "facPurge") {
1293 purgeSelectedFeeds();
1296 if (op == "facEditCats") {
1300 if (op == "facRescore") {
1301 rescoreSelectedFeeds();
1304 if (op == "facUnsubscribe") {
1305 removeSelectedFeeds();
1309 exception_error("feedActionGo", e);
1314 function clearFeedArticles(feed_id) {
1316 notify_progress("Clearing feed...");
1318 var query = "?op=pref-feeds&quiet=1&method=clear&id=" + feed_id;
1320 new Ajax.Request("backend.php", {
1322 onComplete: function(transport) {
1329 function rescoreSelectedFeeds() {
1331 var sel_rows = getSelectedFeeds();
1333 if (sel_rows.length > 0) {
1335 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
1336 var ok = confirm(__("Rescore articles in selected feeds?"));
1339 notify_progress("Rescoring selected feeds...", true);
1341 var query = "?op=pref-feeds&method=rescore&quiet=1&ids="+
1342 param_escape(sel_rows.toString());
1344 new Ajax.Request("backend.php", {
1346 onComplete: function(transport) {
1347 notify_callback2(transport);
1352 alert(__("No feeds are selected."));
1358 function rescore_all_feeds() {
1359 var ok = confirm(__("Rescore all articles? This operation may take a lot of time."));
1362 notify_progress("Rescoring feeds...", true);
1364 var query = "?op=pref-feeds&method=rescoreAll&quiet=1";
1366 new Ajax.Request("backend.php", {
1368 onComplete: function(transport) {
1369 notify_callback2(transport);
1374 function labelColorReset() {
1376 var labels = getSelectedLabels();
1378 if (labels.length > 0) {
1379 var ok = confirm(__("Reset selected labels to default colors?"));
1382 var query = "?op=pref-labels&method=colorreset&ids="+
1383 param_escape(labels.toString());
1385 new Ajax.Request("backend.php", {
1387 onComplete: function(transport) {
1393 alert(__("No labels are selected."));
1397 exception_error("labelColorReset", e);
1402 function inPreferences() {
1406 function editProfiles() {
1409 if (dijit.byId("profileEditDlg"))
1410 dijit.byId("profileEditDlg").destroyRecursive();
1412 var query = "backend.php?op=pref-prefs&method=editPrefProfiles";
1414 dialog = new dijit.Dialog({
1415 id: "profileEditDlg",
1416 title: __("Settings Profiles"),
1417 style: "width: 600px",
1418 getSelectedProfiles: function() {
1419 return getSelectedTableRowIds("prefFeedProfileList");
1421 removeSelected: function() {
1422 var sel_rows = this.getSelectedProfiles();
1424 if (sel_rows.length > 0) {
1425 var ok = confirm(__("Remove selected profiles? Active and default profiles will not be removed."));
1428 notify_progress("Removing selected profiles...", true);
1430 var query = "?op=rpc&method=remprofiles&ids="+
1431 param_escape(sel_rows.toString());
1433 new Ajax.Request("backend.php", {
1435 onComplete: function(transport) {
1443 alert(__("No profiles are selected."));
1446 activateProfile: function() {
1447 var sel_rows = this.getSelectedProfiles();
1449 if (sel_rows.length == 1) {
1451 var ok = confirm(__("Activate selected profile?"));
1454 notify_progress("Loading, please wait...");
1456 var query = "?op=rpc&method=setprofile&id="+
1457 param_escape(sel_rows.toString());
1459 new Ajax.Request("backend.php", {
1461 onComplete: function(transport) {
1462 window.location.reload();
1467 alert(__("Please choose a profile to activate."));
1470 addProfile: function() {
1471 if (this.validate()) {
1472 notify_progress("Creating profile...", true);
1474 var query = "?op=rpc&method=addprofile&title=" +
1475 param_escape(dialog.attr('value').newprofile);
1477 new Ajax.Request("backend.php", {
1479 onComplete: function(transport) {
1486 execute: function() {
1487 if (this.validate()) {
1494 exception_error("editProfiles", e);
1498 function activatePrefProfile() {
1500 var sel_rows = getSelectedFeedCats();
1502 if (sel_rows.length == 1) {
1504 var ok = confirm(__("Activate selected profile?"));
1507 notify_progress("Loading, please wait...");
1509 var query = "?op=rpc&method=setprofile&id="+
1510 param_escape(sel_rows.toString());
1512 new Ajax.Request("backend.php", {
1514 onComplete: function(transport) {
1515 window.location.reload();
1520 alert(__("Please choose a profile to activate."));
1526 function clearFeedAccessKeys() {
1528 var ok = confirm(__("This will invalidate all previously generated feed URLs. Continue?"));
1531 notify_progress("Clearing URLs...");
1533 var query = "?op=pref-feeds&method=clearKeys";
1535 new Ajax.Request("backend.php", {
1537 onComplete: function(transport) {
1538 notify_info("Generated URLs cleared.");
1545 function clearArticleAccessKeys() {
1547 var ok = confirm(__("This will invalidate all previously shared article URLs. Continue?"));
1550 notify_progress("Clearing URLs...");
1552 var query = "?op=rpc&method=clearArticleKeys";
1554 new Ajax.Request("backend.php", {
1556 onComplete: function(transport) {
1557 notify_info("Shared URLs cleared.");
1564 function resetFilterOrder() {
1566 notify_progress("Loading, please wait...");
1568 new Ajax.Request("backend.php", {
1569 parameters: "?op=pref-filters&method=filtersortreset",
1570 onComplete: function(transport) {
1576 exception_error("resetFilterOrder");
1581 function resetFeedOrder() {
1583 notify_progress("Loading, please wait...");
1585 new Ajax.Request("backend.php", {
1586 parameters: "?op=pref-feeds&method=feedsortreset",
1587 onComplete: function(transport) {
1593 exception_error("resetFeedOrder");
1597 function resetCatOrder() {
1599 notify_progress("Loading, please wait...");
1601 new Ajax.Request("backend.php", {
1602 parameters: "?op=pref-feeds&method=catsortreset",
1603 onComplete: function(transport) {
1609 exception_error("resetCatOrder");
1613 function editCat(id, item, event) {
1615 var new_name = prompt(__('Rename category to:'), item.name);
1617 if (new_name && new_name != item.name) {
1619 notify_progress("Loading, please wait...");
1621 new Ajax.Request("backend.php", {
1624 method: 'renamecat',
1628 onComplete: function(transport) {
1634 exception_error("editCat", e);
1638 function editLabel(id, event) {
1640 var query = "backend.php?op=pref-labels&method=edit&id=" +
1643 if (dijit.byId("labelEditDlg"))
1644 dijit.byId("labelEditDlg").destroyRecursive();
1646 dialog = new dijit.Dialog({
1648 title: __("Label Editor"),
1649 style: "width: 600px",
1650 setLabelColor: function(id, fg, bg) {
1665 var query = "?op=pref-labels&method=colorset&kind="+kind+
1666 "&ids=" + param_escape(id) + "&fg=" + param_escape(fg) +
1667 "&bg=" + param_escape(bg) + "&color=" + param_escape(color);
1669 // console.log(query);
1671 var e = $("LICID-" + id);
1674 if (fg) e.style.color = fg;
1675 if (bg) e.style.backgroundColor = bg;
1678 new Ajax.Request("backend.php", { parameters: query });
1682 execute: function() {
1683 if (this.validate()) {
1684 var caption = this.attr('value').caption;
1685 var fg_color = this.attr('value').fg_color;
1686 var bg_color = this.attr('value').bg_color;
1687 var query = dojo.objectToQuery(this.attr('value'));
1689 dijit.byId('labelTree').setNameById(id, caption);
1690 this.setLabelColor(id, fg_color, bg_color);
1693 new Ajax.Request("backend.php", {
1695 onComplete: function(transport) {
1705 exception_error("editLabel", e);
1710 function customizeCSS() {
1712 var query = "backend.php?op=pref-prefs&method=customizeCSS";
1714 if (dijit.byId("cssEditDlg"))
1715 dijit.byId("cssEditDlg").destroyRecursive();
1717 dialog = new dijit.Dialog({
1719 title: __("Customize stylesheet"),
1720 style: "width: 600px",
1721 execute: function() {
1722 notify_progress('Saving data...', true);
1723 new Ajax.Request("backend.php", {
1724 parameters: dojo.objectToQuery(this.attr('value')),
1725 onComplete: function(transport) {
1727 window.location.reload();
1736 exception_error("customizeCSS", e);
1740 function insertSSLserial(value) {
1742 dijit.byId("SSL_CERT_SERIAL").attr('value', value);
1744 exception_error("insertSSLcerial", e);
1748 function gotoExportOpml(filename, settings) {
1749 tmp = settings ? 1 : 0;
1750 document.location.href = "backend.php?op=opml&method=export&filename=" + filename + "&settings=" + tmp;
1754 function batchSubscribe() {
1756 var query = "backend.php?op=pref-feeds&method=batchSubscribe";
1758 // overlapping widgets
1759 if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
1760 if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive();
1762 var dialog = new dijit.Dialog({
1764 title: __("Batch subscribe"),
1765 style: "width: 600px",
1766 execute: function() {
1767 if (this.validate()) {
1768 console.log(dojo.objectToQuery(this.attr('value')));
1770 notify_progress(__("Subscribing to feeds..."), true);
1772 new Ajax.Request("backend.php", {
1773 parameters: dojo.objectToQuery(this.attr('value')),
1774 onComplete: function(transport) {
1785 exception_error("batchSubscribe", e);
1790 function toggleAdvancedPrefs() {
1792 notify_progress("Loading, please wait...");
1794 new Ajax.Request("backend.php", {
1795 parameters: "?op=pref-prefs&method=toggleadvanced",
1796 onComplete: function(transport) {
1801 exception_error("toggleAdvancedPrefs", e);
1805 function clearPluginData(name) {
1807 if (confirm(__("Clear stored data for this plugin?"))) {
1808 notify_progress("Loading, please wait...");
1810 new Ajax.Request("backend.php", {
1811 parameters: "?op=pref-prefs&method=clearplugindata&name=" + param_escape(name),
1812 onComplete: function(transport) {
1818 exception_error("clearPluginData", e);
1822 function clearSqlLog() {
1824 if (confirm(__("Clear all messages in the error log?"))) {
1826 notify_progress("Loading, please wait...");
1827 var query = "?op=pref-system&method=clearLog";
1829 new Ajax.Request("backend.php", {
1831 onComplete: function(transport) {