]>
git.wh0rd.org - tt-rss.git/blob - plugins/instances/instances.js
1 function addInstance() {
3 var query
= "backend.php?op=pluginhandler&plugin=instances&method=addInstance";
5 if (dijit
.byId("instanceAddDlg"))
6 dijit
.byId("instanceAddDlg").destroyRecursive();
8 dialog
= new dijit
.Dialog({
10 title
: __("Link Instance"),
11 style
: "width: 600px",
12 regenKey: function() {
13 new Ajax
.Request("backend.php", {
14 parameters
: "op=pluginhandler&plugin=instances&method=genHash",
15 onComplete: function(transport
) {
16 var reply
= JSON
.parse(transport
.responseText
);
18 dijit
.byId('instance_add_key').attr('value', reply
.hash
);
23 if (this.validate()) {
24 console
.warn(dojo
.objectToQuery(this.attr('value')));
26 notify_progress('Saving data...', true);
27 new Ajax
.Request("backend.php", {
28 parameters
: dojo
.objectToQuery(this.attr('value')),
29 onComplete: function(transport
) {
42 exception_error("addInstance", e
);
48 function updateInstanceList(sort_key
) {
49 new Ajax
.Request("backend.php", {
50 parameters
: "op=pluginhandler&plugin=instances&sort=" + param_escape(sort_key
),
51 onComplete: function(transport
) {
52 dijit
.byId('instanceConfigTab').attr('content', transport
.responseText
);
53 selectTab("instanceConfig", true);
58 function editInstance(id
, event
) {
60 if (!event
|| !event
.ctrlKey
) {
62 selectTableRows('prefInstanceList', 'none');
63 selectTableRowById('LIRR-'+id
, 'LICHK-'+id
, true);
65 var query
= "backend.php?op=pluginhandler&plugin=instances&method=edit&id=" +
68 if (dijit
.byId("instanceEditDlg"))
69 dijit
.byId("instanceEditDlg").destroyRecursive();
71 dialog
= new dijit
.Dialog({
72 id
: "instanceEditDlg",
73 title
: __("Edit Instance"),
74 style
: "width: 600px",
75 regenKey: function() {
76 new Ajax
.Request("backend.php", {
77 parameters
: "op=pluginhandler&plugin=instances&method=genHash",
78 onComplete: function(transport
) {
79 var reply
= JSON
.parse(transport
.responseText
);
81 dijit
.byId('instance_edit_key').attr('value', reply
.hash
);
86 if (this.validate()) {
87 // console.warn(dojo.objectToQuery(this.attr('value')));
89 notify_progress('Saving data...', true);
90 new Ajax
.Request("backend.php", {
91 parameters
: dojo
.objectToQuery(this.attr('value')),
92 onComplete: function(transport
) {
104 } else if (event
.ctrlKey
) {
105 var cb
= $('LICHK-' + id
);
106 cb
.checked
= !cb
.checked
;
112 exception_error("editInstance", e
);
116 function removeSelectedInstances() {
118 var sel_rows
= getSelectedInstances();
120 if (sel_rows
.length
> 0) {
122 var ok
= confirm(__("Remove selected instances?"));
125 notify_progress("Removing selected instances...");
127 var query
= "op=pluginhandler&plugin=instances&method=remove&ids="+
128 param_escape(sel_rows
.toString());
130 new Ajax
.Request("backend.php", {
132 onComplete: function(transport
) {
134 updateInstanceList();
139 alert(__("No instances are selected."));
143 exception_error("removeInstance", e
);
147 function editSelectedInstance() {
148 var rows
= getSelectedInstances();
150 if (rows
.length
== 0) {
151 alert(__("No instances are selected."));
155 if (rows
.length
> 1) {
156 alert(__("Please select only one instance."));
162 editInstance(rows
[0]);
165 function getSelectedInstances() {
166 return getSelectedTableRowIds("prefInstanceList");