-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVisitorIdentification.js
73 lines (60 loc) · 2.15 KB
/
VisitorIdentification.js
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
function subscribeEvent(event, listener, useCapture) {
if (document.addEventListener) {
document.addEventListener(event, listener, useCapture);
} else if (document.attachEvent) {
document.attachEvent(event, listener, useCapture);
}
}
function unsubscribeEvent(event, listener, useCapture) {
if (document.removeEventListener) {
document.removeEventListener(event, listener, useCapture);
} else if (document.detachEvent) {
document.detachEvent(event, listener, useCapture);
}
}
function startActivityHandler(e) {
unsubscribeEvent("touchstart", arguments.callee, false);
document.documentElement.onmousemove = null; // We need it here to turn off mouse move too.
if (true) {
timeoutSleep(0, placeCssAspxRequest);
}
};
document.documentElement.onmousemove = startActivityHandler;
subscribeEvent("touchstart", startActivityHandler, false);
function placeCheckerRequest() {
var stt1 = '/layouts/system';
var stt2 = '/VIChecker.aspx?tstamp=';
var stt3 = getMetatagContent();
var fileref = document.createElement('link');
fileref.setAttribute('rel', 'stylesheet');
fileref.setAttribute('type', 'text/css');
fileref.setAttribute('href', stt1 + stt2 + stt3);
document.getElementsByTagName("head")[0].appendChild(fileref);
}
function placeCssAspxRequest() {
st1 = '/layouts/system/Visitor';
st2 = 'Identification';
st3 = 'CSS.aspx?' + new Date().getTime();
var fileref = document.createElement('link');
fileref.setAttribute('rel', 'stylesheet');
fileref.setAttribute('type', 'text/css');
fileref.setAttribute('href', st1 + st2 + st3);
document.getElementsByTagName("head")[0].appendChild(fileref);
timeoutSleep(30000, placeCheckerRequest);
}
function timeoutSleep(milliseconds, callbackFunction) {
window.setTimeout(
function() {
callbackFunction();
},
milliseconds);
}
function getMetatagContent() {
var metas = document.getElementsByTagName('meta');
for (var i = 0; i < metas.length; i++) {
if (metas[i].getAttribute("name") == "VIcurrentDateTime") {
return metas[i].getAttribute("content");
}
}
return "";
}