Team:SYSU-China/animat.js

From 2013.igem.org

(Difference between revisions)
 
(64 intermediate revisions not shown)
Line 1: Line 1:
 +
    addressUrl = window.location.href;
 +
  if (addressUrl.indexOf("Project") > 0 ) {
 +
          img_left=new Image();
 +
          img_left.src="https://static.igem.org/mediawiki/2013/e/e1/WIKI-MASCOT-RUNNING-LEFT-GREEN.gif" ;
 +
          img_right=new Image();
 +
          img_right.src="https://static.igem.org/mediawiki/2013/7/78/WIKI-MASCOT-RUNNING-RIGHT-GREEN.gif" ;
 +
} else if (addressUrl.indexOf("Judging") > 0 ){
 +
          img_left=new Image();
 +
          img_left.src="https://static.igem.org/mediawiki/2013/d/dd/WIKI-MASCOT-RUNNING-LEFT-RED.gif" ;
 +
          img_right=new Image();
 +
          img_right.src="https://static.igem.org/mediawiki/2013/4/41/WIKI-MASCOT-RUNNING-RIGHT-RED.gif" ;
 +
} else if (addressUrl.indexOf("Safety") > 0 ){
 +
          img_left=new Image();
 +
          img_left.src="https://static.igem.org/mediawiki/2013/8/84/WIKI-MASCOT-RUNNING-LEFT-BLUE.gif" ;
 +
          img_right=new Image();
 +
          img_right.src="https://static.igem.org/mediawiki/2013/5/54/WIKI-MASCOT-RUNNING-RIGHT-BLUE.gif" ;   
 +
} else if (addressUrl.indexOf("Notebook") > 0 ){
 +
          img_left=new Image();
 +
          img_left.src="https://static.igem.org/mediawiki/2013/9/9d/WIKI-MASCOT-RUNNING-LEFT-BRONE.gif" ;
 +
          img_right=new Image();
 +
          img_right.src="https://static.igem.org/mediawiki/2013/a/a2/WIKI-MASCOT-RUNNING-RIGHT-BRONE.gif" ;   
 +
} else if (addressUrl.indexOf("China/Team") > 0 ){
 +
          img_left=new Image();
 +
          img_left.src="https://static.igem.org/mediawiki/2013/1/17/WIKI-MASCOT-RUNNING-LEFT-ORANGE.gif" ;
 +
          img_right=new Image();
 +
          img_right.src="https://static.igem.org/mediawiki/2013/f/f7/WIKI-MASCOT-RUNNING-RIGHT-ORANGE.gif" ;   
 +
} else {   
 +
        img_left=new Image();
 +
        img_left.src="https://static.igem.org/mediawiki/2013/3/32/WIKI-MASCOT-RUNNING-LEFT.gif" ;
 +
        img_right=new Image();
 +
        img_right.src="https://static.igem.org/mediawiki/2013/6/6b/WIKI-MASCOT-RUNNING-RIGHT.gif" ;
 +
    };
$(document).ready(function(){
$(document).ready(function(){
var plength=0;
var plength=0;
var target=$("li.column");
var target=$("li.column");
var img=$("#animat span");
var img=$("#animat span");
-
var mid=img.offset().left + img.width()/2;
+
var mid=img.offset().left + img.width()/2 - parseInt(img.css("left"));
-
        $("#animat span img").attr({"src" : "https://static.igem.org/mediawiki/2013/4/44/WIKI-MASCOT-STAND.png"});
+
target.mouseenter(function(){
-
target.mouseenter(function(){
+
var length=$(this).offset().left + $(this).width()/2 - mid;
var length=$(this).offset().left + $(this).width()/2 - mid;
  img.stop();
  img.stop();
  if(length > plength) {
  if(length > plength) {
-
  $("#animat span img").attr({"src" : "https://static.igem.org/mediawiki/2013/6/6b/WIKI-MASCOT-RUNNING-RIGHT.gif"});    
+
  $("#animat span img").attr({"src" : img_right.src});    
  } else {
  } else {
-
  $("#animat span img").attr({"src" : "https://static.igem.org/mediawiki/2013/3/32/WIKI-MASCOT-RUNNING-LEFT.gif"});   
+
  $("#animat span img").attr({"src" : img_left.src});   
  }
  }
  plength=length;
  plength=length;
Line 22: Line 53:
   
   
});
});
-
var win_width = $(window).width()/2 - $("#address").width()/2;
 
-
$("#address").css("left",win_width);
 
});
});

Latest revision as of 17:27, 28 September 2013

    addressUrl = window.location.href;
 if (addressUrl.indexOf("Project") > 0 ) {
         img_left=new Image();
         img_left.src="WIKI-MASCOT-RUNNING-LEFT-GREEN.gif" ;
         img_right=new Image();
         img_right.src="WIKI-MASCOT-RUNNING-RIGHT-GREEN.gif" ;	

} else if (addressUrl.indexOf("Judging") > 0 ){

         img_left=new Image();
         img_left.src="WIKI-MASCOT-RUNNING-LEFT-RED.gif" ;
         img_right=new Image();
         img_right.src="WIKI-MASCOT-RUNNING-RIGHT-RED.gif" ;	

} else if (addressUrl.indexOf("Safety") > 0 ){

         img_left=new Image();
         img_left.src="WIKI-MASCOT-RUNNING-LEFT-BLUE.gif" ;
         img_right=new Image();
         img_right.src="WIKI-MASCOT-RUNNING-RIGHT-BLUE.gif" ;     

} else if (addressUrl.indexOf("Notebook") > 0 ){

         img_left=new Image();
         img_left.src="WIKI-MASCOT-RUNNING-LEFT-BRONE.gif" ;
         img_right=new Image();
         img_right.src="WIKI-MASCOT-RUNNING-RIGHT-BRONE.gif" ;     

} else if (addressUrl.indexOf("China/Team") > 0 ){

         img_left=new Image();
         img_left.src="WIKI-MASCOT-RUNNING-LEFT-ORANGE.gif" ;
         img_right=new Image();
         img_right.src="WIKI-MASCOT-RUNNING-RIGHT-ORANGE.gif" ;     

} else {

       img_left=new Image();
       img_left.src="WIKI-MASCOT-RUNNING-LEFT.gif" ;
       img_right=new Image();
       img_right.src="WIKI-MASCOT-RUNNING-RIGHT.gif" ;	
    }; 

$(document).ready(function(){ var plength=0; var target=$("li.column"); var img=$("#animat span"); var mid=img.offset().left + img.width()/2 - parseInt(img.css("left"));

	target.mouseenter(function(){

var length=$(this).offset().left + $(this).width()/2 - mid; img.stop(); if(length > plength) { $("#animat span img").attr({"src" : img_right.src}); } else { $("#animat span img").attr({"src" : img_left.src}); } plength=length; img.animate( {left:length}, 500, function(){ $("#animat span img").attr({"src" : "WIKI-MASCOT-STAND.png"});} );

}); });