-
Notifications
You must be signed in to change notification settings - Fork 35
/
tabs.html
142 lines (120 loc) · 4.43 KB
/
tabs.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CRE Tabs</title>
<meta property="og:site_name" content="MH Tools by tsitu">
<meta property="og:type" content="article">
<meta property="og:url" content="https://tsitu.github.io/MH-Tools/tabs.html">
<meta property="og:title" content="CRE Tabs">
<meta property="og:description" content="Provides a convenient way to spin up multiple independent instances of the CRE tool">
<meta property="og:image" content="https://cdn.jsdelivr.net/gh/tsitu/MH-Tools@30fb31004ae976aaf29652c435629dcca926d169/lib/img/cheese.jpg">
<meta property="og:image:secure_url" content="https://cdn.jsdelivr.net/gh/tsitu/MH-Tools@30fb31004ae976aaf29652c435629dcca926d169/lib/img/cheese.jpg">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="icon" type="image/x-icon" href="lib/img/favicon.ico">
<style>
body {
font-family: "Trebuchet MS", "Helvetica", "Arial", "Verdana", "sans-serif";
font-size: 100%;
}
.tab {
height: 100vh;
}
#tabs {
position: relative;
padding-bottom: 3em;
}
#tabs .ui-tabs-nav {
position: absolute;
left: 0.25em;
right: 0.25em;
bottom: 0.25em;
padding: 0em 0.2em 0.2em;
}
#tabs .ui-tabs-nav li {
border-top: none;
border-bottom: 1px solid #ccc;
-moz-border-radius: 0px 0px 4px 4px;
-webkit-border-radius: 0px 0px 4px 4px;
border-radius: 0px 0px 4px 4px;
}
#tabs .ui-tabs-nav li.ui-tabs-selected,
#tabs .ui-tabs-nav li.ui-state-active {
top: -1px;
}
</style>
<script>
var numTabs = 3;
var savedUrl = "";
$(function() {
$("#tabs").tabs({active: 1});
});
function addTab() {
numTabs++;
var tabs = $("#tabs").tabs();
var ul = tabs.find("ul");
$("<li><a href='#tabs-" + numTabs + "'>" + numTabs + "</a></li>").appendTo(ul)
$("<div id='tabs-" + numTabs + "' class='tab'><iframe src='https://tsitu.github.io/MH-Tools/cre.html' width='100%' height='100%'></iframe>").appendTo(tabs);
tabs.tabs("refresh");
}
function saveUrl() {
var active = $("#tabs").tabs("option", "active");
var activeName = "tabs-" + active;
var activeDiv = document.getElementById(activeName);
savedUrl = activeDiv.getElementsByTagName("iframe")[0].contentWindow.document.getElementById("link").href;
console.log("savedUrl: " + savedUrl);
}
function pasteUrl() {
var active = $("#tabs").tabs("option", "active");
var activeName = "tabs-" + active;
var activeDiv = document.getElementById(activeName);
if (savedUrl.length > 0) {
activeDiv.getElementsByTagName("iframe")[0].src = savedUrl;
}
}
$(document).keydown(function(e) {
if (e.keyCode == 67 && e.altKey) {
saveUrl();
}
else if (e.keyCode == 86 && e.altKey) {
pasteUrl();
}
})
</script>
<!-- Google Analytics -->
<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','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-61581935-1', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div id="tabs">
<ul id="buttonList">
<li><a href="#tabs-add" onclick="addTab()">+</a></li>
<li><a href="#tabs-1">1</a></li>
<li><a href="#tabs-2">2</a></li>
<li><a href="#tabs-3">3</a></li>
</ul>
<div id="tabs-add" class="tab"></div>
<div id="tabs-1" class="tab">
<iframe src="https://tsitu.github.io/MH-Tools/cre.html" width="100%" height="100%"></iframe>
</div>
<div id="tabs-2" class="tab">
<iframe src="https://tsitu.github.io/MH-Tools/cre.html" width="100%" height="100%"></iframe>
</div>
<div id="tabs-3" class="tab">
<iframe src="https://tsitu.github.io/MH-Tools/cre.html" width="100%" height="100%"></iframe>
</div>
</div>
<div id="urlbutton">
<button id="saveUrl" onclick="saveUrl()">Save Setup</button>
<button id="pasteUrl" onclick="pasteUrl()">Paste Setup (to current tab)</button>
</div>
</body>
</html>