forked from openspeedtest/Speed-Test
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
224 lines (201 loc) · 8.48 KB
/
index.html
File metadata and controls
224 lines (201 loc) · 8.48 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
220
221
222
223
224
<!DOCTYPE html>
<html lang="en">
<head>
<title>Network Speed Test - Dext</title>
<meta name="description" content="Test your network speed now. Safe, fast, client-side."/>
<link href="assets/css/app.css" rel="stylesheet" type="text/css" />
<script> window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches&&(document.head.innerHTML+='<link id="darkmode" rel="stylesheet" href="assets/css/darkmode.css" type="text/css"/>');function getCookieValue(b,a){return(a=document.cookie.match("(^|;)\\s*"+b+"\\s*=\\s*([^;]+)"))?a.pop():""}if("light"===getCookieValue("mode")){var darkStyle=document.getElementById("darkmode");darkStyle&&darkStyle.parentNode.removeChild(darkStyle)}; </script>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta property="og:image" content="assets/images/img.png" />
<link rel="apple-touch-icon" sizes="180x180" href="assets/images/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="assets/images/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/images/icons/favicon-16x16.png">
<link rel="manifest" href="assets/images/icons/site.webmanifest">
<link rel="mask-icon" href="assets/images/icons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="assets/images/icons/favicon.ico">
<meta name="msapplication-TileColor" content="#ffc40d">
<meta name="msapplication-config" content="assets/images/icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
</head>
<body>
<script type="text/javascript">
var openSpeedTestServerList = [
{"ServerName":"Home", "Download":"downloading", "Upload":"upload", "ServerIcon":"DefaultIcon"}
];
var pingSamples = 10;
var jitterFinalSample = 0.5;
var setPingSamples = true;
var pingTimeOut = 5000;
var setPingTimeout = true;
var pingMethod = "GET";
var pingFile = "Upload";
var ulDataSize = 30;
var ulDelay = 300;
var dlDelay = 300;
var upAdjust = 1.04;
var dlAdjust = 1.04;
var enableClean = true;
var dlDuration = 12;
var ulDuration = 12;
var dlThreads = 6;
var ulThreads = 6;
var setHTTPReq = true;
var saveData = false;
var saveDataURL = "//yourDatabase.Server.com:4500/save?data=";
var stressTest = true;
var selectTest = true;
var selectServer = true;
var enableRun = true;
function ostOnload() {
console.log("OpenSpeedTest V2.5.4 Loaded!")
}
var openChannel = "dev";
// Parse shared results from URL hash
var sharedResultsData = null;
(function() {
if (location.hash.indexOf('#results=') === 0) {
try {
sharedResultsData = JSON.parse(atob(decodeURIComponent(location.hash.substring(9))));
} catch(e) {}
}
})();
// Extract y-values from a polygon points string, downsample to ~maxPts points,
// and normalize to 0-99 integers (0 = no speed, 99 = max speed).
function extractGraph(className, maxPts) {
var el = document.querySelector('.' + className);
if (!el) return null;
var raw = el.getAttribute('points');
if (!raw) return null;
var pairs = raw.trim().split(/\s+/);
// Strip baseline bookend points (first "0,50" and last "130,50")
var yVals = [];
for (var i = 1; i < pairs.length - 1; i++) {
var parts = pairs[i].split(',');
if (parts.length === 2) yVals.push(parseFloat(parts[1]));
}
if (yVals.length === 0) return null;
// Downsample
var step = Math.max(1, Math.floor(yVals.length / maxPts));
var sampled = [];
for (var i = 0; i < yVals.length; i += step) {
// Normalize: y=0 → 99 (max), y=50 → 0 (zero speed)
var n = Math.round((1 - yVals[i] / 50) * 99);
if (n < 0) n = 0; if (n > 99) n = 99;
sampled.push(n);
}
return sampled;
}
function shareResults() {
var d = document.getElementById('downResult').textContent;
var u = document.getElementById('upRestxt').textContent;
var p = document.getElementById('pingResult').textContent;
var j = document.getElementById('jitterDesk').textContent;
var obj = {
d: d, u: u, p: p, j: j,
ua: navigator.userAgent,
t: new Date().toISOString()
};
var dlGraph = extractGraph('line', 25);
var ulGraph = extractGraph('line2', 25);
if (dlGraph) obj.dg = dlGraph;
if (ulGraph) obj.ug = ulGraph;
var data = JSON.stringify(obj);
var encoded = btoa(data);
var url = location.origin + location.pathname + '#results=' + encodeURIComponent(encoded);
var btn = document.getElementById('shareBtn');
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(url).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy Share Link'; }, 2000);
}, function() {
prompt('Copy this link:', url);
});
} else {
prompt('Copy this link:', url);
}
}
// Rebuild a polygon points string from normalized 0-99 values
function buildGraphPoints(vals) {
if (!vals || vals.length === 0) return null;
var pts = '0,50 ';
var step = 130 / (vals.length - 1 || 1);
for (var i = 0; i < vals.length; i++) {
var x = (step * i).toFixed(2);
var y = (50 * (1 - vals[i] / 99)).toFixed(2);
pts += x + ',' + y + ' ';
}
pts += '130,50';
return pts;
}
function renderSharedGraph(symbolId, className, vals) {
if (!vals) return;
var pts = buildGraphPoints(vals);
if (!pts) return;
var sym = document.getElementById(symbolId);
if (!sym) return;
// Remove existing placeholder polygon
var old = sym.querySelector('.' + className);
if (old) old.parentNode.removeChild(old);
var poly = document.createElementNS('http://www.w3.org/2000/svg', 'polygon');
poly.setAttribute('points', pts);
poly.setAttribute('class', className);
sym.appendChild(poly);
}
function displaySharedResults(data) {
var loader = document.getElementById('loading_app');
if (loader) loader.style.display = 'none';
var svg = document.getElementById('OpenSpeedtest');
if (svg) { svg.style.display = 'block'; svg.style.visibility = 'visible'; svg.style.opacity = '1'; }
var introDesk = document.getElementById('intro-Desk');
var introMob = document.getElementById('intro-Mob');
var uiDesk = document.getElementById('UI-Desk');
var uiMob = document.getElementById('UI-Mob');
if (introDesk) introDesk.style.display = 'none';
if (introMob) introMob.style.display = 'none';
if (uiDesk) { uiDesk.style.display = 'block'; uiDesk.style.opacity = '1'; }
if (uiMob) { uiMob.style.display = 'block'; uiMob.style.opacity = '1'; }
var setResult = function(id, val) {
var el = document.getElementById(id);
if (el) el.textContent = val;
};
setResult('downResult', data.d);
setResult('upRestxt', data.u);
setResult('pingResult', data.p);
setResult('jitterDesk', data.j);
setResult('pingMobres', data.p);
setResult('JitterResultMon', data.j);
setResult('oDoLiveSpeed', 'Shared Result');
var statusEl = document.getElementById('oDoLiveStatus');
if (statusEl && data.t) {
statusEl.textContent = new Date(data.t).toLocaleString();
}
// Render shared graphs
renderSharedGraph('graphc1', 'line', data.dg);
renderSharedGraph('graphc2', 'line2', data.ug);
var postActions = document.getElementById('postTestActions');
if (postActions) {
postActions.style.display = 'flex';
var shareBtn = document.getElementById('shareBtn');
if (shareBtn) shareBtn.textContent = 'Copy Link';
}
}
</script>
<div id="loading_app" class="spinner">
<div class="bounce1"></div>
<div class="bounce2"></div>
<div class="bounce3"></div>
</div>
<object style="visibility:hidden" id="OpenSpeedTest-UI" data="assets/images/app.svg" type="image/svg+xml"></object>
<div id="postTestActions" style="display:none;">
<button id="shareBtn" class="action-btn" onclick="shareResults()">Copy Share Link</button>
<button id="newTestBtn" class="action-btn" onclick="location.href=location.pathname">Run New Test</button>
</div>
<div class="Credits">
Based on <a href="https://github.com/openspeedtest/Speed-Test" rel="nofollow">OpenSpeedTest</a>
</div>
<script src="assets/js/app-2.5.4.js"></script>
<script src="assets/js/darkmode.js"></script>
</body>
</html>