nexusframework 0.3.0-beta.72 → 0.3.0-beta.74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +55 -55
- package/README.md +12 -12
- package/about/index.json +5 -5
- package/about/index.nhp +4 -4
- package/icon.png +0 -0
- package/index.d.ts +12 -15
- package/index.js +94 -81
- package/index.js.map +1 -1
- package/index.ts +101 -89
- package/indexOfSkeleton.nhp +133 -133
- package/legacySkeleton.nhp +22 -22
- package/loader/overlay.css +1 -1
- package/loader/overlay.html +25 -25
- package/loader/overlay.scss +152 -152
- package/package.json +102 -89
- package/scripts/es5/compat.js +101 -0
- package/scripts/es5/compat.js.map +1 -0
- package/scripts/es5/compat.min.js +2 -0
- package/scripts/es5/compat.min.js.map +1 -0
- package/scripts/es5/loader.js +0 -0
- package/scripts/es5/loader.js.map +0 -0
- package/scripts/es5/loader.min.js +1 -1
- package/scripts/es5/loader.min.js.map +0 -0
- package/scripts/es5/nexusframeworkclient.js +1092 -1103
- package/scripts/es5/nexusframeworkclient.js.map +1 -1
- package/scripts/es5/nexusframeworkclient.min.js +1 -1
- package/scripts/es5/nexusframeworkclient.min.js.map +1 -1
- package/scripts/es6/compat.js +65 -0
- package/scripts/es6/compat.js.map +1 -0
- package/scripts/es6/compat.min.js +2 -0
- package/scripts/es6/compat.min.js.map +1 -0
- package/scripts/es6/loader.js +0 -0
- package/scripts/es6/loader.js.map +0 -0
- package/scripts/es6/loader.min.js +1 -1
- package/scripts/es6/loader.min.js.map +0 -0
- package/scripts/es6/nexusframeworkclient.js +1026 -1049
- package/scripts/es6/nexusframeworkclient.js.map +1 -1
- package/scripts/es6/nexusframeworkclient.min.js +1 -1
- package/scripts/es6/nexusframeworkclient.min.js.map +1 -1
- package/scripts/index.d.ts +259 -251
- package/scripts/src/compat.ts +62 -0
- package/scripts/src/loader.ts +385 -385
- package/scripts/src/nexusframeworkclient.ts +1163 -1185
- package/scripts/tsconfig.json +11 -11
- package/src/cli.d.ts +1 -0
- package/src/cli.js +102 -102
- package/src/cli.js.map +1 -1
- package/src/cli.ts +101 -101
- package/src/compileScripts.d.ts +2 -2
- package/src/compileScripts.js +145 -145
- package/src/compileScripts.js.map +1 -1
- package/src/compileScripts.ts +153 -153
- package/src/nexusframework.d.ts +177 -168
- package/src/nexusframework.js +3578 -3422
- package/src/nexusframework.js.map +1 -1
- package/src/nexusframework.ts +3631 -3473
- package/templates/basic/package.json +3 -3
- package/templates/basic/www/skeleton.nhp +1 -1
- package/templates/bootstrap/package.json +2 -2
- package/templates/bootstrap/www/skeleton.nhp +1 -1
- package/templates/bootstrap-material-design/package.json +2 -2
- package/templates/bootstrap-material-design/www/skeleton.nhp +1 -1
- package/tsconfig.json +25 -22
- package/types.d.ts +612 -564
|
@@ -9,400 +9,435 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
9
9
|
};
|
|
10
10
|
})();
|
|
11
11
|
/// <reference path="../index.d.ts" />
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return this.request.responseURL || this._url;
|
|
32
|
-
},
|
|
33
|
-
enumerable: true,
|
|
34
|
-
configurable: true
|
|
35
|
-
});
|
|
36
|
-
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "code", {
|
|
37
|
-
get: function () {
|
|
38
|
-
return this.request.status;
|
|
39
|
-
},
|
|
40
|
-
enumerable: true,
|
|
41
|
-
configurable: true
|
|
42
|
-
});
|
|
43
|
-
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "contentLength", {
|
|
44
|
-
get: function () {
|
|
45
|
-
return parseInt(this.request.getResponseHeader("content-length")) || this.request.responseText.length;
|
|
46
|
-
},
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true
|
|
49
|
-
});
|
|
50
|
-
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "contentFromJSON", {
|
|
51
|
-
get: function () {
|
|
52
|
-
if (!this.parsedJson)
|
|
53
|
-
this.parsedJson = JSON.parse(this.request.responseText);
|
|
54
|
-
return this.parsedJson;
|
|
55
|
-
},
|
|
56
|
-
enumerable: true,
|
|
57
|
-
configurable: true
|
|
58
|
-
});
|
|
59
|
-
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "contentAsString", {
|
|
60
|
-
get: function () {
|
|
61
|
-
return this.request.responseText;
|
|
62
|
-
},
|
|
63
|
-
enumerable: true,
|
|
64
|
-
configurable: true
|
|
65
|
-
});
|
|
66
|
-
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "headers", {
|
|
67
|
-
get: function () {
|
|
68
|
-
if (!this.processedHeaders) {
|
|
69
|
-
var headers_1 = this.processedHeaders = {};
|
|
70
|
-
this.request.getAllResponseHeaders().split(/\r?\n/g).forEach(function (header) {
|
|
71
|
-
var index = header.indexOf(":");
|
|
72
|
-
var key, val;
|
|
73
|
-
if (index > 0) {
|
|
74
|
-
key = header.substring(0, index).trim().toLowerCase();
|
|
75
|
-
val = header.substring(index + 1).trim();
|
|
76
|
-
}
|
|
77
|
-
else
|
|
78
|
-
key = header.trim().toLowerCase();
|
|
79
|
-
var list = headers_1[key];
|
|
80
|
-
if (!list)
|
|
81
|
-
list = headers_1[key] = [];
|
|
82
|
-
if (val)
|
|
83
|
-
list.push(val);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
return this.processedHeaders;
|
|
87
|
-
},
|
|
88
|
-
enumerable: true,
|
|
89
|
-
configurable: true
|
|
90
|
-
});
|
|
91
|
-
return NexusFrameworkXMLHttpRequestResponse;
|
|
92
|
-
}());
|
|
93
|
-
var execute_1 = function (method, url, data, cb, extraHeaders, progcb) {
|
|
94
|
-
var request = new XMLHttpRequest();
|
|
95
|
-
request.open(method, url, true);
|
|
96
|
-
if (extraHeaders)
|
|
97
|
-
Object.keys(extraHeaders).forEach(function (key) {
|
|
98
|
-
request.setRequestHeader(key, extraHeaders[key]);
|
|
99
|
-
});
|
|
100
|
-
if (progcb)
|
|
101
|
-
request.onprogress = function (ev) {
|
|
102
|
-
if (ev.lengthComputable && ev.total)
|
|
103
|
-
progcb(ev.loaded, ev.total);
|
|
104
|
-
};
|
|
105
|
-
request.onreadystatechange = function (e) {
|
|
106
|
-
if (request.readyState === XMLHttpRequest.DONE) {
|
|
107
|
-
cb(new NexusFrameworkXMLHttpRequestResponse_1(request, url, !!data));
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
var type = data && data.type;
|
|
111
|
-
if (type)
|
|
112
|
-
switch (type) {
|
|
113
|
-
case "":
|
|
114
|
-
case "text/urlencoded":
|
|
115
|
-
var dat = "";
|
|
116
|
-
for (var _i = 0, _a = data.data; _i < _a.length; _i++) {
|
|
117
|
-
var entry = _a[_i];
|
|
118
|
-
if (dat)
|
|
119
|
-
dat += "&";
|
|
120
|
-
dat += encodeURIComponent(entry[0]);
|
|
121
|
-
dat += "=";
|
|
122
|
-
dat += encodeURIComponent(entry[1]);
|
|
123
|
-
}
|
|
124
|
-
request.setRequestHeader("Content-Type", "text/urlencoded");
|
|
125
|
-
request.send(dat);
|
|
126
|
-
break;
|
|
127
|
-
case "multipart/form-data":
|
|
128
|
-
request.send(data.data);
|
|
129
|
-
break;
|
|
130
|
-
default:
|
|
131
|
-
request.send(data);
|
|
12
|
+
(function (window) {
|
|
13
|
+
var BSON = new window['bson'];
|
|
14
|
+
Object.defineProperties(window, {
|
|
15
|
+
NexusFrameworkTransport: {
|
|
16
|
+
configurable: true,
|
|
17
|
+
set: function (instance) {
|
|
18
|
+
Object.defineProperty(window, "NexusFrameworkTransport", {
|
|
19
|
+
value: instance
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
get: function () {
|
|
23
|
+
var impl;
|
|
24
|
+
if ("XMLHttpRequest" in window) {
|
|
25
|
+
var NexusFrameworkXMLHttpRequestResponse_1 = /** @class */ (function () {
|
|
26
|
+
function NexusFrameworkXMLHttpRequestResponse(request, url, hadData, abResponse) {
|
|
27
|
+
this._url = url;
|
|
28
|
+
this.request = request;
|
|
29
|
+
this.hadData = hadData;
|
|
30
|
+
this.abResponse = abResponse;
|
|
132
31
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
impl = {
|
|
137
|
-
get: function (url, cb, extraHeaders, progcb) {
|
|
138
|
-
execute_1("GET", url, undefined, cb, extraHeaders, progcb);
|
|
139
|
-
},
|
|
140
|
-
head: function (url, cb, extraHeaders, progcb) {
|
|
141
|
-
execute_1("HEAD", url, undefined, cb, extraHeaders, progcb);
|
|
142
|
-
},
|
|
143
|
-
post: function (url, data, cb, extraHeaders, progcb) {
|
|
144
|
-
execute_1("POST", url, data, cb, extraHeaders, progcb);
|
|
145
|
-
},
|
|
146
|
-
put: function (url, data, cb, extraHeaders, progcb) {
|
|
147
|
-
execute_1("PUT", url, data, cb, extraHeaders, progcb);
|
|
148
|
-
},
|
|
149
|
-
execute: execute_1,
|
|
150
|
-
del: function (url, cb, extraHeaders, progcb) {
|
|
151
|
-
execute_1("DELETE", url, undefined, cb, extraHeaders, progcb);
|
|
152
|
-
}
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
impl = {
|
|
157
|
-
get: function (url, cb, extraHeaders) {
|
|
158
|
-
cb({
|
|
159
|
-
url: url,
|
|
160
|
-
code: 0,
|
|
161
|
-
get contentFromJSON() {
|
|
162
|
-
throw new Error("No response to parse.");
|
|
32
|
+
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "url", {
|
|
33
|
+
get: function () {
|
|
34
|
+
return this.request.responseURL || this._url;
|
|
163
35
|
},
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
headers: {}
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true
|
|
167
38
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
url: url,
|
|
172
|
-
code: 0,
|
|
173
|
-
get contentFromJSON() {
|
|
174
|
-
throw new Error("No response to parse.");
|
|
39
|
+
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "code", {
|
|
40
|
+
get: function () {
|
|
41
|
+
return this.request.status;
|
|
175
42
|
},
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
headers: {}
|
|
43
|
+
enumerable: true,
|
|
44
|
+
configurable: true
|
|
179
45
|
});
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
url: url,
|
|
184
|
-
code: 0,
|
|
185
|
-
get contentFromJSON() {
|
|
186
|
-
throw new Error("No response to parse.");
|
|
46
|
+
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "contentLength", {
|
|
47
|
+
get: function () {
|
|
48
|
+
return parseInt(this.request.getResponseHeader("content-length")) || this.request.responseText.length;
|
|
187
49
|
},
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
headers: {}
|
|
50
|
+
enumerable: true,
|
|
51
|
+
configurable: true
|
|
191
52
|
});
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
get contentFromJSON() {
|
|
198
|
-
throw new Error("No response to parse.");
|
|
53
|
+
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "contentFromJSON", {
|
|
54
|
+
get: function () {
|
|
55
|
+
if (!this.parsedJson)
|
|
56
|
+
this.parsedJson = JSON.parse(this.request.responseText);
|
|
57
|
+
return this.parsedJson;
|
|
199
58
|
},
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
headers: {}
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true
|
|
203
61
|
});
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
62
|
+
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "contentFromBSON", {
|
|
63
|
+
get: function () {
|
|
64
|
+
if (!this.parsedBson) {
|
|
65
|
+
var response = this.request.response;
|
|
66
|
+
if (typeof response === "string")
|
|
67
|
+
response = Buffer.from(response, "utf8");
|
|
68
|
+
else
|
|
69
|
+
response = new Buffer(response);
|
|
70
|
+
this.parsedBson = BSON.deserialize(response, { promoteValues: true });
|
|
71
|
+
}
|
|
72
|
+
return this.parsedBson;
|
|
211
73
|
},
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
headers: {}
|
|
74
|
+
enumerable: true,
|
|
75
|
+
configurable: true
|
|
215
76
|
});
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
url: url,
|
|
220
|
-
code: 0,
|
|
221
|
-
get contentFromJSON() {
|
|
222
|
-
throw new Error("No response to parse.");
|
|
77
|
+
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "contentAsString", {
|
|
78
|
+
get: function () {
|
|
79
|
+
return this.request.responseText;
|
|
223
80
|
},
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
headers: {}
|
|
81
|
+
enumerable: true,
|
|
82
|
+
configurable: true
|
|
227
83
|
});
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
84
|
+
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "contentAsArrayBuffer", {
|
|
85
|
+
get: function () {
|
|
86
|
+
return this.request.response;
|
|
87
|
+
},
|
|
88
|
+
enumerable: true,
|
|
89
|
+
configurable: true
|
|
90
|
+
});
|
|
91
|
+
Object.defineProperty(NexusFrameworkXMLHttpRequestResponse.prototype, "headers", {
|
|
92
|
+
get: function () {
|
|
93
|
+
if (!this.processedHeaders) {
|
|
94
|
+
var headers_1 = this.processedHeaders = {};
|
|
95
|
+
this.request.getAllResponseHeaders().split(/\r?\n/g).forEach(function (header) {
|
|
96
|
+
var index = header.indexOf(":");
|
|
97
|
+
var key, val;
|
|
98
|
+
if (index > 0) {
|
|
99
|
+
key = header.substring(0, index).trim().toLowerCase();
|
|
100
|
+
val = header.substring(index + 1).trim();
|
|
101
|
+
}
|
|
102
|
+
else
|
|
103
|
+
key = header.trim().toLowerCase();
|
|
104
|
+
var list = headers_1[key];
|
|
105
|
+
if (!list)
|
|
106
|
+
list = headers_1[key] = [];
|
|
107
|
+
if (val)
|
|
108
|
+
list.push(val);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return this.processedHeaders;
|
|
112
|
+
},
|
|
113
|
+
enumerable: true,
|
|
114
|
+
configurable: true
|
|
115
|
+
});
|
|
116
|
+
return NexusFrameworkXMLHttpRequestResponse;
|
|
117
|
+
}());
|
|
118
|
+
var execute_1 = function (method, url, data, cb, extraHeaders, progcb, wantsBinary) {
|
|
119
|
+
var request = new XMLHttpRequest();
|
|
120
|
+
var responseIsArrayBuffer;
|
|
263
121
|
try {
|
|
264
|
-
|
|
122
|
+
if (!wantsBinary)
|
|
123
|
+
throw false;
|
|
124
|
+
request.responseType = "arraybuffer";
|
|
125
|
+
if (request.responseType !== "arraybuffer") {
|
|
126
|
+
console.error("Could not request arraybuffer");
|
|
127
|
+
throw false;
|
|
128
|
+
}
|
|
129
|
+
responseIsArrayBuffer = true;
|
|
265
130
|
}
|
|
266
131
|
catch (e) {
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
},
|
|
270
|
-
reportPage: function (path) {
|
|
271
|
-
if (window.ga)
|
|
272
|
-
try {
|
|
273
|
-
if (!path)
|
|
274
|
-
path = location.pathname;
|
|
275
|
-
window.ga('set', 'page', path);
|
|
276
|
-
window.ga('send', 'pageview');
|
|
132
|
+
responseIsArrayBuffer = false;
|
|
277
133
|
}
|
|
278
|
-
|
|
279
|
-
|
|
134
|
+
request.open(method, url, true);
|
|
135
|
+
if (extraHeaders)
|
|
136
|
+
Object.keys(extraHeaders).forEach(function (key) {
|
|
137
|
+
request.setRequestHeader(key, extraHeaders[key]);
|
|
138
|
+
});
|
|
139
|
+
if (progcb)
|
|
140
|
+
request.onprogress = function (ev) {
|
|
141
|
+
if (ev.lengthComputable && ev.total)
|
|
142
|
+
progcb(ev.loaded, ev.total);
|
|
143
|
+
};
|
|
144
|
+
request.onreadystatechange = function (e) {
|
|
145
|
+
if (request.readyState === XMLHttpRequest.DONE)
|
|
146
|
+
cb(new NexusFrameworkXMLHttpRequestResponse_1(request, url, !!data, responseIsArrayBuffer));
|
|
147
|
+
};
|
|
148
|
+
var type = data && data.type;
|
|
149
|
+
if (type)
|
|
150
|
+
switch (type) {
|
|
151
|
+
case "":
|
|
152
|
+
case "text/urlencoded":
|
|
153
|
+
var dat = "";
|
|
154
|
+
for (var _i = 0, _a = data.data; _i < _a.length; _i++) {
|
|
155
|
+
var entry = _a[_i];
|
|
156
|
+
if (dat)
|
|
157
|
+
dat += "&";
|
|
158
|
+
dat += encodeURIComponent(entry[0]);
|
|
159
|
+
dat += "=";
|
|
160
|
+
dat += encodeURIComponent(entry[1]);
|
|
161
|
+
}
|
|
162
|
+
request.setRequestHeader("Content-Type", "text/urlencoded");
|
|
163
|
+
request.send(dat);
|
|
164
|
+
break;
|
|
165
|
+
case "text/json":
|
|
166
|
+
request.setRequestHeader("Content-Type", "text/json");
|
|
167
|
+
request.send(JSON.stringify(data.data));
|
|
168
|
+
break;
|
|
169
|
+
case "application/bson":
|
|
170
|
+
request.setRequestHeader("Content-Type", "application/bson");
|
|
171
|
+
request.send(BSON.serialize(data.data));
|
|
172
|
+
break;
|
|
173
|
+
case "multipart/form-data":
|
|
174
|
+
request.send(data.data);
|
|
175
|
+
break;
|
|
176
|
+
default:
|
|
177
|
+
request.send(data);
|
|
178
|
+
}
|
|
179
|
+
else
|
|
180
|
+
request.send(data);
|
|
181
|
+
};
|
|
182
|
+
impl = {
|
|
183
|
+
get: function (url, cb, extraHeaders, progcb, wantsBinary) {
|
|
184
|
+
execute_1("GET", url, undefined, cb, extraHeaders, progcb, wantsBinary);
|
|
185
|
+
},
|
|
186
|
+
head: function (url, cb, extraHeaders, progcb, wantsBinary) {
|
|
187
|
+
execute_1("HEAD", url, undefined, cb, extraHeaders, progcb, wantsBinary);
|
|
188
|
+
},
|
|
189
|
+
post: function (url, data, cb, extraHeaders, progcb, wantsBinary) {
|
|
190
|
+
execute_1("POST", url, data, cb, extraHeaders, progcb, wantsBinary);
|
|
191
|
+
},
|
|
192
|
+
put: function (url, data, cb, extraHeaders, progcb, wantsBinary) {
|
|
193
|
+
execute_1("PUT", url, data, cb, extraHeaders, progcb, wantsBinary);
|
|
194
|
+
},
|
|
195
|
+
execute: execute_1,
|
|
196
|
+
del: function (url, cb, extraHeaders, progcb, wantsBinary) {
|
|
197
|
+
execute_1("DELETE", url, undefined, cb, extraHeaders, progcb, wantsBinary);
|
|
280
198
|
}
|
|
199
|
+
};
|
|
281
200
|
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if (
|
|
304
|
-
|
|
305
|
-
|
|
201
|
+
else
|
|
202
|
+
throw new Error("No transport implementations");
|
|
203
|
+
Object.defineProperty(window, "NexusFrameworkTransport", {
|
|
204
|
+
value: impl
|
|
205
|
+
});
|
|
206
|
+
return impl;
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
NexusFrameworkImpl: {
|
|
210
|
+
configurable: true,
|
|
211
|
+
set: function (instance) {
|
|
212
|
+
Object.defineProperty(window, "NexusFrameworkImpl", {
|
|
213
|
+
value: instance
|
|
214
|
+
});
|
|
215
|
+
},
|
|
216
|
+
get: function () {
|
|
217
|
+
var loader = window.NexusFrameworkLoader;
|
|
218
|
+
var showError = loader.showError;
|
|
219
|
+
var debug = /*function(...args: any[]){};*/ console.log.bind(console);
|
|
220
|
+
var GA_ANALYTICS = {
|
|
221
|
+
reportError: function (err, fatal) {
|
|
222
|
+
if (window.ga)
|
|
223
|
+
try {
|
|
224
|
+
window.ga('send', 'exception', {
|
|
225
|
+
'exDescription': (err.stack || "" + err).replace(/\n/g, "\n\t"),
|
|
226
|
+
'exFatal': fatal
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
catch (e) {
|
|
230
|
+
console.warn(e);
|
|
231
|
+
}
|
|
306
232
|
},
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
233
|
+
reportEvent: function (category, action, label, value) {
|
|
234
|
+
if (window.ga)
|
|
235
|
+
try {
|
|
236
|
+
window.ga('send', 'event', category, action, label, value);
|
|
237
|
+
}
|
|
238
|
+
catch (e) {
|
|
239
|
+
console.warn(e);
|
|
240
|
+
}
|
|
315
241
|
},
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
242
|
+
reportPage: function (path) {
|
|
243
|
+
if (window.ga)
|
|
244
|
+
try {
|
|
245
|
+
if (!path)
|
|
246
|
+
path = location.pathname;
|
|
247
|
+
window.ga('set', 'page', path);
|
|
248
|
+
window.ga('send', 'pageview');
|
|
249
|
+
}
|
|
250
|
+
catch (e) {
|
|
251
|
+
console.warn(e);
|
|
252
|
+
}
|
|
325
253
|
}
|
|
326
254
|
};
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
255
|
+
var r = document.createElement("a");
|
|
256
|
+
var protocol = location.href.match(/^\w+:/)[0];
|
|
257
|
+
var resolveUrl = function (url) {
|
|
258
|
+
r.setAttribute("href", url);
|
|
259
|
+
var href = r.href;
|
|
260
|
+
if (/^\/\//.test(href))
|
|
261
|
+
href = protocol + href;
|
|
262
|
+
return href;
|
|
263
|
+
};
|
|
264
|
+
var convertResponse = function (res, url) {
|
|
265
|
+
if (url === void 0) { url = location.href; }
|
|
266
|
+
var storage;
|
|
267
|
+
return (typeof res.data === "string") ? {
|
|
268
|
+
url: url,
|
|
269
|
+
code: res.code,
|
|
270
|
+
contentAsString: res.data,
|
|
271
|
+
get contentLength() {
|
|
272
|
+
return parseInt(res.headers['content-length'] && res.headers['content-length'][0]) || res.data.length;
|
|
273
|
+
},
|
|
274
|
+
get contentAsArrayBuffer() {
|
|
275
|
+
throw new Error("Not implemented");
|
|
276
|
+
},
|
|
277
|
+
get contentFromBSON() {
|
|
278
|
+
if (!storage)
|
|
279
|
+
storage = JSON.parse(res.data);
|
|
280
|
+
return storage;
|
|
345
281
|
},
|
|
346
|
-
|
|
347
|
-
|
|
282
|
+
get contentFromJSON() {
|
|
283
|
+
if (!storage)
|
|
284
|
+
storage = JSON.parse(res.data);
|
|
285
|
+
return storage;
|
|
286
|
+
},
|
|
287
|
+
headers: res.headers
|
|
288
|
+
} : {
|
|
289
|
+
url: url,
|
|
290
|
+
code: res.code,
|
|
291
|
+
get contentAsString() {
|
|
292
|
+
if (!storage)
|
|
293
|
+
storage = JSON.stringify(res.data);
|
|
294
|
+
return storage;
|
|
295
|
+
},
|
|
296
|
+
get contentAsArrayBuffer() {
|
|
297
|
+
throw new Error("Not implemented");
|
|
298
|
+
},
|
|
299
|
+
contentFromJSON: res.data,
|
|
300
|
+
contentFromBSON: res.data,
|
|
301
|
+
headers: res.headers,
|
|
302
|
+
get contentLength() {
|
|
303
|
+
var length = parseInt(res.headers['content-length'] && res.headers['content-length'][0]);
|
|
304
|
+
if (length)
|
|
305
|
+
return length;
|
|
306
|
+
if (!storage)
|
|
307
|
+
storage = JSON.stringify(res.data);
|
|
308
|
+
return storage.length;
|
|
348
309
|
}
|
|
349
|
-
}
|
|
350
|
-
this._analytics = GA_ANALYTICS;
|
|
351
|
-
}
|
|
352
|
-
NexusFrameworkBase.prototype.resolveUrl = function (url) {
|
|
353
|
-
if (/^\w+\:/.test(url))
|
|
354
|
-
return url;
|
|
355
|
-
return resolveUrl(this.url + url);
|
|
356
|
-
};
|
|
357
|
-
NexusFrameworkBase.prototype.disableAll = function (root) {
|
|
358
|
-
if (root === void 0) { root = document.body; }
|
|
359
|
-
var focusable = root.querySelectorAll("a, input, select, textarea, iframe, button, *[focusable], *[tabindex]");
|
|
360
|
-
for (var i = 0; i < focusable.length; i++) {
|
|
361
|
-
var child = focusable[i];
|
|
362
|
-
var tabindex = child.getAttribute("tabindex");
|
|
363
|
-
if (tabindex == "-1")
|
|
364
|
-
return;
|
|
365
|
-
child.setAttribute("data-tabindex", tabindex ? tabindex : "");
|
|
366
|
-
child.setAttribute("data-tabindex", "-1");
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
NexusFrameworkBase.prototype.enableAll = function (root) {
|
|
370
|
-
if (root === void 0) { root = document.body; }
|
|
371
|
-
var focusable = root.querySelectorAll("*[data-tabindex]");
|
|
372
|
-
for (var i = 0; i < focusable.length; i++) {
|
|
373
|
-
var child = focusable[i];
|
|
374
|
-
child.setAttribute("tabindex", child.getAttribute("data-tabindex"));
|
|
375
|
-
child.removeAttribute("data-tabindex");
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
Object.defineProperty(NexusFrameworkBase.prototype, "analytics", {
|
|
379
|
-
get: function () {
|
|
380
|
-
return this._analytics;
|
|
381
|
-
},
|
|
382
|
-
set: function (value) {
|
|
383
|
-
this._analytics = value ? value : GA_ANALYTICS;
|
|
384
|
-
},
|
|
385
|
-
enumerable: true,
|
|
386
|
-
configurable: true
|
|
387
|
-
});
|
|
388
|
-
NexusFrameworkBase.prototype.reportError = function (err, fatal) {
|
|
389
|
-
console[fatal ? "error" : "warn"](err.stack);
|
|
390
|
-
if (this.errorreporter)
|
|
391
|
-
this.errorreporter(err, fatal);
|
|
392
|
-
};
|
|
393
|
-
NexusFrameworkBase.prototype.installErrorReporter = function (errorreporter) {
|
|
394
|
-
this.errorreporter = errorreporter;
|
|
310
|
+
};
|
|
395
311
|
};
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
this.
|
|
401
|
-
this.
|
|
312
|
+
var loaderContainerRegex = /(^|\s)loader\-(progress|error)\-container(\s|$)/;
|
|
313
|
+
var NexusFrameworkBase = /** @class */ (function () {
|
|
314
|
+
function NexusFrameworkBase(url, io) {
|
|
315
|
+
if (url === void 0) { url = "/"; }
|
|
316
|
+
this.activerid = 0;
|
|
317
|
+
this.components = {};
|
|
318
|
+
this.currentUserID = undefined;
|
|
319
|
+
this.progressVisible = false;
|
|
320
|
+
this.animationTiming = 500;
|
|
321
|
+
this.requestPage = this.defaultRequestPage;
|
|
322
|
+
this._listeners = {};
|
|
323
|
+
url = resolveUrl(url);
|
|
324
|
+
if (!/\/$/.test(url))
|
|
325
|
+
url += "/";
|
|
326
|
+
Object.defineProperties(this, {
|
|
327
|
+
io: {
|
|
328
|
+
value: io
|
|
329
|
+
},
|
|
330
|
+
url: {
|
|
331
|
+
value: url
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
this._analytics = GA_ANALYTICS;
|
|
402
335
|
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
336
|
+
NexusFrameworkBase.prototype.resolveUrl = function (url) {
|
|
337
|
+
if (/^\w+\:/.test(url))
|
|
338
|
+
return url;
|
|
339
|
+
return resolveUrl(this.url + url);
|
|
340
|
+
};
|
|
341
|
+
NexusFrameworkBase.prototype.disableAll = function (root) {
|
|
342
|
+
if (root === void 0) { root = document.body; }
|
|
343
|
+
var focusable = root.querySelectorAll("a, input, select, textarea, iframe, button, *[focusable], *[tabindex]");
|
|
344
|
+
for (var i = 0; i < focusable.length; i++) {
|
|
345
|
+
var child = focusable[i];
|
|
346
|
+
var tabindex = child.getAttribute("tabindex");
|
|
347
|
+
if (tabindex == "-1")
|
|
348
|
+
return;
|
|
349
|
+
child.setAttribute("data-tabindex", tabindex ? tabindex : "");
|
|
350
|
+
child.setAttribute("data-tabindex", "-1");
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
NexusFrameworkBase.prototype.enableAll = function (root) {
|
|
354
|
+
if (root === void 0) { root = document.body; }
|
|
355
|
+
var focusable = root.querySelectorAll("*[data-tabindex]");
|
|
356
|
+
for (var i = 0; i < focusable.length; i++) {
|
|
357
|
+
var child = focusable[i];
|
|
358
|
+
child.setAttribute("tabindex", child.getAttribute("data-tabindex"));
|
|
359
|
+
child.removeAttribute("data-tabindex");
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
Object.defineProperty(NexusFrameworkBase.prototype, "analytics", {
|
|
363
|
+
get: function () {
|
|
364
|
+
return this._analytics;
|
|
365
|
+
},
|
|
366
|
+
set: function (value) {
|
|
367
|
+
this._analytics = value ? value : GA_ANALYTICS;
|
|
368
|
+
},
|
|
369
|
+
enumerable: true,
|
|
370
|
+
configurable: true
|
|
371
|
+
});
|
|
372
|
+
NexusFrameworkBase.prototype.reportError = function (err, fatal) {
|
|
373
|
+
console[fatal ? "error" : "warn"](err.stack);
|
|
374
|
+
if (this.errorreporter)
|
|
375
|
+
this.errorreporter(err, fatal);
|
|
376
|
+
};
|
|
377
|
+
NexusFrameworkBase.prototype.installErrorReporter = function (errorreporter) {
|
|
378
|
+
this.errorreporter = errorreporter;
|
|
379
|
+
};
|
|
380
|
+
NexusFrameworkBase.prototype.registerComponent = function (selector, impl) {
|
|
381
|
+
var _this = this;
|
|
382
|
+
if (impl) {
|
|
383
|
+
this.components[selector] = impl;
|
|
384
|
+
this.createComponents(document.head);
|
|
385
|
+
this.createComponents(document.body);
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
delete this.components[selector];
|
|
389
|
+
var destroy = function (root) {
|
|
390
|
+
var elements = root.querySelectorAll(selector);
|
|
391
|
+
if (!elements.length)
|
|
392
|
+
return;
|
|
393
|
+
for (var i = 0; i < elements.length; i++) {
|
|
394
|
+
var element = elements[i];
|
|
395
|
+
var components = element['__nf_cmapping__'];
|
|
396
|
+
if (!components)
|
|
397
|
+
components = element['__nf_cmapping__'] = {};
|
|
398
|
+
var component = components[selector];
|
|
399
|
+
if (component) {
|
|
400
|
+
try {
|
|
401
|
+
component.destroy();
|
|
402
|
+
}
|
|
403
|
+
catch (e) {
|
|
404
|
+
_this.reportError(e);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
destroy(document.head);
|
|
410
|
+
destroy(document.body);
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
NexusFrameworkBase.prototype.unregisterComponent = function (selector, impl) {
|
|
414
|
+
};
|
|
415
|
+
NexusFrameworkBase.prototype.createComponents = function (root) {
|
|
416
|
+
var _this = this;
|
|
417
|
+
Object.keys(this.components).forEach(function (selector) {
|
|
418
|
+
var elements = root.querySelectorAll(selector);
|
|
419
|
+
if (!elements.length)
|
|
420
|
+
return;
|
|
421
|
+
for (var i = 0; i < elements.length; i++) {
|
|
422
|
+
var element = elements[i];
|
|
423
|
+
var components = element['__nf_cmapping__'];
|
|
424
|
+
if (!components)
|
|
425
|
+
components = element['__nf_cmapping__'] = {};
|
|
426
|
+
if (components[selector])
|
|
427
|
+
continue;
|
|
428
|
+
var componentFactory = _this.components[selector];
|
|
429
|
+
try {
|
|
430
|
+
(components[selector] = new componentFactory()).create(element);
|
|
431
|
+
}
|
|
432
|
+
catch (e) {
|
|
433
|
+
_this.reportError(e);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
};
|
|
438
|
+
NexusFrameworkBase.prototype.destroyComponents = function (root) {
|
|
439
|
+
var _this = this;
|
|
440
|
+
Object.keys(this.components).forEach(function (selector) {
|
|
406
441
|
var elements = root.querySelectorAll(selector);
|
|
407
442
|
if (!elements.length)
|
|
408
443
|
return;
|
|
@@ -421,816 +456,770 @@ Object.defineProperties(window, {
|
|
|
421
456
|
}
|
|
422
457
|
}
|
|
423
458
|
}
|
|
424
|
-
};
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
var _this = this;
|
|
456
|
-
Object.keys(this.components).forEach(function (selector) {
|
|
457
|
-
var elements = root.querySelectorAll(selector);
|
|
458
|
-
if (!elements.length)
|
|
459
|
-
return;
|
|
460
|
-
for (var i = 0; i < elements.length; i++) {
|
|
461
|
-
var element = elements[i];
|
|
462
|
-
var components = element['__nf_cmapping__'];
|
|
463
|
-
if (!components)
|
|
464
|
-
components = element['__nf_cmapping__'] = {};
|
|
465
|
-
var component = components[selector];
|
|
466
|
-
if (component) {
|
|
467
|
-
try {
|
|
468
|
-
component.destroy();
|
|
469
|
-
}
|
|
470
|
-
catch (e) {
|
|
471
|
-
_this.reportError(e);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
});
|
|
476
|
-
};
|
|
477
|
-
NexusFrameworkBase.prototype.restoreComponents = function (root, state) {
|
|
478
|
-
var _this = this;
|
|
479
|
-
Object.keys(this.components).forEach(function (selector) {
|
|
480
|
-
var states = state[selector];
|
|
481
|
-
if (!states)
|
|
482
|
-
return;
|
|
483
|
-
var elements = root.querySelectorAll(selector);
|
|
484
|
-
if (!elements.length)
|
|
485
|
-
return;
|
|
486
|
-
for (var i = 0; i < elements.length; i++) {
|
|
487
|
-
var element = elements[i];
|
|
488
|
-
if (states.length) {
|
|
489
|
-
var _state = states.shift();
|
|
490
|
-
if (_state) {
|
|
491
|
-
var components = element['__nf_cmapping__'];
|
|
492
|
-
if (!components)
|
|
493
|
-
components = element['__nf_cmapping__'] = {};
|
|
494
|
-
var component = components[selector];
|
|
495
|
-
if (!component) {
|
|
496
|
-
var componentFactory = _this.components[selector];
|
|
459
|
+
});
|
|
460
|
+
};
|
|
461
|
+
NexusFrameworkBase.prototype.restoreComponents = function (root, state) {
|
|
462
|
+
var _this = this;
|
|
463
|
+
Object.keys(this.components).forEach(function (selector) {
|
|
464
|
+
var states = state[selector];
|
|
465
|
+
if (!states)
|
|
466
|
+
return;
|
|
467
|
+
var elements = root.querySelectorAll(selector);
|
|
468
|
+
if (!elements.length)
|
|
469
|
+
return;
|
|
470
|
+
for (var i = 0; i < elements.length; i++) {
|
|
471
|
+
var element = elements[i];
|
|
472
|
+
if (states.length) {
|
|
473
|
+
var _state = states.shift();
|
|
474
|
+
if (_state) {
|
|
475
|
+
var components = element['__nf_cmapping__'];
|
|
476
|
+
if (!components)
|
|
477
|
+
components = element['__nf_cmapping__'] = {};
|
|
478
|
+
var component = components[selector];
|
|
479
|
+
if (!component) {
|
|
480
|
+
var componentFactory = _this.components[selector];
|
|
481
|
+
try {
|
|
482
|
+
(component = components[selector] = new componentFactory()).create(element);
|
|
483
|
+
}
|
|
484
|
+
catch (e) {
|
|
485
|
+
_this.reportError(e);
|
|
486
|
+
console.warn(e);
|
|
487
|
+
continue;
|
|
488
|
+
}
|
|
489
|
+
}
|
|
497
490
|
try {
|
|
498
|
-
|
|
491
|
+
component.restore(_state);
|
|
499
492
|
}
|
|
500
493
|
catch (e) {
|
|
501
494
|
_this.reportError(e);
|
|
502
495
|
console.warn(e);
|
|
503
|
-
continue;
|
|
504
496
|
}
|
|
505
497
|
}
|
|
498
|
+
}
|
|
499
|
+
else
|
|
500
|
+
break;
|
|
501
|
+
}
|
|
502
|
+
});
|
|
503
|
+
};
|
|
504
|
+
NexusFrameworkBase.prototype.saveComponents = function (root) {
|
|
505
|
+
var _this = this;
|
|
506
|
+
var state = {};
|
|
507
|
+
Object.keys(this.components).forEach(function (selector) {
|
|
508
|
+
var states = state[selector] = [];
|
|
509
|
+
var elements = root.querySelectorAll(selector);
|
|
510
|
+
if (!elements.length)
|
|
511
|
+
return;
|
|
512
|
+
for (var i = 0; i < elements.length; i++) {
|
|
513
|
+
var element = elements[i];
|
|
514
|
+
var components = element['__nf_cmapping__'];
|
|
515
|
+
if (!components)
|
|
516
|
+
components = element['__nf_cmapping__'] = {};
|
|
517
|
+
var component = components[selector];
|
|
518
|
+
if (!component) {
|
|
519
|
+
var componentFactory = _this.components[selector];
|
|
506
520
|
try {
|
|
507
|
-
component.
|
|
521
|
+
(component = components[selector] = new componentFactory).create(element);
|
|
508
522
|
}
|
|
509
523
|
catch (e) {
|
|
524
|
+
states.push(undefined);
|
|
510
525
|
_this.reportError(e);
|
|
511
526
|
console.warn(e);
|
|
527
|
+
continue;
|
|
512
528
|
}
|
|
513
529
|
}
|
|
514
|
-
}
|
|
515
|
-
else
|
|
516
|
-
break;
|
|
517
|
-
}
|
|
518
|
-
});
|
|
519
|
-
};
|
|
520
|
-
NexusFrameworkBase.prototype.saveComponents = function (root) {
|
|
521
|
-
var _this = this;
|
|
522
|
-
var state = {};
|
|
523
|
-
Object.keys(this.components).forEach(function (selector) {
|
|
524
|
-
var states = state[selector] = [];
|
|
525
|
-
var elements = root.querySelectorAll(selector);
|
|
526
|
-
if (!elements.length)
|
|
527
|
-
return;
|
|
528
|
-
for (var i = 0; i < elements.length; i++) {
|
|
529
|
-
var element = elements[i];
|
|
530
|
-
var components = element['__nf_cmapping__'];
|
|
531
|
-
if (!components)
|
|
532
|
-
components = element['__nf_cmapping__'] = {};
|
|
533
|
-
var component = components[selector];
|
|
534
|
-
if (!component) {
|
|
535
|
-
var componentFactory = _this.components[selector];
|
|
536
530
|
try {
|
|
537
|
-
(component
|
|
531
|
+
states.push(component.save());
|
|
538
532
|
}
|
|
539
533
|
catch (e) {
|
|
540
534
|
states.push(undefined);
|
|
541
535
|
_this.reportError(e);
|
|
542
536
|
console.warn(e);
|
|
543
|
-
continue;
|
|
544
537
|
}
|
|
545
538
|
}
|
|
539
|
+
});
|
|
540
|
+
return state;
|
|
541
|
+
};
|
|
542
|
+
NexusFrameworkBase.prototype.initPageSystem = function (opts) {
|
|
543
|
+
var _this = this;
|
|
544
|
+
if (!loader)
|
|
545
|
+
return console.error("The NexusFramework Loader is required for the dynamic Page System to work correctly.");
|
|
546
|
+
if (!history.pushState || !history.replaceState)
|
|
547
|
+
return console.warn("This browser is missing an essential feature required for the dynamic Page System.");
|
|
548
|
+
if (this.pagesyshandler)
|
|
549
|
+
return console.warn("Page System already initialized, ignoring additional requests to initialize.");
|
|
550
|
+
opts = opts || {};
|
|
551
|
+
var self = this;
|
|
552
|
+
var pageStatesSize = 0;
|
|
553
|
+
var pageStates = [];
|
|
554
|
+
this.animationTiming = opts.animationTiming || 500;
|
|
555
|
+
var pageStateCacheSize = opts.pageHistoryCacheSize || 25000000;
|
|
556
|
+
var wrapCB = function (cb) {
|
|
557
|
+
return function (res) {
|
|
558
|
+
var user = res.headers['x-logged-user'];
|
|
559
|
+
if (user)
|
|
560
|
+
self.currentUserID = user[0];
|
|
561
|
+
else
|
|
562
|
+
self.currentUserID = undefined;
|
|
563
|
+
debug("Current UID", self.currentUserID);
|
|
564
|
+
cb(res);
|
|
565
|
+
if (res.code === 200)
|
|
566
|
+
setTimeout(function () {
|
|
567
|
+
self._analytics.reportPage();
|
|
568
|
+
});
|
|
569
|
+
};
|
|
570
|
+
};
|
|
571
|
+
loader.showError = function (error) {
|
|
572
|
+
var match = location.href.match(beforeHash);
|
|
573
|
+
var baseurl = match && match[1] || location.href;
|
|
574
|
+
var length = error.stack.length;
|
|
575
|
+
var tooBig = pageStateCacheSize <= length;
|
|
546
576
|
try {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
return console.error("The NexusFramework Loader is required for the dynamic Page System to work correctly.");
|
|
562
|
-
if (!history.pushState || !history.replaceState)
|
|
563
|
-
return console.warn("This browser is missing an essential feature required for the dynamic Page System.");
|
|
564
|
-
if (this.pagesyshandler)
|
|
565
|
-
return console.warn("Page System already initialized, ignoring additional requests to initialize.");
|
|
566
|
-
opts = opts || {};
|
|
567
|
-
var self = this;
|
|
568
|
-
var pageStatesSize = 0;
|
|
569
|
-
var pageStates = [];
|
|
570
|
-
this.animationTiming = opts.animationTiming || 500;
|
|
571
|
-
var pageStateCacheSize = opts.pageHistoryCacheSize || 25000000;
|
|
572
|
-
var wrapCB = function (cb) {
|
|
573
|
-
return function (res) {
|
|
574
|
-
var user = res.headers['x-logged-user'];
|
|
575
|
-
if (user)
|
|
576
|
-
self.currentUserID = user[0];
|
|
577
|
-
else
|
|
578
|
-
self.currentUserID = undefined;
|
|
579
|
-
debug("Current UID", self.currentUserID);
|
|
580
|
-
cb(res);
|
|
581
|
-
if (res.code === 200)
|
|
582
|
-
setTimeout(function () {
|
|
583
|
-
self._analytics.reportPage();
|
|
584
|
-
});
|
|
585
|
-
};
|
|
586
|
-
};
|
|
587
|
-
loader.showError = function (error) {
|
|
588
|
-
var match = location.href.match(beforeHash);
|
|
589
|
-
var baseurl = match && match[1] || location.href;
|
|
590
|
-
var length = error.stack.length;
|
|
591
|
-
var tooBig = pageStateCacheSize <= length;
|
|
592
|
-
try {
|
|
593
|
-
var cPageStates = pageStates.length;
|
|
594
|
-
for (var i = 0; i < cPageStates; i++) {
|
|
595
|
-
var state = pageStates[i];
|
|
596
|
-
if (state.url === baseurl) {
|
|
597
|
-
if (tooBig) {
|
|
598
|
-
pageStates.splice(i, 1);
|
|
599
|
-
pageStatesSize -= state.size;
|
|
600
|
-
}
|
|
601
|
-
else {
|
|
602
|
-
state.data = { error: error };
|
|
603
|
-
state.updated = +new Date;
|
|
604
|
-
pageStatesSize += length - state.size;
|
|
577
|
+
var cPageStates = pageStates.length;
|
|
578
|
+
for (var i = 0; i < cPageStates; i++) {
|
|
579
|
+
var state = pageStates[i];
|
|
580
|
+
if (state.url === baseurl) {
|
|
581
|
+
if (tooBig) {
|
|
582
|
+
pageStates.splice(i, 1);
|
|
583
|
+
pageStatesSize -= state.size;
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
state.data = { error: error };
|
|
587
|
+
state.updated = +new Date;
|
|
588
|
+
pageStatesSize += length - state.size;
|
|
589
|
+
}
|
|
590
|
+
throw true;
|
|
605
591
|
}
|
|
606
|
-
throw true;
|
|
607
592
|
}
|
|
593
|
+
if (tooBig)
|
|
594
|
+
throw true;
|
|
595
|
+
pageStates.push({
|
|
596
|
+
url: baseurl,
|
|
597
|
+
data: { error: error },
|
|
598
|
+
updated: +new Date,
|
|
599
|
+
size: length
|
|
600
|
+
});
|
|
601
|
+
pageStatesSize += length;
|
|
608
602
|
}
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
url: baseurl,
|
|
613
|
-
data: { error: error },
|
|
614
|
-
updated: +new Date,
|
|
615
|
-
size: length
|
|
616
|
-
});
|
|
617
|
-
pageStatesSize += length;
|
|
618
|
-
}
|
|
619
|
-
catch (e) {
|
|
620
|
-
if (e !== true)
|
|
621
|
-
throw e;
|
|
622
|
-
}
|
|
623
|
-
return showError(error);
|
|
624
|
-
};
|
|
625
|
-
var transportPageSystem = {
|
|
626
|
-
requestPage: function (path, cb, post, rid) {
|
|
627
|
-
if (self.pagesysprerequest && !self.pagesysprerequest(path)) {
|
|
628
|
-
self.defaultRequestPage(path, post);
|
|
629
|
-
return;
|
|
630
|
-
}
|
|
631
|
-
if (!opts.noprogress) {
|
|
632
|
-
self.disableAll();
|
|
633
|
-
loader.showProgress();
|
|
603
|
+
catch (e) {
|
|
604
|
+
if (e !== true)
|
|
605
|
+
throw e;
|
|
634
606
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
cb(res);
|
|
639
|
-
else
|
|
640
|
-
loader.showProgress(function () {
|
|
641
|
-
cb(res);
|
|
642
|
-
self.enableAll();
|
|
643
|
-
});
|
|
644
|
-
};
|
|
645
|
-
if (post)
|
|
646
|
-
window.NexusFrameworkTransport.post(url, post, wrapCB(_cb));
|
|
647
|
-
else
|
|
648
|
-
window.NexusFrameworkTransport.get(url, wrapCB(_cb));
|
|
649
|
-
}
|
|
650
|
-
};
|
|
651
|
-
if (!opts.noio && !opts.nopagesysio && this.io) {
|
|
652
|
-
var io_1 = this.io;
|
|
653
|
-
this.pagesysimpl = {
|
|
607
|
+
return showError(error);
|
|
608
|
+
};
|
|
609
|
+
var transportPageSystem = {
|
|
654
610
|
requestPage: function (path, cb, post, rid) {
|
|
655
|
-
if (
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
return;
|
|
659
|
-
}
|
|
660
|
-
if (!opts.noprogress) {
|
|
661
|
-
self.disableAll();
|
|
662
|
-
loader.showProgress();
|
|
663
|
-
}
|
|
664
|
-
var headers = {
|
|
665
|
-
"referrer": location.href
|
|
666
|
-
};
|
|
667
|
-
var val = document.cookie;
|
|
668
|
-
if (val)
|
|
669
|
-
headers['cookie'] = val;
|
|
670
|
-
io_1.emit("page", post ? "POST" : "GET", path, post, headers, function (res) {
|
|
671
|
-
if (rid != self.activerid)
|
|
672
|
-
return;
|
|
673
|
-
var cookies = res.headers['set-cookie'];
|
|
674
|
-
if (cookies) {
|
|
675
|
-
cookies.forEach(function (cookie) {
|
|
676
|
-
document.cookie = cookie;
|
|
677
|
-
});
|
|
678
|
-
}
|
|
679
|
-
var _cb = opts.noprogress ? cb : function (res) {
|
|
680
|
-
if (!opts.noprogress)
|
|
681
|
-
cb(res);
|
|
682
|
-
else
|
|
683
|
-
loader.showProgress(function () {
|
|
684
|
-
cb(res);
|
|
685
|
-
self.enableAll();
|
|
686
|
-
});
|
|
687
|
-
};
|
|
688
|
-
wrapCB(_cb)(convertResponse(res, self.resolveUrl(path)));
|
|
689
|
-
});
|
|
611
|
+
if (self.pagesysprerequest && !self.pagesysprerequest(path)) {
|
|
612
|
+
self.defaultRequestPage(path, post);
|
|
613
|
+
return;
|
|
690
614
|
}
|
|
615
|
+
if (!opts.noprogress) {
|
|
616
|
+
self.disableAll();
|
|
617
|
+
loader.showProgress();
|
|
618
|
+
}
|
|
619
|
+
var url = self.resolveUrl(":pagesys/" + path);
|
|
620
|
+
var _cb = opts.noprogress ? cb : function (res) {
|
|
621
|
+
if (opts.noprogress)
|
|
622
|
+
cb(res);
|
|
623
|
+
else
|
|
624
|
+
loader.showProgress(function () {
|
|
625
|
+
cb(res);
|
|
626
|
+
self.enableAll();
|
|
627
|
+
});
|
|
628
|
+
};
|
|
629
|
+
if (post)
|
|
630
|
+
window.NexusFrameworkTransport.post(url, post, wrapCB(_cb), undefined, undefined, true);
|
|
691
631
|
else
|
|
692
|
-
|
|
632
|
+
window.NexusFrameworkTransport.get(url, wrapCB(_cb), undefined, undefined, true);
|
|
693
633
|
}
|
|
694
634
|
};
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
635
|
+
if (!opts.noio && this.io) {
|
|
636
|
+
var io_1 = this.io;
|
|
637
|
+
this.pagesysimpl = {
|
|
638
|
+
requestPage: function (path, cb, post, rid) {
|
|
639
|
+
if (io_1.connected) {
|
|
640
|
+
if (self.pagesysprerequest && !self.pagesysprerequest(path)) {
|
|
641
|
+
self.defaultRequestPage(path, post);
|
|
642
|
+
return;
|
|
643
|
+
}
|
|
644
|
+
if (!opts.noprogress) {
|
|
645
|
+
self.disableAll();
|
|
646
|
+
loader.showProgress();
|
|
647
|
+
}
|
|
648
|
+
var headers = {
|
|
649
|
+
"referrer": location.href
|
|
650
|
+
};
|
|
651
|
+
var val = document.cookie;
|
|
652
|
+
if (val)
|
|
653
|
+
headers['cookie'] = val;
|
|
654
|
+
io_1.emit("page", post ? "POST" : "GET", path, post, headers, function (res) {
|
|
655
|
+
if (rid != self.activerid)
|
|
656
|
+
return;
|
|
657
|
+
var cookies = res.headers['set-cookie'];
|
|
658
|
+
if (cookies) {
|
|
659
|
+
cookies.forEach(function (cookie) {
|
|
660
|
+
document.cookie = cookie;
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
var _cb = opts.noprogress ? cb : function (res) {
|
|
664
|
+
if (!opts.noprogress)
|
|
665
|
+
cb(res);
|
|
666
|
+
else
|
|
667
|
+
loader.showProgress(function () {
|
|
668
|
+
cb(res);
|
|
669
|
+
self.enableAll();
|
|
670
|
+
});
|
|
671
|
+
};
|
|
672
|
+
wrapCB(_cb)(convertResponse(res, self.resolveUrl(path)));
|
|
673
|
+
});
|
|
674
|
+
}
|
|
675
|
+
else
|
|
676
|
+
transportPageSystem.requestPage(path, cb, post, rid);
|
|
677
|
+
}
|
|
678
|
+
};
|
|
707
679
|
}
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
var
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
680
|
+
else
|
|
681
|
+
this.pagesysimpl = transportPageSystem;
|
|
682
|
+
var base = document.getElementsByTagName("base");
|
|
683
|
+
base = base && base[0];
|
|
684
|
+
this.pagesysprerequest = opts.prerequest;
|
|
685
|
+
this.pagesyshandler = opts.handler || (function (res, pageReady) {
|
|
686
|
+
try {
|
|
687
|
+
var contentType = res.headers['content-type'][0];
|
|
688
|
+
if (!/\/html(;.+)?$/.test(contentType.toLowerCase())) {
|
|
689
|
+
throw new Error("Content type is not html");
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
catch (e) { }
|
|
693
|
+
var content = res.contentAsString;
|
|
694
|
+
var bodyindex = content.indexOf("<body");
|
|
695
|
+
if (bodyindex == -1)
|
|
696
|
+
throw new Error("Could not find start of body tag");
|
|
697
|
+
var endbodyindex = content.indexOf("</body>") || content.indexOf("</ body>");
|
|
698
|
+
if (endbodyindex == -1)
|
|
699
|
+
throw new Error("Could not find end of body tag");
|
|
700
|
+
var title = content.match(/<title>([^<]+)<\/\s*title>/);
|
|
701
|
+
document.title = title && title[1] || "Title Not Set";
|
|
702
|
+
var mockhtml = document.createElement("html");
|
|
703
|
+
mockhtml.innerHTML = content.substring(bodyindex, endbodyindex) + "</body>";
|
|
704
|
+
var loaderScript;
|
|
705
|
+
var childs = mockhtml.children;
|
|
706
|
+
var toAdd = [];
|
|
707
|
+
for (var i = 0; i < childs.length; i++) {
|
|
708
|
+
var child = childs[i];
|
|
709
|
+
switch (child.nodeName.toUpperCase()) {
|
|
710
|
+
case "HEAD":
|
|
711
|
+
break;
|
|
712
|
+
case "BODY":
|
|
713
|
+
i = -1;
|
|
714
|
+
childs = child.children;
|
|
715
|
+
break;
|
|
716
|
+
case "SCRIPT":
|
|
717
|
+
var match = child.innerHTML.match(/^NexusFrameworkLoader\.load\((.+)\);?$/);
|
|
718
|
+
if (match)
|
|
719
|
+
loaderScript = JSON.parse(match[1]);
|
|
739
720
|
break;
|
|
740
|
-
|
|
721
|
+
default:
|
|
722
|
+
if (loaderContainerRegex.test(child.className))
|
|
723
|
+
break;
|
|
724
|
+
toAdd.push(child);
|
|
725
|
+
}
|
|
741
726
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
case "SCRIPT":
|
|
753
|
-
break;
|
|
754
|
-
default:
|
|
755
|
-
if (loaderContainerRegex.test(child.className))
|
|
727
|
+
if (!toAdd.length)
|
|
728
|
+
throw new Error("Nothing found in response to add to page");
|
|
729
|
+
if (!loaderScript)
|
|
730
|
+
throw new Error("NexusFrameworkLoader script not found...");
|
|
731
|
+
childs = document.body.children;
|
|
732
|
+
for (var i = childs.length - 1; i >= 0; i--) {
|
|
733
|
+
var child = childs[i];
|
|
734
|
+
switch (child.nodeName.toUpperCase()) {
|
|
735
|
+
case "LINK":
|
|
736
|
+
case "SCRIPT":
|
|
756
737
|
break;
|
|
757
|
-
|
|
738
|
+
default:
|
|
739
|
+
if (loaderContainerRegex.test(child.className))
|
|
740
|
+
break;
|
|
741
|
+
document.body.removeChild(child);
|
|
742
|
+
}
|
|
758
743
|
}
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
744
|
+
var fragment = document.createDocumentFragment();
|
|
745
|
+
toAdd.forEach(function (el) {
|
|
746
|
+
fragment.appendChild(el);
|
|
747
|
+
_this.createComponents(el);
|
|
748
|
+
});
|
|
749
|
+
document.body.appendChild(fragment);
|
|
750
|
+
loader.load(loaderScript, function () {
|
|
751
|
+
self.progressVisible = true;
|
|
752
|
+
loader.resetProgress();
|
|
753
|
+
pageReady();
|
|
754
|
+
});
|
|
755
|
+
return true;
|
|
770
756
|
});
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
return;
|
|
790
|
-
if (startsWith.test(url))
|
|
791
|
-
try {
|
|
792
|
-
var match = url.match(/^(.+)#.*$/);
|
|
793
|
-
if (match)
|
|
794
|
-
url = match[1];
|
|
795
|
-
self.requestPage(url.substring(self.url.length));
|
|
757
|
+
var forwardPopState;
|
|
758
|
+
var beforeHash = /^([^#]+)(#.*)?$/;
|
|
759
|
+
var chash = location.href.match(beforeHash)[1];
|
|
760
|
+
var startsWith = new RegExp("^" + this.url.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "(.*)$", "i");
|
|
761
|
+
var AnchorElementComponent = /** @class */ (function () {
|
|
762
|
+
function AnchorElementComponent() {
|
|
763
|
+
var _this = this;
|
|
764
|
+
this.handler = function (e) {
|
|
765
|
+
if (_this.element.hasAttribute("data-nopagesys") || _this.element.hasAttribute("data-nodynamic"))
|
|
766
|
+
return;
|
|
767
|
+
var href = _this.element.getAttribute("href");
|
|
768
|
+
if (!href || !href.length)
|
|
769
|
+
return;
|
|
770
|
+
var url = _this.element.href;
|
|
771
|
+
var bhash = url.match(beforeHash);
|
|
772
|
+
if (bhash[2] && chash === bhash[1])
|
|
773
|
+
return;
|
|
774
|
+
if (startsWith.test(url))
|
|
796
775
|
try {
|
|
797
|
-
|
|
776
|
+
var match = url.match(/^(.+)#.*$/);
|
|
777
|
+
if (match)
|
|
778
|
+
url = match[1];
|
|
779
|
+
self.requestPage(url.substring(self.url.length));
|
|
780
|
+
try {
|
|
781
|
+
e.stopPropagation();
|
|
782
|
+
}
|
|
783
|
+
catch (e) { }
|
|
784
|
+
try {
|
|
785
|
+
e.preventDefault();
|
|
786
|
+
}
|
|
787
|
+
catch (e) { }
|
|
798
788
|
}
|
|
799
|
-
catch (e) {
|
|
800
|
-
|
|
801
|
-
e.preventDefault();
|
|
789
|
+
catch (e) {
|
|
790
|
+
console.warn(e);
|
|
802
791
|
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
792
|
+
else
|
|
793
|
+
debug("Navigating", url);
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
AnchorElementComponent.prototype.create = function (element) {
|
|
797
|
+
element.addEventListener("click", this.handler);
|
|
798
|
+
this.element = element;
|
|
810
799
|
};
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
var method = _this.element.getAttribute("method") || "get";
|
|
830
|
-
var enctype = _this.element.getAttribute("enctype") || "text/urlencoded";
|
|
831
|
-
var action = _this.element.getAttribute("action") || "";
|
|
832
|
-
var url = resolveUrl(action);
|
|
833
|
-
if (startsWith.test(url)) {
|
|
834
|
-
try {
|
|
835
|
-
var match = url.match(/^(.+)#.*$/);
|
|
836
|
-
if (match)
|
|
837
|
-
url = match[1];
|
|
838
|
-
var formData = new FormData(_this.element);
|
|
839
|
-
loader.showProgress(undefined, "Submitting Form", "Your form data is being processed");
|
|
840
|
-
if (method.trim().toLowerCase() === "post")
|
|
841
|
-
self.requestPage(url.substring(self.url.length), { type: enctype, data: formData });
|
|
842
|
-
else {
|
|
843
|
-
var first = true;
|
|
844
|
-
var reqUrl = url.substring(self.url.length) + "?";
|
|
845
|
-
for (var _i = 0, _a = formData; _i < _a.length; _i++) {
|
|
846
|
-
var entry = _a[_i];
|
|
847
|
-
if (first)
|
|
848
|
-
first = false;
|
|
849
|
-
else
|
|
850
|
-
reqUrl += "&";
|
|
851
|
-
reqUrl += encodeURIComponent(entry[0]);
|
|
852
|
-
reqUrl += "=";
|
|
853
|
-
reqUrl += encodeURIComponent(entry[1]);
|
|
854
|
-
}
|
|
855
|
-
self.requestPage(reqUrl);
|
|
856
|
-
}
|
|
800
|
+
AnchorElementComponent.prototype.destroy = function () {
|
|
801
|
+
this.element.removeEventListener("click", this.handler);
|
|
802
|
+
};
|
|
803
|
+
AnchorElementComponent.prototype.restore = function (data) { };
|
|
804
|
+
AnchorElementComponent.prototype.save = function () { };
|
|
805
|
+
return AnchorElementComponent;
|
|
806
|
+
}());
|
|
807
|
+
var FormElementComponent = /** @class */ (function () {
|
|
808
|
+
function FormElementComponent() {
|
|
809
|
+
var _this = this;
|
|
810
|
+
this.handler = function (e) {
|
|
811
|
+
if (_this.element.hasAttribute("data-nopagesys") || _this.element.hasAttribute("data-nodynamic"))
|
|
812
|
+
return;
|
|
813
|
+
var method = _this.element.getAttribute("method") || "get";
|
|
814
|
+
var enctype = _this.element.getAttribute("enctype") || "text/urlencoded";
|
|
815
|
+
var action = _this.element.getAttribute("action") || "";
|
|
816
|
+
var url = resolveUrl(action);
|
|
817
|
+
if (startsWith.test(url)) {
|
|
857
818
|
try {
|
|
858
|
-
|
|
819
|
+
var match = url.match(/^(.+)#.*$/);
|
|
820
|
+
if (match)
|
|
821
|
+
url = match[1];
|
|
822
|
+
var formData = new FormData(_this.element);
|
|
823
|
+
loader.showProgress(undefined, "Submitting Form", "Your form data is being processed");
|
|
824
|
+
if (method.trim().toLowerCase() === "post")
|
|
825
|
+
self.requestPage(url.substring(self.url.length), { type: enctype, data: formData });
|
|
826
|
+
else {
|
|
827
|
+
var first = true;
|
|
828
|
+
var reqUrl = url.substring(self.url.length) + "?";
|
|
829
|
+
for (var _i = 0, _a = formData; _i < _a.length; _i++) {
|
|
830
|
+
var entry = _a[_i];
|
|
831
|
+
if (first)
|
|
832
|
+
first = false;
|
|
833
|
+
else
|
|
834
|
+
reqUrl += "&";
|
|
835
|
+
reqUrl += encodeURIComponent(entry[0]);
|
|
836
|
+
reqUrl += "=";
|
|
837
|
+
reqUrl += encodeURIComponent(entry[1]);
|
|
838
|
+
}
|
|
839
|
+
self.requestPage(reqUrl);
|
|
840
|
+
}
|
|
841
|
+
try {
|
|
842
|
+
e.stopPropagation();
|
|
843
|
+
}
|
|
844
|
+
catch (e) { }
|
|
845
|
+
try {
|
|
846
|
+
e.preventDefault();
|
|
847
|
+
}
|
|
848
|
+
catch (e) { }
|
|
849
|
+
Array.prototype.forEach.call(_this.element.querySelectorAll("a, input, select, textarea, iframe, button, *[name]"), function (el) {
|
|
850
|
+
el.setAttribute("disabled", "disabled");
|
|
851
|
+
el.className += " disabled";
|
|
852
|
+
});
|
|
853
|
+
Array.prototype.forEach.call(_this.element.querySelectorAll("button:not([type]), button[type=submit]"), function (button) {
|
|
854
|
+
button.innerHTML = "Processing Request";
|
|
855
|
+
});
|
|
856
|
+
Array.prototype.forEach.call(_this.element.querySelectorAll("input[type=submit]"), function (input) {
|
|
857
|
+
input.value = "Processing Request";
|
|
858
|
+
});
|
|
859
|
+
return;
|
|
859
860
|
}
|
|
860
|
-
catch (e) {
|
|
861
|
-
|
|
862
|
-
e.preventDefault();
|
|
861
|
+
catch (e) {
|
|
862
|
+
debug(e);
|
|
863
863
|
}
|
|
864
|
-
catch (e) { }
|
|
865
|
-
Array.prototype.forEach.call(_this.element.querySelectorAll("a, input, select, textarea, iframe, button, *[name]"), function (el) {
|
|
866
|
-
el.setAttribute("disabled", "disabled");
|
|
867
|
-
el.className += " disabled";
|
|
868
|
-
});
|
|
869
|
-
Array.prototype.forEach.call(_this.element.querySelectorAll("button:not([type]), button[type=submit]"), function (button) {
|
|
870
|
-
button.innerHTML = "Processing Request";
|
|
871
|
-
});
|
|
872
|
-
Array.prototype.forEach.call(_this.element.querySelectorAll("input[type=submit]"), function (input) {
|
|
873
|
-
input.value = "Processing Request";
|
|
874
|
-
});
|
|
875
|
-
return;
|
|
876
864
|
}
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
865
|
+
debug("Submitting", url);
|
|
866
|
+
};
|
|
867
|
+
}
|
|
868
|
+
FormElementComponent.prototype.create = function (element) {
|
|
869
|
+
element.addEventListener("submit", this.handler);
|
|
870
|
+
this.element = element;
|
|
882
871
|
};
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
if (replace === void 0) { replace = false; }
|
|
897
|
-
var match = path.match(/\.([^\/]+)([\?#].*)?$/);
|
|
898
|
-
if (match && match[0] !== "htm" && match[0] !== "html") {
|
|
899
|
-
_this.defaultRequestPage(path, post);
|
|
900
|
-
debug("Ignoring navigation", path, match);
|
|
901
|
-
}
|
|
902
|
-
else {
|
|
903
|
-
debug("requestPage", path);
|
|
904
|
-
var rid_1 = ++self.activerid;
|
|
905
|
-
var baseurl_1 = _this.resolveUrl(path);
|
|
906
|
-
var fullurl_1 = baseurl_1 + (match && match[2] || "");
|
|
907
|
-
if (replace)
|
|
908
|
-
history.replaceState(!!post, "Loading...", fullurl_1);
|
|
909
|
-
else {
|
|
910
|
-
history.pushState(!!post, "Loading...", fullurl_1);
|
|
911
|
-
chash = fullurl_1.match(beforeHash)[1];
|
|
912
|
-
window.scrollTo(0, 0);
|
|
872
|
+
FormElementComponent.prototype.destroy = function () {
|
|
873
|
+
this.element.removeEventListener("submit", this.handler);
|
|
874
|
+
};
|
|
875
|
+
FormElementComponent.prototype.restore = function (data) { };
|
|
876
|
+
FormElementComponent.prototype.save = function () { };
|
|
877
|
+
return FormElementComponent;
|
|
878
|
+
}());
|
|
879
|
+
var requestPage = this.requestPage = function (path, post, replace) {
|
|
880
|
+
if (replace === void 0) { replace = false; }
|
|
881
|
+
var match = path.match(/\.([^\/]+)([\?#].*)?$/);
|
|
882
|
+
if (match && match[0] !== "htm" && match[0] !== "html") {
|
|
883
|
+
_this.defaultRequestPage(path, post);
|
|
884
|
+
debug("Ignoring navigation", path, match);
|
|
913
885
|
}
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
}
|
|
942
|
-
var location_1 = res.headers['x-location'] || res.headers['location'];
|
|
943
|
-
if (location_1) {
|
|
944
|
-
var url = resolveUrl(location_1[0]);
|
|
945
|
-
if (startsWith.test(url)) {
|
|
946
|
-
_this.requestPage(url.substring(_this.url.length), undefined, true);
|
|
886
|
+
else {
|
|
887
|
+
debug("requestPage", path);
|
|
888
|
+
var rid_1 = ++self.activerid;
|
|
889
|
+
var baseurl_1 = _this.resolveUrl(path);
|
|
890
|
+
var fullurl_1 = baseurl_1 + (match && match[2] || "");
|
|
891
|
+
if (replace)
|
|
892
|
+
history.replaceState(!!post, "Loading...", fullurl_1);
|
|
893
|
+
else {
|
|
894
|
+
history.pushState(!!post, "Loading...", fullurl_1);
|
|
895
|
+
chash = fullurl_1.match(beforeHash)[1];
|
|
896
|
+
window.scrollTo(0, 0);
|
|
897
|
+
}
|
|
898
|
+
loader.resetError();
|
|
899
|
+
loader.resetProgress();
|
|
900
|
+
_this.pagesysimpl.requestPage(path, function (res) {
|
|
901
|
+
try {
|
|
902
|
+
if (rid_1 !== self.activerid)
|
|
903
|
+
return;
|
|
904
|
+
if (!res.code) {
|
|
905
|
+
loader.showProgress(undefined, "Connection Issue", "Check your network and try again");
|
|
906
|
+
document.title = "Connection Issue";
|
|
907
|
+
history.replaceState(res.hadData, "Connection Issue", fullurl_1);
|
|
908
|
+
setTimeout(function () {
|
|
909
|
+
if (rid_1 !== self.activerid)
|
|
910
|
+
return;
|
|
911
|
+
requestPage(path, post, true);
|
|
912
|
+
}, 900000);
|
|
947
913
|
return;
|
|
948
914
|
}
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
915
|
+
else if (res.code === 502 || res.code === 503) {
|
|
916
|
+
loader.showProgress(undefined, "Scheduled Maintenance", "Sorry but this website is undergoing scheduled maintenance");
|
|
917
|
+
document.title = "Scheduled Maintenance";
|
|
918
|
+
history.replaceState(res.hadData, "Scheduled Maintenance", fullurl_1);
|
|
919
|
+
setTimeout(function () {
|
|
920
|
+
if (rid_1 !== self.activerid)
|
|
921
|
+
return;
|
|
922
|
+
requestPage(path, post, true);
|
|
923
|
+
}, 900000);
|
|
958
924
|
return;
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
var
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
925
|
+
}
|
|
926
|
+
var location_1 = res.headers['x-location'] || res.headers['location'];
|
|
927
|
+
if (location_1) {
|
|
928
|
+
var url = resolveUrl(location_1[0]);
|
|
929
|
+
if (startsWith.test(url)) {
|
|
930
|
+
_this.requestPage(url.substring(_this.url.length), undefined, true);
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
console.warn("Requested redirect to external url:", url);
|
|
934
|
+
window.location.href = url;
|
|
935
|
+
return;
|
|
936
|
+
}
|
|
937
|
+
var contentDisposition = res.headers['content-disposition'];
|
|
938
|
+
if (contentDisposition && contentDisposition[0].toLowerCase() == "attachment")
|
|
939
|
+
throw new Error("Attachment disposition");
|
|
940
|
+
_this.pagesyshandler(res, function () {
|
|
941
|
+
if (rid_1 !== self.activerid)
|
|
942
|
+
return;
|
|
974
943
|
try {
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
944
|
+
var title = document.title;
|
|
945
|
+
var length_1 = res.contentLength;
|
|
946
|
+
var tooBig = pageStateCacheSize <= length_1;
|
|
947
|
+
var stateData = tooBig ? undefined : {
|
|
948
|
+
title: title,
|
|
949
|
+
user: self.currentUserID,
|
|
950
|
+
scroll: [window.scrollX, window.scrollY],
|
|
951
|
+
body: self.saveComponents(document.body),
|
|
952
|
+
basehref: base ? base['href'] : undefined,
|
|
953
|
+
response: res
|
|
954
|
+
};
|
|
955
|
+
var i;
|
|
956
|
+
var cPageStates = pageStates.length;
|
|
957
|
+
try {
|
|
958
|
+
for (i = 0; i < cPageStates; i++) {
|
|
959
|
+
var state = pageStates[i];
|
|
960
|
+
if (state.url === baseurl_1) {
|
|
961
|
+
if (tooBig) {
|
|
962
|
+
pageStates.splice(i, 1);
|
|
963
|
+
pageStatesSize -= state.size;
|
|
964
|
+
}
|
|
965
|
+
else {
|
|
966
|
+
state.data = stateData;
|
|
967
|
+
state.updated = +new Date;
|
|
968
|
+
pageStatesSize += length_1 - state.size;
|
|
969
|
+
}
|
|
970
|
+
throw true;
|
|
986
971
|
}
|
|
972
|
+
}
|
|
973
|
+
if (!tooBig) {
|
|
974
|
+
pageStates.push({
|
|
975
|
+
url: baseurl_1,
|
|
976
|
+
data: stateData,
|
|
977
|
+
updated: +new Date,
|
|
978
|
+
size: length_1
|
|
979
|
+
});
|
|
980
|
+
pageStatesSize += length_1;
|
|
987
981
|
throw true;
|
|
988
982
|
}
|
|
983
|
+
else
|
|
984
|
+
debug("Response too big to store", baseurl_1, length_1);
|
|
989
985
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
if (over > 0) {
|
|
1007
|
-
pageStates.sort(function (a, b) {
|
|
1008
|
-
return a.updated - b.updated;
|
|
1009
|
-
});
|
|
1010
|
-
var found = 0;
|
|
1011
|
-
for (i = 0; i < cPageStates; i++) {
|
|
1012
|
-
found += pageStates[i].size;
|
|
1013
|
-
if (found >= over)
|
|
1014
|
-
break;
|
|
986
|
+
catch (e) {
|
|
987
|
+
if (e === true) {
|
|
988
|
+
var over = pageStatesSize - pageStateCacheSize;
|
|
989
|
+
if (over > 0) {
|
|
990
|
+
pageStates.sort(function (a, b) {
|
|
991
|
+
return a.updated - b.updated;
|
|
992
|
+
});
|
|
993
|
+
var found = 0;
|
|
994
|
+
for (i = 0; i < cPageStates; i++) {
|
|
995
|
+
found += pageStates[i].size;
|
|
996
|
+
if (found >= over)
|
|
997
|
+
break;
|
|
998
|
+
}
|
|
999
|
+
i++;
|
|
1000
|
+
pageStates.splice(0, i);
|
|
1001
|
+
debug("Trimmed", i, "items...");
|
|
1015
1002
|
}
|
|
1016
|
-
i++;
|
|
1017
|
-
pageStates.splice(0, i);
|
|
1018
|
-
debug("Trimmed", i, "items...");
|
|
1019
1003
|
}
|
|
1004
|
+
else
|
|
1005
|
+
throw e;
|
|
1020
1006
|
}
|
|
1007
|
+
history.replaceState(res.hadData, document.title, fullurl_1);
|
|
1008
|
+
self.emit("page", baseurl_1, path);
|
|
1009
|
+
}
|
|
1010
|
+
catch (e) {
|
|
1011
|
+
debug(e);
|
|
1012
|
+
if (replace)
|
|
1013
|
+
window.location.reload(true);
|
|
1021
1014
|
else
|
|
1022
|
-
|
|
1015
|
+
try {
|
|
1016
|
+
chash = undefined;
|
|
1017
|
+
forwardPopState = [path, post];
|
|
1018
|
+
debug("Going backwards");
|
|
1019
|
+
history.go(-1);
|
|
1020
|
+
}
|
|
1021
|
+
catch (e) { }
|
|
1023
1022
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1023
|
+
});
|
|
1024
|
+
}
|
|
1025
|
+
catch (e) {
|
|
1026
|
+
debug(e);
|
|
1027
|
+
if (replace)
|
|
1028
|
+
window.location.reload(true);
|
|
1029
|
+
else
|
|
1030
|
+
try {
|
|
1031
|
+
chash = undefined;
|
|
1032
|
+
forwardPopState = [path, post];
|
|
1033
|
+
debug("Going backwards");
|
|
1034
|
+
history.go(-1);
|
|
1035
|
+
}
|
|
1036
|
+
catch (e) { }
|
|
1037
|
+
}
|
|
1038
|
+
}, post, rid_1);
|
|
1039
|
+
}
|
|
1040
|
+
};
|
|
1041
|
+
this.registerComponent("a", AnchorElementComponent);
|
|
1042
|
+
this.registerComponent("form", FormElementComponent);
|
|
1043
|
+
window.addEventListener('popstate', function (e) {
|
|
1044
|
+
try {
|
|
1045
|
+
var state;
|
|
1046
|
+
var bhash = location.href.match(beforeHash);
|
|
1047
|
+
var cStates = pageStates.length;
|
|
1048
|
+
var baseurl = bhash[1];
|
|
1049
|
+
for (var i = 0; i < cStates; i++) {
|
|
1050
|
+
var _state = pageStates[i];
|
|
1051
|
+
if (_state.url === baseurl) {
|
|
1052
|
+
state = _state;
|
|
1053
|
+
break;
|
|
1054
|
+
}
|
|
1041
1055
|
}
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
chash = undefined;
|
|
1049
|
-
forwardPopState = [path, post];
|
|
1050
|
-
debug("Going backwards");
|
|
1051
|
-
history.go(-1);
|
|
1052
|
-
}
|
|
1053
|
-
catch (e) { }
|
|
1056
|
+
var hasState = !!state;
|
|
1057
|
+
var rid_2 = ++self.activerid;
|
|
1058
|
+
var error = hasState && state.data.error;
|
|
1059
|
+
if (error) {
|
|
1060
|
+
showError(error);
|
|
1061
|
+
return;
|
|
1054
1062
|
}
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
var cStates = pageStates.length;
|
|
1065
|
-
var baseurl = bhash[1];
|
|
1066
|
-
for (var i = 0; i < cStates; i++) {
|
|
1067
|
-
var _state = pageStates[i];
|
|
1068
|
-
if (_state.url === baseurl) {
|
|
1069
|
-
state = _state;
|
|
1070
|
-
break;
|
|
1063
|
+
if (forwardPopState) {
|
|
1064
|
+
debug("forwardPopState", forwardPopState);
|
|
1065
|
+
var forward_1 = forwardPopState;
|
|
1066
|
+
setTimeout(function () {
|
|
1067
|
+
if (rid_2 === self.activerid)
|
|
1068
|
+
self.defaultRequestPage(forward_1[0], forward_1[1]);
|
|
1069
|
+
});
|
|
1070
|
+
forwardPopState = undefined;
|
|
1071
|
+
return;
|
|
1071
1072
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
var rid_2 = ++self.activerid;
|
|
1075
|
-
var error = hasState && state.data.error;
|
|
1076
|
-
if (error) {
|
|
1077
|
-
showError(error);
|
|
1078
|
-
return;
|
|
1079
|
-
}
|
|
1080
|
-
if (forwardPopState) {
|
|
1081
|
-
debug("forwardPopState", forwardPopState);
|
|
1082
|
-
var forward_1 = forwardPopState;
|
|
1083
|
-
setTimeout(function () {
|
|
1084
|
-
if (rid_2 === self.activerid)
|
|
1085
|
-
self.defaultRequestPage(forward_1[0], forward_1[1]);
|
|
1086
|
-
});
|
|
1087
|
-
forwardPopState = undefined;
|
|
1088
|
-
return;
|
|
1089
|
-
}
|
|
1090
|
-
if (chash === baseurl) {
|
|
1091
|
-
debug("Only hash has changed...", baseurl);
|
|
1092
|
-
return;
|
|
1093
|
-
}
|
|
1094
|
-
console.log(baseurl, chash, e);
|
|
1095
|
-
console.trace();
|
|
1096
|
-
chash = bhash[1];
|
|
1097
|
-
if (e.state)
|
|
1098
|
-
alert("You submitted data to this page, which cannot be re-sent. Because of this, what you're viewing may not be the same now.");
|
|
1099
|
-
if (!hasState)
|
|
1100
|
-
throw new Error("No state for: " + baseurl + ", reloading...");
|
|
1101
|
-
if (state.data.user != self.currentUserID)
|
|
1102
|
-
throw new Error("User has changed since state was created, reloading...");
|
|
1103
|
-
document.title = state.data.title;
|
|
1104
|
-
loader.resetProgress();
|
|
1105
|
-
loader.resetError();
|
|
1106
|
-
self.pagesyshandler(state.data.response, function (err) {
|
|
1107
|
-
if (rid_2 !== self.activerid)
|
|
1073
|
+
if (chash === baseurl) {
|
|
1074
|
+
debug("Only hash has changed...", baseurl);
|
|
1108
1075
|
return;
|
|
1109
|
-
try {
|
|
1110
|
-
if (err)
|
|
1111
|
-
throw err;
|
|
1112
|
-
if (state.data.body)
|
|
1113
|
-
self.restoreComponents(document.body, state.data.body);
|
|
1114
|
-
if (state.data.scroll)
|
|
1115
|
-
window.scrollTo.apply(window, state.data.scroll);
|
|
1116
|
-
debug("Used stored page state!", state);
|
|
1117
1076
|
}
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1077
|
+
chash = bhash[1];
|
|
1078
|
+
if (e.state)
|
|
1079
|
+
alert("You submitted data to this page, which cannot be re-sent. Because of this, what you're viewing may not be the same now.");
|
|
1080
|
+
if (!hasState)
|
|
1081
|
+
throw new Error("No state for: " + baseurl + ", reloading...");
|
|
1082
|
+
if (state.data.user != self.currentUserID)
|
|
1083
|
+
throw new Error("User has changed since state was created, reloading...");
|
|
1084
|
+
document.title = state.data.title;
|
|
1085
|
+
loader.resetProgress();
|
|
1086
|
+
loader.resetError();
|
|
1087
|
+
self.pagesyshandler(state.data.response, function (err) {
|
|
1088
|
+
if (rid_2 !== self.activerid)
|
|
1089
|
+
return;
|
|
1090
|
+
try {
|
|
1091
|
+
if (err)
|
|
1092
|
+
throw err;
|
|
1093
|
+
if (state.data.body)
|
|
1094
|
+
self.restoreComponents(document.body, state.data.body);
|
|
1095
|
+
if (state.data.scroll)
|
|
1096
|
+
window.scrollTo.apply(window, state.data.scroll);
|
|
1097
|
+
debug("Used stored page state!", state);
|
|
1098
|
+
}
|
|
1099
|
+
catch (err) {
|
|
1100
|
+
debug(err);
|
|
1101
|
+
var url = location.href;
|
|
1102
|
+
if (startsWith.test(url)) {
|
|
1103
|
+
try {
|
|
1104
|
+
if (/reloading\.\.\.$/.test(err.message)) {
|
|
1105
|
+
self.requestPage(url.substring(self.url.length), undefined, true);
|
|
1106
|
+
return;
|
|
1107
|
+
}
|
|
1108
|
+
console.error("Unknown error occured, actually navigating to page...");
|
|
1109
|
+
}
|
|
1110
|
+
catch (e) {
|
|
1111
|
+
console.error(e);
|
|
1126
1112
|
}
|
|
1127
|
-
console.error("Unknown error occured, actually navigating to page...");
|
|
1128
1113
|
}
|
|
1129
|
-
|
|
1130
|
-
|
|
1114
|
+
location.reload(true);
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
catch (err) {
|
|
1119
|
+
debug(err);
|
|
1120
|
+
var url = location.href;
|
|
1121
|
+
if (startsWith.test(url)) {
|
|
1122
|
+
try {
|
|
1123
|
+
if (/reloading\.\.\.$/.test(err.message)) {
|
|
1124
|
+
self.requestPage(url.substring(self.url.length), undefined, true);
|
|
1125
|
+
return;
|
|
1131
1126
|
}
|
|
1127
|
+
console.error("Unknown error occured, actually navigating to page...");
|
|
1132
1128
|
}
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
});
|
|
1136
|
-
}
|
|
1137
|
-
catch (err) {
|
|
1138
|
-
debug(err);
|
|
1139
|
-
var url = location.href;
|
|
1140
|
-
if (startsWith.test(url)) {
|
|
1141
|
-
try {
|
|
1142
|
-
if (/reloading\.\.\.$/.test(err.message)) {
|
|
1143
|
-
self.requestPage(url.substring(self.url.length), undefined, true);
|
|
1144
|
-
return;
|
|
1129
|
+
catch (e) {
|
|
1130
|
+
console.error(e);
|
|
1145
1131
|
}
|
|
1146
|
-
console.error("Unknown error occured, actually navigating to page...");
|
|
1147
|
-
}
|
|
1148
|
-
catch (e) {
|
|
1149
|
-
console.error(e);
|
|
1150
1132
|
}
|
|
1133
|
+
location.reload(true);
|
|
1151
1134
|
}
|
|
1152
|
-
location.reload(true);
|
|
1153
|
-
}
|
|
1154
|
-
});
|
|
1155
|
-
return true;
|
|
1156
|
-
};
|
|
1157
|
-
NexusFrameworkBase.prototype.defaultRequestPage = function (path, post) {
|
|
1158
|
-
if (post)
|
|
1159
|
-
throw new Error("Posting is not supported without an initialized page system, yet");
|
|
1160
|
-
else
|
|
1161
|
-
location.href = this.resolveUrl(path);
|
|
1162
|
-
};
|
|
1163
|
-
NexusFrameworkBase.prototype.on = function (event, cb) {
|
|
1164
|
-
var listeners = this._listeners[event];
|
|
1165
|
-
if (listeners)
|
|
1166
|
-
listeners.push(cb);
|
|
1167
|
-
else
|
|
1168
|
-
this._listeners[event] = listeners = [cb];
|
|
1169
|
-
};
|
|
1170
|
-
NexusFrameworkBase.prototype.off = function (event, cb) {
|
|
1171
|
-
var index;
|
|
1172
|
-
var listeners = this._listeners[event];
|
|
1173
|
-
if (listeners && (index = listeners.indexOf(cb)) > -1)
|
|
1174
|
-
listeners.splice(index, 1);
|
|
1175
|
-
};
|
|
1176
|
-
NexusFrameworkBase.prototype.emit = function (event) {
|
|
1177
|
-
var args = [];
|
|
1178
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1179
|
-
args[_i - 1] = arguments[_i];
|
|
1180
|
-
}
|
|
1181
|
-
var self = this;
|
|
1182
|
-
var listeners = this._listeners[event];
|
|
1183
|
-
if (listeners)
|
|
1184
|
-
listeners.forEach(function (cb) {
|
|
1185
|
-
cb.apply(self, args);
|
|
1186
1135
|
});
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
function
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1136
|
+
return true;
|
|
1137
|
+
};
|
|
1138
|
+
Object.defineProperty(NexusFrameworkBase.prototype, "currentUser", {
|
|
1139
|
+
get: function () {
|
|
1140
|
+
return this.currentUserID;
|
|
1141
|
+
},
|
|
1142
|
+
enumerable: true,
|
|
1143
|
+
configurable: true
|
|
1144
|
+
});
|
|
1145
|
+
NexusFrameworkBase.prototype.defaultRequestPage = function (path, post) {
|
|
1146
|
+
if (post)
|
|
1147
|
+
throw new Error("Posting is not supported without an initialized page system, yet");
|
|
1148
|
+
else
|
|
1149
|
+
location.href = this.resolveUrl(path);
|
|
1150
|
+
};
|
|
1151
|
+
NexusFrameworkBase.prototype.on = function (event, cb) {
|
|
1152
|
+
var listeners = this._listeners[event];
|
|
1153
|
+
if (listeners)
|
|
1154
|
+
listeners.push(cb);
|
|
1155
|
+
else
|
|
1156
|
+
this._listeners[event] = listeners = [cb];
|
|
1157
|
+
};
|
|
1158
|
+
NexusFrameworkBase.prototype.off = function (event, cb) {
|
|
1159
|
+
var index;
|
|
1160
|
+
var listeners = this._listeners[event];
|
|
1161
|
+
if (listeners && (index = listeners.indexOf(cb)) > -1)
|
|
1162
|
+
listeners.splice(index, 1);
|
|
1163
|
+
};
|
|
1164
|
+
NexusFrameworkBase.prototype.emit = function (event) {
|
|
1165
|
+
var args = [];
|
|
1166
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
1167
|
+
args[_i - 1] = arguments[_i];
|
|
1168
|
+
}
|
|
1169
|
+
var self = this;
|
|
1170
|
+
var listeners = this._listeners[event];
|
|
1171
|
+
if (listeners)
|
|
1172
|
+
listeners.forEach(function (cb) {
|
|
1173
|
+
cb.apply(self, args);
|
|
1174
|
+
});
|
|
1175
|
+
};
|
|
1176
|
+
return NexusFrameworkBase;
|
|
1177
|
+
}());
|
|
1178
|
+
var impl;
|
|
1179
|
+
if (window.io)
|
|
1180
|
+
impl = /** @class */ (function (_super) {
|
|
1181
|
+
__extends(NexusFrameworkWithIO, _super);
|
|
1182
|
+
function NexusFrameworkWithIO(url) {
|
|
1183
|
+
var _this = _super.call(this, url, window.io({
|
|
1184
|
+
path: "/:io"
|
|
1185
|
+
})) || this;
|
|
1186
|
+
var io = _this.io;
|
|
1187
|
+
io.on("connect", function () {
|
|
1188
|
+
io.emit("init", loader.requestedResources());
|
|
1189
|
+
});
|
|
1190
|
+
return _this;
|
|
1191
|
+
}
|
|
1192
|
+
return NexusFrameworkWithIO;
|
|
1193
|
+
}(NexusFrameworkBase));
|
|
1194
|
+
else
|
|
1195
|
+
impl = /** @class */ (function (_super) {
|
|
1196
|
+
__extends(NexusFrameworkNoIO, _super);
|
|
1197
|
+
function NexusFrameworkNoIO(url) {
|
|
1198
|
+
return _super.call(this, url) || this;
|
|
1199
|
+
}
|
|
1200
|
+
return NexusFrameworkNoIO;
|
|
1201
|
+
}(NexusFrameworkBase));
|
|
1202
|
+
Object.defineProperty(window, "NexusFrameworkImpl", {
|
|
1203
|
+
value: impl
|
|
1204
|
+
});
|
|
1205
|
+
return impl;
|
|
1206
|
+
}
|
|
1226
1207
|
},
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1208
|
+
NexusFrameworkClient: {
|
|
1209
|
+
configurable: true,
|
|
1210
|
+
set: function (instance) {
|
|
1211
|
+
Object.defineProperty(window, "NexusFrameworkClient", {
|
|
1212
|
+
value: instance
|
|
1213
|
+
});
|
|
1214
|
+
},
|
|
1215
|
+
get: function () {
|
|
1216
|
+
var instance = new window.NexusFrameworkImpl();
|
|
1217
|
+
Object.defineProperty(window, "NexusFrameworkClient", {
|
|
1218
|
+
value: instance
|
|
1219
|
+
});
|
|
1220
|
+
return instance;
|
|
1221
|
+
}
|
|
1233
1222
|
}
|
|
1234
|
-
}
|
|
1235
|
-
});
|
|
1223
|
+
});
|
|
1224
|
+
})(window);
|
|
1236
1225
|
//# sourceMappingURL=nexusframeworkclient.js.map
|