-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScript.js
59 lines (52 loc) · 1.65 KB
/
Script.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
var lb = null;
var gsplits = null
var gLBread = false;
var myDoc;
var inter;
function doSelect(that,values) {
//does the final selection on a listbox
that.Data.SelectTexts(values);
}
function hashChanged(hashVal) {
sSelector = hashVal.substr(1) //remove #
var splits = sSelector.split("=") //split by = as in LB01=A;B;C
gsplits = splits[1].split(";") //split right side by ; as in A;B;C => A, B, C
var intervalFunc = function() {
if (gLBread == true) { //check read flag for true
doSelect(lb, gsplits) //call selection method
gLBread = false; //set flag back to false
} else { //check for flag was false
window.setTimeout(intervalFunc,50) //try again in 50 ms
}
}
if (!lb) { //no reference to the LB yet?
gLBread = false;
lb = myDoc.GetObject(splits[0], function() { //get the LB object asynch
gLBread = true //set flag when object available
});
window.setTimeout(intervalFunc,1) //set timeout to be asynch as well
} else { //have already the LB obj?
intervalFunc(); //directly call handler
}
}
Qva.AddDocumentExtension('silentSelect', function() {
myDoc = Qv.GetCurrentDocument()
if ("onhashchange" in window) { // event supported?
window.onhashchange = function () { //set event handler
hashChanged(window.location.hash); //handle event
}
}
else { // event not supported:
var storedHash = window.location.hash;
window.setInterval(function () {
if (window.location.hash != storedHash) {
storedHash = window.location.hash;
hashChanged(storedHash);
}
}, 100);
}
if (window.location.hash) {
//initially handle the hash parameters of the url
hashChanged(window.location.hash);
}
})