download_notification.js
3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
var win;
var head;
var sUrl;
var type;
var request;
var request_type;
var request_details;
/*
* Create the download notification dialog
*/
var showDownloadNotification = function(sUrl, head, action, code, request_type, details){
createNotification();
this.sUrl = sUrl + 'download_notification.php';
if(details === undefined) details = '';
if(request_type === undefined) request_type = 'submit';
if(type === undefined) type = 'system';
this.head = head;
this.code = code;
this.request = request;
this.request_type = request_type;
this.request_details = new Array();
this.request_details[0] = action;
this.request_details[1] = details;
// create the window
this.win = new Ext.Window({
applyTo : 'download_notification',
layout : 'fit',
width : 370,
height : 150,
resizable : false,
closable : false,
closeAction :'destroy',
y : 150,
shadow: false,
modal: true
});
this.win.show();
var info = document.getElementById('download_link');
Ext.Ajax.request({
url: this.sUrl,
success: function(response) {
info.innerHTML = response.responseText;
document.getElementById('download_link').focus();
},
failure: function(response) {
alert('Error. Couldn\'t locate download.');
},
params: {
action: 'fetch',
head: head,
code: this.code,
request_type: this.request_type,
request: this.request
}
});
}
/*
* Create the html required to display the download link
*/
var createNotification = function() {
if(document.getElementById('download-panel')){
p = document.getElementById('download-panel');
}else {
p = document.getElementById('pageBody').appendChild(document.createElement('div'));
p.id = 'download-panel';
}
inner = '<div id="download_notification" class="x-hidden"><div class="x-window-header">Download Notification</div><div class="x-window-body">';
inner = inner + '<div id="popup_content"><div id="download_link">Loading...</div></div></div></div>';
p.innerHTML = inner;
}
/*
* Close the popup
*/
var panel_close = function() {
this.win.destroy();
}
/**
* Defer the download to next login
*/
var deferDownload = function() {
if (confirm("This will defer the download until your next login")) {
panel_close();
}
}
/**
* Delete the download and close the window
*/
var deleteDownload = function() {
if (confirm("Cancelling will delete the download.\nYou will not be able to start the download at a later time.\n\nAre you sure?")) {
var info = document.getElementById('exportcode');
Ext.Ajax.request({
url: this.sUrl,
success: function(response) {
if(response.responseText == 'success'){
if(this.request_type == 'close'){
// follow the close action
this.win.destroy();
return;
}
}
info.innerHTML = response.responseText;
},
failure: function(response) {
alert('Error. Couldn\'t delete download.');
},
params: {
action: 'delete',
code: this.code
}
});
panel_close();
}
}