]> git.wh0rd.org Git - tt-rss.git/blob - plugins/updater/updater.js
Merge pull request #432 from andersk/floating
[tt-rss.git] / plugins / updater / updater.js
1 function updateSelf() {
2         try {
3                 var query = "backend.php?op=pluginhandler&plugin=updater&method=updateSelf";
4
5                 if (dijit.byId("updateSelfDlg"))
6                         dijit.byId("updateSelfDlg").destroyRecursive();
7
8                 var dialog = new dijit.Dialog({
9                         id: "updateSelfDlg",
10                         title: __("Update Tiny Tiny RSS"),
11                         style: "width: 600px",
12                         closable: false,
13                         performUpdate: function(step) {
14                                 dijit.byId("self_update_start_btn").attr("disabled", true);
15                                 dijit.byId("self_update_stop_btn").attr("disabled", true);
16
17                                 notify_progress("Loading, please wait...", true);
18                                 new Ajax.Request("backend.php", {
19                                 parameters: "op=pluginhandler&plugin=updater&method=performUpdate&step=" + step +
20                                         "&params=" + param_escape(JSON.stringify(dialog.attr("update-params"))),
21                                 onComplete: function(transport) {
22                                         try {
23                                                 rv = JSON.parse(transport.responseText);
24                                                 if (rv) {
25                                                         notify('');
26
27                                                         rv['log'].each(function(line) {
28                                                                 $("self_update_log").innerHTML += "<li>" + line + "</li>";
29                                                         });
30
31                                                         dialog.attr("update-params", rv['params']);
32
33                                                         if (!rv['stop']) {
34                                                                 window.setTimeout("dijit.byId('updateSelfDlg').performUpdate("+(step+1)+")", 500);
35                                                         } else {
36                                                                 dijit.byId("self_update_stop_btn").attr("disabled", false);
37                                                         }
38
39                                                 } else {
40                                                         console.log(transport.responseText);
41                                                         notify_error("Received invalid data from server.");
42                                                 }
43
44                                                 dialog.attr("updated", true);
45                                         } catch (e) {
46                                                 exception_error("updateSelf/inner", e);
47                                         }
48                                 } });
49                         },
50                         close: function() {
51                                 if (dialog.attr("updated")) {
52                                         window.location.reload();
53                                 } else {
54                                         dialog.hide();
55                                 }
56                         },
57                         start: function() {
58                                 if (prompt(__("Backup your tt-rss directory before continuing. Please type 'yes' to continue.")) == 'yes') {
59                                         dialog.performUpdate(0);
60                                 }
61                         },
62                         href: query});
63
64                 dialog.show();
65         } catch (e) {
66                 exception_error("batchSubscribe", e);
67         }
68 }
69