-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathindex.min.js
1 lines (1 loc) · 2.21 KB
/
index.min.js
1
"use strict";var domApp=document.querySelector(".app");var domTime=document.querySelector(".time");var domDate=document.querySelector(".date");var domCnDate=document.querySelector(".cn-date");function geturl(url){var arr=url.split("?");if(!arr[1]){return{}}var res=arr[1].split("&");var items={};for(var i=0;i<res.length;i++){var a=res[i].split("=");items[a[0]]=a[1]}return items}function formatDate(date){var fmt=arguments.length>1&&arguments[1]!==undefined?arguments[1]:"yyyy-MM-dd";if(!date){return""}if(typeof date==="number"||typeof date==="string"){date=new Date(Number(date))}var o={"M+":date.getMonth()+1,"d+":date.getDate(),"h+":date.getHours(),"m+":date.getMinutes(),"s+":date.getSeconds(),"q+":Math.floor((date.getMonth()+3)/3),S:date.getMilliseconds()};if(/(y+)/.test(fmt))fmt=fmt.replace(RegExp.$1,"".concat(date.getFullYear()).substr(4-RegExp.$1.length));for(var k in o)if(new RegExp("(".concat(k,")")).test(fmt))fmt=fmt.replace(RegExp.$1,RegExp.$1.length===1?o[k]:"00".concat(o[k]).substr("".concat(o[k]).length));return fmt}function render(){var time=new Date();var len=time.getTime();var offset=time.getTimezoneOffset()*60000;var utcTime=len+offset;var date=new Date(utcTime+3600000*8);var lunar=calendar.solar2lunar(date.getUTCFullYear(),date.getUTCMonth()+1,date.getUTCDate());var dateText="".concat(formatDate(date,"yyyy.M.d")," ").concat(urlQuery.l=="en"?["SUN","MON","TUES","WED","THUR","FRI","SAT"][date.getDay()]:"星期"+["日","一","二","三","四","五","六"][date.getDay()]);var timeText="".concat(date.getHours(),":").concat(date.getMinutes());var cnDateText="".concat(lunar.IMonthCn).concat(lunar.IDayCn," ").concat(lunar.Animal,"\u5E74");if(domDate.innerHTML!=dateText)domDate.innerHTML=dateText;if(domTime.innerHTML!=timeText)domTime.innerHTML=timeText;if(domCnDate.innerHTML!=cnDateText)domCnDate.innerHTML=cnDateText}var urlQuery=geturl(location.href);var config={fontSize:+(urlQuery.fs||7),rotate:urlQuery.r,lang:urlQuery.l};domTime.style.fontSize=config.fontSize+"rem";domDate.style.fontSize=config.fontSize/2.5+"rem";domCnDate.style.fontSize=config.fontSize/4+"rem";domApp.style.cssText="-webkit-transform: rotate(".concat(config.rotate||0,"deg) translate3d(-50%,-50%,0)");render();setInterval(function(){render()},1000);