-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmyscript.js
More file actions
179 lines (157 loc) · 5.23 KB
/
Copy pathmyscript.js
File metadata and controls
179 lines (157 loc) · 5.23 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
$(document).ready(function(){
// Add smooth scrolling to all links in navbar + footer link
$(".navbar a, footer a[href='#myPage']").on('click', function(event) {
// Make sure this.hash has a value before overriding default behavior
if (this.hash !== "") {
// Prevent default anchor click behavior
event.preventDefault();
// Store hash
var hash = this.hash;
// Using jQuery's animate() method to add smooth page scroll
// The optional number (900) specifies the number of milliseconds it takes to scroll to the specified area
$('html, body').animate({
scrollTop: $(hash).offset().top
}, 900, function(){
// Add hash (#) to URL when done scrolling (default click behavior)
window.location.hash = hash;
});
} // End if
});
// Get the modal
var modal = document.getElementById('myModal');
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks on <span> (x), close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
//The first two statement slide in
$(".fastanim").each(function(){
$(this).addClass("slide1");
});
$(window).scroll(function() {
$(".slideanim").each(function(){
var pos = $(this).offset().top;
var winTop = $(window).scrollTop();
if (pos < winTop + 600) {
$(this).addClass("slide1");
}
});
});
})
//(document.getElementsByClassName("page")).click(locateMe());
function locateMe(){
var loc = location.pathname.substring(location.pathname.lastIndexOf("/")+1);
switch(loc){
case "index.html":
checkCookie(1);
break;
case "page2.html":
checkCookie(2);
break;
case "page3.html":
checkCookie(3);
break;
case "page4.html":
checkCookie(4);
break;
case "page5.html":
checkCookie(5);
break;
case "page6.html":
checkCookie(6);
break;
case "page7.html":
checkCookie(7);
break;
case "default":
alert("No Such page exist");
break;
}
}
function setCookie(cname,cvalue,exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*60*60*1000));//exdays= number of hours for cookie to be expires
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie =decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) ==' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
function checkCookie(level) {
var prior = getCookie("currentlevel");
if(prior != ""){
if(level>prior){
setCookie("currentlevel",level,0.5);
}
}else{
setCookie("currentlevel",level,0.5);
}
};
function checkcurrentlevel(){
var level=parseInt(getCookie("currentlevel"));
alert(level);
for (var i = level + 1; i >= 1; i--) {
if(i>=8){continue;}
var ID = "p"+i;
document.getElementById(ID).classList.remove("unable");
};
alert("loop");
for (var j = level + 1; j <=7 ; j++) {
var ID2 = "pa"+j;
var ID3 = "pb"+j;
document.getElementById(ID2).style.cursor="not-allowed";
document.getElementById(ID3).style.cursor="not-allowed";
document.getElementById(ID2).removeAttribute('href');
document.getElementById(ID3).removeAttribute('href');
};
}
/*
var css= 'a:focus,a:hover{text-decoration:none }';
var style = document.createElement('style');
if(style.styleSheet){
style.styleSheet.cssText=css;
}else{
style.appendChild(document.createTextNode(css));
}
for (var j = 3; j <=7 ; j++) {
var ID2 = "pa"+j;
var ID3 = "pb"+j;
document.getElementById(ID2).removeAttribute('href');
document.getElementById(ID2).style.cursor="default";
//document.getElementById(ID2).getElementsByTagName('a').appendChild(style);
document.getElementById(ID3).removeAttribute('href');
document.getElementById(ID3).style.cursor="default";
//document.getElementById(ID3).getElementsByTagName('a').appendChild(style);
};
*/
//document.getElementById("p2").removeAttribute('href');
/*
$(window).scroll(function() {
$(".slideanim").each(function(){
var pos = $(this).offset().top;
var winTop = $(window).scrollTop();
if (pos < winTop + 600) {
$(this).addClass("slide1");
}
});
});
*/