PageSourceSearch

https://gold.bullionvault.jp/javascript/autologout.js

js bullionvault.jp collected 2026-10-02 04:59:50 UTC 4,181 bytes, 119 lines download raw bytes

1/* Functions to handle window autologouts
2 - autologout object must be in the top level frame and is a singleton
3 - autologout must be reset whenever new content is viewed (done through pingMainFrame.js)
4 - main window does the redirection and time tracking for autologout
5 */
6
7function Autologout(autologoutCountdownRemaining) {
8
9	// Initialise constants
10	this.warningDuration = 3*60; // Show warning for 3 minutes
11	this.warningDisplayed = false;
12	this.autologoutCountdown = 30*60; // Autologout in 30 minutes
13	this.autologoutCountdownRemaining = autologoutCountdownRemaining ? autologoutCountdownRemaining : this.autologoutCountdown;
14	this.timerId = null;
15
16	// Update modified and start countdown
17	this.updateLastModified();
18	this.tick();
19}
20
21Autologout.prototype.kill = function() {
22	this.updateLastModified();
23	if (this.timerId) {
24		clearTimeout(this.timerId);
25		this.timerId = null;
26	}
27};
28
29Autologout.prototype.updateLastModified = function() {
30	this.modifiedTime = new Date().getTime();
31	updateAutologoutLastModified(this.modifiedTime, this.autologoutCountdownRemaining)
32};
33
34function updateAutologoutLastModified(modifiedTime, autologoutCountdownRemaining) {
35	try {
36		localStorage.setItem('autoLogoutLastModified', modifiedTime);
37		localStorage.setItem('autoLogoutCountdownRemaining', autologoutCountdownRemaining);
38	} catch (err) {
39		// Happens with Safari in private browsing mode, nothing we can do
40		return;
41	}
42};
43
44Autologout.prototype.reset = function() {
45	this.autologoutCountdownRemaining = this.autologoutCountdown;
46	this.kill();
47	this.tick();
48};
49
50Autologout.prototype.tick = function() {
51	// the reference to 'this' is passed in as calling the function from the setTimeout
52	var self = this;
53	this.timerId = setTimeout( function() { self.tick() }, 1000);
54
55	// Check if there was activity on another tab
56	var lastModified = localStorage.getItem('autoLogoutLastModified');
57	if (lastModified && lastModified != this.modifiedTime) {
58		// Another tab was modified later than this one. Reset our counter but don't update modified
59		// state globally since it wasn't driven by user action
60		this.modifiedTime = lastModified;
61		var autologoutCountdownRemaining = localStorage.getItem('autoLogoutCountdownRemaining');
62		this.autologoutCountdownRemaining = autologoutCountdownRemaining ? autologoutCountdownRemaining : this.autologoutCountdownRemaining;
63	} else {
64		// Decrement remaining time
65		this.autologoutCountdownRemaining--;
66	}
67
68	// Show warning modal if needed
69	if (this.autologoutCountdownRemaining <= this.warningDuration && !this.warningDisplayed) {
70		$('#modal_autologout').one('show.bs.modal', function () {
71			self.warningDisplayed = true;
72		});
73		// Refresh page when modal is hidden
74		$('#modal_autologout').one('hidden.bs.modal', function () {
75			location.reload();
76		});
77		// Close any existing modals first
78		if ($(".modal.in").length > 0) {
79
80			// Add/remove fade effects selectively to enable immediate transition between modals
81			$(".modal-backdrop.in").removeClass("fade");
82			$(".modal.in").each(function() {
83				$(this).removeClass("fade");
84				$(this).modal('hide');
85				$(this).addClass("fade");
86			});
87
88			// Show autologout warning immediately
89			$('#modal_autologout').removeClass("fade");
90			$("#modal_autologout").modal('show');
91			$('#modal_autologout').addClass("fade");
92			$(".modal-backdrop.in").addClass("fade");
93		} else {
94			$("#modal_autologout").modal('show');
95		}
96	} else if (this.autologoutCountdownRemaining >= this.warningDuration && this.warningDisplayed) {
97		$("#modal_autologout").modal('hide');
98	}
99
100	// Update the countdown time in the warning modal
101	if (this.warningDisplayed) {
102		var tMin = Math.max(Math.floor(this.autologoutCountdownRemaining / 60), 0);
103		var tSec = Math.max(this.autologoutCountdownRemaining - tMin * 60, 0) + "";
104		if (tSec.length === 1) {
105			tSec = "0" + tSec;
106		}
107		$("#modal_autologout #timeout").html(tMin + ":" + tSec);
108	}
109
110	// Logout when countdown runs out
111	if (this.autologoutCountdownRemaining <= 0) {
112		this.updateLastModified();
113		var form = document.createElement("form");
114		form.method = "POST";
115		form.action = "/secure/logout.do";
116		document.body.appendChild(form);
117		form.submit();
118	}
119};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.