-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscript.js
79 lines (68 loc) · 2.28 KB
/
script.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
function byId(id) {
return document.getElementById(id);
}
function byClass(c) {
return document.getElementsByClassName(c);
}
function fullscreen(elm) {
(elm.requestFullscreen ? elm.requestFullscreen() : (elm.webkitRequestFullscreen ? elm.webkitRequestFullscreen() : (elm.mozRequestFullScreen ? elm.mozRequestFullScreen() : (elm.msRequestFullscreen ? elm.msRequestFullscreen() : alert('Your browser does not support fullscreen!')))))
}
var currentTab = 1;
var currentTabs = 1;
function openTab(id) {
for (var i = 0, tabcontents = byId('tabs').children; i < tabcontents.length; i++) {
tabcontents[i].style.display = 'none';
}
for (var i = 0, tabbtns = byId('tabbtns').children; i < tabbtns.length; i++) {
tabbtns[i].className = tabbtns[i].className.replace(' active', '');
}
byId('tab'+id).style.display = 'block';
currentTab = id;
byId('tabb'+id).className += ' active';
}
window.onload = function() {
byId('address').addEventListener('keyup', function (event) {
if (event.keyCode == 13) {
document.getElementById('load').click();
}
});
}
function load() {
byId('iweb' + currentTab).src = byId('address').value;
}
function close() {
byId('tabb'+currentTab).parentNode.removeChild(byId('tab'+currentTab));
byId('tab'+currentTab).parentNode.removeChild(byId('tab'+currentTab));
}
function newtab() {
var t = ++currentTab;
var tabbtn = document.createElement('button');
tabbtn.className = 'btn';
tabbtn.setAttribute('onclick', 'openTab('+t+')');
tabbtn.id = 'tabb'+t;
tabbtn.innerHTML = 'Tab '+t;
var div = document.createElement('div');
div.id = 'tab'+t;
div.className = 'tabcontent';
div.style.display = 'none';
var closeBtn = document.createElement('span');
closeBtn.onclick = 'close()';
closeBtn.className = 'topright';
closeBtn.innerHTML = '[x]';
div.appendChild(closeBtn);
var fullBtn = document.createElement('span');
fullBtn.onclick = 'close()';
fullBtn.className = 'topright2';
fullBtn.innerHTML = '[+]';
div.appendChild(fullBtn);
var iframe = document.createElement('iframe');
iframe.src = '';
iframe.height = 500;
iframe.width = 1000;
iframe.id = 'iweb'+t;
iframe.allowFullscreen = true;
div.appendChild(iframe);
byId('tabbtns').appendChild(tabbtn);
byId('tabs').appendChild(div);
openTab(t);
}