-
Notifications
You must be signed in to change notification settings - Fork 36
/
index.html
103 lines (103 loc) · 3.28 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<!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>