0
私はこのスクリプトをインターネット上で見つけました。私はそれを非常に理解したいと思います。私は否定的な票を得るかもしれないことを知っていますが、現在の世界人口、特にスクリプトで選択された値とこれらの値のそれぞれの背後にある理由を見積もるには私は何か助けていただければ幸いです。特定のjavascript機能の背後にあるコンセプトを把握する
<body>
<script type="text/javascript">
function maind() {
startdate = new Date()
now(startdate.getYear(), startdate.getMonth(), startdate.getDate(), startdate.getHours(), startdate.getMinutes(), startdate.getSeconds())
}
function ChangeValue(number, pv) {
numberstring = ""
var j = 0
var i = 0
while (number > 1) {
numberstring = (Math.round(number - 0.5) % 10) + numberstring
number = number/10
j++
if (number > 1 && j == 3) {
numberstring = "," + numberstring
j = 0
}
i++
}
numberstring = numberstring
if (pv == 1) {
document.getElementById("worldpop").innerHTML = numberstring
}
}
function now(year, month, date, hours, minutes, seconds) {
startdatum = new Date(year, month, date, hours, minutes, seconds)
var now = 5600000000.0
var now2 = 5690000000.0
var groeipercentage = (now2 - now)/now * 100
var groeiperseconde = (now * (groeipercentage/100))/365.0/24.0/60.0/60.0
nu = new Date()
schuldstartdatum = new Date(96, 1, 1)
secondenoppagina = (nu.getTime() - startdatum.getTime())/1000
totaleschuld = (nu.getTime() - schuldstartdatum.getTime())/1000 * groeiperseconde + now
ChangeValue(totaleschuld, 1);
timerID = setTimeout("now(startdatum.getYear(),startdatum.getMonth(),startdatum.getDate(),startdatum.getHours(),startdatum.getMinutes(),startdatum.getSeconds())", 200)
}
window.onload = maind
</script>
Current world population (estimated): <span id="worldpop" style="font-weight: bold"></span>.
</body>
これはあまり書かれていないJavaScriptのチャンクです。あなたはそれについて何を正確に理解していないのですか? – georg
@georg日付やvar now、var now2 ...のような静的な値を選択してください。あなたが気づいているより良い既存のスクリプトを提案できるなら、それを感謝します。 – mikeb
本書は、「1996年1月1日の初めに、年間9,000,000人の成長が予想される5,600,000,000人がいた。それから1秒あたりの成長を計算し、200ミリ秒ごとに世界人口のおよその価値を示す」 – devnull69