-
Notifications
You must be signed in to change notification settings - Fork 48
Expand file tree
/
Copy pathindex.htm
More file actions
331 lines (297 loc) · 12 KB
/
index.htm
File metadata and controls
331 lines (297 loc) · 12 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
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
<html>
<head>
<title>How to get local IP address:</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="styles.css">
<script src="jquery-1.10.2.min.js"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-38882316-1', 'junkcode.net');
ga('send', 'pageview');
</script>
<script>
var addrs = Object.create(null);
var runningOnPc = true;
var scanning = false;
var scanHref = null;
var scanImg = null;
var scanCap = null;
var space = "0.0.0"
var upper = 255;
var lower = 0;
var dirUp = true;
var img = new Image();
var table=null;
var givenIP = false;
function updateDisplay(newAddr) {
if (newAddr in addrs) return;
else addrs[newAddr] = true;
displayAddrs = Object.keys(addrs).filter(function (k) { return addrs[k]; });
//document.getElementById('list').textContent = displayAddrs.join(" or perhaps ") || "n/a";
var row=table.insertRow(1)//<h3><a href="http://'+newAddr+':8111" target="_blank">Try it </h3>
//newAddr=newAddr.substr(1);
row.innerHTML='\
<td><h1 id="c'+newAddr+'">'+newAddr+'</h1></td>\
<td><img id="i'+newAddr+'" src="Find.png" onload=""></td>';
if(runningOnPc){
row.innerHTML+='\
<td>\
<a href="http://chart.apis.google.com/chart?chs=300x300&cht=qr&chld=|1&chl=http%3A%2F%2Fip.junkcode.net/index.htm?ip='+newAddr+'" alt="QR Code"/>\
<img src="http://chart.apis.google.com/chart?chs=100x100&cht=qr&chld=|1&chl=http%3A%2F%2Fip.junkcode.net/index.htm?ip='+newAddr+'" alt="QR Code"/>\
</a>\
</td>';
}else{
row.innerHTML+='\
<td>\
<a href="#" id="h'+newAddr+'" onclick="scan(\''+newAddr+'\')"/>\
<h3>Scan for correct IP</h3>\
</a>\
</td>';
}
//console.log(row);
//console.log(addrs);
checkImage1(newAddr);
autoWorking();
return true;
}
function getIP(){
// code source: http://net.ipcalf.com/
// NOTE: window.RTCPeerConnection is "not a constructor" in FF22/23
var RTCPeerConnection = /*window.RTCPeerConnection ||*/ window.webkitRTCPeerConnection || window.mozRTCPeerConnection;
if (RTCPeerConnection) (function () {
var rtc = new RTCPeerConnection({iceServers:[]});
if (window.mozRTCPeerConnection) { // FF needs a channel/stream to proceed
rtc.createDataChannel('', {reliable:false});
};
rtc.onicecandidate = function (evt) {
if (evt.candidate) grepSDP(evt.candidate.candidate);
};
rtc.createOffer(function (offerDesc) {
grepSDP(offerDesc.sdp);
rtc.setLocalDescription(offerDesc);
}, function (e) { console.warn("offer failed", e); });
//addrs = Object.create(null);
addrs["0.0.0.0"] = false;
function grepSDP(sdp) {
var hosts = [];
sdp.split('\r\n').forEach(function (line) { // c.f. http://tools.ietf.org/html/rfc4566#page-39
if (~line.indexOf("a=candidate")) { // http://tools.ietf.org/html/rfc4566#section-5.13
var parts = line.split(' '), // http://tools.ietf.org/html/rfc5245#section-15.1
addr = parts[4],
type = parts[7];
if (type === 'host') updateDisplay(addr);
} else if (~line.indexOf("c=")) { // http://tools.ietf.org/html/rfc4566#section-5.7
var parts = line.split(' '),
addr = parts[2];
updateDisplay(addr);
}
});
}
})(); else {
return false;
document.getElementById('list').innerHTML = "... nothing";
showManualGetIP();
//document.getElementById('list').nextSibling.textContent = "In Chrome and Firefox your IP should display automatically, by the power of WebRTCskull.";
}
}
function scan(addr){
scanHref= document.getElementById("h"+addr);
scanImg = document.getElementById("i"+addr);
scanCap = document.getElementById("c"+addr);
scanImg.onclick="";
scanImg.src="Find.png";
if(scanning){
scanImg.src="Remove.png";
stopScan();
}else{
scanning=true;
scanHref.innerHTML='<h3>Stop</h3>';
var splitted = addr.split('.'),
lastDaddr = parseInt(splitted[3],10);
console.log("lastnum: "+splitted[3]+" -- "+lastDaddr);
space = splitted[0]+"."+splitted[1]+"."+splitted[2];
upper = lastDaddr;
lower = lastDaddr;
runScan();
}
}
function stopScan(){
scanning=false;
scanHref.innerHTML='<h3>Scan for correct IP</h3>';
}
// scanning function
function runScan(){
console.log("scanning2");
if(!scanning)return;
scanImg.src="Find.png";
var timer;
function clearTimer() {
if (timer) {
clearTimeout(timer);
timer = null;
}
}
dirUp=!dirUp;
if(dirUp && upper<=255){
upper+=1;
src=space+"."+upper;
console.log("up");
}else{
console.log("down");
if(lower>0){
lower-=1;
src=space+"."+lower;
}else{
if(upper>255){
scanImg.src="Remove.png";
stopScan();
}
runScan();
console.log("out");
return;
}
}
function handleFail() {
scanImg.src="Remove.png";
this.onload = this.onabort = this.onerror = function() {};
clearTimer();
runScan();
}
img.onload = function() { /// Succes !
clearTimer();
stopScan();
scanImg.src="Check.png";
gotMatch(src);
};
img.onerror = img.onabort = handleFail; //fail
scanCap.innerHTML=src;
img.src = "http://"+src+":8111/css/vader/images/ui-icons_bbbbbb_256x240.png"; // fires off loading of image
timer = setTimeout(function(img) {
return function() {
handleFail.call(img);
};
}(img), 200);
}
// url parameter get
function get(name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
}
// warning if automatic ip discovery isn't working
function autoWorking(){
document.getElementById("manual").style.display = 'none';
document.getElementById("nw").style.display = 'none';
}
// init function
function run(){
table=document.getElementById("myTable");
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
runningOnPc = false;
document.getElementById('mainTXT').innerHTML="Try Scan or oppen this page on commputer";
}
var newAddr = get("ip");
if(newAddr){
//autoWorking();
//alert(newAddr);
givenIP=true;
updateDisplay(newAddr);
}else{
getIP();
}
//console.log(addrs);
/* for(var i=0;i<displayAddrs.length;i++){
console.log(displayAddrs);
}
*/
}
function showManualGetIP(){
document.getElementById("manual").style.display = 'block';
}
// refreshes QR images of manual ip
function manIpRefresh(input){
//document.getElementById("mlink").href="http://"+input.value+":8111";
document.getElementById("mQRlink").href="http://chart.apis.google.com/chart?chs=300x300&cht=qr&chld=|1&chl=http%3A%2F%2Fip.junkcode.net/index.htm?ip="+input.value+"";
document.getElementById("mQRimg").src="http://chart.apis.google.com/chart?chs=100x100&cht=qr&chld=|1&chl=http%3A%2F%2Fip.junkcode.net/index.htm?ip="+input.value+"";
checkImage(input.value,document.getElementById("imgmanual"));
}
// chcecks if ip coresponds with WarThunder
function checkImage1(src){
var dst = document.getElementById("i"+src);
checkImage(src,dst)
}
function checkImage(src,dst) {
dst.onload="";
var img = new Image();
img.onload = function() {
gotMatch(src);
dst.src="Check.png"
};
img.onerror = function() {
dst.src="Remove.png"
if(!runningOnPc){
var r=confirm("No connection on this IP. Run Scan on similar addresses?");
if (r==true){
scan(src);
}
}
}
img.src = "http://"+src+":8111/css/vader/images/ui-icons_bbbbbb_256x240.png"; // fires off loading of image
}
function gotMatch(adr){
if(!runningOnPc){
alert("Found conntact. "+adr);
/*if(r){
window.location.replace("intent://ip/#Intent;scheme=junkcode;package=net.junkcode.warthundertacticalmap;ip="+adr+";end");
}*/
}
document.getElementById('mainTXT').style.color = "#006699";
}
</script>
</head>
<body onload='run()'>
<h1 style="color: red" id ="mainTXT">Open this page on computer running War Thunder</h1>
<h3 style="color: red;" id="nw">Automatic detection not working (try using Chrom or firefox), see bellow how to get it manualy </h3>
<h2 style="color: green"><u>New help guide</u> >><a href="./help">Here</a><<</h2>
<div class="datagrid"><table id="myTable">
<thead><tr><th>IPs</th><th>Test</th><th>Get it mobile</th></tr></thead>
<tbody>
<tr>
<td><input type="text" name="manualip" onchange="manIpRefresh(this)"> <a href="#">Test</a></td>
<td><!--<h3><a target="_blank" id="mlink">Try it</h3> --><img id="imgmanual" src="Find.png"></td>
<td>
<a alt="QR Code" id="mQRlink"/>
<img src="Remove.png" alt="QR Code" id="mQRimg"/>
</a>
</td>
</tr>
</tbody>
</table></div>
<a href="#" onclick="showManualGetIP()">
<h3>How to manualy get local IP address</h3>
</a>
<div id="manual">
<p>
<strong>1</strong>. Open windows Start menu (or press keys WIN+R) and type "cmd"</p>
<p>
<img alt="" src="http://ip.junkcode.net/start.png" style="width: 468px; height: 540px;" /></p>
<p>
</p>
<p>
2. In command window type "ipconfig" and hit Enter</p>
<p>
<img alt="" src="http://ip.junkcode.net/cmd.png" style="width: 677px; height: 342px;" /></p>
<p>
3. You will find your local IP address on the line "<code>IPv4 Address</code>" under adapter for Local Area Network (LAN) (name may differ) and if you can't find it be sure to check if it isn't scroled up.</p>
<p>
<img alt="" src="http://ip.junkcode.net/ipconfig.png" style="width: 677px; height: 342px;" />
</p>
</div>
<p>
If you encounter any problem contact me on <a href="mailto:help@junkcode.net?subject=I%20can't%20get%20my%20IP">help@junkcode.net</a></p>
<p>
<a href="http://junkcode.net/">Back to Main page</a></p>
</body>
</html>