This repository has been archived by the owner on Nov 8, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
scripts.js
177 lines (147 loc) · 5.73 KB
/
scripts.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
// JavaScript Document
var TimeToFade = 500.0;
var navSlideshowPics = new Array("/images/Slideshow/slideshow1.png","/images/Slideshow/slideshow2.png","/images/Slideshow/slideshow3.png","/images/Slideshow/slideshow4.png","/images/Slideshow/slideshow5.png");
var footerSlideshowPics = new Array("/images/Slideshow/slideshow1.png","/images/Slideshow/slideshow2.png","/images/Slideshow/slideshow3.png","/images/Slideshow/slideshow4.png","/images/Slideshow/slideshow5.png");
var navTimer = new Timer(4000, "navSlideshow.slide()");
var footerTimer = new Timer(10000, "footerSlideshow.slide()");
var navSlideshow = new Slideshow("navTimer", "headerimg1", navSlideshowPics, false, "");
var footerSlideshow = new Slideshow("footerTimer", "footer", footerSlideshowPics, false, "");
function load() {
if (true) {
navTimer.fire();
//footerTimer.fire();
}
//articleSelect('Join the MPArors at our <i>FIRST</i> competition','/images/Regional.png','/Competition','article1');
}
function redirect(input) {
window.location = input;
}
//Timer Code
function Timer (interval, command) {
this.interval = interval;
this.fire = function() {
//Function to call
setTimeout(command,this.interval);
};
this.rearm = function() {
//Function to call
this.fire();
};
}
////////////////////
///Slideshow Code///
////////////////////
function Slideshow (timer, frame, files, buttons, buttonId) {
this.frame = frame;
this.files = files;
this.totalSlides = this.files.length-1;
this.timer = timer;
this.currentSlide = 0;
this.buttons = buttons;
this.buttonGroup = buttonId;
this.slide = function() {
//Fade the slide
this.currentSlide++;
if (this.currentSlide > this.totalSlides) {
this.currentSlide = 0;
}
//console.log(this.currentSlide);
setTimeout(this.timer+".rearm()",1);
command = "document.getElementById('"+this.frame+"').style.background = 'url("+this.files[this.currentSlide]+")'";
commandTwo = "fade('"+this.frame+"')";
fade(this.frame);
setTimeout(command,500);
setTimeout(commandTwo,500);
};
}
//Interactive Code
function interactiveArrow(idPrefix,targetSlide,currentSlide) {
document.getElementById(idPrefix+currentSlide).style.display = "none";
document.getElementById(idPrefix+targetSlide).style.display = "block";
}
////////////////////
//System Functions//
////////////////////
function delay(command, time) {
setTimeout(command, time);
}
function fade(eid) {
var element = document.getElementById(eid);
if(element == null)
return;
if(element.FadeState == null) {
if(element.style.opacity == null
|| element.style.opacity == ''
|| element.style.opacity == '1') {
element.FadeState = 2;
}
else {
element.FadeState = -2;
}
}
if(element.FadeState == 1 || element.FadeState == -1) {
element.FadeState = element.FadeState == 1 ? -1 : 1;
element.FadeTimeLeft = TimeToFade - element.FadeTimeLeft;
}
else {
element.FadeState = element.FadeState == 2 ? -1 : 1;
element.FadeTimeLeft = TimeToFade;
setTimeout("animateFade(" + new Date().getTime() + ",'" + eid + "')", 33);
}
}
function animateFade(lastTick, eid) {
var curTick = new Date().getTime();
var elapsedTicks = curTick - lastTick;
var element = document.getElementById(eid);
if(element.FadeTimeLeft <= elapsedTicks) {
element.style.opacity = element.FadeState == 1 ? '1' : '0';
element.style.filter = 'alpha(opacity = '
+ (element.FadeState == 1 ? '100' : '0') + ')';
element.FadeState = element.FadeState == 1 ? 2 : -2;
return;
}
element.FadeTimeLeft -= elapsedTicks;
var newOpVal = element.FadeTimeLeft/TimeToFade;
if(element.FadeState == 1)
newOpVal = 1 - newOpVal;
element.style.opacity = newOpVal;
element.style.filter = 'alpha(opacity = ' + (newOpVal*100) + ')';
setTimeout("animateFade(" + curTick + ",'" + eid + "')", 33);
}
function switchvideo(video) {
if (video == 1) {
document.getElementById('video2').style.display = 'none';
//document.getElementById('video2').src = 'http://www.youtube.com/embed/vYuOKb3gO7E';
document.getElementById('video1').style.display = "block";
video2.videoembed2.pause();
}
if (video == 2) {
document.getElementById('video1').style.display = 'none';
document.getElementById('video2').style.display = "block";
//document.getElementById('video1').src = 'http://www.youtube.com/embed/i1QyM9WTF18';
video1.videoembed1.pause();
}
}
function boxClose() {
document.getElementById('box').style.display = 'none';
document.getElementById('box').style.width = 0;
document.getElementById('box').style.height = 0;
//document.getElementById('video1').src = 'http://www.youtube.com/embed/i1QyM9WTF18';
//document.getElementById('video2').src = 'http://www.youtube.com/embed/vYuOKb3gO7E';
video1.videoembed1.pause();
video2.videoembed2.pause();
}
function articleSelect(articleText, articleImage, articleLink, articleId) {
document.getElementById('article1').style.background = "";
document.getElementById('article2').style.background = "";
document.getElementById('article3').style.background = "";
document.getElementById('article4').style.background = "";
document.getElementById('article5').style.background = "";
document.getElementById('article6').style.background = "";
document.getElementById('article7').style.background = "";
document.getElementById('article8').style.background = "";
document.getElementById('articleText').innerHTML = articleText;
document.getElementById('newsFeed').style.background = 'url("'+articleImage+'")';
document.getElementById('articleLink').href = articleLink;
document.getElementById(articleId).style.background = '#78A600';
}