diff options
author | Andrew Dolgov <[email protected]> | 2011-04-20 15:53:50 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2011-04-20 15:53:50 +0400 |
commit | bf758124d2bec8977af8b735a4f9a949f24c6fcd (patch) | |
tree | de9359fa80e74dfd1f6eee730c8cfab41adaad29 /prefs.js | |
parent | 2b020009b1bd1e2c1e527c2adf94fe0fc780849b (diff) | |
parent | 9530efa1b506f4a0d64088ae30aec38ff27de331 (diff) |
backend: merge with shared-feedbrowser
Diffstat (limited to 'prefs.js')
-rw-r--r-- | prefs.js | 175 |
1 files changed, 175 insertions, 0 deletions
@@ -5,6 +5,16 @@ var hotkey_prefix_pressed = false; var seq = ""; +function instancelist_callback2(transport) { + try { + dijit.byId('instanceConfigTab').attr('content', transport.responseText); + selectTab("instanceConfig", true); + notify(""); + } catch (e) { + exception_error("instancelist_callback2", e); + } +} + function feedlist_callback2(transport) { try { dijit.byId('feedConfigTab').attr('content', transport.responseText); @@ -66,6 +76,14 @@ function updateFeedList(sort_key) { } }); } +function updateInstanceList(sort_key) { + new Ajax.Request("backend.php", { + parameters: "?op=pref-instances&sort=" + param_escape(sort_key), + onComplete: function(transport) { + instancelist_callback2(transport); + } }); +} + function updateUsersList(sort_key) { try { @@ -1760,3 +1778,160 @@ function insertSSLserial(value) { exception_error("insertSSLcerial", e); } } + +function getSelectedInstances() { + return getSelectedTableRowIds("prefInstanceList"); +} + +function addInstance() { + try { + var query = "backend.php?op=dlg&id=addInstance"; + + if (dijit.byId("instanceAddDlg")) + dijit.byId("instanceAddDlg").destroyRecursive(); + + dialog = new dijit.Dialog({ + id: "instanceAddDlg", + title: __("Link Instance"), + style: "width: 600px", + regenKey: function() { + new Ajax.Request("backend.php", { + parameters: "?op=rpc&subop=genHash", + onComplete: function(transport) { + var reply = JSON.parse(transport.responseText); + if (reply) + dijit.byId('instance_add_key').attr('value', reply.hash); + + } }); + }, + execute: function() { + if (this.validate()) { + console.warn(dojo.objectToQuery(this.attr('value'))); + + notify_progress('Saving data...', true); + new Ajax.Request("backend.php", { + parameters: dojo.objectToQuery(this.attr('value')), + onComplete: function(transport) { + dialog.hide(); + notify(''); + updateInstanceList(); + } }); + } + }, + href: query, + }); + + dialog.show(); + + } catch (e) { + exception_error("addInstance", e); + } +} + +function editInstance(id, event) { + try { + if (!event || !event.ctrlKey) { + + selectTableRows('prefInstanceList', 'none'); + selectTableRowById('LIRR-'+id, 'LICHK-'+id, true); + + var query = "backend.php?op=pref-instances&subop=edit&id=" + + param_escape(id); + + if (dijit.byId("instanceEditDlg")) + dijit.byId("instanceEditDlg").destroyRecursive(); + + dialog = new dijit.Dialog({ + id: "instanceEditDlg", + title: __("Edit Instance"), + style: "width: 600px", + regenKey: function() { + new Ajax.Request("backend.php", { + parameters: "?op=rpc&subop=genHash", + onComplete: function(transport) { + var reply = JSON.parse(transport.responseText); + if (reply) + dijit.byId('instance_edit_key').attr('value', reply.hash); + + } }); + }, + execute: function() { + if (this.validate()) { +// console.warn(dojo.objectToQuery(this.attr('value'))); + + notify_progress('Saving data...', true); + new Ajax.Request("backend.php", { + parameters: dojo.objectToQuery(this.attr('value')), + onComplete: function(transport) { + dialog.hide(); + notify(''); + updateInstanceList(); + } }); + } + }, + href: query, + }); + + dialog.show(); + + } else if (event.ctrlKey) { + var cb = $('LICHK-' + id); + cb.checked = !cb.checked; + toggleSelectRow(cb); + } + + + } catch (e) { + exception_error("editInstance", e); + } +} + +function removeSelectedInstances() { + try { + var sel_rows = getSelectedInstances(); + + if (sel_rows.length > 0) { + + var ok = confirm(__("Remove selected instances?")); + + if (ok) { + notify_progress("Removing selected instances..."); + + var query = "?op=pref-instances&subop=remove&ids="+ + param_escape(sel_rows.toString()); + + new Ajax.Request("backend.php", { + parameters: query, + onComplete: function(transport) { + notify(''); + updateInstanceList(); + } }); + } + + } else { + alert(__("No instances are selected.")); + } + + } catch (e) { + exception_error("removeInstance", e); + } +} + +function editSelectedInstance() { + var rows = getSelectedInstances(); + + if (rows.length == 0) { + alert(__("No instances are selected.")); + return; + } + + if (rows.length > 1) { + alert(__("Please select only one instance.")); + return; + } + + notify(""); + + editInstance(rows[0]); +} + |