-
Notifications
You must be signed in to change notification settings - Fork 0
/
page-load-status.html
58 lines (57 loc) · 2.2 KB
/
page-load-status.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<!DOCTYPE>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<div id="pageLoadStatus"></div>
<script>
var _ = {};
/**
* Gets or sets cookies
* @param name
* @param value (null to delete or undefined to get)
* @param options (domain, expire (in days))
* @return value or true
*/
_.cookie = function(name, value, options)
{
if (typeof value === "undefined") {
var n, v,
cookies = document.cookie.split(";");
for (var i = 0; i < cookies.length; i++) {
n = $.trim(cookies[i].substr(0,cookies[i].indexOf("=")));
v = cookies[i].substr(cookies[i].indexOf("=")+1);
if (n === name){
return unescape(v);
}
}
} else {
options = options || {};
if (!value) {
value = "";
options.expires = -365;
} else {
value = escape(value);
}
if (options.expires) {
var d = new Date();
d.setDate(d.getDate() + options.expires);
value += "; expires=" + d.toUTCString();
}
if (options.domain) {
value += "; domain=" + options.domain;
}
if (options.path) {
value += "; path=" + options.path;
}
document.cookie = name + "=" + value;
}
};
var hasLoadedBefore = _.cookie('hasLoadedBefore');
if(!!hasLoadedBefore) $('#pageLoadStatus').text('This page has been loaded before.');
else $('#pageLoadStatus').text('This page loaded at first time.');
_.cookie('hasLoadedBefore', true);
</script>
</body>
</html>