-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscrn.html
More file actions
219 lines (191 loc) · 6.85 KB
/
scrn.html
File metadata and controls
219 lines (191 loc) · 6.85 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>
<body>
<style>
#scrnrotate{
display:none;
}
*:after
{
box-sizing: border-box;
hyphens: auto;
overflow-wrap: break-word;
}
.api-support
{
display: block;
}
.hidden,
[hidden]
{
display: none;
}
.field-wrapper
{
margin-top: 1em;
}
.buttons-wrapper
{
text-align: center;
}
.value
{
font-weight: bold;
}
.log
{
border: 1px solid #333333;
height: 200px;
line-height: 1.3em;
overflow-y: scroll;
width: 100%;
display:none;
}
sbutton,
input,
select,
textarea
{
font-size: inherit;
}
.sbutton
{
padding: 0.5em;
margin: 1em 0;
}
.sbutton + .sbutton
{
margin-left: 1em;
}
</style>
<script>
$(document).ready(function(){
$("#pleaserotate-backdrop").click(function(){
$("input#lock-button").click();
});
});
</script>
<button id="pleaserotate-backdrop">click</button>
<div id="scrnrotate">
<h1>Screen Orientation API</h1>
<span id="so-unsupported" class="api-support hidden">API not supported</span>
<span id="soo-supported" class="api-support hidden">Old API version supported</span>
<div id="so-results">
<ul>
<li>
The orientation of the device is <span id="orientation" class="value">unavailable</span>.
</li>
<li class="new-api hidden">
The angle of the device is <span id="angle" class="value">unavailable</span>.
</li>
</ul>
<form>
<label for="orientation-type">Lock the device in:</label>
<select id="orientation-type">
<option value="landscape-primary">landscape-primary</option>
<option value="landscape-secondary">landscape-secondary</option>
</select>
<br />
<input class="sbutton" id="lock-button" type="submit" value="Lock!" />
<input class="sbutton" id="unlock-button" type="reset" value="Unlock!" />
</form>
</div>
<script>
var prefix = 'orientation' in screen ? '' :
'mozOrientation' in screen ? 'moz' :
'msOrientation' in screen ? 'ms' :
null;
if (prefix === null) {
document.getElementById('so-unsupported').classList.remove('hidden');
['lock-button', 'unlock-button'].forEach(function(elementId) {
document.getElementById(elementId).setAttribute('disabled', 'disabled');
});
} else {
var select = document.getElementById('orientation-type');
var orientationElem = document.getElementById('orientation');
var onChangeHandler;
var Fullscreen = {
launch: function(element) {
if(element.requestFullscreen) {
element.requestFullscreen();
} else if(element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if(element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if(element.msRequestFullscreen) {
element.msRequestFullscreen();
}
},
exit: function() {
if(document.exitFullscreen) {
document.exitFullscreen();
} else if(document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if(document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
}
};
// Determine what version of the API is implemented
if ('orientation' in screen && 'angle' in screen.orientation) {
// The browser supports the new version of the API
// Show the properties supported by the new version
var newProperties = document.getElementsByClassName('new-api');
for(var i = 0; i < newProperties.length; i++) {
newProperties[i].classList.remove('hidden');
}
document.getElementById('lock-button').addEventListener('click', function (event) {
event.preventDefault();
screen.orientation.lock(select.value);
});
document.getElementById('unlock-button').addEventListener('click', function (event) {
event.preventDefault();
screen.orientation.unlock();
});
var angleElem = document.getElementById('angle');
onChangeHandler = function() {
orientationElem.textContent = screen.orientation.type;
angleElem.textContent = screen.orientation.angle;
};
screen.orientation.addEventListener('change', onChangeHandler);
onChangeHandler();
} else {
// The browser supports the old version of the API, so the user is informed of that
document.getElementById('soo-supported').classList.remove('hidden');
// Remove the options that aren't available in the old version of the API
var unavailableOptions = [
document.querySelector('#orientation-type option[value="any"]'),
document.querySelector('#orientation-type option[value="natural"]')
];
for(var i = 0; i < unavailableOptions.length; i++) {
unavailableOptions[i].parentElement.removeChild(unavailableOptions[i]);
}
document.getElementById('lock-button').addEventListener('click', function (event) {
event.preventDefault();
setTimeout(function () {
screen[prefix + (prefix === '' ? 'l' : 'L') + 'ockOrientation'](select.value);
}, 1);
});
document.getElementById('unlock-button').addEventListener('click', function (event) {
event.preventDefault();
screen[prefix + (prefix === '' ? 'u' : 'U') + 'nlockOrientation']();
});
onChangeHandler = function() {
var orientationProperty = prefix + (prefix === '' ? 'o' : 'O') + 'rientation';
orientationElem.textContent = screen[orientationProperty];
};
screen.addEventListener(prefix + 'orientationchange', onChangeHandler);
onChangeHandler();
}
}
</script>
</div>
</body>
</html>