-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimple-Model-View-Controller.js
56 lines (54 loc) · 1.8 KB
/
Simple-Model-View-Controller.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
var hash = window.location.hash.substr(1);
function locationHashChanged() {
var hash = window.location.hash.substr(1);
anchorControler(hash);
}
function anchorControler(hash) {
switch (hash) {
//if hash is #export-validation
case 'export-validation':
var exceptionArray = [
'#export-validation'
];
hideAllExcept(exceptionArray);
break;
//if hash is #simple-search
case "simple-search":
var exceptionArray = [
'#simple-search'
];
hideAllExcept(exceptionArray);
break;
//default and #bulk-search
default:
var exceptionArray = [
'#bulk-search'
];
hideAllExcept(exceptionArray);
}
function hideAllExcept(exceptionObj) {
/**********************************
List all views/divs in results.html
**********************************/
var anchorPages = {
"0": "#bulk-search",
"1": "#simple-search",
"2": "#export-validation",
"3": "#bulk-search-results",
"4": "#simple-search-results"
}
var anchorLenght = Object.keys(anchorPages).length;
var exceptionLenght = Object.keys(exceptionObj).length;
for (var i = 0; i < anchorLenght; i++) {
for (var y = 0; y < exceptionLenght; y++) {
console.log('hello world ' + exceptionObj[y] + ' and ' + anchorPages[i])
if (exceptionObj[y] !== anchorPages[i]) {
$(anchorPages[i]).hide();
} else {
$(exceptionObj[y]).show();
}
}
}
}
}
anchorControler(hash);