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 var query = "backend.php?op=pref-users&method=edit&id=" +
89 if (dijit.byId("userEditDlg"))
90 dijit.byId("userEditDlg").destroyRecursive();
92 dialog = new dijit.Dialog({
94 title: __("User Editor"),
95 style: "width: 600px",
97 if (this.validate()) {
99 notify_progress("Saving data...", true);
101 var query = dojo.formToQuery("user_edit_form");
103 new Ajax.Request("backend.php", {
105 onComplete: function(transport) {
116 exception_error("editUser", e);
121 function editFilter(id) {
124 var query = "backend.php?op=pref-filters&method=edit&id=" + param_escape(id);
126 if (dijit.byId("feedEditDlg"))
127 dijit.byId("feedEditDlg").destroyRecursive();
129 if (dijit.byId("filterEditDlg"))
130 dijit.byId("filterEditDlg").destroyRecursive();
132 dialog = new dijit.Dialog({
134 title: __("Edit Filter"),
135 style: "width: 600px",
137 var query = "backend.php?" + dojo.formToQuery("filter_edit_form") + "&savemode=test";
139 if (dijit.byId("filterTestDlg"))
140 dijit.byId("filterTestDlg").destroyRecursive();
142 var test_dlg = new dijit.Dialog({
144 title: "Test Filter",
145 style: "width: 600px",
150 selectRules: function(select) {
151 $$("#filterDlg_Matches input[type=checkbox]").each(function(e) {
154 e.parentNode.addClassName("Selected");
156 e.parentNode.removeClassName("Selected");
159 selectActions: function(select) {
160 $$("#filterDlg_Actions input[type=checkbox]").each(function(e) {
164 e.parentNode.addClassName("Selected");
166 e.parentNode.removeClassName("Selected");
170 editRule: function(e) {
171 var li = e.parentNode;
172 var rule = li.getElementsByTagName("INPUT")[1].value;
173 addFilterRule(li, rule);
175 editAction: function(e) {
176 var li = e.parentNode;
177 var action = li.getElementsByTagName("INPUT")[1].value;
178 addFilterAction(li, action);
180 removeFilter: function() {
181 var msg = __("Remove filter?");
186 notify_progress("Removing filter...");
188 var id = this.attr('value').id;
190 var query = "?op=pref-filters&method=remove&ids="+
193 new Ajax.Request("backend.php", {
195 onComplete: function(transport) {
200 addAction: function() { addFilterAction(); },
201 addRule: function() { addFilterRule(); },
202 deleteAction: function() {
203 $$("#filterDlg_Actions li.[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) });
205 deleteRule: function() {
206 $$("#filterDlg_Matches li.[class*=Selected]").each(function(e) { e.parentNode.removeChild(e) });
208 execute: function() {
209 if (this.validate()) {
211 notify_progress("Saving data...", true);
213 var query = dojo.formToQuery("filter_edit_form");
217 new Ajax.Request("backend.php", {
219 onComplete: function(transport) {
231 exception_error("editFilter", e);
235 function getSelectedLabels() {
236 var tree = dijit.byId("labelTree");
237 var items = tree.model.getCheckedItems();
240 items.each(function(item) {
241 rv.push(tree.model.store.getValue(item, 'bare_id'));
247 function getSelectedUsers() {
248 return getSelectedTableRowIds("prefUserList");
251 function getSelectedFeeds() {
252 var tree = dijit.byId("feedTree");
253 var items = tree.model.getCheckedItems();
256 items.each(function(item) {
257 if (item.id[0].match("FEED:"))
258 rv.push(tree.model.store.getValue(item, 'bare_id'));
264 function getSelectedCategories() {
265 var tree = dijit.byId("feedTree");
266 var items = tree.model.getCheckedItems();
269 items.each(function(item) {
270 if (item.id[0].match("CAT:"))
271 rv.push(tree.model.store.getValue(item, 'bare_id'));
277 function getSelectedFilters() {
278 var tree = dijit.byId("filterTree");
279 var items = tree.model.getCheckedItems();
282 items.each(function(item) {
283 rv.push(tree.model.store.getValue(item, 'bare_id'));
290 function removeSelectedLabels() {
292 var sel_rows = getSelectedLabels();
294 if (sel_rows.length > 0) {
296 var ok = confirm(__("Remove selected labels?"));
299 notify_progress("Removing selected labels...");
301 var query = "?op=pref-labels&method=remove&ids="+
302 param_escape(sel_rows.toString());
304 new Ajax.Request("backend.php", {
306 onComplete: function(transport) {
312 alert(__("No labels are selected."));
318 function removeSelectedUsers() {
322 var sel_rows = getSelectedUsers();
324 if (sel_rows.length > 0) {
326 var ok = confirm(__("Remove selected users? Neither default admin nor your account will be removed."));
329 notify_progress("Removing selected users...");
331 var query = "?op=pref-users&method=remove&ids="+
332 param_escape(sel_rows.toString());
334 new Ajax.Request("backend.php", {
336 onComplete: function(transport) {
343 alert(__("No users are selected."));
347 exception_error("removeSelectedUsers", e);
353 function removeSelectedFilters() {
357 var sel_rows = getSelectedFilters();
359 if (sel_rows.length > 0) {
361 var ok = confirm(__("Remove selected filters?"));
364 notify_progress("Removing selected filters...");
366 var query = "?op=pref-filters&method=remove&ids="+
367 param_escape(sel_rows.toString());
369 new Ajax.Request("backend.php", {
371 onComplete: function(transport) {
376 alert(__("No filters are selected."));
380 exception_error("removeSelectedFilters", e);
387 function removeSelectedFeeds() {
391 var sel_rows = getSelectedFeeds();
393 if (sel_rows.length > 0) {
395 var ok = confirm(__("Unsubscribe from selected feeds?"));
399 notify_progress("Unsubscribing from selected feeds...", true);
401 var query = "?op=pref-feeds&method=remove&ids="+
402 param_escape(sel_rows.toString());
406 new Ajax.Request("backend.php", {
408 onComplete: function(transport) {
414 alert(__("No feeds are selected."));
418 exception_error("removeSelectedFeeds", e);
424 function clearSelectedFeeds() {
426 var sel_rows = getSelectedFeeds();
428 if (sel_rows.length > 1) {
429 alert(__("Please select only one feed."));
433 if (sel_rows.length > 0) {
435 var ok = confirm(__("Erase all non-starred articles in selected feed?"));
438 notify_progress("Clearing selected feed...");
439 clearFeedArticles(sel_rows[0]);
444 alert(__("No feeds are selected."));
451 function purgeSelectedFeeds() {
453 var sel_rows = getSelectedFeeds();
455 if (sel_rows.length > 0) {
457 var pr = prompt(__("How many days of articles to keep (0 - use default)?"), "0");
459 if (pr != undefined) {
460 notify_progress("Purging selected feed...");
462 var query = "?op=rpc&method=purge&ids="+
463 param_escape(sel_rows.toString()) + "&days=" + pr;
467 new Ajax.Request("prefs.php", {
469 onComplete: function(transport) {
476 alert(__("No feeds are selected."));
483 function editSelectedUser() {
484 var rows = getSelectedUsers();
486 if (rows.length == 0) {
487 alert(__("No users are selected."));
491 if (rows.length > 1) {
492 alert(__("Please select only one user."));
501 function resetSelectedUserPass() {
505 var rows = getSelectedUsers();
507 if (rows.length == 0) {
508 alert(__("No users are selected."));
512 if (rows.length > 1) {
513 alert(__("Please select only one user."));
517 var ok = confirm(__("Reset password of selected user?"));
520 notify_progress("Resetting password for selected user...");
524 var query = "?op=pref-users&method=resetPass&id=" +
527 new Ajax.Request("backend.php", {
529 onComplete: function(transport) {
530 notify_info(transport.responseText, true);
536 exception_error("resetSelectedUserPass", e);
540 function selectedUserDetails() {
544 var rows = getSelectedUsers();
546 if (rows.length == 0) {
547 alert(__("No users are selected."));
551 if (rows.length > 1) {
552 alert(__("Please select only one user."));
558 var query = "backend.php?op=pref-users&method=userdetails&id=" + id;
560 if (dijit.byId("userDetailsDlg"))
561 dijit.byId("userDetailsDlg").destroyRecursive();
563 dialog = new dijit.Dialog({
564 id: "userDetailsDlg",
565 title: __("User details"),
566 style: "width: 600px",
567 execute: function() {
575 exception_error("selectedUserDetails", e);
580 function editSelectedFilter() {
581 var rows = getSelectedFilters();
583 if (rows.length == 0) {
584 alert(__("No filters are selected."));
588 if (rows.length > 1) {
589 alert(__("Please select only one filter."));
599 function joinSelectedFilters() {
600 var rows = getSelectedFilters();
602 if (rows.length == 0) {
603 alert(__("No filters are selected."));
607 var ok = confirm(__("Combine selected filters?"));
610 notify_progress("Joining filters...");
612 var query = "?op=pref-filters&method=join&ids="+
613 param_escape(rows.toString());
617 new Ajax.Request("backend.php", {
619 onComplete: function(transport) {
625 function editSelectedFeed() {
626 var rows = getSelectedFeeds();
628 if (rows.length == 0) {
629 alert(__("No feeds are selected."));
633 if (rows.length > 1) {
634 return editSelectedFeeds();
639 editFeed(rows[0], {});
643 function editSelectedFeeds() {
646 var rows = getSelectedFeeds();
648 if (rows.length == 0) {
649 alert(__("No feeds are selected."));
653 notify_progress("Loading, please wait...");
655 var query = "backend.php?op=pref-feeds&method=editfeeds&ids=" +
656 param_escape(rows.toString());
660 if (dijit.byId("feedEditDlg"))
661 dijit.byId("feedEditDlg").destroyRecursive();
663 new Ajax.Request("backend.php", {
665 onComplete: function(transport) {
669 var dialog = new dijit.Dialog({
671 title: __("Edit Multiple Feeds"),
672 style: "width: 600px",
673 getChildByName: function (name) {
675 this.getChildren().each(
677 if (child.name == name) {
684 toggleField: function (checkbox, elem, label) {
685 this.getChildByName(elem).attr('disabled', !checkbox.checked);
688 if (checkbox.checked)
689 $(label).removeClassName('insensitive');
691 $(label).addClassName('insensitive');
694 execute: function() {
695 if (this.validate() && confirm(__("Save changes to selected feeds?"))) {
696 var query = dojo.objectToQuery(this.attr('value'));
698 /* Form.serialize ignores unchecked checkboxes */
700 if (!query.match("&private=") &&
701 this.getChildByName('private').attr('disabled') == false) {
702 query = query + "&private=false";
706 if (!query.match("&cache_images=") &&
707 this.getChildByName('cache_images').attr('disabled') == false) {
708 query = query + "&cache_images=false";
713 if (!query.match("&hide_images=") &&
714 this.getChildByName('hide_images').attr('disabled') == false) {
715 query = query + "&hide_images=false";
719 if (!query.match("&include_in_digest=") &&
720 this.getChildByName('include_in_digest').attr('disabled') == false) {
721 query = query + "&include_in_digest=false";
724 if (!query.match("&always_display_enclosures=") &&
725 this.getChildByName('always_display_enclosures').attr('disabled') == false) {
726 query = query + "&always_display_enclosures=false";
729 if (!query.match("&mark_unread_on_update=") &&
730 this.getChildByName('mark_unread_on_update').attr('disabled') == false) {
731 query = query + "&mark_unread_on_update=false";
736 notify_progress("Saving data...", true);
738 new Ajax.Request("backend.php", {
740 onComplete: function(transport) {
746 content: transport.responseText});
753 exception_error("editSelectedFeeds", e);
757 function opmlImportComplete(iframe) {
759 if (!iframe.contentDocument.body.innerHTML) return false;
761 Element.show(iframe);
765 if (dijit.byId('opmlImportDlg'))
766 dijit.byId('opmlImportDlg').destroyRecursive();
768 var content = iframe.contentDocument.body.innerHTML;
770 dialog = new dijit.Dialog({
772 title: __("OPML Import"),
773 style: "width: 600px",
774 onCancel: function() {
779 execute: function() {
790 exception_error("opmlImportComplete", e);
794 function opmlImport() {
796 var opml_file = $("opml_file");
798 if (opml_file.value.length == 0) {
799 alert(__("Please choose an OPML file first."));
802 notify_progress("Importing, please wait...", true);
804 Element.show("upload_iframe");
811 function updateFilterList() {
812 var user_search = $("filter_search");
814 if (user_search) { search = user_search.value; }
816 new Ajax.Request("backend.php", {
817 parameters: "?op=pref-filters&search=" + param_escape(search),
818 onComplete: function(transport) {
819 dijit.byId('filterConfigTab').attr('content', transport.responseText);
824 function updateLabelList() {
825 new Ajax.Request("backend.php", {
826 parameters: "?op=pref-labels",
827 onComplete: function(transport) {
828 dijit.byId('labelConfigTab').attr('content', transport.responseText);
833 function updatePrefsList() {
834 new Ajax.Request("backend.php", {
835 parameters: "?op=pref-prefs",
836 onComplete: function(transport) {
837 dijit.byId('genConfigTab').attr('content', transport.responseText);
842 function updateSystemList() {
843 new Ajax.Request("backend.php", {
844 parameters: "?op=pref-system",
845 onComplete: function(transport) {
846 dijit.byId('systemConfigTab').attr('content', transport.responseText);
851 function selectTab(id, noupdate, method) {
854 notify_progress("Loading, please wait...");
856 if (id == "feedConfig") {
858 } else if (id == "filterConfig") {
860 } else if (id == "labelConfig") {
862 } else if (id == "genConfig") {
864 } else if (id == "userConfig") {
866 } else if (id == "systemConfig") {
870 var tab = dijit.byId(id + "Tab");
871 dijit.byId("pref-tabs").selectChild(tab);
876 exception_error("selectTab", e);
880 function init_second_stage() {
883 document.onkeydown = pref_hotkey_handler;
884 loading_set_progress(50);
887 dojo.addOnLoad(function() {
888 var tab = getURLParam('tab');
891 tab = dijit.byId(tab + "Tab");
892 if (tab) dijit.byId("pref-tabs").selectChild(tab);
895 var method = getURLParam('method');
897 if (method == 'editFeed') {
898 var param = getURLParam('methodparam');
900 window.setTimeout('editFeed(' + param + ')', 100);
904 setTimeout("hotkey_prefix_timeout()", 5*1000);
907 exception_error("init_second_stage", e);
914 dojo.registerModulePath("lib", "..");
915 dojo.registerModulePath("fox", "../../js/");
917 dojo.require("dijit.ColorPalette");
918 dojo.require("dijit.Dialog");
919 dojo.require("dijit.form.Button");
920 dojo.require("dijit.form.CheckBox");
921 dojo.require("dijit.form.DropDownButton");
922 dojo.require("dijit.form.FilteringSelect");
923 dojo.require("dijit.form.Form");
924 dojo.require("dijit.form.RadioButton");
925 dojo.require("dijit.form.Select");
926 dojo.require("dijit.form.SimpleTextarea");
927 dojo.require("dijit.form.TextBox");
928 dojo.require("dijit.form.ValidationTextBox");
929 dojo.require("dijit.InlineEditBox");
930 dojo.require("dijit.layout.AccordionContainer");
931 dojo.require("dijit.layout.BorderContainer");
932 dojo.require("dijit.layout.ContentPane");
933 dojo.require("dijit.layout.TabContainer");
934 dojo.require("dijit.Menu");
935 dojo.require("dijit.ProgressBar");
936 dojo.require("dijit.ProgressBar");
937 dojo.require("dijit.Toolbar");
938 dojo.require("dijit.Tree");
939 dojo.require("dijit.tree.dndSource");
940 dojo.require("dojo.data.ItemFileWriteStore");
942 dojo.require("lib.CheckBoxTree");
943 dojo.require("fox.PrefFeedTree");
944 dojo.require("fox.PrefFilterTree");
945 dojo.require("fox.PrefLabelTree");
949 dojo.addOnLoad(function() {
950 loading_set_progress(50);
952 var clientTzOffset = new Date().getTimezoneOffset() * 60;
954 new Ajax.Request("backend.php", {
955 parameters: {op: "rpc", method: "sanityCheck",
956 clientTzOffset: clientTzOffset },
957 onComplete: function(transport) {
958 backend_sanity_check_callback(transport);
963 exception_error("init", e);
967 function validatePrefsReset() {
969 var ok = confirm(__("Reset to defaults?"));
973 query = "?op=pref-prefs&method=resetconfig";
976 new Ajax.Request("backend.php", {
978 onComplete: function(transport) {
980 notify_info(transport.responseText);
986 exception_error("validatePrefsReset", e);
993 function pref_hotkey_handler(e) {
996 if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
999 var shift_key = false;
1001 var cmdline = $('cmdline');
1004 shift_key = e.shiftKey;
1010 keycode = window.event.keyCode;
1015 var keychar = String.fromCharCode(keycode);
1017 if (keycode == 27) { // escape
1018 hotkey_prefix = false;
1021 if (keycode == 16) return; // ignore lone shift
1022 if (keycode == 17) return; // ignore lone ctrl
1024 if (!shift_key) keychar = keychar.toLowerCase();
1026 var hotkeys = getInitParam("hotkeys");
1028 if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) {
1030 var date = new Date();
1031 var ts = Math.round(date.getTime() / 1000);
1033 hotkey_prefix = keychar;
1034 hotkey_prefix_pressed = ts;
1036 cmdline.innerHTML = keychar;
1037 Element.show(cmdline);
1042 Element.hide(cmdline);
1044 var hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
1045 hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey;
1046 hotkey_prefix = false;
1048 var hotkey_action = false;
1049 var hotkeys = getInitParam("hotkeys");
1051 for (sequence in hotkeys[1]) {
1052 if (sequence == hotkey) {
1053 hotkey_action = hotkeys[1][sequence];
1058 switch (hotkey_action) {
1059 case "feed_subscribe":
1062 case "create_label":
1065 case "create_filter":
1069 //helpDialog("prefs");
1072 console.log("unhandled action: " + hotkey_action + "; hotkey: " + hotkey);
1076 exception_error("hotkey_handler", e);
1080 function removeCategory(id, item) {
1083 var ok = confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name));
1086 var query = "?op=pref-feeds&method=removeCat&ids="+
1089 notify_progress("Removing category...");
1091 new Ajax.Request("backend.php", {
1093 onComplete: function(transport) {
1100 exception_error("removeCategory", e);
1104 function removeSelectedCategories() {
1106 var sel_rows = getSelectedCategories();
1108 if (sel_rows.length > 0) {
1110 var ok = confirm(__("Remove selected categories?"));
1113 notify_progress("Removing selected categories...");
1115 var query = "?op=pref-feeds&method=removeCat&ids="+
1116 param_escape(sel_rows.toString());
1118 new Ajax.Request("backend.php", {
1120 onComplete: function(transport) {
1126 alert(__("No categories are selected."));
1132 function createCategory() {
1134 var title = prompt(__("Category title:"));
1138 notify_progress("Creating category...");
1140 var query = "?op=pref-feeds&method=addCat&cat=" +
1141 param_escape(title);
1143 new Ajax.Request("backend.php", {
1145 onComplete: function(transport) {
1152 exception_error("createCategory", e);
1156 function showInactiveFeeds() {
1158 var query = "backend.php?op=pref-feeds&method=inactiveFeeds";
1160 if (dijit.byId("inactiveFeedsDlg"))
1161 dijit.byId("inactiveFeedsDlg").destroyRecursive();
1163 dialog = new dijit.Dialog({
1164 id: "inactiveFeedsDlg",
1165 title: __("Feeds without recent updates"),
1166 style: "width: 600px",
1167 getSelectedFeeds: function() {
1168 return getSelectedTableRowIds("prefInactiveFeedList");
1170 removeSelected: function() {
1171 var sel_rows = this.getSelectedFeeds();
1173 console.log(sel_rows);
1175 if (sel_rows.length > 0) {
1176 var ok = confirm(__("Remove selected feeds?"));
1179 notify_progress("Removing selected feeds...", true);
1181 var query = "?op=pref-feeds&method=remove&ids="+
1182 param_escape(sel_rows.toString());
1184 new Ajax.Request("backend.php", {
1186 onComplete: function(transport) {
1194 alert(__("No feeds are selected."));
1197 execute: function() {
1198 if (this.validate()) {
1206 exception_error("showInactiveFeeds", e);
1211 function opmlRegenKey() {
1214 var ok = confirm(__("Replace current OPML publishing address with a new one?"));
1218 notify_progress("Trying to change address...", true);
1220 var query = "?op=pref-feeds&method=regenOPMLKey";
1222 new Ajax.Request("backend.php", {
1224 onComplete: function(transport) {
1225 var reply = JSON.parse(transport.responseText);
1227 var new_link = reply.link;
1229 var e = $('pub_opml_url');
1233 e.innerHTML = new_link;
1235 new Effect.Highlight(e);
1240 notify_error("Could not change feed URL.");
1245 exception_error("opmlRegenKey", e);
1250 function feedActionChange() {
1252 var chooser = $("feedActionChooser");
1253 var opid = chooser[chooser.selectedIndex].value;
1255 chooser.selectedIndex = 0;
1258 exception_error("feedActionChange", e);
1262 function feedActionGo(op) {
1264 if (op == "facEdit") {
1266 var rows = getSelectedFeeds();
1268 if (rows.length > 1) {
1269 editSelectedFeeds();
1275 if (op == "facClear") {
1276 clearSelectedFeeds();
1279 if (op == "facPurge") {
1280 purgeSelectedFeeds();
1283 if (op == "facEditCats") {
1287 if (op == "facRescore") {
1288 rescoreSelectedFeeds();
1291 if (op == "facUnsubscribe") {
1292 removeSelectedFeeds();
1296 exception_error("feedActionGo", e);
1301 function clearFeedArticles(feed_id) {
1303 notify_progress("Clearing feed...");
1305 var query = "?op=pref-feeds&quiet=1&method=clear&id=" + feed_id;
1307 new Ajax.Request("backend.php", {
1309 onComplete: function(transport) {
1316 function rescoreSelectedFeeds() {
1318 var sel_rows = getSelectedFeeds();
1320 if (sel_rows.length > 0) {
1322 //var ok = confirm(__("Rescore last 100 articles in selected feeds?"));
1323 var ok = confirm(__("Rescore articles in selected feeds?"));
1326 notify_progress("Rescoring selected feeds...", true);
1328 var query = "?op=pref-feeds&method=rescore&quiet=1&ids="+
1329 param_escape(sel_rows.toString());
1331 new Ajax.Request("backend.php", {
1333 onComplete: function(transport) {
1334 notify_callback2(transport);
1339 alert(__("No feeds are selected."));
1345 function rescore_all_feeds() {
1346 var ok = confirm(__("Rescore all articles? This operation may take a lot of time."));
1349 notify_progress("Rescoring feeds...", true);
1351 var query = "?op=pref-feeds&method=rescoreAll&quiet=1";
1353 new Ajax.Request("backend.php", {
1355 onComplete: function(transport) {
1356 notify_callback2(transport);
1361 function labelColorReset() {
1363 var labels = getSelectedLabels();
1365 if (labels.length > 0) {
1366 var ok = confirm(__("Reset selected labels to default colors?"));
1369 var query = "?op=pref-labels&method=colorreset&ids="+
1370 param_escape(labels.toString());
1372 new Ajax.Request("backend.php", {
1374 onComplete: function(transport) {
1380 alert(__("No labels are selected."));
1384 exception_error("labelColorReset", e);
1389 function inPreferences() {
1393 function editProfiles() {
1396 if (dijit.byId("profileEditDlg"))
1397 dijit.byId("profileEditDlg").destroyRecursive();
1399 var query = "backend.php?op=pref-prefs&method=editPrefProfiles";
1401 dialog = new dijit.Dialog({
1402 id: "profileEditDlg",
1403 title: __("Settings Profiles"),
1404 style: "width: 600px",
1405 getSelectedProfiles: function() {
1406 return getSelectedTableRowIds("prefFeedProfileList");
1408 removeSelected: function() {
1409 var sel_rows = this.getSelectedProfiles();
1411 if (sel_rows.length > 0) {
1412 var ok = confirm(__("Remove selected profiles? Active and default profiles will not be removed."));
1415 notify_progress("Removing selected profiles...", true);
1417 var query = "?op=rpc&method=remprofiles&ids="+
1418 param_escape(sel_rows.toString());
1420 new Ajax.Request("backend.php", {
1422 onComplete: function(transport) {
1430 alert(__("No profiles are selected."));
1433 activateProfile: function() {
1434 var sel_rows = this.getSelectedProfiles();
1436 if (sel_rows.length == 1) {
1438 var ok = confirm(__("Activate selected profile?"));
1441 notify_progress("Loading, please wait...");
1443 var query = "?op=rpc&method=setprofile&id="+
1444 param_escape(sel_rows.toString());
1446 new Ajax.Request("backend.php", {
1448 onComplete: function(transport) {
1449 window.location.reload();
1454 alert(__("Please choose a profile to activate."));
1457 addProfile: function() {
1458 if (this.validate()) {
1459 notify_progress("Creating profile...", true);
1461 var query = "?op=rpc&method=addprofile&title=" +
1462 param_escape(dialog.attr('value').newprofile);
1464 new Ajax.Request("backend.php", {
1466 onComplete: function(transport) {
1473 execute: function() {
1474 if (this.validate()) {
1481 exception_error("editProfiles", e);
1485 function activatePrefProfile() {
1487 var sel_rows = getSelectedFeedCats();
1489 if (sel_rows.length == 1) {
1491 var ok = confirm(__("Activate selected profile?"));
1494 notify_progress("Loading, please wait...");
1496 var query = "?op=rpc&method=setprofile&id="+
1497 param_escape(sel_rows.toString());
1499 new Ajax.Request("backend.php", {
1501 onComplete: function(transport) {
1502 window.location.reload();
1507 alert(__("Please choose a profile to activate."));
1513 function clearFeedAccessKeys() {
1515 var ok = confirm(__("This will invalidate all previously generated feed URLs. Continue?"));
1518 notify_progress("Clearing URLs...");
1520 var query = "?op=pref-feeds&method=clearKeys";
1522 new Ajax.Request("backend.php", {
1524 onComplete: function(transport) {
1525 notify_info("Generated URLs cleared.");
1532 function resetFilterOrder() {
1534 notify_progress("Loading, please wait...");
1536 new Ajax.Request("backend.php", {
1537 parameters: "?op=pref-filters&method=filtersortreset",
1538 onComplete: function(transport) {
1544 exception_error("resetFilterOrder");
1549 function resetFeedOrder() {
1551 notify_progress("Loading, please wait...");
1553 new Ajax.Request("backend.php", {
1554 parameters: "?op=pref-feeds&method=feedsortreset",
1555 onComplete: function(transport) {
1561 exception_error("resetFeedOrder");
1565 function resetCatOrder() {
1567 notify_progress("Loading, please wait...");
1569 new Ajax.Request("backend.php", {
1570 parameters: "?op=pref-feeds&method=catsortreset",
1571 onComplete: function(transport) {
1577 exception_error("resetCatOrder");
1581 function editCat(id, item, event) {
1583 var new_name = prompt(__('Rename category to:'), item.name);
1585 if (new_name && new_name != item.name) {
1587 notify_progress("Loading, please wait...");
1589 new Ajax.Request("backend.php", {
1592 method: 'renamecat',
1596 onComplete: function(transport) {
1602 exception_error("editCat", e);
1606 function editLabel(id, event) {
1608 var query = "backend.php?op=pref-labels&method=edit&id=" +
1611 if (dijit.byId("labelEditDlg"))
1612 dijit.byId("labelEditDlg").destroyRecursive();
1614 dialog = new dijit.Dialog({
1616 title: __("Label Editor"),
1617 style: "width: 600px",
1618 setLabelColor: function(id, fg, bg) {
1633 var query = "?op=pref-labels&method=colorset&kind="+kind+
1634 "&ids=" + param_escape(id) + "&fg=" + param_escape(fg) +
1635 "&bg=" + param_escape(bg) + "&color=" + param_escape(color);
1637 // console.log(query);
1639 var e = $("LICID-" + id);
1642 if (fg) e.style.color = fg;
1643 if (bg) e.style.backgroundColor = bg;
1646 new Ajax.Request("backend.php", { parameters: query });
1650 execute: function() {
1651 if (this.validate()) {
1652 var caption = this.attr('value').caption;
1653 var fg_color = this.attr('value').fg_color;
1654 var bg_color = this.attr('value').bg_color;
1655 var query = dojo.objectToQuery(this.attr('value'));
1657 dijit.byId('labelTree').setNameById(id, caption);
1658 this.setLabelColor(id, fg_color, bg_color);
1661 new Ajax.Request("backend.php", {
1663 onComplete: function(transport) {
1673 exception_error("editLabel", e);
1678 function customizeCSS() {
1680 var query = "backend.php?op=pref-prefs&method=customizeCSS";
1682 if (dijit.byId("cssEditDlg"))
1683 dijit.byId("cssEditDlg").destroyRecursive();
1685 dialog = new dijit.Dialog({
1687 title: __("Customize stylesheet"),
1688 style: "width: 600px",
1689 execute: function() {
1690 notify_progress('Saving data...', true);
1691 new Ajax.Request("backend.php", {
1692 parameters: dojo.objectToQuery(this.attr('value')),
1693 onComplete: function(transport) {
1695 window.location.reload();
1704 exception_error("customizeCSS", e);
1708 function insertSSLserial(value) {
1710 dijit.byId("SSL_CERT_SERIAL").attr('value', value);
1712 exception_error("insertSSLcerial", e);
1716 function gotoExportOpml(filename, settings) {
1717 tmp = settings ? 1 : 0;
1718 document.location.href = "backend.php?op=opml&method=export&filename=" + filename + "&settings=" + tmp;
1722 function batchSubscribe() {
1724 var query = "backend.php?op=pref-feeds&method=batchSubscribe";
1726 // overlapping widgets
1727 if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
1728 if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive();
1730 var dialog = new dijit.Dialog({
1732 title: __("Batch subscribe"),
1733 style: "width: 600px",
1734 execute: function() {
1735 if (this.validate()) {
1736 console.log(dojo.objectToQuery(this.attr('value')));
1738 notify_progress(__("Subscribing to feeds..."), true);
1740 new Ajax.Request("backend.php", {
1741 parameters: dojo.objectToQuery(this.attr('value')),
1742 onComplete: function(transport) {
1753 exception_error("batchSubscribe", e);
1758 function toggleAdvancedPrefs() {
1760 notify_progress("Loading, please wait...");
1762 new Ajax.Request("backend.php", {
1763 parameters: "?op=pref-prefs&method=toggleadvanced",
1764 onComplete: function(transport) {
1769 exception_error("toggleAdvancedPrefs", e);
1773 function clearPluginData(name) {
1775 if (confirm(__("Clear stored data for this plugin?"))) {
1776 notify_progress("Loading, please wait...");
1778 new Ajax.Request("backend.php", {
1779 parameters: "?op=pref-prefs&method=clearplugindata&name=" + param_escape(name),
1780 onComplete: function(transport) {
1786 exception_error("clearPluginData", e);
1790 function clearSqlLog() {
1792 if (confirm(__("Clear all messages in the error log?"))) {
1794 notify_progress("Loading, please wait...");
1795 var query = "?op=pref-system&method=clearLog";
1797 new Ajax.Request("backend.php", {
1799 onComplete: function(transport) {