-
Notifications
You must be signed in to change notification settings - Fork 0
/
javascript.js
77 lines (77 loc) · 3.2 KB
/
javascript.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
74
75
76
77
function QuickLinks(){
var innerHTMLC = "";
//Disable the below line if you want a custom sort
categories.sort();
//Loop through each category and make the appropriate links and div elements
for(categories_num = 0;categories_num<categories.length;categories_num++){
//alert('<div class="menu" id="header'+categories_num+'"><div class="menutitle">');
innerHTMLC = innerHTMLC.concat('<div class="menu" id="header'+categories_num+'"><div class="menutitle">');
innerHTMLC = innerHTMLC.concat(categories[categories_num]);
innerHTMLC = innerHTMLC.concat('</div><div class="ispacer"></div><div class="menucontent">');
key_list=keys(links[categories[categories_num]]).sort();
var i = 0;
for(x in links[categories[categories_num]]){
innerHTMLC = innerHTMLC.concat('<a class="speed" href=');
innerHTMLC = innerHTMLC.concat(links[categories[categories_num]][key_list[i]]);
innerHTMLC = innerHTMLC.concat('>');
innerHTMLC = innerHTMLC.concat(key_list[i]);
innerHTMLC = innerHTMLC.concat('</a>');
innerHTMLC = innerHTMLC.concat();
i++;
}
innerHTMLC = innerHTMLC.concat('</div></div>');
//Make each category have it's own style sheet, makes browsers render faster (less DOM crawling)
innerHTMLC = innerHTMLC.concat('<style>#header'+categories_num+':hover .menucontent{display:block;}</style>');
//Add the new menu to the DOM tree
document.getElementById("container").innerHTML = document.getElementById("container").innerHTML.concat(innerHTMLC);
innerHTMLC="";
}
}
function search_DOM(){
//Creates the search engine layout
var innerHTMLC = "";
//Disable the below line if you want a custom sort
//search_categories.sort();
//Loop through each category and make the appropriate links and div elements
for(categories_num = 0;categories_num<search_categories.length;categories_num++){
key_list=keys(search[search_categories[categories_num]]);
//Enable the below to sort searches
//key_list=keys(search[search_categories[categories_num]]).sort();
var i = 0;
for(x in search[search_categories[categories_num]]){
innerHTMLC = innerHTMLC.concat('<form method="get" action="');
innerHTMLC = innerHTMLC.concat(search[search_categories[categories_num]][key_list[i]]);
if(i==0){
innerHTMLC = innerHTMLC.concat('" > <input type="search" autofocus name="q" placeholder="');
}else{
innerHTMLC = innerHTMLC.concat('" > <input type="search" name="q" placeholder="');
}
innerHTMLC = innerHTMLC.concat(key_list[i]);
innerHTMLC = innerHTMLC.concat('" /> </form>');
i++;
//Add the new searches to the DOM tree
document.getElementById("search").innerHTML = innerHTMLC;
}
}
}
function addValues(){
//Scrolls through the DOM tree and adds target='_blank'
var alist = document.getElementsByTagName("a");
for (i = 0; i <= alist.length-1; i++){
alist[i].target="_blank";
}
var alist = document.getElementsByTagName("form");
for (i = 0; i <= alist.length-1; i++){
alist[i].target="_blank";
}
}
function keys(obj){
//Takes the object and finds the keys.
var keys = [];
for(var key in obj){
if(obj.hasOwnProperty(key)) {
keys.push(key);
}
}
return keys;
}