|
1
|
|
|
/* |
|
2
|
|
|
* ***************************************************************************** |
|
3
|
|
|
* Contributions to this work were made on behalf of the GÉANT project, a |
|
4
|
|
|
* project that has received funding from the European Union’s Framework |
|
5
|
|
|
* Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus), |
|
6
|
|
|
* Horizon 2020 research and innovation programme under Grant Agreements No. |
|
7
|
|
|
* 691567 (GN4-1) and No. 731122 (GN4-2). |
|
8
|
|
|
* On behalf of the aforementioned projects, GEANT Association is the sole owner |
|
9
|
|
|
* of the copyright in all material which was developed by a member of the GÉANT |
|
10
|
|
|
* project. GÉANT Vereniging (Association) is registered with the Chamber of |
|
11
|
|
|
* Commerce in Amsterdam with registration number 40535155 and operates in the |
|
12
|
|
|
* UK as a branch of GÉANT Vereniging. |
|
13
|
|
|
* |
|
14
|
|
|
* Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. |
|
15
|
|
|
* UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK |
|
16
|
|
|
* |
|
17
|
|
|
* License: see the web/copyright.inc.php file in the file structure or |
|
18
|
|
|
* <base_url>/copyright.php after deploying the software |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
/**************************************************************** |
|
22
|
|
|
* * |
|
23
|
|
|
* Notification Handling * |
|
24
|
|
|
* * |
|
25
|
|
|
****************************************************************/ |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/* Get Height of the Browser Window */ |
|
29
|
|
|
|
|
30
|
|
|
function getWindowHeight() { |
|
31
|
|
|
var windowHeight = 0; |
|
32
|
|
|
if (typeof (window.innerHeight) === 'number') { |
|
33
|
|
|
windowHeight = window.innerHeight; |
|
34
|
|
|
} else { |
|
35
|
|
|
if (document.documentElement && document.documentElement.clientHeight) { |
|
36
|
|
|
windowHeight = document.documentElement.clientHeight; |
|
37
|
|
|
} else { |
|
38
|
|
|
if (document.body && document.body.clientHeight) { |
|
39
|
|
|
windowHeight = document.body.clientHeight; |
|
40
|
|
|
} |
|
41
|
|
|
} |
|
42
|
|
|
} |
|
43
|
|
|
return windowHeight; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
/* Center an element in the browser window */ |
|
48
|
|
|
|
|
49
|
|
|
function centerElement(el) { |
|
50
|
|
|
if (document.getElementById) { |
|
51
|
|
|
var windowHeight = getWindowHeight(); |
|
52
|
|
|
if (windowHeight > 0) { |
|
53
|
|
|
var contentHeight = el.offsetHeight; |
|
54
|
|
|
if (windowHeight - contentHeight > 0) { |
|
55
|
|
|
el.parentNode.style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px'; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
} |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
/* Display errors/warnings/infos in an overlay box, */ |
|
63
|
|
|
|
|
64
|
|
|
function createMsgbox(type, onclick) { |
|
65
|
|
|
var body = document.getElementsByTagName("body")[0]; |
|
66
|
|
|
if (document.getElementById("overlay") === null) { |
|
67
|
|
|
var overlay = document.createElement("div"); |
|
68
|
|
|
overlay.setAttribute("id", "overlay"); |
|
69
|
|
|
body.appendChild(overlay); |
|
70
|
|
|
} else { |
|
71
|
|
|
body.removeChild(document.getElementById("msgbox")); |
|
72
|
|
|
} |
|
73
|
|
|
var msgbox = document.createElement("div"); |
|
74
|
|
|
if (type === "qr") { |
|
75
|
|
|
msgbox.setAttribute("id", "qrbox") |
|
76
|
|
|
} else { |
|
77
|
|
|
msgbox.setAttribute("id", "msgbox"); |
|
78
|
|
|
} |
|
79
|
|
|
var div = document.createElement("div"); |
|
80
|
|
|
var msg = document.createElement("div"); |
|
81
|
|
|
if (type === "err") { |
|
82
|
|
|
msg.setAttribute("id", "errorbox"); |
|
83
|
|
|
} else if (type === "warn") { |
|
84
|
|
|
msg.setAttribute("id", "warnbox"); |
|
85
|
|
|
} else if (type === "info") { |
|
86
|
|
|
msg.setAttribute("class", "graybox"); |
|
87
|
|
|
} else if (type === "qr") { |
|
88
|
|
|
msg.setAttribute("class", "qrbox"); |
|
89
|
|
|
} |
|
90
|
|
|
var img = document.createElement("img"); |
|
91
|
|
|
img.setAttribute("src", "../resources/images/icons/button_cancel.png"); |
|
92
|
|
|
img.setAttribute("alt", "cancel"); |
|
93
|
|
|
if (onclick) { |
|
94
|
|
|
if (type === "qr") { |
|
95
|
|
|
img.setAttribute("onclick", "removeQRbox(); " + onclick); |
|
96
|
|
|
} else { |
|
97
|
|
|
img.setAttribute("onclick", "removeMsgbox(); " + onclick); |
|
98
|
|
|
} |
|
99
|
|
|
} else { |
|
100
|
|
|
if (type === "qr") { |
|
101
|
|
|
img.setAttribute("onclick", "removeQRbox()"); |
|
102
|
|
|
} else { |
|
103
|
|
|
img.setAttribute("onclick", "removeMsgbox()"); |
|
104
|
|
|
} |
|
105
|
|
|
} |
|
106
|
|
|
msg.appendChild(img); |
|
107
|
|
|
div.appendChild(msg); |
|
108
|
|
|
msgbox.appendChild(div); |
|
109
|
|
|
body.appendChild(msgbox); |
|
110
|
|
|
return msg; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
|
|
114
|
|
|
function removeMsgbox() { |
|
115
|
|
|
var body = document.getElementsByTagName("body")[0]; |
|
116
|
|
|
body.removeChild(document.getElementById("overlay")); |
|
117
|
|
|
body.removeChild(document.getElementById("msgbox")); |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
function removeQRbox() { |
|
121
|
|
|
var body = document.getElementsByTagName("body")[0]; |
|
122
|
|
|
body.removeChild(document.getElementById("overlay")); |
|
123
|
|
|
body.removeChild(document.getElementById("qrbox")); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
function addEvent(elem, type, eventHandle) { |
|
127
|
|
|
if (elem === null || elem === undefined) { |
|
128
|
|
|
return; |
|
129
|
|
|
} |
|
130
|
|
|
if (elem.addEventListener) { |
|
131
|
|
|
elem.addEventListener(type, eventHandle, false); |
|
132
|
|
|
} else if (elem.attachEvent) { |
|
133
|
|
|
elem.attachEvent("on" + type, eventHandle); |
|
134
|
|
|
} |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
|
|
138
|
|
|
function overlay_resize() { |
|
139
|
|
|
var el = document.getElementById("msgbox"); |
|
140
|
|
|
if (!el || !el.firstChild || !el.firstChild.firstChild) { |
|
141
|
|
|
return; |
|
142
|
|
|
} |
|
143
|
|
|
centerElement(el.firstChild.firstChild); |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
addEvent(window, "resize", overlay_resize); |
|
147
|
|
|
|
|
148
|
|
|
function popupRedirectWindow(form) { |
|
149
|
|
|
postXML(createWindow, form); |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
function popupStatsWindow(form) { |
|
153
|
|
|
postXML(createWindow, form); |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
function popupQRWindow(form) { |
|
157
|
|
|
postXML(createQRWindow, form); |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
function createWindow() { |
|
161
|
|
|
if (this.readyState === 4 && this.status === 200) { |
|
162
|
|
|
var infoBox; |
|
163
|
|
|
infoBox = createMsgbox("info"); |
|
164
|
|
|
infoBox.innerHTML += this.responseText; |
|
165
|
|
|
centerElement(infoBox); |
|
166
|
|
|
} |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
function createQRWindow() { |
|
170
|
|
|
if (this.readyState === 4 && this.status === 200) { |
|
171
|
|
|
var qrBox; |
|
172
|
|
|
qrBox = createMsgbox("qr"); |
|
173
|
|
|
qrBox.innerHTML += this.responseText; |
|
174
|
|
|
centerElement(qrBox); |
|
175
|
|
|
} |
|
176
|
|
|
} |