ひけー!ひけー!
Table of Contents
|
ノーマルフォント(分まで表示)
<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; } </style> <script type="text/javascript"> var space window.onload=function(){space = document.getElementById("page-content");getTime();} function getTime(){ var date = new Date(); space.innerHTML = date.getFullYear() + "/" + addDigit((date.getMonth()+1)) + "/" + date.getDate() + " " + addDigit(date.getHours()) + ":" + addDigit(date.getMinutes()); setTimeout(getTime,300); 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>
サンプル: です
[[iframe http://shitake-crude-production.wikidot.com/javascript:timeviewer/code/1 width="120" scrolling="no"]]
ノーマルフォント(秒まで表示)
<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; } </style> <script type="text/javascript"> var space window.onload=function(){space = document.getElementById("page-content");getTime();} function getTime(){ var date = new Date(); space.innerHTML = date.getFullYear() + "/" + addDigit((date.getMonth()+1)) + "/" + date.getDate() + " " + addDigit(date.getHours()) + ":" + addDigit(date.getMinutes()) + " " + addDigit(date.getSeconds()); setTimeout(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>
サンプル:
[[iframe http://shitake-crude-production.wikidot.com/local--code/javascript:timeviewer/2 width="130" scrolling="no"]]
h1(分まで表示)
<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; } h1{padding:0px; margin:0px;} </style> <script type="text/javascript"> var space window.onload=function(){space = document.getElementById("view");getTime();} function getTime(){ var date = new Date(); space.innerHTML = date.getFullYear() + "/" + addDigit((date.getMonth()+1)) + "/" + date.getDate() + " " + addDigit(date.getHours()) + ":" + addDigit(date.getMinutes()); setTimeout(getTime,50); function addDigit(num){ var strNum = String(num); if(strNum.length < 2)strNum = "0" + strNum; return strNum; } } </script> </head> <body> <h1 id="view"></h1> </body> </html>
サンプル:
[[iframe http://shitake-crude-production.wikidot.com/local--code/javascript:timeviewer/3 width="230" height="25" scrolling="no"]]
h1(秒まで表示)
<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; } h1{padding:0px; margin:0px;} </style> <script type="text/javascript"> var space window.onload=function(){space = document.getElementById("view");getTime();} function getTime(){ var date = new Date(); space.innerHTML = date.getFullYear() + "/" + addDigit((date.getMonth()+1)) + "/" + date.getDate() + " " + addDigit(date.getHours()) + ":" + addDigit(date.getMinutes()) + " " + addDigit(date.getSeconds()); setTimeout(getTime,50); function addDigit(num){ var strNum = String(num); if(strNum.length < 2)strNum = "0" + strNum; return strNum; } } </script> </head> <body> <h1 id="view"></h1> </body> </html>
サンプル:
[[iframe http://shitake-crude-production.wikidot.com/local--code/javascript:timeviewer/3 width="260" height="25" scrolling="no"]]
太字(分まで表示)
<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; } b{padding:0px; margin:0px;} </style> <script type="text/javascript"> var space window.onload=function(){space = document.getElementById("view");getTime();} function getTime(){ var date = new Date(); space.innerHTML = date.getFullYear() + "/" + addDigit((date.getMonth()+1)) + "/" + date.getDate() + " " + addDigit(date.getHours()) + ":" + addDigit(date.getMinutes()); setTimeout(getTime,50); function addDigit(num){ var strNum = String(num); if(strNum.length < 2)strNum = "0" + strNum; return strNum; } } </script> </head> <body> <b id="view"></b> </body> </html>
サンプル:
[[iframe http://shitake-crude-production.wikidot.com/local--code/javascript:timeviewer/5 width="140" height="16" scrolling="no"]]
太字(秒まで表示)
<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; } b{padding:0px; margin:0px;} </style> <script type="text/javascript"> var space window.onload=function(){space = document.getElementById("view");getTime();} function getTime(){ var date = new Date(); space.innerHTML = date.getFullYear() + "/" + addDigit((date.getMonth()+1)) + "/" + date.getDate() + " " + addDigit(date.getHours()) + ":" + addDigit(date.getMinutes()) + " " + addDigit(date.getSeconds()); setTimeout(getTime,50); function addDigit(num){ var strNum = String(num); if(strNum.length < 2)strNum = "0" + strNum; return strNum; } } </script> </head> <body> <b id="view"></b> </body> </html>
サンプル:
[[iframe http://shitake-crude-production.wikidot.com/local--code/javascript:timeviewer/6 width="160" hegiht="16" scrolling="no"]]
iframe位置調整用div
.normalFontTime iframe{ display:inline-block; height:1em; bottom:0px; margin:0px; } .normalFontTime p{ padding:0px; }
[[module css]]
@import url(http://shitake-crude-production.wikidot.com/local--code/javascript:timeviewer/7);
[[/module]]
var space
window.onload=function(){
space = document.getElementById("page-content");
getTime();
}
- 変数"space"を宣言
- 変数"space"は
- onloadイベント(ページ読み込み時に発火)
- ドキュメント要素"page-content"を取得
- 関数"getTime()"を起動
function getTime(){
var date = new Date();
space.innerHTML = date.getFullYear() + "/" + addDigit((date.getMonth()+1)) + "/" + date.getDate() + " " + addDigit(date.getHours()) + ":" + addDigit(date.getMinutes());
setTimeout(getTime,300);
function addDigit(num){
var strNum = String(num);
if(strNum.length < 2)strNum = "0" + strNum;
return strNum;
}
}
- 関数"getTime()"は
- 変数"date"を宣言、内容を関数"new Date()"に初期化
- 変数"space"にhtmlで要素を出力、内容は
- "date.getFullYear()"等の、定義が要らないメソッド
- 文字列"/"、ダブルクオーテーションで囲われている
- 関数"addDigit(num)"を起動し、
- 変数"strNum"を宣言、内容を"String(num)"に初期化