From 61a06f4736e5a6c8fcb34121c9e4719bb4d3a442 Mon Sep 17 00:00:00 2001 From: jjwwcc Date: Tue, 27 Aug 2024 21:03:06 -0700 Subject: [PATCH] Create script.js --- cd/script.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 cd/script.js diff --git a/cd/script.js b/cd/script.js new file mode 100644 index 0000000..6fbbdac --- /dev/null +++ b/cd/script.js @@ -0,0 +1,33 @@ +// 倒计时功能 +function updateCountdown() { + const targetDate = new Date('2027-10-15'); + const today = new Date(); + const timeDifference = targetDate - today; + const daysRemaining = Math.ceil(timeDifference / (1000 * 60 * 60 * 24)); + + document.getElementById('countdown').textContent = `距离大学申请截止日还有 ${daysRemaining} 天`; +} + +// 进度条功能 +function updateProgress(id, valueId) { + const range = document.getElementById(id); + const valueDisplay = document.getElementById(valueId); + + range.addEventListener('input', function () { + valueDisplay.textContent = `${range.value}%`; + localStorage.setItem(id, range.value); + }); + + const storedValue = localStorage.getItem(id); + if (storedValue) { + range.value = storedValue; + valueDisplay.textContent = `${storedValue}%`; + } +} + +document.addEventListener('DOMContentLoaded', function() { + updateCountdown(); + updateProgress('activity1', 'value1'); + updateProgress('activity2', 'value2'); + updateProgress('activity3', 'value3'); +});