Team:UCLA/Template/Javascript

From 2014.igem.org

(Difference between revisions)
Line 1: Line 1:
<html>
<html>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
 +
 +
<!--TOP NAVIGATION MENU BAR-->
<script type="text/javascript">
<script type="text/javascript">
$(document).ready(function() {
$(document).ready(function() {
Line 12: Line 14:
});
});
</script>
</script>
 +
 +
 +
<!--SIDE SPIDER ANIMATION-->
 +
<script type="text/javascript">
 +
//rotator - delay, children
 +
(function( $ ){
 +
$.fn.rotator = function(delay, time, child){
 +
//set curImage val
 +
var currImg = 0;
 +
var currIt = true;
 +
//set array of images
 +
var ss = $(this).children(child);
 +
var ssize = ss.size();
 +
var startTime = new Date().getTime();
 +
var interval = setInterval(function() {
 +
if(currIt){
 +
$(ss[currImg]).css('opacity','1');
 +
currIt = !currIt;
 +
}else if (!currIt){
 +
                $(ss[currImg]).css('opacity','0');
 +
$(ss[currImg+1]).css('opacity','1');
 +
currIt = !currIt;
 +
currImg++;
 +
}
 +
//reset
 +
if(currImg >= ssize){
 +
currImg = 0;
 +
$(ss[currImg]).css('opacity','1');
 +
}
 +
if(new Date().getTime() - startTime > time){
 +
clearInterval(interval);
 +
return;
 +
}
 +
}, delay);
 +
return this;
 +
};
 +
})(jQuery);
 +
 +
 +
$(document).ready(function(){
 +
$("#down").click(function() {
 +
$("#spider").rotator(50, 1000, 'img');
 +
$("#spider").animate({
 +
"top": "+=100px"
 +
}, 1000);
 +
});
 +
$("#up").click(function() {
 +
$("#spider").rotator(50, 1000, 'img');
 +
$("#spider").animate({
 +
"top": "-=100px"
 +
}, 1000);
 +
});
 +
});
 +
</script>
 +
 +
</html>
</html>

Revision as of 00:18, 19 July 2014