Farmer Against Potatoes Idle攻略メモ
javascript練習用ページ
最終更新:
potatoidle
-
view
管理人がjavascriptの練習をするページ
@Wikiの仕様によりjavascriptを入れたページは管理者以外編集できません
@Wikiの仕様によりjavascriptを入れたページは管理者以外編集できません
マルチプレイヤー用のタイマーを作ってみるテストをしています
document.write(古の記述らしい)
#javascript(){{ document.write("hello"); }}
表示↓
ページを開いた時の時刻表示
#javascript(){{ const now = new Date(); const hh = now.getHours().toString().padStart(2, '0'); // 時 const mm = now.getMinutes().toString().padStart(2, '0'); // 分 const ss = now.getSeconds().toString().padStart(2, '0'); // 秒 document.write(`現在時刻 ${hh}:${mm}:${ss}`); }}
表示↓
単純なカウントダウン
&html(<div id="countdown">60</div>) #javascript(){{ let remaining = 60; // 初期値(秒) const countdownEl = document.getElementById("countdown"); const timer = setInterval(() => { countdownEl.textContent = remaining + " 秒"; remaining--; if (remaining < 0) { clearInterval(timer); countdownEl.textContent = "時間切れ!"; } }, 1000); // 1000ms = 1秒ごとに更新 }}
表示↓
60
マルチプレイヤー
開催状況を表示
タイマーを表示
変数名が他の所と被った場合にエラーが出ていた
javascriptプラグインの記述を分けていても内部的にはまとめて実行されている可能性がある
javascriptプラグインの記述を分けていても内部的にはまとめて実行されている可能性がある