-
Notifications
You must be signed in to change notification settings - Fork 0
/
load_on_click.html
132 lines (86 loc) · 2.85 KB
/
load_on_click.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
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript" src="http://code.jquery.com/jquery.min.js"></script>
<script>
function clickfunction(item){
var val = Number(item.replace('app', ''));
var numiframes = 1;
var miniframe = val - numiframes;
var maxiframe = val + numiframes;
if(miniframe<0) miniframe = 0;
if(maxiframe>38) maxframe = 38;
var alliframes = [];
for (var i = miniframe; i < maxiframe + 1; i++) {
alliframes.push('iframe' + i)
};
console.log(alliframes)
// this is the full set of iframes we care about
var iframes = $('.tab-pane>iframe');
// loop through the iframes and remove all but be sure
// not to remove the one they clicked on.
for (var i = 0; i < iframes.length; i++) {
var theid = iframes[i].id;
if($.inArray(theid, alliframes) == -1){$('#' + theid).remove()};
};
for (var i = miniframe; i < maxiframe + 1 ; i++) {
if($('#iframe' + i).length == 0){
$('#app' + i).append('<iFrame width = "100%" height = "400px" class="iframeapp" id = "iframe' + i + '" src="https://spatial.shinyapps.io/blog_app' + i + '/"></iFrame>');
}
}
};
</script>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#code0">Code 0</a></li>
<li><a id="apptoggle0" data-toggle="tab" href="#app0" onclick = "clickfunction(this.hash.substr(1))">App 0</a></li>
</ul>
<div class="tab-content">
<div id="code0" data-appear-top-offset="500" class="tab-pane fade in active">
<pre><code>
https://github.com/morr/jquery.appear
</code></pre>
</div>
<div id="app0" class="tab-pane fade">
</div>
</div>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#code1">Code 1</a></li>
<li><a id="apptoggle1" data-toggle="tab" href="#app1" onclick = "clickfunction(this.hash.substr(1))">App 1</a></li>
</ul>
<div class="tab-content">
<div id="code1" data-appear-top-offset="500" class="tab-pane fade in active">
<pre><code>
https://github.com/morr/jquery.appear
</code></pre>
</div>
<div id="app1" class="tab-pane fade">
</div>
</div>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#code2">Code 2</a></li>
<li><a id="apptoggle2" data-toggle="tab" href="#app2" onclick = "clickfunction(this.hash.substr(1))">App 2</a></li>
</ul>
<div class="tab-content">
<div id="code2" data-appear-top-offset="500" class="tab-pane fade in active">
<pre><code>
https://github.com/morr/jquery.appear
</code></pre>
</div>
<div id="app2" class="tab-pane fade">
</div>
</div>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#code3">Code 3</a></li>
<li><a id="apptoggle3" data-toggle="tab" href="#app3" onclick = "clickfunction(this.hash.substr(1))">App 3</a></li>
</ul>
<div class="tab-content">
<div id="code3" data-appear-top-offset="500" class="tab-pane fade in active">
<pre><code>
https://github.com/morr/jquery.appear
</code></pre>
</div>
<div id="app3" class="tab-pane fade">
</div>
</div>
</body>
</html>