-
Notifications
You must be signed in to change notification settings - Fork 0
/
tab.htm
executable file
·161 lines (144 loc) · 7.03 KB
/
tab.htm
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
<!DOCTYPE html>
<html>
<head>
<script src="jquery-1.7.1.min.js"></script>
<script src="jquery-ui-1.8.17.custom.min.js"></script>
<script>
var embedable_code_head = '<object width="480" height="296" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"><param name="flashvars" value="cid=';
var embedable_code_center = '&autoplay=false"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="src" value="http://www.ustream.tv/flash/viewer.swf"/><embed flashvars="cid=';
var embedable_code_tail = '&autoplay=false" width="480" height="296" allowfullscreen="true" allowscriptaccess="always" src="http://www.ustream.tv/flash/viewer.swf" type="application/x-shockwave-flash"></embed></object>';
var displays = [{
query_id: "#sortable1",
index: 1,
timeout_id: 0,
delay_seconds: 300,
current_index: 0 },
{
query_id: "#sortable2",
index: 2,
timeout_id: 0,
delay_seconds: 300,
current_index: 0 },
{
query_id: "#sortable3",
index: 3,
timeout_id: 0,
delay_seconds: 300,
current_index: 0 },
{
query_id: "#sortable4",
index: 4,
timeout_id: 0,
delay_seconds: 300,
current_index: 0 }];
var set_screen = function(s) {
s.current_index += 1;
sources = $(s.query_id).sortable("toArray");
if (s.current_index >= sources.length) {
s.current_index %= sources.length;
}
var id = sources[s.current_index].substring(2);
$('#screen' + s.index).html(embedable_code_head + id + embedable_code_center + id + embedable_code_tail);
s.timeout_id = window.setTimeout(function(){set_screen(s);}, s.delay_seconds * 1000);
};
var id_from_button = function(n) {
var request = new XMLHttpRequest();
request.open('GET', 'http://globalgamejam.org/streams?tid_3=' + $('#site' + n).val(), false);
request.send(null);
if (request.status === 200) {
var ggj_response = request.responseText;
var re = /<embed[^>]*flashvars="[^"]*cid=([0-9]+)/
return re.exec(ggj_response)[1];
}
};
jQuery(function(){
$( "#sortable1, #sortable2, #sortable3, #sortable4" ).sortable({
connectWith: ".connectedSortable"
}).disableSelection();
$(".delete-item").click(function(){
$(this).parent().remove();
});
$( ".connectedSortable" ).sortable({
stop: function(event, ui) {
//alert($( ".connectedSortable" ).sortable("toArray"));
}
});
for (var fid = 1; fid <= 4; fid++){
$('#site' + fid).change(function() {
var re = /site([0-9]*)/
var n = re.exec(this.id)[1];
$("#delay" + n).change(function() {
displays[n-1].delay_seconds = $(this).val();
});
var newLi;
var ustream_re = /(http:\/\/(www\.)?ustream\.tv\/channel\/(.*))/
var ustream_result = ustream_re.exec($('#site' + n).val());
if (ustream_result) {
var newLi = $('<li id="' + n + '-' + ustream_result[3] + '">' + ustream_result[0] + '</li>');
} else {
var newId = id_from_button(n);
var newLi = $('<li id="' + n + '-' + newId + '">' + $('#site' + n).val() + '</li>');
}
$(newLi).append('<div class="delete-item">X</div>').click(function() {
$(this).remove();
});
$('#sortable' + n).append(newLi);
window.clearTimeout(displays[n-1].timeout_id);
displays[n-1].current_index = -1;
set_screen(displays[n-1]);
// set_screen(n, newId);
});
}
});
</script>
<style>
body { background-color: black; }
.delete-item { display:inline; color:red; }
.connectedSortable { background-color:white; list-style-type:none; padding:5px; margin-top:1em; border: 1px solid black; }
.connectedSortable .delete-item { float:right; width:1em; }
input { width:100%; }
.settings td { padding:1em; background-color:gray30; border:2px solid black; vertical-align:top; }
table { border-collapse: collapse; }
</style>
</head>
<body>
<table>
<tr>
<td><div id="screen1"></div></td>
<td><div id="screen2"></div></td>
</tr><tr>
<td><div id="screen3"></div></td>
<td><div id="screen4"></div></td>
</tr>
</table>
<table class="settings">
<tr>
<td>
<input style="margin-top: 0px; border:1px solid black" type="text" id="site1" placeholder="Site for window 1"/>
<input type="number" min="10" max="2000000" id="delay1" value="300"/>
<ul id="sortable1" class="connectedSortable">
</ul>
</td>
<td>
<input type="text" id="site2" placeholder="Site for window 2"/>
<input type="number" min="10" max="2000000" id="delay2" value="300"/>
<ul id="sortable2" class="connectedSortable">
</ul>
</td>
</tr><tr>
<td>
<input type="text" id="site3" placeholder="Site for window 3"/>
<input type="number" min="10" max="2000000" id="delay1" value="300"/>
<ul id="sortable3" class="connectedSortable">
</ul>
</td>
<td>
<input type="text" id="site4" placeholder="Site for window 4"/>
<input type="number" min="10" max="2000000" id="delay2" value="300"/>
<ul id="sortable4" class="connectedSortable">
</ul>
</td>
</tr>
</table>
</body>
</html>