-
Notifications
You must be signed in to change notification settings - Fork 14
/
script.js
295 lines (272 loc) · 8.07 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
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
function set_pagetitle() {
var u = ["Urimeligt", "Usandsynligt", "Uetiskt", "Uranholdigt", "Ungarnsk",
"Underligt", "Urmenneskeligt", "Ugennemtænkte", "Ustyrligt",
"Ungdommeligt", "Undtagelsesvist", "Uniformt", "Uregerligt"];
var c = ["Cirklende", "Chokerende", "Ciskønnede", "Charmerende",
"Centrerede", "Camouflerede", "Caribiske", "Censurerede",
"C. L. Seifert-pushende", "Chokoladedryppende"];
var p = ["Pandas", "Pandas", "Pandas", "Pandaers"];
var h = ["Hemmelighed", "Huskeliste", "Havarikommision", "Habengut",
"Hjemmeside", "Hemisfære", "Hengivenhed", "Hurlumhejseri"];
var choose = function(es) { return es[Math.floor(Math.random()*es.length)]; };
$('#pagetitle').html(choose(u) + " " + choose(c) + "<br>" + choose(p) + " " + choose(h));
}
var channelList = [
{
title:"bitreich.org",
mp3:"http://bitreich.org:3232/live"
},
{
title:"DEF CON Radio",
mp3:"http://ice1.somafm.com/defcon-256-mp3"
},
{
title:"DR P1",
mp3:"http://live-icy.gss.dr.dk/A/A03H.mp3"
},
{
title:"DR P2",
mp3:"http://live-icy.gss.dr.dk/A/A04H.mp3"
},
{
title:"DR P3",
mp3:"http://live-icy.gss.dr.dk/A/A05H.mp3"
},
{
title:"DR P4 Midt & Vest",
mp3:"http://live-icy.gss.dr.dk/A/A09H.mp3"
},
{
title:"DR P5",
mp3:"http://live-icy.gss.dr.dk/A/A25H.mp3"
},
{
title:"DR P6 Beat",
mp3:"http://live-icy.gss.dr.dk/A/A29H.mp3"
},
{
title:"DR P7 Mix",
mp3:"http://live-icy.gss.dr.dk/A/A21H.mp3"
},
{
title:"DR P8 Jazz",
mp3:"http://live-icy.gss.dr.dk/A/A22H.mp3"
},
{
title:"Globus Guld (Kolding)",
mp3:"http://stream2.wlmm.dk/guldkoldingmp3"
},
{
title:"HeartBeats",
mp3:"https://streaming02.zfast.co.uk/proxy/heartbea?mp=/stream"
},
{
title:"Lush",
mp3:"http://ice1.somafm.com/lush-128-aac"
},
{
title:"Pop FM",
mp3:"http://stream.popfm.dk/pop128"
},
{
title:"Antenne Bayern",
mp3:"http://mp3channels.webradio.antenne.de/antenne"
},
{
title:"Reprezent 107.3FM",
mp3:"http://radio.canstream.co.uk:8022/live.mp3"
},
{
title:"Radio Alfa (Østjylland)",
mp3:"https://radioserver.dk/alfa"
},
{
title:"Radio Monte Carlo FM",
mp3:"http://icecast.unitedradio.it/RMC.mp3"
},
{
title:"Radio Monte Carlo 2",
mp3:"http://edge.singsingmusic.net/MC2.mp3"
},
{
title:"Radio Riviera",
mp3:"http://rivieraradio.ice.infomaniak.ch:80/rivieraradio-high"
},
{
title:"Radio Viborg",
mp3:"http://netradio.radioviborg.dk/viborg"
},
{
title:"The Lake",
mp3:"http://hyades.shoutca.st:8627/;"
},
{
title:"Uniradioen",
mp3:"http://uniradio.out.airtime.pro:8000/uniradio_a"
},
{
title:"Retro Radio",
mp3:"http://streammp3.retro-radio.dk/retro-mp3"
},
{
title:"Radio Alfas Juleradio",
mp3:"http://89.249.7.68/alfaevent"
},
{
title:"Radio LOUD",
mp3:"https://stream.radioloud.dk/loud128#.mp3"
},
{
title:"Radio4",
mp3:"http://netradio.radio4.dk/radio4"
},
{
title:"Intergalactic.fm Disco Fetish",
mp3:"http://radio.intergalactic.fm/2"
},
];
var sortedChannels = channelList.sort(function(a,b){
var A = a.title.toUpperCase();
var B = b.title.toUpperCase();
if (A < B){return -1;}
if (A > B){return 1;}
return 0;
});
var defaultChannel =
{
title:"Radio Alfa (Østjylland)",
mp3:"http://netradio.radioalfa.dk/"
};
function getParameterByName(name, url) {
if (!url) {
url = window.location.href;
}
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
function show_dictionary() {
$("#tabs1-ordbog").html(`
<h1><a name="tabs1-ordbog">DIKURDBOG</a></h1>
<div id="CSVTable"></div>
`);
$(function() {
$.ajaxSetup({ mimeType: "text/plain" });
$('#CSVTable').CSVToTable('ordbog.csv');
});
}
function get_latest_commits() {
$.getJSON("https://api.github.com/repos/Athas/ucph.dk/commits")
.done(function(data) {
$.each(data.slice(0, 10), function(i, item) {
$("<li/>", {
'html': $("<a/>", {
'href': item.html_url,
'text': item.commit.author.name + ": " + item.commit.message
})}
).appendTo("#commits");
});
});
}
function startup() {
// Setup radio.
var playlist = new jPlayerPlaylist({
jPlayer: "#jpId",
cssSelectorAncestor: "#jp_container_1",
swfPath: "./jplayer",
supplied: "oga, mp3",
wmode: "window",
preload: "none",
useStateClassSkin: true,
autoBlur: false,
smoothPlayBar: true,
keyEnabled: false
}, sortedChannels);
$('#tab-container').easytabs({
panelContext: $(document),
updateHash: true
});
var jp = $("#jpId");
jp.bind($.jPlayer.event.play, function(event){
var kanal = $("a.jp-playlist-current").text();
document.title = kanal + " -- UCPH";
}).bind($.jPlayer.event.pause, function () {
// Don't buffer the radio while paused.
$(this).jPlayer("clearMedia");
playlist.select(playlist.current);
});
var requestedChannel = getParameterByName("radio");
if (requestedChannel != null){
var flatTitle;
var elm;
var i;
var givenChannel = defaultChannel;
for (i in channelList){
elm = channelList[i];
flatTitle = elm["title"].replace(/\s/g,'').toLowerCase();
if (flatTitle.indexOf(requestedChannel) !== -1){
givenChannel = elm;
}
};
jp.bind($.jPlayer.event.play, function(event){
$("#jpId").jPlayer("setMedia", givenChannel)
.jPlayer("play");}
);
};
// Set a random pagetitle.
set_pagetitle();
// Generate and show the dictionary from ordbog.csv.
show_dictionary();
get_latest_commits();
// Handle focus events.
$(window).focus(function(){
set_pagetitle();
if ($("a.jp-playlist-current").text() == "DR P3"){
$("#panda")[0].src = "./image/montecarlo.png";
}
else{$("#panda")[0].src = "./image/pandahoved-cirkel.png";
}
});
// Handle rus introduction.
if (Cookies.get("vis_ikke_slide") == undefined){
var overlay_html = `
<div class="overlay" id="ny_slide_overlay">
<div class="centered-box-helper">
<div class="centered-box">
<h1>Velkommen til UCPH.dk!</h1>
<p>
Vi har oprettet en underside beregnet til nye studerende
på DIKU. Vil du se den?
</p>
<p>
<a class="knap groen" id="ja-knap">
Ja tak, det lyder dejligt
</a>
<a class="knap roed" id="nej-knap">
Nej, det gider jeg ikke
</a>
<a class="knap blaa" id="aldrig-knap">
Nej, og spørg mig ikke igen
</a>
</p>
</div>
</div>
</div>
`;
$(document.body).append(overlay_html);
$("#ja-knap").click(function() {
$("#ny_slide_overlay").remove();
window.location.href = "#tabs1-ny-paa-diku";
});
$("#nej-knap").click(function() {
$("#ny_slide_overlay").remove();
});
$("#aldrig-knap").click(function() {
$("#ny_slide_overlay").remove();
Cookies.set("vis_ikke_slide", "en værdi", {expires: 365});
});
}
}