-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
57 lines (45 loc) · 1.36 KB
/
script.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
var footer = document.getElementById("foot01");
if (footer !== null){
document.getElementById("foot01").innerHTML =
"<p>© " + new Date().getFullYear() + " Stephen Akerson. All rights reserved.</p>";
}
document.getElementById("nav01").innerHTML =
"<ul id='menu'>" +
"<li><a href='index.html'>Home</a></li>" +
"<li><a href='countries.html'>Countries</a></li>" +
"<li><a href='about.html'>About</a></li>" +
"</ul>";
var images = {
base: "images/",
yosemite:{
base: "yosemite/",
pics: ["snow_bros.JPG", "stephen_mustache.JPG", "tim_snowpack.JPG"]
},
tahoe:{
base: "tahoe/",
pics: ["tahoe_cove.JPG"]
}
};
var yosemiteImgIndex = 0;
function destination(location){
return document.getElementById(location);
}
function baseImageUrl(destination){
return images.base + images[destination].base;
}
function imgSetter(location, imgIndex){
domElement = destination(location);
domElement.src = baseImageUrl(location) + images[location].pics[imgIndex];
}
function imgChanger(){
yosemiteImgIndex++;
if (yosemiteImgIndex % images.yosemite.pics.length === 0){
yosemiteImgIndex = 0;
}
imgSetter('yosemite', yosemiteImgIndex);
}
imgSetter('yosemite', yosemiteImgIndex);
document.getElementById("yosemite").addEventListener('click', imgChanger);
document.getElementById("yosemiteBlog").onclick = function () {
location.href = "yosemite.html";
};