soltioxの日記: javascript
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title>連投お助けタイマー</title>
<META http-equiv="Content-Script-Type" content="text/javascript">
<META http-equiv="Content-Style-Type" content="text/css">
<STYLE type="text/css">
<!--
span {
color: black;
background-color: forestgreen;
border-color: forestgreen;
border-style: outset;
border-width: 3px;
padding: 0;
}
-->
</STYLE>
<script type="text/javascript">
<!--
function SetFirst(id){
document.getElementById(id).style.backgroundColor="limegreen";
document.getElementById(id).style.borderColor="limegreen";
document.getElementById(id).style.color="darkgreen";
}
function SetInd(id){
document.getElementById(id).style.backgroundColor="gold";
document.getElementById(id).style.borderColor="gold";
document.getElementById(id).style.color="white";
}
function ResetInd(id){
document.getElementById(id).style.backgroundColor="forestgreen";
document.getElementById(id).style.borderColor="forestgreen";
document.getElementById(id).style.color="black";
}
function ResetAll(){
for (i=0; i<11; i++){
ResetInd("s"+i);
}
}
function ChkSet(){
intNextSpan = 0;
for (i=1; i<11; i++){
if (document.getElementById("s"+i).style.color=="black"){
intNextSpan = i;
break;
}
}
return intNextSpan;
}
function CountStart(){
intInit = parseInt(document.getElementById("txtinit").value) * 1000;
ResetAll();
SetFirst("s0");
setTimeout("CountFirst()",intInit);
}
function CountFirst(){
intCount = parseInt(document.getElementById("txtcount").value) * 100;
SetInd("s0");
setTimeout("CountTime(intCount)",intCount);
}
function CountTime(intCount){
intInd = ChkSet();
SetInd("s"+intInd);
if (intInd > 0){
setTimeout("CountTime(intCount)",intCount);
}
}
//-->
</script>
</head>
<body>
<p>
<span id="s0">00</span>
<span id="s1">01</span>
<span id="s2">02</span>
<span id="s3">03</span>
<span id="s4">04</span>
<span id="s5">05</span>
<span id="s6">06</span>
<span id="s7">07</span>
<span id="s8">08</span>
<span id="s9">09</span>
<span id="s10">10</span>
</p>
<form>
init:
<input type="text" name="txtinit" id="txtinit"
value="10" size="5" maxlenght="3">
/ count:
<input type="text" name="txtcount" id="txtcount"
value="60" size="5" maxlenght="3">
<input type="button" name="btnstart" value="start" onClick="CountStart()">
<input type="button" name="btnreset" value="reset" onClick="ResetAll()">
</form>
"init"は、送信受付までの時間(秒)。<br>
適当に入れといてくだしあ。<br>
"count"は、連投規制時間(秒)。<br>
板毎に違うので注意。<br>
計時完了前に"reset"クリックすると、<br>
ひたすら計時し続けるので注意。<br>
うざかったら、[f5]で止まります。<br>
</body>
</html>
2ちゃんで手動連投する時のタイマー。設定時間はsetting.txtとか見れば分かるんじゃないかな。
拡張子が"html"のテキストファイルにコピペって、ブラウザで開いて使います。
関数名でちまちま分けずに、でっかい無名関数の中で、イベントのプロパティを見分けて処理分岐するのが、jsの流儀なのかも?
ちなみに、規制時間60secはbbspinkの設定 …… げふんげふん
javascript More ログイン