1 Star 0 Fork 2

墨趣/node-paper-calendar

forked from lamber/node-paper-calendar 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
index.html 3.28 KB
一键复制 编辑 原始数据 按行查看 历史
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<title>Calendar</title>
<style type="text/css">
body {
margin:0;
padding:0;
}
.frm {
margin:0;
position:fixed;
left:50%;
top:50%;
}
img {
margin:0;
position:absolute;
left:0;
top:0;
width:100%;
height:100%;
display:block;
border:none;
}
.frm.rotate {
transform: rotate(90deg);
-webkit-transform: rotate(90deg);
}
</style>
</head>
<body>
<div id="frm" class="frm"></div>
</body>
<script type="text/javascript">
function getQuery () {
var q = {};
var s = document.location.href.split('?');
if (s.length < 2) {
return {};
}
s = s[1].split('&');
var i, k, t;
for (i = 0; i < s.length; i ++) {
t = s[i].split('=');
if (t.length === 2) {
q[t[0]] = t[1];
}
}
return q;
}
function refresh(){
var imgElement = document.getElementById('frm');
var srcUrl = '/calendar?t=' + Math.random();
var query = getQuery();
var width = document.documentElement.clientWidth;
var height = document.documentElement.clientHeight;
if (width < height) {
query.width = height;
query.height = width;
imgElement.className = 'frm rotate';
imgElement.style.marginLeft = '-' + parseInt(height / 2) + 'px';
imgElement.style.marginTop = '-' + parseInt(width / 2) + 'px';
imgElement.style.width = height + 'px';
imgElement.style.height = width + 'px';
} else {
query.width = width;
query.height = height;
imgElement.className = 'frm';
imgElement.style.marginLeft = '-' + parseInt(width / 2) + 'px';
imgElement.style.marginTop = '-' + parseInt(height / 2) + 'px';
imgElement.style.width = width + 'px';
imgElement.style.height = height + 'px';
}
var k;
for (k in query) {
srcUrl += '&' + k + '=' + query[k];
}
var img = new Image();
img.onload = function () {
imgElement.innerHTML = '';
imgElement.appendChild(img);
setTimeout(function(){
refresh();
}, ('interval' in query) ? parseInt(query.interval) : 1800000);
};
img.onerror = function () {
setTimeout(function(){
refresh();
}, 3000);
};
img.src = srcUrl;
}
refresh();
// 每半天刷新一次页面,避免设备浏览器内存占用过大
setTimeout(function(){
document.location.reload();
}, 3600000 * 12)
</script>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/ink-interest/node-paper-calendar.git
git@gitee.com:ink-interest/node-paper-calendar.git
ink-interest
node-paper-calendar
node-paper-calendar
master

搜索帮助