-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexscript.js
231 lines (173 loc) · 6.98 KB
/
indexscript.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
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
var links = document.querySelectorAll(".link");
var linklist = Array.from(links);
var currentpg;
var menu = document.getElementById("menu");
var backbutton = document.getElementById("back");
var nextbutton = document.getElementById("next");
var skrb = document.getElementById("skrb");
var thms = document.querySelectorAll(".artthm");
var thmlist = Array.from(thms);
var drops = document.querySelectorAll(".drop");
var droplist = Array.from(drops);
let timeoutover = true; //timeout for the scroll so ur computer doesn't crash
function retimer(){
timeoutover = true;
}
function isvisible(check){ //checks for visible
if (check.classList.contains("vis")){
return true;
}else if (check.classList.contains("invis")){
return false;
}
}
function hide(object){ //hides
object.classList.replace("vis", "invis");
}
function reveal(object){ //reveals
object.classList.replace("invis", "vis");
}
function mobilehidemenu() {
if (window.innerWidth > 600){
menu.classList = "vis"
}else{
menu.classList = "invis"
}
}
function highlightpage() {
if (timeoutover == false){
return;
}else{
timeoutover = false;
setTimeout(retimer, 100);
if (scrollY < window.innerHeight){ //top of the page nothing in the menu is highlighted
for (i=0; i < linklist.length; i++){
linklist[i].classList.replace("current", "notcurrent");
}
} else if(scrollY > window.innerHeight && scrollY < window.innerHeight * 1.6){ //about page is at 1xviewport
for (i=0; i < linklist.length; i++){
linklist[i].classList.replace("current", "notcurrent");
}
linklist[0].classList.replace("notcurrent", "current");
}else if(scrollY > window.innerHeight * 1.6 && scrollY < window.innerHeight * 2.6){ //recent page is at 1.6xviewport
for (i=0; i < linklist.length; i++){
linklist[i].classList.replace("current", "notcurrent");
}
linklist[1].classList.replace("notcurrent", "current");
}else if(scrollY > window.innerHeight * 2.6 && scrollY < window.innerHeight * 4.6){ //art page is at 2.6xviewport
for (i=0; i < linklist.length; i++){
linklist[i].classList.replace("current", "notcurrent");
}
linklist[2].classList.replace("notcurrent", "current");
}else if(scrollY > window.innerHeight * 4.6 && scrollY < document.body.scrollHeight - window.innerHeight * 1.1){ //insta page is at 4.6xviewport
for (i=0; i < linklist.length; i++){
linklist[i].classList.replace("current", "notcurrent");
}
linklist[3].classList.replace("notcurrent", "current");
}else if(scrollY > document.body.scrollHeight - window.innerHeight * 1.1){ //contact page is 1.1 viewport up
for (i=0; i < linklist.length; i++){
linklist[i].classList.replace("current", "notcurrent");
}
linklist[4].classList.replace("notcurrent", "current");
}
}
}
function closedrop() { //loop hide all descriptions
for (i = 0; i < droplist.length; i++) {
hide(droplist[i]);
}
hide(backbutton);
hide(nextbutton);
hide(skrb);
}
function opendesc(thingie) { //reveal description of the box u clicked on
var whichthm = thmlist.indexOf(thingie);
var bigimgs = droplist[whichthm].getElementsByClassName("bigimg"); //expanding the first thmnail
var thmnail = droplist[whichthm].getElementsByClassName("descimg");
bigimgs[0].src = thmnail[0].src;
reveal(droplist[whichthm]);
reveal(backbutton);
reveal(nextbutton);
reveal(skrb);
}
function bac(){
var currentvisdesc = undefined
for (j = 0; j <droplist.length; j++) { //checking which desc isvisible
if ( isvisible(droplist[j]) == true) {
currentvisdesc = j; //storing it
}
}
nextvisdesc = currentvisdesc - 1; //setting previous desc
if (nextvisdesc < 0){ //on the first desc, previous desc is the last desc.....
nextvisdesc = droplist.length -1;
}
hide(droplist[currentvisdesc]);
reveal(droplist[nextvisdesc]);
var bigimgs = droplist[nextvisdesc].getElementsByClassName("bigimg");
var thmnails = droplist[nextvisdesc].getElementsByClassName("descimg");
if (droplist[nextvisdesc].classList.contains("haspdf") == true) //if there's a pdf
{
reveal(droplist[nextvisdesc].querySelector(".window")); //show pdf not bigimg
hide(droplist[nextvisdesc].querySelector(".bigimg"))
}
else{
bigimgs[0].src = thmnails[0].src; //otherwise expand the first thmnail
}
}
function nex(){
var currentvisdesc = undefined
for (j = 0; j <droplist.length; j++) { //checking which desc isvisible
if ( isvisible(droplist[j]) == true) {
currentvisdesc = j; //storing it
}
}
nextvisdesc = currentvisdesc + 1; //setting next desc
if (nextvisdesc >= droplist.length){ //on the last desc, next desc is the first desc.....
nextvisdesc = 0;
}
hide(droplist[currentvisdesc]);
reveal(droplist[nextvisdesc]);
var bigimgs = droplist[nextvisdesc].getElementsByClassName("bigimg");
var thmnails = droplist[nextvisdesc].getElementsByClassName("descimg");
if (droplist[nextvisdesc].classList.contains("haspdf") == true) //if there's a pdf
{
reveal(droplist[nextvisdesc].querySelector(".window")); //show pdf not bigimg
hide(droplist[nextvisdesc].querySelector(".bigimg"))
}
else{
bigimgs[0].src = thmnails[0].src; //otherwise expand the first thmnail
}
}
function enlarge(frog) { //enlarges thumbnails
var newimgsrc = frog.src;
var bois = document.getElementsByClassName("bigimg");
var pdfs = document.getElementsByClassName("window");
if (frog.classList.contains("pdfthm") == true){ //if thumbnail is tagged as pdf
for (k=0; k<pdfs.length; k++) { //show all pdf windows
reveal(pdfs[k]);
}
for (j=0; j<bois.length; j++) { //hide all bigimg
hide(bois[j]);
}
}else{ //if thumbanil is not tagged as pdf
for (h=0; h<pdfs.length; h++) { //hide all pdf windows
hide(pdfs[h]);
}
for (k=0; k<bois.length; k++) { //show all bigimg
reveal(bois[k]);
bois[k].src = newimgsrc; //choose which bigimg to show
}
}
}
function enlargerec(thumbnail) { //enlarges thumbnails of recent section
var newimgsrc = thumbnail.src;
var recimg = document.getElementById("bigimgrec");
var recpdf = document.getElementById("windowrec");
if (thumbnail.classList.contains("pdfthm") == true){ //if thumbnail is tagged as pdf
reveal(recpdf); //hides img and shows pdf
hide(recimg);
}else{
hide(recpdf); //hides pdf and shows img
reveal(recimg);
recimg.src = newimgsrc; //choose which bigimg to show
}
}