<html>
<head>
<title>太空人表盘</title>
<meta charset="UTF-8">
<link href="./assets/css/style.css" rel="stylesheet">
<script src="./assets/js/timeGeneration.js"></script>
</head>
<body>
<div class="jun-meter">
<div class="jun-time-h-h" id="hh"></div>
<div class="jun-time-h-l" id="hl"></div>
<div class="jun-time-rect"></div>
<div class="jun-human"></div>
<div class="jun-time-m-h" id="mh"></div>
<div class="jun-time-m-l" id="ml"></div>
<div class="jun-time-s-h" id="sh"></div>
<div class="jun-time-s-l" id="sl"></div>
<div class="jun-date" id="date"></div>
<div class="jun-calendar-date" id="calendarDate"></div>
</div>
</body>
<script>
function WatchMeter() {
// 初始化dom
this._initDom()
// 更新
this.update()
this.date = new TimeGeneration()
}
// 修改原型
WatchMeter.prototype = {
constructor: WatchMeter,
// 初始化Dom
_initDom: function () {
this.elem = {}
this.elem.hh = document.getElementById('hh')
this.elem.hl = document.getElementById('hl')
this.elem.mh = document.getElementById('mh')
this.elem.ml = document.getElementById('ml')
this.elem.sh = document.getElementById('sh')
this.elem.sl = document.getElementById('sl')
this.elem.date = document.getElementById('date')
this.elem.calendarDate = document.getElementById('calendarDate')
},
// 更新
update: function () {
var _this = this
setInterval(function () {
_this._render(_this.date.getDate(), _this.date.getCalendarDate(), _this.date.getTime())
}, 1000)
},
// 渲染
_render: function (date, calendarDate, time) {
this._setNumberImage(this.elem.hh, time[0])
this._setNumberImage(this.elem.hl, time[1])
this._setNumberImage(this.elem.mh, time[2])
this._setNumberImage(this.elem.ml, time[3])
this._setNumberImage(this.elem.sh, time[4])
this._setNumberImage(this.elem.sl, time[5])
this.elem.date.innerText = date[2] + " " +date[0] + "-" +date[1]
this.elem.calendarDate.innerText = calendarDate
},
// 设置数字图片
_setNumberImage: function (elem, value) {
elem.style.backgroundImage = "url(./assets/img/" + value + ".svg)";
}
}
var myWatchMeter = new WatchMeter()
</script>
</html>
【 JavaScript资源 】基于JavaScript 实现的网红太空人表盘demo
需积分: 0 177 浏览量
更新于2024-04-03
收藏 1.06MB ZIP 举报
这款基于JavaScript的网红太空人表盘是一个充满创意和趣味性的时钟插件。它巧妙地将太空人元素与时钟功能相结合,为用户带来独特的视觉体验。无论是用于个人网页装饰,还是作为项目展示的一部分,这款表盘都能为你的作品增添一份科技感与时尚感。
禾戊之昂
- 粉丝: 3327
- 资源: 45
最新资源
- 5 薪酬结构统计分析表(依据基本信息自动生成).xlsx
- 4 员工工资表-部门薪酬分析.xlsx
- 8 公司工程部人事薪酬分析.xlsx
- 13 公司人力资源薪酬工资统计表.xlsx
- 7 薪酬市场数据统计分析.xlsx
- 9 公司员工薪酬统计分析表.xlsx
- 10 财务分析员工薪酬统计表.xlsx
- 12 财务报表员工薪酬结算.xlsx
- 11 财务报表员工薪酬分析.xlsx
- 15 薪资情况分析表.xlsx
- 14 薪资筹划财务分析表.xlsx
- 18 财务汇报部门历年薪酬统计图表.xlsx
- 16 月度工资支出数据汇总图表.xlsx
- 17财务报告年度工资统计图表1.xlsx
- 20 工资表-部分统计-图表展示.xlsx
- 21 公司部门工资情况汇报图表模板.xlsx