Last change
on this file since 24930 was 24930, checked in by sjm84, 12 years ago |
Added in a place to put functions that can potentially be useful anywhere in the Greenstone Javascript code
|
File size:
1.2 KB
|
Line | |
---|
1 | gs.functions = new Array();
|
---|
2 |
|
---|
3 | gs.functions.ajaxRequest = function()
|
---|
4 | {
|
---|
5 | var activexmodes=["Msxml2.XMLHTTP", "Microsoft.XMLHTTP"];
|
---|
6 | if(window.ActiveXObject)
|
---|
7 | {
|
---|
8 | for (var i=0; i<activexmodes.length; i++)
|
---|
9 | {
|
---|
10 | try
|
---|
11 | {
|
---|
12 | return new ActiveXObject(activexmodes[i]);
|
---|
13 | }
|
---|
14 | catch(e){}
|
---|
15 | }
|
---|
16 | }
|
---|
17 | else if (window.XMLHttpRequest)
|
---|
18 | {
|
---|
19 | return new XMLHttpRequest();
|
---|
20 | }
|
---|
21 | else
|
---|
22 | {
|
---|
23 | return false
|
---|
24 | }
|
---|
25 | }
|
---|
26 |
|
---|
27 | gs.functions.makeToggle = function(buttons, divs)
|
---|
28 | {
|
---|
29 | var buttonArray = (buttons.length) ? buttons : [buttons];
|
---|
30 | var divArray = (divs.length) ? divs : [divs];
|
---|
31 |
|
---|
32 | for(var i = 0; i < buttonArray.length; i++)
|
---|
33 | {
|
---|
34 | buttonArray[i].onclick = function()
|
---|
35 | {
|
---|
36 | for(var j = 0; j < divArray.length; j++)
|
---|
37 | {
|
---|
38 | if(divArray[j].style.display == "none")
|
---|
39 | {
|
---|
40 | divArray[j].style.display = "block";
|
---|
41 | }
|
---|
42 | else
|
---|
43 | {
|
---|
44 | divArray[j].style.display = "none";
|
---|
45 | }
|
---|
46 | }
|
---|
47 |
|
---|
48 | for(var j = 0; j < buttonArray.length; j++)
|
---|
49 | {
|
---|
50 | if(buttonArray[j].getAttribute("src") == gs.imageURLs.collapse)
|
---|
51 | {
|
---|
52 | buttonArray[j].setAttribute("src", gs.imageURLs.expand);
|
---|
53 | }
|
---|
54 | else if(buttonArray[j].getAttribute("src") == gs.imageURLs.expand)
|
---|
55 | {
|
---|
56 | buttonArray[j].setAttribute("src", gs.imageURLs.collapse);
|
---|
57 | }
|
---|
58 | }
|
---|
59 | };
|
---|
60 | }
|
---|
61 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.