-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
200 lines (168 loc) · 6.06 KB
/
index.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
function showWeather(identifier) {
var x = document.getElementById("weather-data-" + identifier);
if (x.style.display === "block") {
x.style.display = "none";
} else {
var otherData = document.getElementsByClassName("weather-data");
for (var i = 0; i < otherData.length; i++) {
var weatherData = otherData[i]
weatherData.style.display = "none"
}
x.style.display = "block";
}
var otherData = document.getElementsByClassName("weather-image");
for (var data in otherData) {
if (!isNaN(parseInt(data))) {
var weatherData = otherData[data]
weatherData.style.display = "none"
}
}
var otherData = document.getElementsByClassName("weather-video");
for (var data in otherData) {
if (!isNaN(parseInt(data))) {
var weatherData = otherData[data]
weatherData.style.display = "none"
}
}
var otherData = document.getElementsByClassName("weather-sound");
for (var data in otherData) {
if (!isNaN(parseInt(data))) {
var weatherData = otherData[data]
weatherData.style.display = "none"
}
}
}
function showWork(identifier) {
var x = document.getElementById("work-data-" + identifier);
if (x.style.display === "block") {
x.style.display = "none";
} else {
var otherData = document.getElementsByClassName("work-data");
for (var i = 0; i < otherData.length; i++) {
var weatherData = otherData[i]
weatherData.style.display = "none"
}
x.style.display = "block";
}
}
function showImage(event, identifier) {
var image = document.getElementById("weather-image-" + identifier);
var hyperlink = document.getElementById("image-link-" + identifier);
// var x = event.clientX;
// var y = event.clientY;
// var coords = "X coords: " + x + ", Y coords: " + y;
// document.getElementById("demo").innerHTML = coords;
if (image.style.display === "block") {
image.style.display = "none";
} else {
image.style.display = "block";
image.style.top= event.clientY + 'px'
image.style.left= event.clientX + 'px'
}
return false;
}
function showVideo(event, identifier) {
var video = document.getElementById("weather-video-" + identifier);
var hyperlink = document.getElementById("video-link-" + identifier);
if (video.style.display === "block") {
video.style.display = "none";
} else {
video.style.display = "block";
video.style.top= event.clientY + 'px'
video.style.left= event.clientX + 'px'
}
return false;
}
function showSound(event, identifier) {
var sound = document.getElementById("weather-sound-" + identifier);
var hyperlink = document.getElementById("sound-link-" + identifier);
if (sound.style.display === "block") {
sound.style.display = "none";
sound.pause();
} else {
sound.style.display = "block";
sound.style.top = event.clientY + "px";
sound.style.left = event.clientX + "px";
sound.play();
}
return false;
}
// var container = document.querySelector("#mid");
// var activeItem = null;
// var active = false;
// container.addEventListener("touchstart", dragStart, false);
// container.addEventListener("touchend", dragEnd, false);
// container.addEventListener("touchmove", drag, false);
// container.addEventListener("mousedown", dragStart, false);
// container.addEventListener("mouseup", dragEnd, false);
// container.addEventListener("mousemove", drag, false);
// function dragStart(e) {
// if (e.target !== e.currentTarget) {
// active = true;
// // this is the item we are interacting with
// activeItem = e.target;
// if (activeItem !== null) {
// if (!activeItem.xOffset) {
// activeItem.xOffset = 0;
// }
// if (!activeItem.yOffset) {
// activeItem.yOffset = 0;
// }
// if (e.type === "touchstart") {
// activeItem.initialX = e.touches[0].clientX - activeItem.xOffset;
// activeItem.initialY = e.touches[0].clientY - activeItem.yOffset;
// } else {
// console.log("doing something!");
// activeItem.initialX = e.clientX - activeItem.xOffset;
// activeItem.initialY = e.clientY - activeItem.yOffset;
// }
// }
// }
// }
// function dragEnd(e) {
// if (activeItem !== null) {
// activeItem.initialX = activeItem.currentX;
// activeItem.initialY = activeItem.currentY;
// }
// active = false;
// activeItem = null;
// }
// function drag(e) {
// if (active) {
// if (e.type === "touchmove") {
// e.preventDefault();
// activeItem.currentX = e.touches[0].clientX - activeItem.initialX;
// activeItem.currentY = e.touches[0].clientY - activeItem.initialY;
// } else {
// activeItem.currentX = e.clientX - activeItem.initialX;
// activeItem.currentY = e.clientY - activeItem.initialY;
// }
// activeItem.xOffset = activeItem.currentX;
// activeItem.yOffset = activeItem.currentY;
// setTranslate(activeItem.currentX, activeItem.currentY, activeItem);
// }
// }
// function setTranslate(xPos, yPos, el) {
// el.style.transform = "translate3d(" + xPos + "px, " + yPos + "px, 0)";
// }
// window.onload=function(){
// var allLinks = document.getElementsByClassName("image-link");
// for (var i = 0; i < allLinks.length; i++) {
// allLinks[i].addEventListener('click', function (e) {
// var rect = e.target.getBoundingClientRect();
// var x = e.clientX - rect.left; //x position within the element.
// // var images = document.getElementsByClassName("weather-image");
// // for (var i = 0; i < images.length; i++) {
// // var leftPosition = images[i].style.left;
// // var slice = parseInt(leftPosition.slice(0,leftPosition.length - 2))
// // images[i].style.left = (slice + x) + 'px'
// // }
// // var videos = document.getElementsByClassName("weather-video");
// // for (var i = 0; i < videos.length; i++) {
// // var leftPosition = videos[i].style.left;
// // var slice = parseInt(leftPosition.slice(0,leftPosition.length - 2))
// // videos[i].style.left = (slice + x) + 'px'
// // }
// });
// }
// }