-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
103 lines (88 loc) · 3.22 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
<html>
<head>
<style>
*{
margin:0;
padding:0;
}
table {
border: none;
}
</style>
</head>
<body bgcolor="#000000">
<div id="demo"></div>
<script>
var link;
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
linkobj = JSON.parse(this.responseText);
document.getElementById("demo").innerHTML = generateIframe();
//console.log(linkobj[linkobj.findIndex(i => i.id === "0")].link);
}
};
var urlParams = new URLSearchParams(window.location.search);
if ( urlParams.has('type') ) {
xmlhttp.open("GET", urlParams.get('type').concat(".json"), true);
} else {
xmlhttp.open("GET", "new_weather_link_test.json", true);
}
xmlhttp.send();
function generateIframe() {
if ( urlParams.has('view') ) {
var view = urlParams.get('view');
} else {
var view = "9x";
}
if ( urlParams.has('top') ) {
var top = urlParams.get('top');
var toplink = linkobj[top].link;
linkobj[top].link = linkobj[0].link;
linkobj[0].link = toplink;
}
if (isNaN(view)) {
var text = "";
var viewwidth = 3;
var viewheight = 3;
var percentheight = 100 / viewheight;
var percentwidth = 100 / viewwidth;
var widthd = 2 * percentwidth;
var no = 0;
text += "<table style=\"width: 100%; height: 100%\" cellspacing=\"0\" cellpadding=\"0\">"
text += "<tr><td colspan=\"2\" rowspan=\"2\" style=\"width: " + widthd + "%; height: " + widthd + "%\">"
text += "<iframe style=\"height: 100%; width: 100%\" src=\"" + linkobj[linkobj.findIndex(i => i.id === no.toString())].link + "\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe></td>";
for (no = 1; no < 3; no++) {
text += "<td style=\"height: " + percentwidth + "%; width: " + percentwidth + "%\"><iframe style=\"height: 100%; width: 100%\" src=\"" + linkobj[linkobj.findIndex(i => i.id === no.toString())].link + "\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe></td>";
text += "</tr><tr>";
}
for (no = 3; no < 6; no++) {
text += "<td style=\"height: " + percentwidth + "%; width: " + percentwidth + "%\"><iframe style=\"height: 100%; width: 100%\" src=\"" + linkobj[linkobj.findIndex(i => i.id === no.toString())].link + "\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe></td>";
}
text += "</tr></table>";
} else {
var viewwidth = Math.ceil(Math.sqrt(view));
var viewheight = Math.ceil(view / viewwidth);
var percentheight = 100 / viewheight;
var percentwidth = 100 / viewwidth;
var text = "";
var i;
var j;
var no;
for (i = 0; i < viewheight; i++){
for (j = 0; j < viewwidth; j++) {
no = viewwidth * i + j;
if (no < view) {
text += "<iframe style=\"height: " + percentheight + "%; width: " + percentwidth + "%\" src=\"" + linkobj[linkobj.findIndex(i => i.id === no.toString())].link + "\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen></iframe>"
}
}
if (i < viewheight - 1) {
text += "<br>";
}
}
}
return text;
}
</script>
</body>
</html>