Created
March 22, 2013 06:32
-
-
Save iberianpig/5219408 to your computer and use it in GitHub Desktop.
現在の画面にタイマーを表示するのブックマークレット。デフォルト設定値は25分。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:var s=prompt('Please type XXmin (defalt is 25 min)',''); if(!s){s=25*60}else{s=s*60;} var r=s;var bar='';var Rate=30; function displayTimer(){bar='';for(i=Math.floor(s/Rate);i>0;i--){bar+='|';}bar='<font color="green">'+bar.substr(0,Math.floor(r/Rate))+'</font><font color="#c0c0c0">'+bar.substr(Math.floor(r/Rate),s)+'</font>'; document.getElementById('dtimer').innerHTML='TIME: ' + r-- + ' sec'+'<br>'+bar; if(r==0){ alert("Time Up!!"); document.getElementById('dclose').style.display='none'; document.getElementById('dtimer').style.display='none'; } } function delchild(elm){(elm.parentNode||elm.parentElement).removeChild(elm); }window.scroll(0,0); var dup=false; if(document.getElementById('dtimer')){delchild(document.getElementById('dtimer')); delchild(document.getElementById('dclose'));dup=true; }var clk=document.createElement('div'); if(document.all){var vwidth=document.body.clientWidth; }else{var vwidth='100%'; }document.body.insertBefore(clk,document.body.firstChild); clk.setAttribute('id','dtimer'); with(clk.style){ width='100%'; height='100%'; fontSize='60px'; padding='100px 0px 0px 0px'; textAlign='center'; opacity=0.8; filter='alpha(opacity=80)'; zIndex=998; backgroundColor='white'; position='absolute'; left=0; top=0; }var cls=document.createElement('div'); if(document.all){cls.innerHTML='<a href=\'\'>X</a>'; }else{cls.innerHTML='<a href=\'\'>X</a> '; }if(cls.attachEvent){cls.attachEvent('onclick',function(){document.getElementById('dclose').style.display='none'; document.getElementById('dtimer').style.display='none'; return false; }); }else{cls.addEventListener('click',function(event){document.getElementById('dclose').style.display='none'; document.getElementById('dtimer').style.display='none';r=0; event.preventDefault(); },false); }document.body.insertBefore(cls,document.body.firstChild); cls.setAttribute('id','dclose'); with(cls.style){ width='100%'; height='50px'; fontSize='30px'; textAlign='right'; zIndex=999; position='absolute'; }if(dup==false&&r>0){setInterval(displayTimer,1000)}else{clearInterval(0)} void(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment