1+ < html lang ="zh ">
2+ < head >
3+ < title > 主页日历钟-20250915</ title >
4+ < meta charset ="utf-8 ">
5+
6+ < meta name ="applicable-device " content ="pc,mobile ">
7+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
8+ < meta http-equiv ="Content-Type " content ="text/html;charset=utf-8 ">
9+
10+ < script src ="calendar.js "> </ script >
11+ </ head >
12+
13+ < body style ="text-align: center ">
14+
15+ < div class ="a-nav item " id ='clock '>
16+ < div class ="aclass " style ="width: 100%;height: 80%; "> </ div >
17+ < div >
18+ < object style ="border:0;margin-top:0 " type ="text/x-scriptlet " id ='clock_obj ' data ="white_clock.html "
19+ width ="90% " height ="80% ">
20+ </ object >
21+ < div id ="showHistory " style ="margin-top:0 ">
22+ < span id ="clockText " style ="color: #34b1ff;font-size: 12px;letter-spacing: 0; "> </ span >
23+ < span id ="workdayText " style ="color: #ff9044;font-size: 18px;letter-spacing: 1px; "> </ span >
24+ </ div >
25+ </ div >
26+ </ div >
27+
28+
29+ < script >
30+ function darkModeHandler ( ) {
31+ const mediaQuery = window . matchMedia ( '(prefers-color-scheme: dark)' ) ;
32+ if ( mediaQuery . matches ) {
33+ document . body . style . background = '#1b1b1b' ;
34+ }
35+ }
36+
37+ function showDate ( ) {
38+ let dNow = new Date ( ) ;
39+ let dYear = dNow . getFullYear ( ) ;
40+ let dMonth = dNow . getMonth ( ) + 1 ;
41+ let dDay = dNow . getDate ( ) ;
42+ let date_obj = calendar . solar2lunar ( dYear , dMonth , dDay ) ;
43+ let lValue = dYear + "年" + dMonth + "月" + dDay + "日 " + date_obj . ncWeek + " " + date_obj . gzYear + date_obj . Animal + "年 " + date_obj . IMonthCn + date_obj . IDayCn ;
44+ console . log ( lValue ) ;
45+ return lValue ;
46+ }
47+
48+ function getNowFormatDate ( ) {
49+ let date = new Date ( ) ;
50+ let seperator1 = "-" ;
51+ let seperator2 = ":" ;
52+ let month = date . getMonth ( ) + 1 ;
53+ let strDate = date . getDate ( ) ;
54+ let strHours = date . getHours ( ) ;
55+ let strMinutes = date . getMinutes ( ) ;
56+ let strSeconds = date . getSeconds ( ) + 1 ;
57+ if ( month >= 1 && month <= 9 ) {
58+ month = "0" + month
59+ }
60+ if ( strDate >= 0 && strDate <= 9 ) {
61+ strDate = "0" + strDate
62+ }
63+ if ( strHours >= 0 && strHours <= 9 ) {
64+ strHours = "0" + strHours
65+ }
66+ if ( strMinutes >= 0 && strMinutes <= 9 ) {
67+ strMinutes = "0" + strMinutes
68+ }
69+ if ( strSeconds >= 0 && strSeconds <= 9 ) {
70+ strSeconds = "0" + strSeconds
71+ }
72+ let current_date = date . getFullYear ( ) + seperator1 + month + seperator1 + strDate + " " + strHours + seperator2 + strMinutes + seperator2 + strSeconds ;
73+ console . log ( `current date: ${ current_date } ` ) ;
74+ return current_date
75+ }
76+
77+ function init_clock ( ) {
78+ let data = showDate ( ) ;
79+ document . getElementById ( 'clockText' ) . textContent = data . substring ( 5 , data . length ) ;
80+ setInterval ( function ( ) {
81+ let time = getNowFormatDate ( ) ;
82+ document . getElementById ( 'workdayText' ) . textContent = time . split ( " " ) [ 1 ] ;
83+ } , 1000 ) ;
84+ }
85+
86+ document . addEventListener ( 'DOMContentLoaded' , function ( ) {
87+ darkModeHandler ( ) ;
88+ init_clock ( ) ;
89+ } ) ;
90+
91+ </ script >
92+
93+ </ body >
94+
95+ < style >
96+ .a-nav {
97+ position : relative;
98+ }
99+
100+ .aclass {
101+ position : absolute;
102+ z-index : 999 ;
103+ }
104+ </ style >
105+
106+ </ html >
0 commit comments