-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathdevicetester.html
279 lines (266 loc) · 8.85 KB
/
devicetester.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9" >
<title>Magaka Device tester</title>
<style>
html,body {
width:100%;
height:100%;
}
BODY {
background-image:url('libs/wood.jpg');
}
#topbox {
position:absolute;
right:10px;
top:10px;
background-color:#000000;
padding:10px;
margin-bottom:20px;
color:#ffffff;
font-family:Helvetica;
line-height:45px;
font-size:12px;
-moz-box-shadow: 0px 0px 20px #ffffff;
-webkit-box-shadow: 0px 0px 20px #ffffff;
box-shadow: 0px 0px 20px #ffffff;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
width:600px;
-webkit-user-select:none;
-moz-user-select:none;
}
.optionbox {
position:absolute;
right:10px;
top:10px;
border:2px solid #ffffff;
height:20px;
width:20px;
line-height:20px;
padding:0px;
margin:0px;
text-align:center;
background-color:#ffffff;
color:#000000;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
font-size:20px;
cursor:pointer;
-moz-box-shadow: 0px 0px 5px #ffffff;
-webkit-box-shadow: 0px 0px 5px #ffffff;
box-shadow: 0px 0px 5px #ffffff;
}
.blackbox {
right:20px;
top:20px;
border:2px solid #000000;
background-color:#000000;
-moz-box-shadow: 0px 0px 5px #000000;
-webkit-box-shadow: 0px 0px 5px #000000;
box-shadow: 0px 0px 5px #000000;
color:#ffffff;
}
#topbox INPUT {
border:0px;
font-size:12px;
padding:5px;
margin:0px;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
}
</style>
</head>
<body onload="init()">
<div class="optionbox blackbox" id="openbox" onclick="document.getElementById('topbox').style.display='block'">+</div>
<div id="topbox">
<div class="optionbox" id="closebox" onclick="document.getElementById('topbox').style.display='none'">×</div>
URL: <br><input id="pageurl" type='text' value='' style='width:580px' onchange="gotohome()"><br>
<input type='button' value='Turn' onclick='turn()'> <span id="selector"></span> <span id="current"></span> <input type='button' value='Home' onclick='gotohome()'> <input type='button' value='Tools' onclick='gototools()'> <input type='button' value='Index' onclick='gotoindex()'> <input type='button' value='Refresh' onclick='gotorefresh()'><br>
<input type='button' value='Turn' onclick='turnsizes()'>
Width: <input type="text" id="pwidth" style="width:50px" onchange="resizedisplay()">
Height: <input type="text" id="pheight" style="width:50px" onchange="resizedisplay()">
Topmargin: <input type="text" id="ptopmargin" style="width:50px" onchange="resizedisplay()">
Bottommargin: <input type="text" id="pbottommargin" style="width:50px" onchange="resizedisplay()">
<span id="orient"></span>
</div>
<div id="display" style="background-color:white;border:20px solid black;-moz-border-radius: 20px;border-radius: 15px;-moz-box-shadow: 5px 5px 5px rgba(0,0,0,0.5);-webkit-box-shadow: 5px 5px 5px rgba(0,0,0,0.5);box-shadow: 5px 5px 5px rgba(0,0,0,0.5);">
<div style="float:left;width:100%;height:20px;background-color:black;color:white;font-size:12px;text-align:center;overflow:hidden;border:1px dashed white" id="head"></div>
<iframe frameborder=0 id="ifram" style="float:left;margin:0px;padding:0px;width:100%;height:748px"></iframe>
<div style="float:left;width:100%;height:20px;background-color:black;color:white;font-size:12px;text-align:center;overflow:hidden;border:1px dashed white" id="bottom"></div>
</div>
</body>
<script>
var devices=[
{
id:"ipadfl",
label:"iPad (Fullscreen, landscape)",
width:1024,
height:768,
topmargin:20,
bottommargin:0,
next:"ipadfp"
},
{
id:"ipadfp",
label:"iPad (Fullscreen, portrait)",
width:768,
height:1024,
topmargin:20,
bottommargin:0,
next:"ipadfl"
},
{
id:"ipadsl",
label:"iPad (Safari, landscape)",
width:1024,
height:768,
topmargin:108,
bottommargin:0,
next:"ipadsp"
},
{
id:"ipadsp",
label:"iPad (Safari, portrait)",
width:768,
height:1024,
topmargin:108,
bottommargin:0,
next:"ipadsl"
},
{
id:"iphonefl",
label:"iPhone (Fullscreen, landscape)",
width:480,
height:320,
topmargin:20,
bottommargin:0,
next:"iphonefp"
},
{
id:"iphonefp",
label:"iPhone (Fullscreen, portrait)",
width:320,
height:480,
topmargin:20,
bottommargin:0,
next:"iphonefl"
},
{
id:"iphonesl",
label:"iPhone (Safari, landscape)",
width:480,
height:320,
topmargin:80,
bottommargin:44,
next:"iphonesp"
},
{
id:"iphonesp",
label:"iPhone (Safari, portrait)",
width:320,
height:480,
topmargin:80,
bottommargin:44,
next:"iphonesl"
}
];
function init() {
var device=getdevicebyid(geturlparameter("device"));
device=(device?device:0);
var text="<select id='deviceselect' onchange='devicechanged()'>";
for (var a=0;a<devices.length;a++)
text+="<option value='"+a+"' "+(a==device?"selected":"")+">"+devices[a].label+"<\/option>"
text+="<\/select>";
document.getElementById('selector').innerHTML=text;
document.getElementById("pageurl").value=(geturlparameter("url")?geturlparameter("url"):"index.html");
apply(device);
}
function devicechanged(e) {
apply(document.getElementById('deviceselect').selectedIndex);
}
function apply(dev) {
settextvalues(devices[dev]);
resizedisplay();
}
function settextvalues(device) {
if (!device.width||(device.width<=50)) device.width=50;
if (!device.height||(device.height<=50)) device.height=50;
if (!device.topmargin) device.topmargin=0;
if (!device.bottommargin) device.bottommargin=0;
if (device.topmargin+device.bottommargin>=device.height) device.height=device.topmargin+device.bottommargin+10;
document.getElementById("pwidth").value=device.width;
document.getElementById("pheight").value=device.height;
document.getElementById("ptopmargin").value=device.topmargin;
document.getElementById("pbottommargin").value=device.bottommargin;
document.getElementById("orient").innerHTML=(device.width>device.height?"Landscape":"Portrait");
}
function resizedisplay() {
var tmpdevice={width:parseInt(document.getElementById("pwidth").value),height:parseInt(document.getElementById("pheight").value),topmargin:parseInt(document.getElementById("ptopmargin").value),bottommargin:parseInt(document.getElementById("pbottommargin").value)};
settextvalues(tmpdevice);
document.getElementById("display").style.width=tmpdevice.width+"px";
document.getElementById("display").style.height=tmpdevice.height+"px";
if (tmpdevice.topmargin) {
document.getElementById("head").style.display="block";
document.getElementById("head").style.height=(tmpdevice.topmargin-2)+"px";
} else document.getElementById("head").style.display="none";
if (tmpdevice.bottommargin) {
document.getElementById("bottom").style.display="block";
document.getElementById("bottom").style.height=(tmpdevice.bottommargin-2)+"px";
} else document.getElementById("bottom").style.display="none";
document.getElementById("ifram").style.height=(tmpdevice.height-tmpdevice.topmargin-tmpdevice.bottommargin)+"px";
if (!document.getElementById("ifram").src) gotohome();
}
function pageurl() {
return document.getElementById("pageurl").value;
}
function gotohome() {
document.getElementById("ifram").src=pageurl();
}
function gotoindex() {
document.getElementById("ifram").src=pageurl()+"?tool=index";
}
function gototools() {
document.getElementById("ifram").src=pageurl()+"?tool=help";
}
function gotorefresh() {
document.getElementById("ifram").src=document.getElementById("ifram").contentWindow.location;
}
function turn() {
var org=devices[document.getElementById('deviceselect').selectedIndex];
var next=org.next;
var found=null;
for (var i=0;i<devices.length;i++)
if (devices[i].id==next) { found=i; break; }
if (found!=null) {
document.getElementById('deviceselect').selectedIndex=found;
devicechanged();
}
}
function turnsizes() {
var tmp=document.getElementById("pwidth").value;
document.getElementById("pwidth").value=document.getElementById("pheight").value;
document.getElementById("pheight").value=tmp;
resizedisplay();
}
function geturlparameter(name) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "";
else
return results[1];
}
function getdevicebyid(id) {
for (var i=0;i<devices.length;i++)
if (devices[i].id==id) return i;
return null;
}
</script>
</html>