あのタイムリミットカウンター

テンプレート変動型
http://shitake-crude-production.wikidot.com/javascript:devil/code/1

<html>
<head>
<style type="text/css">
@import url(http://scp-jp.wdfiles.com/local--files/japanese-syntax/scp-WikidotCss.css);
 
body {
  padding:0px;
  margin: 0px;
  height:1em;
background-color:transparent;
}
</style>
<script type="text/javascript">
var base;
 document.addEventListener( 'DOMContentLoaded',function() {
space = document.getElementById("page-content");
var time = decodeURI(window.location.href.split("#")[1]);
var year = time.substring(0,4);
var month = time.substring(4,6);
var day = time.substring(6,8);
var hour = time.substring(8,10);
var min = time.substring(10,12);
base = new Date(year+'-'+month+'-'+day+' '+hour+':'+min+':00').getTime();
getTime();});
function getTime(){
var today = new Date().getTime();
var late = today-base;
var pretype="";
var type = "経過";
if(late < 0){
late *= -1;
pretype="残り";
type = "";
}
var lsec = Math.floor(late/1000);
var lmin = Math.floor(lsec/60);
var lhour = Math.floor(lmin/60);
var lday = Math.floor(lhour/24);
 
var output = addDigit(lsec%60) + ""+type;
if(lmin > 0){
output = addDigit(lmin%60)+"分"+output;
if(lhour > 0){
output = addDigit(lhour%24)+"時間"+output;
if( lday > 0){
output = lday+"日"+output;
}
}
}
document.getElementById("page-content").innerHTML = pretype+output;
setTimeout(function(){getTime();},50);
function addDigit(num){
var strNum = String(num);
if(strNum.length < 2){
strNum = "0"+strNum;
}
return strNum;
}
 
}
</script>
</head>
<body>
<div id="page-content">
</div>
</body>
</html>

例:
基準日付: 2017年08月05日22時06分

[[iframe http://shitake-crude-production.wikidot.com/javascript:devil/code/1#201708052206 width="300" height="50" scrolling="no"]]

テンプレート固定型
http://shitake-crude-production.wikidot.com/javascript:devil/code/2

<html>
<head>
<style type="text/css">
@import url(http://scp-jp.wdfiles.com/local--files/japanese-syntax/scp-WikidotCss.css);
 
body {
  padding:0px;
  margin: 0px;
  height:1em;
background-color:transparent;
}
</style>
<script type="text/javascript">
var base;
 document.addEventListener( 'DOMContentLoaded',function() {
space = document.getElementById("page-content");
var time = decodeURI(window.location.href.split("#")[1]);
var year = time.substring(0,4);
var month = time.substring(4,6);
var day = time.substring(6,8);
var hour = time.substring(8,10);
var min = time.substring(10,12);
base = new Date(year+'-'+month+'-'+day+' '+hour+':'+min+':00').getTime();
getTime();});
function getTime(){
var today = new Date().getTime();
var late = today-base;
var pretype="";
var type = "経過";
if(late < 0){
late *= -1;
pretype="残り";
type = "";
}
 
var lsec = Math.floor(late/1000);
var lmin = Math.floor(lsec/60);
var lhour = Math.floor(lmin/60);
var lday = Math.floor(lhour/24);
 
var output = addDigit(lsec%60) + ""+type;
output = addDigit(lmin%60)+""+output;
output = addDigit(lhour%24)+"時間"+output;
output = lday+""+output;
 
document.getElementById("page-content").innerHTML = pretype+output;
setTimeout(function(){getTime();},50);
function addDigit(num){
var strNum = String(num);
if(strNum.length < 2){
strNum = "0"+strNum;
}
return strNum;
}
 
}
</script>
</head>
<body>
<div id="page-content">
</div>
</body>
</html>

基準日付: 2017年08月05日22時06分

[[iframe http://shitake-crude-production.wikidot.com/javascript:devil/code/2#201708052206 width="300" height="50" scrolling="no"]]




テンプレート固定型
http://shitake-crude-production.wikidot.com/javascript:devil/code/2

<html>
<head>
<style type="text/css">
@import url(http://scp-jp.wdfiles.com/local--files/japanese-syntax/scp-WikidotCss.css);
 
body {
  padding:0px;
  margin: 0px;
  height:1em;
background-color:transparent;
}
</style>
<script type="text/javascript">
var base;
var limit;
 document.addEventListener( 'DOMContentLoaded',function() {
space = document.getElementById("page-content");
var time = decodeURI(window.location.href.split("#")[1]);
var year = time.substring(0,4);
var month = time.substring(4,6);
var day = time.substring(6,8);
var hour = time.substring(8,10);
var min = time.substring(10,12);
base = new Date(year+'-'+month+'-'+day+' '+hour+':'+min+':00').getTime();
year = time.substring(12,16);
month = time.substring(16,18);
day = time.substring(18,20);
hour = time.substring(20,22);
min = time.substring(22,24);
limit = new Date(year+'-'+month+'-'+day+' '+hour+':'+min+':00').getTime();
limit -= base;
getTime();});
 
function getTime(){
var today = new Date().getTime();
today -= base;
 
var persentNum = Math.floor((today/limit)*10000) ;
persentNum /= 100;
if(persentNum > 100)persentNum = 100;
var persent = persentNum + "%";
 
document.getElementById("page-content").innerHTML = persent;
setTimeout(function(){getTime();},50);
 
}
</script>
</head>
<body>
<div id="page-content">
</div>
</body>
</html>

基準日付: 2017年07月05日22時06分
100%になる日: 2018年08月05日22時06分

[[iframe http://shitake-crude-production.wikidot.com/javascript:devil/code/3#201707052206201808052206 width="300" height="50" scrolling="no"]]

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License