-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.js
170 lines (124 loc) · 4.68 KB
/
index.js
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
/*!
* Author: Emanuel Rojas Vásquez
* https://github.com/erovas
*/
(function(window, document){
var DEV = window.Device;
var BODY = document.body;
var px = 'px';
function throttled(callback, delay) {
delay = delay || 50;
var fire = null;
var last = null;
return function() {
var ctx = this;
var args = arguments;
if(!last){
callback.apply(ctx, args);
last = Date.now();
}
else {
clearTimeout(fire);
fire = setTimeout(function() {
if((Date.now() - last) >= delay){
callback.apply(ctx, args);
last = Date.now();
}
}, delay - (Date.now() - last));
}
}
}
function setScrollbar(){
scrollBarXWidth.innerText = DEV.scrollBar.X.width + px;
scrollBarYWidth.innerText = DEV.scrollBar.Y.width + px;
scrollBarXHeight.innerText = DEV.scrollBar.X.height + px;
scrollBarYHeight.innerText = DEV.scrollBar.Y.height + px;
scrollBarXPosition.innerText = ( ((DEV.scrollBar.X.position * 100) | 0) / 100 ) + px;
scrollBarYPosition.innerText = ( ((DEV.scrollBar.Y.position * 100) | 0) / 100 ) + px;
scrollBarXMaxPosition.innerText = DEV.scrollBar.X.maxPosition + px;
scrollBarYMaxPosition.innerText = DEV.scrollBar.Y.maxPosition + px;
}
function setResize(){
//#region OS
var OS = DEV.OS;
OSName.innerText = OS.name;
OSVersion.innerText = OS.version;
//#endregion
//#region browser
var browser = DEV.browser;
browserName.innerText = browser.name;
browserMajor.innerText = browser.major;
browserVersion.innerText = browser.version;
//#endregion
//#region CPU
CPU.innerText = DEV.CPU + ' bit';
//#endregion
//#region Type
isMobile.innerText = DEV.isMobile;
isTablet.innerText = DEV.isTablet;
isDesktop.innerText = DEV.isDesktop;
//#endregion
//#region Viewports
wresolution.innerText = DEV.resolution.width + px;
hresolution.innerText = DEV.resolution.height + px;
wscreenViewport.innerText = DEV.screenViewport.width + px;
hscreenViewport.innerText = DEV.screenViewport.height + px;
winnerViewport.innerText = DEV.innerViewport.width + px;
hinnerViewport.innerText = DEV.innerViewport.height + px;
wouterViewport.innerText = DEV.outerViewport.width + px;
houterViewport.innerText = DEV.outerViewport.height + px;
wclientViewport.innerText = DEV.clientViewport.width + px;
hclientViewport.innerText = DEV.clientViewport.height + px;
wavailViewport.innerText = DEV.availViewport.width + px;
havailViewport.innerText = DEV.availViewport.height + px;
vw.innerText = DEV.vw + px;
vh.innerText = DEV.vh + px;
//#endregion
//#region addressBar
waddressBarSize.innerText = DEV.addressBar.width + px;
haddressBarSize.innerText = DEV.addressBar.height + px;
//#endregion
//#region scrollBar
setScrollbar();
//#endregion
//#region orientation
angle.innerText = DEV.orientation.angle + 'º';
type.innerText = DEV.orientation.type;
//#endregion
//#region Miscelaneous
isDark.innerText = DEV.isDarkMode;
isLight.innerText = DEV.isLightMode;
isSafe.innerText = DEV.isSafeConnection;
isFullScreen.innerText = DEV.isFullScreen;
isPortrait.innerText = DEV.isPortrait;
isLandscape.innerText = DEV.isLandscape;
isTouchScreen.innerText = DEV.isTouchScreen;
touchPoints.innerText = DEV.touchPoints;
pixelRatio.innerText = DEV.pixelRatio;
workers.innerText = DEV.workers;
//#endregion
}
setResize();
var inserted = null;
var debounced = function() {
if(inserted)
clearTimeout(inserted);
inserted = setTimeout(function() { setResize(); }, 150);
}
window.onresize = debounced;
window.onscroll = throttled(setScrollbar);
checkScrollX.onchange = function(){
if(checkScrollX.checked)
BODY.style.width = '3000px';
else
BODY.style.width = '';
setScrollbar();
}
checkScrollY.onchange = function(){
if(checkScrollY.checked)
BODY.style.height = '2000px';
else
BODY.style.height = '';
setScrollbar();
}
})(window, document);