hof 22.0.0-timeout-warning-beta.1 → 22.0.0-timeout-warning-beta.3
Sign up to get free protection for your applications and to get access to all the features.
- package/.nyc_output/3971586e-d34a-49de-8cd7-964103fb3317.json +1 -0
- package/.nyc_output/processinfo/{39337dba-f075-4b5c-ad46-31665a16d443.json → 3971586e-d34a-49de-8cd7-964103fb3317.json} +1 -1
- package/.nyc_output/processinfo/index.json +1 -1
- package/CHANGELOG.md +5 -0
- package/frontend/themes/gov-uk/client-js/index.js +0 -1
- package/frontend/themes/gov-uk/client-js/session-timeout-dialog.js +47 -56
- package/model/apis/axios-settings.js +21 -0
- package/model/apis/html-to-pdf-converter.js +10 -8
- package/model/index.js +102 -87
- package/package.json +4 -4
- package/sandbox/public/js/bundle.js +49 -57
- package/.nyc_output/39337dba-f075-4b5c-ad46-31665a16d443.json +0 -1
package/model/index.js
CHANGED
@@ -2,10 +2,10 @@
|
|
2
2
|
'use strict';
|
3
3
|
|
4
4
|
const _ = require('lodash');
|
5
|
-
const
|
5
|
+
const axios = require('axios').default;
|
6
6
|
const url = require('url');
|
7
7
|
const EventEmitter = require('events').EventEmitter;
|
8
|
-
|
8
|
+
const axiosSetting = require('./apis/axios-settings');
|
9
9
|
const REFERENCE = /^\$ref:/;
|
10
10
|
|
11
11
|
function timeDiff(from, to, d) {
|
@@ -27,10 +27,10 @@ module.exports = class Model extends EventEmitter {
|
|
27
27
|
this.set(attributes, {
|
28
28
|
silent: true
|
29
29
|
});
|
30
|
-
this._request =
|
30
|
+
this._request = axios;
|
31
31
|
}
|
32
32
|
|
33
|
-
save(options, callback) {
|
33
|
+
async save(options, callback) {
|
34
34
|
if (typeof options === 'function' && arguments.length === 1) {
|
35
35
|
callback = options;
|
36
36
|
options = {};
|
@@ -38,21 +38,18 @@ module.exports = class Model extends EventEmitter {
|
|
38
38
|
options = {};
|
39
39
|
}
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
return this.request(reqConf, data, callback);
|
52
|
-
});
|
41
|
+
let data = await this.prepare();
|
42
|
+
data = JSON.stringify(data);
|
43
|
+
const reqConf = this.requestConfig(options);
|
44
|
+
reqConf.method = options.method || 'POST';
|
45
|
+
reqConf.headers = Object.assign({
|
46
|
+
'Content-Type': 'application/json',
|
47
|
+
'Content-Length': Buffer.byteLength(data)
|
48
|
+
}, reqConf.headers || {});
|
49
|
+
return await this.request(reqConf, data, callback);
|
53
50
|
}
|
54
51
|
|
55
|
-
fetch(options, callback) {
|
52
|
+
async fetch(options, callback) {
|
56
53
|
if (typeof options === 'function' && arguments.length === 1) {
|
57
54
|
callback = options;
|
58
55
|
options = {};
|
@@ -61,10 +58,10 @@ module.exports = class Model extends EventEmitter {
|
|
61
58
|
}
|
62
59
|
const reqConf = this.requestConfig(options);
|
63
60
|
reqConf.method = options.method || 'GET';
|
64
|
-
return this.request(reqConf, callback);
|
61
|
+
return await this.request(reqConf, callback);
|
65
62
|
}
|
66
63
|
|
67
|
-
delete(options, callback) {
|
64
|
+
async delete(options, callback) {
|
68
65
|
if (typeof options === 'function' && arguments.length === 1) {
|
69
66
|
callback = options;
|
70
67
|
options = {};
|
@@ -73,7 +70,7 @@ module.exports = class Model extends EventEmitter {
|
|
73
70
|
}
|
74
71
|
const reqConf = this.requestConfig(options);
|
75
72
|
reqConf.method = options.method || 'DELETE';
|
76
|
-
return this.request(reqConf, callback);
|
73
|
+
return await this.request(reqConf, callback);
|
77
74
|
}
|
78
75
|
|
79
76
|
requestConfig(options) {
|
@@ -86,7 +83,7 @@ module.exports = class Model extends EventEmitter {
|
|
86
83
|
});
|
87
84
|
}
|
88
85
|
|
89
|
-
request(originalSettings, body, callback) {
|
86
|
+
async request(originalSettings, body, callback) {
|
90
87
|
if (typeof body === 'function' && arguments.length === 2) {
|
91
88
|
callback = body;
|
92
89
|
body = undefined;
|
@@ -94,96 +91,114 @@ module.exports = class Model extends EventEmitter {
|
|
94
91
|
|
95
92
|
let settings = Object.assign({}, originalSettings);
|
96
93
|
settings.timeout = settings.timeout || this.options.timeout;
|
97
|
-
settings
|
98
|
-
settings
|
99
|
-
|
100
|
-
settings = _.omit(settings, urlKeys, 'data', 'url');
|
94
|
+
settings = axiosSetting(settings, body);
|
95
|
+
settings = _.omit(settings, urlKeys);
|
101
96
|
this.emit('sync', originalSettings);
|
102
97
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
98
|
+
try {
|
99
|
+
const authData = await this.auth();
|
100
|
+
let authVal = authData;
|
101
|
+
if (typeof authVal === 'string') {
|
102
|
+
const [user, ...rest] = authVal.split(':');
|
103
|
+
authVal = {
|
104
|
+
user,
|
105
|
+
pass: rest.join(':'),
|
110
106
|
sendImmediately: true
|
111
107
|
};
|
112
108
|
}
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
const _callback = (err, data, statusCode) => {
|
120
|
-
if (timeoutTimer) {
|
121
|
-
clearTimeout(timeoutTimer);
|
122
|
-
timeoutTimer = null;
|
123
|
-
}
|
109
|
+
if (authVal) {
|
110
|
+
settings.headers = {
|
111
|
+
...settings.headers,
|
112
|
+
Authorization: `Bearer ${authVal.bearer}`
|
113
|
+
};
|
114
|
+
}
|
124
115
|
|
125
|
-
|
126
|
-
|
116
|
+
const startTime = process.hrtime();
|
117
|
+
let timeoutTimer;
|
127
118
|
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
}
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
119
|
+
if (timeoutTimer) {
|
120
|
+
clearTimeout(timeoutTimer);
|
121
|
+
timeoutTimer = null;
|
122
|
+
}
|
123
|
+
|
124
|
+
const data = await new Promise((resolve, reject) => {
|
125
|
+
const _callback = (err, responseData, statusCode) => {
|
126
|
+
if (timeoutTimer) {
|
127
|
+
clearTimeout(timeoutTimer);
|
128
|
+
timeoutTimer = null;
|
129
|
+
}
|
130
|
+
|
131
|
+
const endTime = process.hrtime();
|
132
|
+
const responseTime = timeDiff(startTime, endTime);
|
133
|
+
if (err) {
|
134
|
+
this.emit('fail', err, responseData, originalSettings, statusCode, responseTime);
|
135
|
+
reject(err);
|
136
|
+
} else {
|
137
|
+
this.emit('success', responseData, originalSettings, statusCode, responseTime);
|
138
|
+
resolve(responseData);
|
139
|
+
}
|
140
|
+
};
|
141
|
+
|
142
|
+
this._request(settings)
|
143
|
+
.then(response => {
|
144
|
+
return this.handleResponse(response)
|
145
|
+
.then(responseData => _callback(null, responseData, response.status))
|
146
|
+
.catch(error => {
|
151
147
|
error.headers = response.headers;
|
152
|
-
|
153
|
-
|
154
|
-
|
148
|
+
_callback(error, null, response.status);
|
149
|
+
});
|
150
|
+
})
|
151
|
+
.catch(err => {
|
152
|
+
if (err.code === 'ETIMEDOUT' || err.code === 'ESOCKETTIMEDOUT') {
|
153
|
+
err.message = 'Connection timed out';
|
154
|
+
err.status = 504;
|
155
|
+
}
|
156
|
+
err.status = err.status || 503;
|
157
|
+
return _callback(err, null, err.status);
|
155
158
|
});
|
156
|
-
});
|
157
159
|
});
|
158
160
|
|
159
|
-
|
160
|
-
|
161
|
+
if (typeof callback === 'function') {
|
162
|
+
callback(null, data);
|
163
|
+
}
|
164
|
+
return data;
|
165
|
+
} catch (error) {
|
166
|
+
if (typeof callback === 'function') {
|
167
|
+
callback(error);
|
168
|
+
}
|
169
|
+
return error;
|
161
170
|
}
|
162
|
-
return promise;
|
163
171
|
}
|
164
172
|
|
165
|
-
handleResponse(response
|
166
|
-
let data =
|
173
|
+
async handleResponse(response) {
|
174
|
+
let data = null;
|
167
175
|
try {
|
168
|
-
|
176
|
+
if (typeof response.data === 'object') {
|
177
|
+
data = response.data;
|
178
|
+
} else if (typeof response.data === 'string' && response.data.trim() !== '') {
|
179
|
+
data = JSON.parse(response.data);
|
180
|
+
} else {
|
181
|
+
data = {};
|
182
|
+
}
|
169
183
|
} catch (err) {
|
170
|
-
err.
|
171
|
-
err.
|
172
|
-
|
184
|
+
err.message = 'Failed to parse response data';
|
185
|
+
err.status = response.status;
|
186
|
+
err.body = response.data;
|
187
|
+
throw err;
|
173
188
|
}
|
174
|
-
return this.parseResponse(response.
|
189
|
+
return await this.parseResponse(response.status, data);
|
175
190
|
}
|
176
191
|
|
177
|
-
parseResponse(statusCode, data
|
192
|
+
async parseResponse(statusCode, data) {
|
178
193
|
if (statusCode < 400) {
|
179
194
|
try {
|
180
|
-
data = this.parse(data);
|
181
|
-
|
195
|
+
data = await this.parse(data);
|
196
|
+
return data;
|
182
197
|
} catch (err) {
|
183
|
-
|
198
|
+
throw err;
|
184
199
|
}
|
185
200
|
} else {
|
186
|
-
|
201
|
+
throw this.parseError(statusCode, data);
|
187
202
|
}
|
188
203
|
}
|
189
204
|
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "hof",
|
3
3
|
"description": "A bootstrap for HOF projects",
|
4
|
-
"version": "22.0.0-timeout-warning-beta.
|
4
|
+
"version": "22.0.0-timeout-warning-beta.3",
|
5
5
|
"license": "MIT",
|
6
6
|
"main": "index.js",
|
7
7
|
"author": "HomeOffice",
|
@@ -21,13 +21,13 @@
|
|
21
21
|
"url": "https://github.com/UKHomeOfficeForms/hof/issues"
|
22
22
|
},
|
23
23
|
"scripts": {
|
24
|
-
"test": "yarn run unit && yarn run test:
|
24
|
+
"test": "yarn run unit && yarn run test:jest && yarn run test:functional && yarn run test:client && yarn run test:lint",
|
25
25
|
"unit": "LOG_LEVEL=error nyc _mocha \"test/**/*.spec.js\" \"sandbox/test/**/*.spec.js\"",
|
26
26
|
"unit:nocov": "LOG_LEVEL=error mocha \"test/**/*.spec.js\" \"sandbox/test/**/*.spec.js\"",
|
27
27
|
"test:lint": "eslint . --config ./node_modules/eslint-config-hof/default.js",
|
28
28
|
"test:functional": "funkie mocha ./test/functional-tests --timeout 20000 --exit",
|
29
29
|
"test:client": "karma start test/frontend/toolkit/karma.conf.js",
|
30
|
-
"test:
|
30
|
+
"test:jest": "jest test/frontend/jest",
|
31
31
|
"test:acceptance": "TAGS=\"${TAGS:=@feature}\" yarn run test:cucumber",
|
32
32
|
"test:acceptance_browser": "ACCEPTANCE_WITH_BROWSER=true TAGS=\"${TAGS:=@feature}\" yarn run test:cucumber",
|
33
33
|
"test:cucumber": "cucumber-js -f @cucumber/pretty-formatter \"sandbox/test/_features/**/*.feature\" --require sandbox/test/_features/test.setup.js --require \"sandbox/test/_features/step_definitions/**/*.js\" --tags $TAGS",
|
@@ -36,6 +36,7 @@
|
|
36
36
|
},
|
37
37
|
"dependencies": {
|
38
38
|
"aliasify": "^2.1.0",
|
39
|
+
"axios": "^1.5.1",
|
39
40
|
"bluebird": "^3.7.2",
|
40
41
|
"body-parser": "^1.15.1",
|
41
42
|
"browserify": "^17.0.0",
|
@@ -83,7 +84,6 @@
|
|
83
84
|
"notifications-node-client": "^6.0.0",
|
84
85
|
"redis": "^3.1.2",
|
85
86
|
"reqres": "^3.0.1",
|
86
|
-
"request": "^2.79.0",
|
87
87
|
"rimraf": "^3.0.2",
|
88
88
|
"sass": "^1.56.2",
|
89
89
|
"serve-static": "^1.14.1",
|
@@ -286,7 +286,6 @@ var skipToMain = require('./skip-to-main');
|
|
286
286
|
var cookie = require('./govuk-cookies');
|
287
287
|
var cookieSettings = require('./cookieSettings');
|
288
288
|
var sessionDialog = require('./session-timeout-dialog');
|
289
|
-
GOVUK.sessionDialog.init();
|
290
289
|
|
291
290
|
toolkit.detailsSummary();
|
292
291
|
|
@@ -299,6 +298,9 @@ helpers.documentReady(characterCount);
|
|
299
298
|
helpers.documentReady(validation);
|
300
299
|
|
301
300
|
},{"../../../toolkit":12,"./cookieSettings":1,"./govuk-cookies":2,"./session-timeout-dialog":4,"./skip-to-main":5,"govuk-frontend":13}],4:[function(require,module,exports){
|
301
|
+
/* eslint max-len: 0 */
|
302
|
+
'use strict';
|
303
|
+
|
302
304
|
const $ = require('jquery');
|
303
305
|
|
304
306
|
// Modal dialog prototype
|
@@ -318,8 +320,8 @@ window.GOVUK.sessionDialog = {
|
|
318
320
|
$timer: $('#js-modal-dialog .timer'),
|
319
321
|
$accessibleTimer: $('#js-modal-dialog .at-timer'),
|
320
322
|
|
321
|
-
secondsSessionTimeout: parseInt($('#js-modal-dialog').data('session-timeout') || 1800),
|
322
|
-
secondsTimeoutWarning: parseInt($('#js-modal-dialog').data('session-timeout-warning') || 300),
|
323
|
+
secondsSessionTimeout: parseInt($('#js-modal-dialog').data('session-timeout'), 10 || 1800),
|
324
|
+
secondsTimeoutWarning: parseInt($('#js-modal-dialog').data('session-timeout-warning'), 10 || 300),
|
323
325
|
timeoutRedirectUrl: $('#js-modal-dialog').data('url-redirect'),
|
324
326
|
timeSessionRefreshed: new Date(),
|
325
327
|
|
@@ -327,18 +329,18 @@ window.GOVUK.sessionDialog = {
|
|
327
329
|
window.GOVUK.sessionDialog.$closeButton.on('click', function (e) {
|
328
330
|
e.preventDefault();
|
329
331
|
window.GOVUK.sessionDialog.closeDialog();
|
330
|
-
})
|
332
|
+
});
|
331
333
|
|
332
334
|
// Close modal when ESC pressed
|
333
335
|
$(document).keydown(function (e) {
|
334
336
|
if (window.GOVUK.sessionDialog.isDialogOpen() && e.keyCode === 27) {
|
335
337
|
window.GOVUK.sessionDialog.closeDialog();
|
336
338
|
}
|
337
|
-
})
|
339
|
+
});
|
338
340
|
},
|
339
341
|
|
340
342
|
isDialogOpen: function () {
|
341
|
-
return window.GOVUK.sessionDialog.el
|
343
|
+
return window.GOVUK.sessionDialog.el && window.GOVUK.sessionDialog.el.open;
|
342
344
|
},
|
343
345
|
|
344
346
|
isConfigured: function () {
|
@@ -355,6 +357,8 @@ window.GOVUK.sessionDialog = {
|
|
355
357
|
window.GOVUK.sessionDialog.saveLastFocusedEl();
|
356
358
|
window.GOVUK.sessionDialog.makePageContentInert();
|
357
359
|
window.GOVUK.sessionDialog.el.showModal();
|
360
|
+
window.GOVUK.sessionDialog.el.open = true;
|
361
|
+
console.log(window.GOVUK.sessionDialog.el)
|
358
362
|
}
|
359
363
|
},
|
360
364
|
|
@@ -362,6 +366,8 @@ window.GOVUK.sessionDialog = {
|
|
362
366
|
if (window.GOVUK.sessionDialog.isDialogOpen()) {
|
363
367
|
$('html, body').removeClass(window.GOVUK.sessionDialog.dialogIsOpenClass);
|
364
368
|
window.GOVUK.sessionDialog.el.close();
|
369
|
+
window.GOVUK.sessionDialog.el.open = false;
|
370
|
+
console.log(window.GOVUK.sessionDialog.el)
|
365
371
|
window.GOVUK.sessionDialog.setFocusOnLastFocusedEl();
|
366
372
|
window.GOVUK.sessionDialog.removeInertFromPageContent();
|
367
373
|
window.GOVUK.sessionDialog.refreshSession();
|
@@ -382,7 +388,7 @@ window.GOVUK.sessionDialog = {
|
|
382
388
|
if (window.GOVUK.sessionDialog.$lastFocusedEl) {
|
383
389
|
window.setTimeout(function () {
|
384
390
|
window.GOVUK.sessionDialog.$lastFocusedEl.focus();
|
385
|
-
}, 0)
|
391
|
+
}, 0);
|
386
392
|
}
|
387
393
|
},
|
388
394
|
|
@@ -405,51 +411,46 @@ window.GOVUK.sessionDialog = {
|
|
405
411
|
},
|
406
412
|
|
407
413
|
numberToWords: function (n) {
|
408
|
-
|
409
|
-
let
|
410
|
-
let
|
411
|
-
let
|
412
|
-
let
|
413
|
-
let
|
414
|
-
let
|
415
|
-
let
|
416
|
-
|
417
|
-
|
418
|
-
let i
|
419
|
-
let word
|
420
|
-
let words = 'and'
|
421
|
-
|
422
|
-
if (parseInt(string) === 0) {
|
414
|
+
const string = n.toString();
|
415
|
+
let start;
|
416
|
+
let end;
|
417
|
+
let chunk;
|
418
|
+
let ints;
|
419
|
+
let i;
|
420
|
+
let word;
|
421
|
+
let words = 'and';
|
422
|
+
|
423
|
+
if (parseInt(string, 10) === 0) {
|
423
424
|
return 'zero';
|
424
425
|
}
|
425
426
|
|
426
427
|
/* Array of units as words */
|
427
|
-
units = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'];
|
428
|
+
const units = ['', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'];
|
428
429
|
|
429
430
|
/* Array of tens as words */
|
430
|
-
tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];
|
431
|
+
const tens = ['', '', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'];
|
431
432
|
|
432
433
|
/* Array of scales as words */
|
433
|
-
scales = ['', 'thousand', 'million', 'billion', 'trillion', 'quadrillion', 'quintillion', 'sextillion', 'septillion', 'octillion', 'nonillion', 'decillion', 'undecillion', 'duodecillion', 'tredecillion', 'quatttuor-decillion', 'quindecillion', 'sexdecillion', 'septen-decillion', 'octodecillion', 'novemdecillion', 'vigintillion', 'centillion'];
|
434
|
+
const scales = ['', 'thousand', 'million', 'billion', 'trillion', 'quadrillion', 'quintillion', 'sextillion', 'septillion', 'octillion', 'nonillion', 'decillion', 'undecillion', 'duodecillion', 'tredecillion', 'quatttuor-decillion', 'quindecillion', 'sexdecillion', 'septen-decillion', 'octodecillion', 'novemdecillion', 'vigintillion', 'centillion'];
|
434
435
|
|
435
|
-
/* Split user
|
436
|
+
/* Split user argument into 3 digit chunks from right to left */
|
436
437
|
start = string.length;
|
437
|
-
chunks = [];
|
438
|
+
const chunks = [];
|
438
439
|
while (start > 0) {
|
439
440
|
end = start;
|
440
441
|
chunks.push(string.slice((start = Math.max(0, start - 3)), end));
|
441
442
|
}
|
442
443
|
|
443
444
|
/* Check if function has enough scale words to be able to stringify the user argument */
|
444
|
-
chunksLen = chunks.length
|
445
|
+
const chunksLen = chunks.length;
|
445
446
|
if (chunksLen > scales.length) {
|
446
447
|
return '';
|
447
448
|
}
|
448
449
|
|
449
450
|
/* Stringify each integer in each chunk */
|
450
|
-
words = []
|
451
|
+
words = [];
|
451
452
|
for (i = 0; i < chunksLen; i++) {
|
452
|
-
chunk = parseInt(chunks[i]);
|
453
|
+
chunk = parseInt(chunks[i], 10);
|
453
454
|
|
454
455
|
if (chunk) {
|
455
456
|
/* Split chunk into array of individual integers */
|
@@ -461,22 +462,22 @@ window.GOVUK.sessionDialog = {
|
|
461
462
|
}
|
462
463
|
|
463
464
|
/* Add scale word if chunk is not zero and array item exists */
|
464
|
-
if ((word
|
465
|
+
if ((word === scales[i])) {
|
465
466
|
words.push(word);
|
466
467
|
}
|
467
468
|
|
468
469
|
/* Add unit word if array item exists */
|
469
|
-
if ((word
|
470
|
+
if ((word === units[ints[0]])) {
|
470
471
|
words.push(word);
|
471
472
|
}
|
472
473
|
|
473
474
|
/* Add tens word if array item exists */
|
474
|
-
if ((word
|
475
|
+
if ((word === tens[ints[1]])) {
|
475
476
|
words.push(word);
|
476
477
|
}
|
477
478
|
|
478
479
|
/* Add hundreds word if array item exists */
|
479
|
-
if ((word
|
480
|
+
if ((word === units[ints[2]])) {
|
480
481
|
words.push(word + ' hundred');
|
481
482
|
}
|
482
483
|
}
|
@@ -502,7 +503,7 @@ window.GOVUK.sessionDialog = {
|
|
502
503
|
},
|
503
504
|
|
504
505
|
pluralise: function (n, unit) {
|
505
|
-
return n
|
506
|
+
return n === 1 ? unit : unit + 's';
|
506
507
|
},
|
507
508
|
|
508
509
|
numericSpan: function (n, unit) {
|
@@ -518,7 +519,7 @@ window.GOVUK.sessionDialog = {
|
|
518
519
|
countdownAtText: function (minutes, seconds) {
|
519
520
|
const minutesText = window.GOVUK.sessionDialog.timeToWords(minutes, 'minute');
|
520
521
|
const secondsText = window.GOVUK.sessionDialog.timeToWords(seconds, 'second');
|
521
|
-
return minutes > 0 ? minutesText :
|
522
|
+
return minutes > 0 ? minutesText : secondsText;
|
522
523
|
},
|
523
524
|
|
524
525
|
startCountdown: function () {
|
@@ -537,11 +538,8 @@ window.GOVUK.sessionDialog = {
|
|
537
538
|
const timerExpired = secondsUntilSessionTimeout <= window.GOVUK.sessionDialog.secondsFinalWarning;
|
538
539
|
|
539
540
|
if (!timerExpired) {
|
540
|
-
|
541
541
|
const minutesLeft = parseInt(secondsUntilSessionTimeout / 60, 10);
|
542
542
|
const secondsLeft = parseInt(secondsUntilSessionTimeout % 60, 10);
|
543
|
-
|
544
|
-
|
545
543
|
const atMinutesText = window.GOVUK.sessionDialog.timeToWords(minutesLeft, 'minute');
|
546
544
|
const atSecondsText = window.GOVUK.sessionDialog.timeToWords(secondsLeft, 'second');
|
547
545
|
|
@@ -552,14 +550,13 @@ window.GOVUK.sessionDialog = {
|
|
552
550
|
const countdownText = window.GOVUK.sessionDialog.countdownText(minutesLeft, secondsLeft);
|
553
551
|
const text = window.GOVUK.sessionDialog.warningTextPrefix + '<strong>' + countdownText + '</strong>' + window.GOVUK.sessionDialog.warningTextSuffix;
|
554
552
|
const countdownAtText = window.GOVUK.sessionDialog.countdownAtText(atMinutesText, atSecondsText);
|
555
|
-
const atText = window.GOVUK.sessionDialog.warningTextPrefix + countdownAtText + window.GOVUK.sessionDialog.warningTextSuffix
|
553
|
+
const atText = window.GOVUK.sessionDialog.warningTextPrefix + countdownAtText + window.GOVUK.sessionDialog.warningTextSuffix + 'bgbhj ' + window.GOVUK.sessionDialog.warningText;
|
556
554
|
const extraText = '\n' + window.GOVUK.sessionDialog.warningTextExtra;
|
557
555
|
|
558
556
|
$timer.html(text + ' ' + extraText);
|
559
557
|
|
560
558
|
// Update screen reader friendly content every 20 secs
|
561
559
|
if (secondsLeft % 20 === 0) {
|
562
|
-
|
563
560
|
// Read out the extra content only once.
|
564
561
|
// Don't read out on iOS VoiceOver which stalls on the longer text
|
565
562
|
if (!timerRunOnce && !iOS) {
|
@@ -570,9 +567,9 @@ window.GOVUK.sessionDialog = {
|
|
570
567
|
}
|
571
568
|
}
|
572
569
|
|
573
|
-
window.GOVUK.sessionDialog.addTimer(countdown,20);
|
570
|
+
window.GOVUK.sessionDialog.addTimer(countdown, 20);
|
574
571
|
}
|
575
|
-
})()
|
572
|
+
})();
|
576
573
|
},
|
577
574
|
|
578
575
|
// Clears all timers
|
@@ -583,7 +580,7 @@ window.GOVUK.sessionDialog = {
|
|
583
580
|
},
|
584
581
|
|
585
582
|
refreshSession: function () {
|
586
|
-
$.get(
|
583
|
+
$.get('');
|
587
584
|
window.GOVUK.sessionDialog.timeSessionRefreshed = new Date();
|
588
585
|
window.GOVUK.sessionDialog.controller();
|
589
586
|
},
|
@@ -616,20 +613,16 @@ window.GOVUK.sessionDialog = {
|
|
616
613
|
|
617
614
|
const secondsUntilSessionTimeout = window.GOVUK.sessionDialog.secondsUntilSessionTimeout();
|
618
615
|
|
619
|
-
//timed out - redirect
|
620
616
|
if (secondsUntilSessionTimeout <= 0) {
|
617
|
+
// timed out - redirect
|
621
618
|
window.GOVUK.sessionDialog.redirect();
|
622
|
-
}
|
623
|
-
|
624
|
-
//timeout warning - show countdown and schedule redirect
|
625
|
-
else if (secondsUntilSessionTimeout <= window.GOVUK.sessionDialog.secondsTimeoutWarning) {
|
619
|
+
} else if (secondsUntilSessionTimeout <= window.GOVUK.sessionDialog.secondsTimeoutWarning) {
|
620
|
+
// timeout warning - show countdown and schedule redirect
|
626
621
|
window.GOVUK.sessionDialog.openDialog();
|
627
622
|
window.GOVUK.sessionDialog.startCountdown();
|
628
|
-
window.GOVUK.sessionDialog.addTimer(window.GOVUK.sessionDialog.controller,window.GOVUK.sessionDialog.secondsUntilSessionTimeout());
|
629
|
-
}
|
630
|
-
|
631
|
-
//wait for warning
|
632
|
-
else {
|
623
|
+
window.GOVUK.sessionDialog.addTimer(window.GOVUK.sessionDialog.controller, window.GOVUK.sessionDialog.secondsUntilSessionTimeout());
|
624
|
+
} else {
|
625
|
+
// wait for warning
|
633
626
|
window.GOVUK.sessionDialog.addTimer(window.GOVUK.sessionDialog.controller, window.GOVUK.sessionDialog.secondsUntilTimeoutWarning());
|
634
627
|
}
|
635
628
|
},
|
@@ -641,9 +634,8 @@ window.GOVUK.sessionDialog = {
|
|
641
634
|
window.GOVUK.sessionDialog.controller();
|
642
635
|
}
|
643
636
|
}
|
644
|
-
}
|
645
|
-
|
646
|
-
window.GOVUK = GOVUK;
|
637
|
+
};
|
638
|
+
window.GOVUK.sessionDialog.init();
|
647
639
|
|
648
640
|
},{"jquery":14}],5:[function(require,module,exports){
|
649
641
|
const skipToMain = function () {
|