Team:Queens-Canada/mobile/animat0r.js

From 2010.igem.org

Revision as of 15:26, 24 October 2010 by Glh (Talk | contribs)

var rate = 1.6; var interval = 40; var smallmode = 0;

var br = '
';

var md = "";

function getElementsByClass(searchClass,node,tag) { var classElements = new Array(); if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } } return classElements; }

function clearButtons() { t1 = document.getElementById('tier0m'); foo = getElementsByClass('t1btnmD', t1, "div"); for(x in foo) { foo[x].className = 't1btnm'; }

foo = getElementsByClass('t1btnlD', t1, "div"); for(x in foo) { foo[x].className = 't1btnl'; }

foo = getElementsByClass('t1btnrD', t1, "div"); for(x in foo) { foo[x].className = 't1btnr'; } }

function setButton(t1i) { clearButtons(); foo = getElementsByClass('t1btnm', t1i, "div"); for(x in foo) { foo[x].className = 't1btnmD'; }

foo = getElementsByClass('t1btnl', t1i, "div"); for(x in foo) { foo[x].className = 't1btnlD'; }

foo = getElementsByClass('t1btnr', t1i, "div"); for(x in foo) { foo[x].className = 't1btnrD'; } }

function showT2(callback) { clearButtons(); t2 = document.getElementById('tier2'); t2b = document.getElementById('tier2b'); if(t2.style.top == '0px') { if(callback) callback(); if(t2b.innerHTML != "") { if(smallmode) { animateOpenSmallT2(null, 0.01); } else { animateOpenT2(null, 0.01); } } } else { animateCloseT2(callback, 0.01); } }

function showSmallT2(callback) { clearButtons(); t2 = document.getElementById('tier2'); if(t2.style.top == '0px') { callback(); animateOpenSmallT2(null, 0.01); } else { animateCloseT2(callback, 0.01); } }

function showPage(page) { clearButtons(); if(page == "sponsors") setButton(document.getElementById('funds')); document.getElementById('the_frame').src = page; animateCloseT2(null, 0.01); }

function mt(name, title) { if(title == null) title = name; return '' + title + ' '; }

function anatomy() { t2 = document.getElementById('tier2b'); t2.innerHTML = br + mt("blood", "blood") + md + mt("digestive", "digestive") + md + mt("nervous", "neuromuscular") + md + mt("skin", "exterior") + md + mt("reproductive", "reproductive"); animateOpenDecide(); setButton(document.getElementById('anatomy')); }

function animateOpenDecide() { t2 = document.getElementById('tier2b'); if(t2.clientHeight > 34) { animateOpenT2(null, 0.01); } else { animateOpenSmallT2(null, 0.01); } }

function genetics() { t2 = document.getElementById('tier2b'); t2.innerHTML = mt("promoter/5' utr") + md + mt("termination", "introns/termination") + md + mt("rnai", "rnai/3' utr") + md + mt("strains"); animateOpenDecide(); setButton(document.getElementById('genetics')); }

function practical() { t2 = document.getElementById('tier2b'); t2.innerHTML = br + mt("transformation") + md + mt("care") + md + mt("miscellaneous"); animateOpenDecide(); setButton(document.getElementById('practical')); }

function context() { t2 = document.getElementById('tier2b'); t2.innerHTML = br + mt("intro", "introduction") + md + mt("history in science") + md + mt("resources", "online resources"); animateOpenDecide(); setButton(document.getElementById('context')); }

function people() { t2 = document.getElementById('tier2b'); t2.innerHTML = br + mt("team") + md + mt("contributors"); animateOpenDecide(); setButton(document.getElementById('people')); }

function biobricks() { t2 = document.getElementById('tier2b'); t2.innerHTML = br + mt("parts", "our bricks") + md + mt("contributing parts"); animateOpenDecide(); setButton(document.getElementById('biobricks')); }

function progress() { t2 = document.getElementById('tier2b'); t2.innerHTML = br + mt("idea", "idea") + md + mt("notebook") + md + mt("safety"); animateOpenDecide(); setButton(document.getElementById('progress')); }

function animateCloseT2(callback, progress) { if((progress == 0) || (!progress)) progress = 0.01; progress = 1 - ((1 - progress) / rate); t2 = document.getElementById('tier2'); if(t2.style.top == '0px') { if(callback != null) callback(); return; } t2b = document.getElementById('tier2b'); if(smallmode) { t2.style.top = (19 - (19 * progress)) + 'px'; } else { t2.style.top = (50 - (50 * progress)) + 'px'; } t2b.style.opacity = 1 - progress;

if(progress > 0.995) { t2b.style.opacity = 0; if(callback != null) callback(); t2.style.top = '0px'; t2.style.height = '49px'; t2.style.bottom = ; } else { setTimeout('animateCloseT2(' + callback + ', ' + progress + ')', interval); } }

function animateOpenT2(progress) { if((progress == 0) || (!progress)) progress = 0.01; progress = 1 - ((1 - progress) / rate); t2 = document.getElementById('tier2'); t2.style.top = (50 * progress) + 'px'; t2b = document.getElementById('tier2b'); t2b.style.opacity = progress; smallmode = 0;

if(progress > 0.995) { t2b.style.opacity = 1; t2.style.top = '50px'; t2.style.height = ; t2.style.bottom = '0px'; } else { setTimeout('animateOpenT2(' + progress + ')', interval); } }

function animateOpenSmallT2(progress) { if((progress == 0) || (!progress)) progress = 0.01; progress = 1 - ((1 - progress) / rate); t2 = document.getElementById('tier2'); t2.style.top = (19 * progress) + 'px'; t2b = document.getElementById('tier2b'); t2b.style.opacity = progress; smallmode = 1;

if(progress > 0.995) { t2b.style.opacity = 1; t2.style.top = '19px'; t2.style.height = ; t2.style.bottom = '0px'; } else { setTimeout('animateOpenSmallT2(' + progress + ')', interval); } }