]> git.wh0rd.org Git - tt-rss.git/blob - plugins/import_export/import_export.js
feedbrowser hack
[tt-rss.git] / plugins / import_export / import_export.js
1 function exportData() {
2         try {
3
4                 var query = "backend.php?op=pluginhandler&plugin=import_export&method=exportData";
5
6                 if (dijit.byId("dataExportDlg"))
7                         dijit.byId("dataExportDlg").destroyRecursive();
8
9                 var exported = 0;
10
11                 dialog = new dijit.Dialog({
12                         id: "dataExportDlg",
13                         title: __("Export Data"),
14                         style: "width: 600px",
15                         prepare: function() {
16
17                                 notify_progress("Loading, please wait...");
18
19                                 new Ajax.Request("backend.php", {
20                                         parameters: "op=pluginhandler&plugin=import_export&method=exportrun&offset=" + exported,
21                                         onComplete: function(transport) {
22                                                 try {
23                                                         var rv = JSON.parse(transport.responseText);
24
25                                                         if (rv && rv.exported != undefined) {
26                                                                 if (rv.exported > 0) {
27
28                                                                         exported += rv.exported;
29
30                                                                         $("export_status_message").innerHTML =
31                                                                                 "<img src='images/indicator_tiny.gif'> " +
32                                                                                 "Exported %d articles, please wait...".replace("%d",
33                                                                                         exported);
34
35                                                                         setTimeout('dijit.byId("dataExportDlg").prepare()', 2000);
36
37                                                                 } else {
38
39                                                                         $("export_status_message").innerHTML =
40                                                                                 ngettext("Finished, exported %d article. You can download the data <a class='visibleLink' href='%u'>here</a>.", "Finished, exported %d articles. You can download the data <a class='visibleLink' href='%u'>here</a>.", exported)
41                                                                                 .replace("%d", exported)
42                                                                                 .replace("%u", "backend.php?op=pluginhandler&plugin=import_export&subop=exportget");
43
44                                                                         exported = 0;
45
46                                                                 }
47
48                                                         } else {
49                                                                 $("export_status_message").innerHTML =
50                                                                         "Error occured, could not export data.";
51                                                         }
52                                                 } catch (e) {
53                                                         exception_error("exportData", e, transport.responseText);
54                                                 }
55
56                                                 notify('');
57
58                                         } });
59
60                         },
61                         execute: function() {
62                                 if (this.validate()) {
63
64
65
66                                 }
67                         },
68                         href: query});
69
70                 dialog.show();
71
72
73         } catch (e) {
74                 exception_error("exportData", e);
75         }
76 }
77
78 function dataImportComplete(iframe) {
79         try {
80                 if (!iframe.contentDocument.body.innerHTML) return false;
81
82                 Element.hide(iframe);
83
84                 notify('');
85
86                 if (dijit.byId('dataImportDlg'))
87                         dijit.byId('dataImportDlg').destroyRecursive();
88
89                 var content = iframe.contentDocument.body.innerHTML;
90
91                 dialog = new dijit.Dialog({
92                         id: "dataImportDlg",
93                         title: __("Data Import"),
94                         style: "width: 600px",
95                         onCancel: function() {
96
97                         },
98                         content: content});
99
100                 dialog.show();
101
102         } catch (e) {
103                 exception_error("dataImportComplete", e);
104         }
105 }
106
107 function importData() {
108
109         var file = $("export_file");
110
111         if (file.value.length == 0) {
112                 alert(__("Please choose the file first."));
113                 return false;
114         } else {
115                 notify_progress("Importing, please wait...", true);
116
117                 Element.show("data_upload_iframe");
118
119                 return true;
120         }
121 }
122
123