-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
678 lines (660 loc) · 26.2 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
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" id="this-viewport" content="width=device-width, initial-scale=1, user-scalable=0">
<script>
function scaleViewport(refWidth, refHeight){
var clientWidth = document.documentElement.clientWidth;
if (!refWidth) refWidth = 500;
if (!refHeight) refHeight = 950;
var scaleFactor = Math.min(window.screen.width/refWidth, window.screen.height/refHeight);
if (scaleFactor < 1){
var mvp = document.getElementById('this-viewport');
mvp.setAttribute('content', 'width=device-width, initial-scale=' + scaleFactor + ', user-scalable=0');
if (clientWidth !== document.documentElement.clientWidth){
console.log("Screen scaling: " + scaleFactor);
}else{
mvp.setAttribute('content', 'width=device-width, initial-scale=1, user-scalable=0');
}
}else{
scaleFactor = 1;
}
//if (window.matchMedia("(orientation: portrait)").matches)...
return scaleFactor;
}
window.edgeSqViewportScale = scaleViewport();
</script>
<title>EdgeSquare</title>
<meta name="application-name" content="EdgeSquare"/>
<meta name="apple-mobile-web-app-title" content="EdgeSquare">
<meta name="description" content="Online simulator for edge-to-edge displays with notch or any form of camera cutout. Check out how your web application will look on modern smartphones.">
<meta name="theme-color" content="#000">
<link rel="icon" sizes="192x192" href="img/icon.png">
<link rel="apple-touch-icon" href="img/icon.png">
<!-- open graph settings -->
<meta property="og:title" content="EdgeSquare"/>
<meta property="og:determiner" content="the" />
<meta property="og:url" content="https://byteteilchen.de/edge-2-edge/"/>
<meta property="og:description" content="Online simulator for edge-to-edge displays with notch or any form of camera cutout. Check out how your web application will look on modern smartphones.">
<meta property="og:image" content="https://byteteilchen.de/edge-2-edge/img/icon.png"/>
<meta property="og:image:width" content="192"/>
<meta property="og:image:height" content="192"/>
<meta property="og:image:type" content="image/png"/>
<meta property="og:image:alt" content="Bytemind Icon"/>
<meta property="og:type" content="website"/>
<meta property="og:locale" content="en_GB"/>
<meta property="og:locale:alternate" content="en_US"/>
<meta property="og:locale:alternate" content="de_DE"/>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/googleMaterialIcons.css">
<script>
//Add svg-inject if not file origin
if (window.location.origin.indexOf("file://") != 0){
(function(){
var scr = document.createElement("script");
scr.src = "js/svg-inject.min.js";
document.head.appendChild(scr);
})();
}else{
window.SVGInject = function(){};
}
</script>
</head>
<style>
#controls .pickr {
border: 1px solid;
border-radius: 17px;
padding: 2px;
width: 27px;
height: 27px;
overflow: hidden;
display: flex;
}
.pickr .pcr-button::before,
.pickr .pcr-button::after {
border-radius: 15px !important;
}
.pickr button,
.pcr-app button {
min-width: auto;
min-height: auto;
height: 100% !important;
width: 100% !important;
}
.pickr button:focus {
box-shadow: none !important;
}
</style>
<body >
<!-- Overlays 1 -->
<div id="overlay-area">
<div class="overlay-buttons">
<button id="info-btn" title="Info" onclick="EdgeSq.toggleInfo();"><i class="material-icons">info</i></button>
<button id="ctrls-btn" title="Toggle settings" onclick="EdgeSq.toggleSettings();"><i class="material-icons">tune</i></button>
<button id="fullscreen-btn" title="Toggle fullscreen" onclick="EdgeSq.toggleFullScreen();"><i class="material-icons">fullscreen</i></button>
<!--<button id="fullscreen-exit-btn" onclick="EdgeSq.toggleFullScreen();" style="display: none;"><i class="material-icons">fullscreen_exit</i></button>-->
<button id="github-btn" title="Show on GitHub"><a href="https://github.com/bytemind-de/edge-sq-display-simulator"><img src="img/svg/github.svg"/></a></button>
</div>
<!--<div class="overlay-buttons">
<button id="twitter-btn"><img src="img/svg/twitter.svg" onload="SVGInject(this)"/></button>
<button id="sepia-btn"><img src="img/svg/sepia.svg" onload="SVGInject(this)"/></button>
</div>-->
</div>
<!-- CONTROLS -->
<div id="controls">
<h3>Edge-2-Edge Display Simulator</h3>
<div>
<p>App URL</p>
<input id="app-url" type="url" spellcheck="false" placeholder="http://localhost:8080/index.html" onchange="EdgeSq.setAppUrl(this.value);">
</div>
<div>
<p>Device</p>
<label>Name:</label><select id="device-name" onchange="EdgeSq.setDevice(this.value);">
<!-- Available devices | filled dynamically -->
</select>
</div>
<div>
<p>Status Bar</p>
<label>Background:</label><input id="status-bar-background" type="color">
<label>Color:</label><input id="status-bar-color" type="color">
</div>
<div>
<p>Navigation Bar</p>
<label>Background:</label><input id="nav-bar-background" type="color">
<label>Color:</label><input id="nav-bar-color" type="color">
</div>
<div>
<p>Toggles</p>
<div style="margin: 12px;">
<label>Display state:</label><button id="toggle-display" onclick="EdgeSq.toggleDisplayState();">Full</button>
</div>
<div style="margin: 12px;">
<label>Device scale:</label><button id="toggle-scale" onclick="EdgeSq.toggleDeviceScale();">Viewport</button><input id="device-scale-factor" value=0.6 onchange="EdgeSq.setDeviceScalingFactor(this.value);">
</div>
</div>
<p id="open-source-label">
<a href="https://github.com/bytemind-de/edge-sq-display-simulator" target=_blank><svg style="width: 209px;height: 27px;padding:5px 0;"><text x="0" y="90%" style="fill: url(#bytemind-color-gradient);">Open-source by bytemind.de</text></svg></a>
</p>
</div>
<!-- SIM -->
<div id="display">
<!-- STATUS BARS / CUTOUTS / NOTCHES -->
<div id="status-bar">
<!-- Samsung S10/S10e camera cutout -->
<div id="notch-samsung-s10e" class="notch-theme">
<span style="width: 20px;"></span>
<span class="sb-clock"><em>12:00</em></span>
<span class="sb-note"></span>
<span class="sb-email"></span>
<span class="sb-text"><em>...</em></span>
<span class="sb-filler"></span>
<span class="sb-bluetooth"></span>
<span class="sb-wifi"></span>
<span class="sb-cell-signal"></span>
<span class="sb-battery"><em>99%</em></span>
<span class="sb-camera-hole-1 notch-part"></span>
<span style="width: 20px;"></span>
</div>
<!-- Samsung S10+ camera cutout -->
<div id="notch-samsung-s10p" class="notch-theme">
<span style="width: 20px;"></span>
<span class="sb-clock"><em>12:00</em></span>
<span class="sb-note"></span>
<span class="sb-email"></span>
<span class="sb-text"><em>...</em></span>
<span class="sb-filler"></span>
<span class="sb-bluetooth"></span>
<span class="sb-wifi"></span>
<span class="sb-cell-signal"></span>
<span class="sb-battery"><em>99%</em></span>
<span class="sb-camera-hole-2 notch-part"></span>
<span style="width: 20px;"></span>
</div>
<!-- Android 10 plain -->
<div id="notch-pixel-3" class="notch-theme thinner" style="display: none;">
<span style="width: 10px;"></span>
<span class="sb-clock"><em>12:00</em></span>
<span class="sb-filler"></span>
<span class="sb-wifi"></span>
<span class="sb-cell-signal"></span>
<span class="sb-battery"></span>
<span style="width: 10px;"></span>
</div>
<!-- Pixel 4a (basically mirrored S10e) camera cutout -->
<div id="notch-pixel-4a" class="notch-theme">
<span style="width: 20px;"></span>
<span class="sb-camera-hole-1 notch-part"></span>
<span class="sb-clock"><em>12:00</em></span>
<span class="sb-email"></span>
<span class="sb-filler"></span>
<span class="sb-note"></span>
<span class="sb-text"><em>...</em></span>
<span class="sb-bluetooth"></span>
<span class="sb-wifi"></span>
<span class="sb-cell-signal"></span>
<span class="sb-battery"><em>99%</em></span>
<span style="width: 20px;"></span>
</div>
<!-- iPhone X/XS/11 Pro notch -->
<div id="notch-iphone-x" class="notch-theme" style="display: none;">
<span class="sb-clock" style="width: 83px; text-align: center; flex: 0 0 auto;"><em>12:00</em></span>
<span class="sb-filler"></span>
<span class="sb-iphone-x-array notch-part"></span>
<span class="sb-filler"></span>
<span class="sb-cell-signal"></span>
<span class="sb-wifi"></span>
<span class="sb-battery" style="transform: rotate(90deg); height: 22px; width: 22px;"></span>
<span style="width: 17px;"></span>
</div>
<!-- iPhone 6 (probably 3-8) -->
<div id="notch-iphone-6" class="notch-theme thin" style="display: none;">
<span style="width: 0px;"></span>
<span class="sb-text"><em>••••• Provider 3G</em></span>
<span class="sb-clock" style="text-align: center; flex: 1 0 auto;"><em>12:00</em></span>
<span style="width: 34px;"></span>
<span class="sb-bluetooth"></span>
<span class="sb-wifi"></span>
<span class="sb-battery" style="transform: rotate(90deg); height: 22px; width: 22px;"></span>
<span style="width: 0px;"></span>
</div>
<!-- iPhone 13 Pro notch -->
<div id="notch-iphone-13" class="notch-theme" style="display: none;">
<span class="sb-clock" style="width: 83px; text-align: center; flex: 0 0 auto;"><em>12:00</em></span>
<span class="sb-filler"></span>
<span class="sb-iphone-13-array notch-part"></span>
<span class="sb-filler"></span>
<span class="sb-cell-signal"></span>
<span class="sb-wifi"></span>
<span class="sb-battery" style="transform: rotate(90deg); height: 22px; width: 22px;"></span>
<span style="width: 17px;"></span>
</div>
</div>
<!-- APP -->
<iframe id="app" src="index.html" title="Preview" allow="geolocation;microphone"></iframe>
<!-- NAVIGATION BARS -->
<div id="nav-bar">
<!-- Default Android on-screen navigation bar -->
<div id="nav-android-1" class="nav-bar-theme">
<span class="nb-recent">|||</span>
<span class="nb-home"><div></div></span>
<span class="nb-back">◄</span>
</div>
<!-- Android on-screen with gesture bar -->
<div id="nav-android-2" class="nav-bar-theme">
<span class="nb-home-android-gesture"><div></div></span>
</div>
<!-- Default iOS touch navigation bar -->
<div id="nav-ios-touch-1" class="nav-bar-theme" style="display: none;">
<span class="nb-home-ios"><div></div></span>
</div>
<!-- no navigation bar (hardware buttons) -->
<div id="nav-hardware" class="nav-bar-theme" style="display: none;">
</div>
</div>
</div>
<!-- Overlays 2 -->
<div id="info-popup" style="display: none;">
<div id="info-popup-content">
<h3>Welcome</h3>
<p>EdgeSquare is a web based online simulator for mobile edge-to-edge displays with notch or any other form of camera cutout.</p>
<h3>Getting started</h3>
<ul>
<li>Enter the URL of your web application or use the demo app</li>
<li>Choose a device from the selector</li>
<li>Adjust colors as needed</li>
<li>Discover how your website/app REALLY looks on modern mobile phone displays</li>
</ul>
<h3>Good to know</h3>
<ul>
<li>Devices are defined by their available pixels (viewport size) and <b>not</b> their physical size. You can use the 'Device scale' toggle to get the approximate real size.</li>
<li>If your app/website/server uses the 'user-agent' of the browser to adjust the look (e.g. by loading a special version for mobile browsers) you need to work with browser extensions to simulate the correct behavior.</li>
<li>For more info or questions visit <a href="https://github.com/bytemind-de/edge-sq-display-simulator" target=_blank>the GitHub project page</a>.</li>
</ul>
<h3>My display</h3>
<ul id="own-viewport-info"></ul>
<br>
<p style="text-align: center;">Have fun :-)</p>
<br>
<div id="info-popup-close">GO!</div>
</div>
</div>
<script>
//Edge-Sq Setup
(function(){
var EdgeSq = {};
window.EdgeSq = EdgeSq;
//DEVICES:
EdgeSq.devices = {
samsung_s10e: {
name: "Samsung S10/S10e",
displayHeight: "760px", displayWidth: "360px", displayRadius: "42px",
statusBarHeight: "38px", navBarHeight: "48px",
notch: "notch-samsung-s10e", navBar: "nav-android-1",
physWidth: [70]
},
samsung_s10_plus: {
name: "Samsung S10+",
displayHeight: "869px", displayWidth: "412px", displayRadius: "42px",
statusBarHeight: "38px", navBarHeight: "48px",
notch: "notch-samsung-s10p", navBar: "nav-android-1",
physWidth: [74]
},
iphone_13_pro: {
name: "iPhone 13 Pro",
displayHeight: "844px", displayWidth: "390px", displayRadius: "42px",
statusBarHeight: "34px", navBarHeight: "34px",
notch: "notch-iphone-13", navBar: "nav-ios-touch-1",
physWidth: [72]
},
iphone_x: {
name: "iPhone X/11 Pro",
displayHeight: "812px", displayWidth: "375px", displayRadius: "42px",
statusBarHeight: "42px", navBarHeight: "34px",
notch: "notch-iphone-x", navBar: "nav-ios-touch-1",
physWidth: [71]
},
iphone_xr: {
name: "iPhone XR/11/XS Max",
displayHeight: "896px", displayWidth: "414px", displayRadius: "42px",
statusBarHeight: "42px", navBarHeight: "34px",
notch: "notch-iphone-x", navBar: "nav-ios-touch-1",
physWidth: [76]
},
iphone_6_plus: {
name: "iPhone 6-8 Plus",
displayHeight: "736px", displayWidth: "414px", displayRadius: "0px",
statusBarHeight: "20px", navBarHeight: "0px",
notch: "notch-iphone-6", navBar: "nav-hardware",
physWidth: [78]
},
iphone_6: {
name: "iPhone 6-8/SE 2020",
displayHeight: "667px", displayWidth: "375px", displayRadius: "0px",
statusBarHeight: "20px", navBarHeight: "0px",
notch: "notch-iphone-6", navBar: "nav-hardware",
physWidth: [67]
},
iphone_5: {
name: "iPhone 5",
displayHeight: "568px", displayWidth: "320px", displayRadius: "0px",
statusBarHeight: "20px", navBarHeight: "0px",
notch: "notch-iphone-6", navBar: "nav-hardware",
physWidth: [59]
},
google_pixel_3: {
name: "Google Pixel 3",
//it seems users can change this in the settings: displayHeight: "824px", displayWidth: "412px", displayRadius: "30px",
displayHeight: "786px", displayWidth: "393px", displayRadius: "30px",
statusBarHeight: "28px", navBarHeight: "20px",
notch: "notch-pixel-3", navBar: "nav-android-2",
physWidth: [69]
},
google_pixel_4a: {
name: "Google Pixel 4a",
displayHeight: "891px", displayWidth: "411px", displayRadius: "42px",
statusBarHeight: "38px", navBarHeight: "20px",
notch: "notch-pixel-4a", navBar: "nav-android-2",
physWidth: [69]
},
android_tablet_landscape: {
name: "Android Tablet (landscape)",
displayHeight: "768px", displayWidth: "1024px", displayRadius: "42px",
statusBarHeight: "38px", navBarHeight: "48px",
notch: "notch-samsung-s10e", navBar: "nav-android-1",
physWidth: [245]
}
}
var referencePhysWidth = 67;
var referenceDisplayWidth = 375;
var deviceSelector = document.getElementById('device-name');
deviceSelector.innerHTML = "";
Object.keys(EdgeSq.devices).forEach(function(key){
deviceSelector.innerHTML += "<option value='" + key + "'>" + EdgeSq.devices[key].name + "</option>";
});
EdgeSq.activeDevice = localStorage.getItem('edge-sq-device') || "samsung_s10e";
EdgeSq.scale = localStorage.getItem('edge-sq-scale') || "viewport";
EdgeSq.deviceScalingFactor = localStorage.getItem('edge-sq-scale-factor') || 0.6;
//DOM
//TODO: make hard-coded IDs configurable
//status-bar
applyIconToClass("sb-cell-signal", "signal_cellular_alt");
applyIconToClass("sb-wifi", "signal_wifi_4_bar");
applyIconToClass("sb-battery", "battery_full");
applyIconToClass("sb-note", "notification_important");
applyIconToClass("sb-bluetooth", "bluetooth");
applyIconToClass("sb-email", "email");
//colors
EdgeSq.activeSbBackground = localStorage.getItem('edge-sq-status-bar-bg') || "#000000";
EdgeSq.activeSbColor = localStorage.getItem('edge-sq-status-bar-col') || "#ffffff";
EdgeSq.activeNavBackground = localStorage.getItem('edge-sq-nav-bar-bg') || "#000000";
EdgeSq.activeNavColor = localStorage.getItem('edge-sq-nav-bar-col') || "#ffffff";
//controls
//app URL
EdgeSq.setAppUrl = function(url){
document.getElementById('app-url').value = url;
document.getElementById('app').src = url;
localStorage.setItem('edge-sq-app-url', url);
}
EdgeSq.setStatusBarBackground = function(color){
document.documentElement.style.setProperty('--status-bar-bg', color);
sbBackColor = color;
//document.getElementById('status-bar-background').value = color;
localStorage.setItem('edge-sq-status-bar-bg', color);
}
EdgeSq.setStatusBarColor = function(color){
document.documentElement.style.setProperty('--status-bar-col', color);
//document.getElementById('status-bar-color').value = color;
localStorage.setItem('edge-sq-status-bar-col',color);
}
EdgeSq.setNavBarBackground = function(color){
document.documentElement.style.setProperty('--nav-bar-bg', color);
//document.getElementById('nav-bar-background').value = color;
localStorage.setItem('edge-sq-nav-bar-bg', color);
}
EdgeSq.setNavBarColor = function(color){
document.documentElement.style.setProperty('--nav-bar-col', color);
//document.getElementById('nav-bar-color').value = color;
localStorage.setItem('edge-sq-nav-bar-col', color);
}
EdgeSq.setDevice = function(deviceId){
var deviceData = EdgeSq.devices[deviceId];
document.documentElement.style.setProperty('--display-h', deviceData.displayHeight || "850px");
document.documentElement.style.setProperty('--display-w', deviceData.displayWidth || "400px");
document.documentElement.style.setProperty('--display-rad', deviceData.displayRadius || "42px");
document.documentElement.style.setProperty('--status-bar-h', deviceData.statusBarHeight || "38px");
document.documentElement.style.setProperty('--nav-bar-h', deviceData.navBarHeight || "48px");
document.getElementById('device-name').value = deviceId;
var notches = document.getElementsByClassName("notch-theme");
for (var i=0; i<notches.length; i++){
notches[i].style.display = "none";
}
document.getElementById(deviceData.notch).style.removeProperty("display");
var navbars = document.getElementsByClassName("nav-bar-theme");
for (var i=0; i<navbars.length; i++){
navbars[i].style.display = "none";
}
document.getElementById(deviceData.navBar).style.removeProperty("display");
localStorage.setItem('edge-sq-device', deviceId);
EdgeSq.activeDevice = deviceId;
refreshDeviceScale();
}
EdgeSq.toggleDisplayState = function(){
var display = document.getElementById("display");
var btn = document.getElementById("toggle-display");
if (display.classList.contains("classic")){
display.classList.remove("classic");
showStatusBarIcons();
btn.innerHTML = "Full";
}else if (display.classList.contains("fullscreen")){
display.classList.remove("fullscreen");
display.classList.add("classic");
btn.innerHTML = "Edge-to-Edge";
}else{
display.classList.add("fullscreen");
hideStatusBarIcons();
btn.innerHTML = "Classic";
}
}
function hideStatusBarIcons(){
var notches = document.getElementsByClassName("notch-theme");
for (var i=0; i<notches.length; i++){
var icons = notches[i].children;
for (var j=0; j<icons.length; j++){
if (!icons[j].classList.contains("notch-part")){
icons[j].style.visibility = "hidden";
}
}
}
}
function showStatusBarIcons(){
var notches = document.getElementsByClassName("notch-theme");
for (var i=0; i<notches.length; i++){
var icons = notches[i].children;
for (var j=0; j<icons.length; j++){
icons[j].style.removeProperty("visibility");
}
}
}
EdgeSq.setDeviceScalingFactor = function(newFactor){
EdgeSq.deviceScalingFactor = newFactor;
localStorage.setItem('edge-sq-scale-factor', newFactor);
refreshDeviceScale();
}
EdgeSq.toggleDeviceScale = function(){
if (EdgeSq.scale == "viewport"){
EdgeSq.scale = "physical";
}else{
EdgeSq.scale = "viewport";
}
localStorage.setItem('edge-sq-scale', EdgeSq.scale);
refreshDeviceScale();
}
function refreshDeviceScale(){
var display = document.getElementById("display");
var btn = document.getElementById("toggle-scale");
var dsIn = document.getElementById("device-scale-factor");
if (EdgeSq.scale == "viewport"){
btn.innerHTML = "Viewport";
dsIn.classList.add("hidden");
display.style.removeProperty("transform");
}else{
btn.innerHTML = "Real";
dsIn.classList.remove("hidden");
var d = EdgeSq.devices[EdgeSq.activeDevice];
if (d.physWidth){
var physWidth = d.physWidth[0];
var widthPx = Number.parseInt(d.displayWidth);
var factorPx = Math.round((referenceDisplayWidth / widthPx)*1000)/1000;
var factorReal = Math.round((physWidth / referencePhysWidth)*1000)/1000;
display.style.transform = "scale(" + (factorPx * factorReal * EdgeSq.deviceScalingFactor) + ")";
}else{
display.style.transform = "scale(" + (EdgeSq.deviceScalingFactor) + ")";
}
}
dsIn.value = EdgeSq.deviceScalingFactor;
}
//helpers
function applyIconToClass(clazz, icon){
var elements = document.getElementsByClassName(clazz);
if (elements && elements.length > 0){
for (var i=0; i<elements.length; i++){
elements[i].innerHTML += "<i class='material-icons'>" + icon + "</i>";
}
}
}
EdgeSq.toggleInfo = function(){
clearTimeout(infoHideTimer);
var info = document.getElementById("info-popup");
if (info.classList.contains("visible")){
info.classList.remove("visible");
infoHideTimer = setTimeout(function(){
info.style.display = "none";
}, 500);
}else{
info.style.removeProperty("display");
setTimeout(function(){
info.classList.add("visible");
//calculate own viewport
var ownVpInfo = document.getElementById("own-viewport-info");
ownVpInfo.innerHTML = "";
ownVpInfo.innerHTML += ("<li>Own viewport scale: " + window.edgeSqViewportScale + "</li>");
ownVpInfo.innerHTML += ("<li>Viewport width: " + Math.round(window.innerWidth * window.edgeSqViewportScale) + "</li>");
ownVpInfo.innerHTML += ("<li>Viewport height: " + Math.round(window.innerHeight * window.edgeSqViewportScale) + "</li>");
}, 0);
}
}
document.getElementById("info-popup").addEventListener("click", function(e){
e = window.event || e;
if(this === e.target){
EdgeSq.toggleInfo();
}
});
document.getElementById("info-popup-close").addEventListener("click", function(e){
EdgeSq.toggleInfo();
});
EdgeSq.toggleFullScreen = function(){
if (!document.fullscreenElement){
document.documentElement.requestFullscreen();
}else{
if (document.exitFullscreen){
document.exitFullscreen();
}
}
}
EdgeSq.toggleSettings = function(){
clearTimeout(settingsHideTimer);
var ctrls = document.getElementById("controls");
if (ctrls.classList.contains("hidden")){
setTimeout(function(){
ctrls.style.removeProperty("display");
}, 0);
setTimeout(function(){
ctrls.classList.remove("hidden");
}, 25);
}else{
ctrls.classList.add("hidden");
settingsHideTimer = setTimeout(function(){
ctrls.style.display = "none";
}, 500);
}
}
var infoHideTimer;
var settingsHideTimer;
//initialize
EdgeSq.setAppUrl(localStorage.getItem('edge-sq-app-url') || "https://sepia-framework.github.io/app/");
EdgeSq.setDevice(EdgeSq.activeDevice);
EdgeSq.setStatusBarBackground(EdgeSq.activeSbBackground);
EdgeSq.setStatusBarColor(EdgeSq.activeSbColor);
EdgeSq.setNavBarBackground(EdgeSq.activeNavBackground);
EdgeSq.setNavBarColor(EdgeSq.activeNavColor);
EdgeSq.userHasSeenInfo = localStorage.getItem('edge-sq-has-seen-info');
if (!EdgeSq.userHasSeenInfo){
EdgeSq.toggleInfo();
localStorage.setItem('edge-sq-has-seen-info', true);
}
})();
</script>
<!-- low prio style sheets and js -->
<link rel="stylesheet" href="css/pickr-classic.min.css"/>
<script src="js/pickr.min.js"></script>
<script>
(function(){
var defaultColorPickerSettings = {
theme: 'classic',
components: {
// Main components
preview: true,
opacity: true,
hue: true,
// Input / output Options
interaction: {
hex: true,
rgba: true,
hsla: false,
hsva: false,
cmyk: false,
input: true,
clear: false,
save: true,
cancel: false
}
}
};
var colorControls = {
statusBarBack: {ele: '#status-bar-background', fun: EdgeSq.setStatusBarBackground, def: EdgeSq.activeSbBackground},
statusBarCol: {ele: '#status-bar-color', fun: EdgeSq.setStatusBarColor, def: EdgeSq.activeSbColor},
navBarBack: {ele: '#nav-bar-background', fun: EdgeSq.setNavBarBackground, def: EdgeSq.activeNavBackground},
navBarCol: {ele: '#nav-bar-color', fun: EdgeSq.setNavBarColor, def: EdgeSq.activeNavColor}
}
Object.keys(colorControls).forEach(function(ctrl){
var ctrlData = colorControls[ctrl];
var pickrConf = JSON.parse(JSON.stringify(defaultColorPickerSettings));
pickrConf.el = ctrlData.ele;
var pickr = Pickr.create(pickrConf);
pickr
.on('init', function(instance){
instance.setColor(ctrlData.def, true);
instance.applyColor(true);
})
.on('hide', function(instance){
instance.applyColor(true);
})
.on('change', function(color, instance){
ctrlData.fun(color.toHEXA().toString());
})
.on('save', function(color, instance){
instance.hide();
})
;
});
})();
</script>
<div style="position: absolute; width: 0px; height: 0px; overflow: hidden;">
<svg><defs><linearGradient id="bytemind-color-gradient">
<stop offset=".15" stop-color="#44c8be"></stop><stop offset=".40" stop-color="#5683c4"></stop>
<stop offset=".85" stop-color="#a147b0"></stop>
</linearGradient></defs></svg>
</div>
</body>
</html>