-
Notifications
You must be signed in to change notification settings - Fork 102
/
Copy pathindex.html
321 lines (291 loc) · 13.2 KB
/
index.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
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
<html>
<head>
<title>Hatnote Listen to Wikipedia</title>
<meta name="title" content="Hatnote Listen to Wikipedia">
<meta name="description" content="Listen to recent changes on Wikipedia">
<meta name="keywords" content="hatnote, listen, recent changes, sound, music, wikipedia, edits, visualization">
<meta name="author" content="Stephen LaPorte and Mahmoud Hashemi">
<link rel="stylesheet" type="text/css" href="css/nouislider.custom.css">
<script src="js/seedrandom.js" type="text/javascript"></script>
<script src="js/jquery-1.9.1.min.js"></script>
<script src="js/d3.min.js"></script>
<script src="js/howler.min.js"></script>
<script src="js/reconnecting-websocket.min.js" type="text/javascript"></script>
<script src="js/app.js" type="text/javascript"></script>
<script src="js/jquery.nouislider.min.js"></script>
<script src="js/howler.min.js"></script>
<script>
var global_mute = false;
var global_volume = 50;
$(function(){
Howler.volume(global_volume * .01);
$("#volumeControl").click(function() {
if (!global_mute) {
global_mute = false;
Howler.mute();
$("#volumeControl").css("background-position", "0 0");
} else {
global_mute = false;
Howler.unmute();
$("#volumeControl").css("background-position", "0 -46px");
}
});
$("#volumeSlider").noUiSlider({
range : [-99, 0],
start : 0,
handles : 1,
step : 1,
orientation : "horizontal",
slide : function() {
global_volume = 100 + $(this).val();
var howler_volume = global_volume * 0.01;
if (howler_volume <= 0.01) {
Howler.mute();
} else {
Howler.unmute();
Howler.volume(global_volume * .01);
}
}}); });
</script>
<script>
/* Settings
======== */
var scale_factor = 5,
note_overlap = 15,
note_timeout = 300,
current_notes = 0,
max_life = 60000,
DEFAULT_LANG = 'en';
/* Colors
====== */
var body_background_color = '#f8f8f8',
body_text_color = '#000',
svg_background_color = '#1c2733',
svg_text_color = '#fff',
newuser_box_color = 'rgb(41, 128, 185)',
bot_color = 'rgb(155, 89, 182)',
anon_color = 'rgb(46, 204, 113)',
edit_color = '#fff',
sound_totals = 51,
total_edits = 0;
/* Languages
========= */
var langs = {
'en': ['English', 'ws://wikimon.hatnote.com:9000'],
'de': ['German', 'ws://wikimon.hatnote.com:9010'],
'ru': ['Russian', 'ws://wikimon.hatnote.com:9020'],
'uk': ['Ukrainian', 'ws://wikimon.hatnote.com:9310'],
'ja': ['Japanese', 'ws://wikimon.hatnote.com:9030'],
'es': ['Spanish', 'ws://wikimon.hatnote.com:9040'],
'fr': ['French', 'ws://wikimon.hatnote.com:9050'],
'nl': ['Dutch', 'ws://wikimon.hatnote.com:9060'],
'it': ['Italian', 'ws://wikimon.hatnote.com:9070'],
'sv': ['Swedish', 'ws://wikimon.hatnote.com:9080'],
'ar': ['Arabic', 'ws://wikimon.hatnote.com:9090'],
'fa': ['Farsi', 'ws://wikimon.hatnote.com:9210'],
'he': ['Hebrew' , 'ws://wikimon.hatnote.com:9230'],
'id': ['Indonesian', 'ws://wikimon.hatnote.com:9100'],
'zh': ['Chinese', 'ws://wikimon.hatnote.com:9240'],
'as': ['Assamese', 'ws://wikimon.hatnote.com:9150'],
'hi': ['Hindi', 'ws://wikimon.hatnote.com:9140'],
'bn': ['Bengali', 'ws://wikimon.hatnote.com:9160'],
'pa': ['Punjabi', 'ws://wikimon.hatnote.com:9120'],
'te': ['Telugu', 'ws://wikimon.hatnote.com:9160'],
'ta': ['Tamil', 'ws://wikimon.hatnote.com:9110'],
'ml': ['Malayalam', 'ws://wikimon.hatnote.com:9250'],
'mr': ['Western Mari', 'ws://wikimon.hatnote.com:9130'],
'kn': ['Kannada', 'ws://wikimon.hatnote.com:9170'],
'or': ['Oriya', 'ws://wikimon.hatnote.com:9180'],
'sa': ['Sanskrit', 'ws://wikimon.hatnote.com:9190'],
'gu': ['Gujarati' , 'ws://wikimon.hatnote.com:9200'],
'pl': ['Polish' , 'ws://wikimon.hatnote.com:9260'],
'mk': ['Macedonian' , 'ws://wikimon.hatnote.com:9270'],
'be': ['Belarusian' , 'ws://wikimon.hatnote.com:9280'],
'sr': ['Serbian' , 'ws://wikimon.hatnote.com:9290'],
'bg': ['Bulgarian' , 'ws://wikimon.hatnote.com:9300'],
'hu': ['Hungarian', 'ws://wikimon.hatnote.com:9320'],
'ca': ['Catalan', 'ws://wikimon.hatnote.com:9330'],
'wikidata': ['Wikidata' , 'ws://wikimon.hatnote.com:9220']
}
/*
============== */
var w = window,
d = document,
e = d.documentElement,
g = d.getElementsByTagName('#area svg')[0],
width = w.innerWidth || e.clientWidth || g.clientWidth;
height = (w.innerHeight - $('#header').height())|| (e.clientHeight - $('#header').height()) || (g.clientHeight - $('#header').height());
var celesta = [],
clav = [],
epm = 0,
edit_times = [],
SOCKETS = {},
swells = [],
all_loaded = false,
s_titles = true,
s_welcome = true,
s_langs = [];
var user_announcements = false;
setTimeout(function() {
user_announcements = true;
}, 20000);
$(function(){
$('body').css('background-color', body_background_color)
$('body').css('color', body_text_color)
$('svg').css('background-color', svg_background_color)
$('svg text').css('color', svg_text_color)
// :(
$('head').append('<style type="text/css">.newuser-label {fill:' + svg_text_color +
';} .bot {fill:' + bot_color +
';} .anon {fill:' + anon_color +
';} .bot </style>');
$('body').append('<div id="loading"><p>Loading sound files ...</p></div>')
var svg = d3.select("#area").append("svg")
.attr({width: width, height: height})
.style('background-color', '#1c2733');
var update_window = function() {
width = w.innerWidth || e.clientWidth || g.clientWidth;
height = (w.innerHeight - $('#header').height())|| (e.clientHeight - $('#header').height()) || (g.clientHeight - $('#header').height());
svg.attr("width", width).attr("height", height);
if (epm_text) {
epm_container.attr('transform', 'translate(0, ' + (height - 25) + ')')
}
/*rate_bg.attr("width", width).attr("height", height);*/
}
window.onresize = update_window;
$('#welcome').click(make_click_handler($('#welcome'), 'nowelcomes')
);
$('#titles').click(
make_click_handler($('#titles'), 'notitles')
);
$('#about-link').click(function(){
// because we use window.location to set languages.
$('html, body').animate({scrollTop:$(document).height()}, 'slow');
return false;
});
// TODO: Volume slider?
var loaded_sounds = 0
var sound_load = function(r) {
loaded_sounds += 1
if (loaded_sounds == sound_totals) {
all_loaded = true
$('#loading').remove()
console.log('Loading complete')
} else {
console.log('Loading : ' + loaded_sounds + ' files out of ' + sound_totals)
}
}
// load celesta and clav sounds
for (var i = 1; i <= 24; i++) {
if (i > 9) {
fn = 'c0' + i;
} else {
fn = 'c00' + i;
}
celesta.push(new Howl({
urls : ['sounds/celesta/' + fn + '.ogg',
'sounds/celesta/' + fn + '.mp3'],
volume : 0.2,
onload : sound_load(),
}))
clav.push(new Howl({
urls : ['sounds/clav/' + fn + '.ogg',
'sounds/clav/' + fn + '.mp3'],
volume : 0.2,
onload : sound_load(),
}))
}
// load swell sounds
for (var i = 1; i <= 3; i++) {
swells.push(new Howl({
urls : ['sounds/swells/swell' + i + '.ogg',
'sounds/swells/swell' + i + '.mp3'],
volume : 1,
onload : sound_load(),
}))
}
/*
function testuser() {
data = {user: 'Slaporte'}
newuser_action(data, 'en', svg)
}
testuser()
*/
for (lang in langs) {
if (langs.hasOwnProperty(lang)) {
if (lang == 'wikidata') {
$('#lang-boxes').append('<p><input type="checkbox" name="' + langs[lang][0] + '" id="' + lang + '-enable"/><label for="' + lang + '-enable">' + langs[lang][0] + ' <span class="conStatus" id="' + lang + '-status"></span></label></p>')
} else {
$('#lang-boxes').append('<p><input type="checkbox" name="' + langs[lang][0] + '" id="' + lang + '-enable"/><label for="' + lang + '-enable">' + langs[lang][0] + ' Wikipedia <span class="conStatus" id="' + lang + '-status"></span></label></p>')
}
SOCKETS[lang] = new wikipediaSocket.init(langs[lang][1], lang, svg);
var box = $('#' + lang + '-enable');
if (box.is(':checked')) {
enable(lang)
}
box.click(make_click_handler(box, lang));
}
}
enabled_langs = return_lang_settings();
if (!enabled_langs.length) {
enabled_langs.push(DEFAULT_LANG)
}
for (var i = 0; i < enabled_langs.length + 1; i ++) {
var lang = enabled_langs[i];
$('#' + lang + '-enable').prop('checked', true);
if (SOCKETS[lang] && (!SOCKETS[lang].connection ||
SOCKETS[lang].connection.readyState == 3)) {
SOCKETS[lang].connect();
}
}
})
</script>
<link href='css/style.css' rel='stylesheet' type='text/css'>
</head>
<body>
<div id='header'>
<span class="about-link">
<span id="volumeWrapper" class="interface">
<span id="volumeSlider" class="noUiSlider"></span>
</span><a id="about-link" href="">about</a> & <a href="http://blog.hatnote.com/" target="_blank">blog</a> & <a href="https://itunes.apple.com/us/app/listen-to-wikipedia/id832934300" target="_blank">app</a></span>
<h1>Listen to Wikipedia</h1>
</div>
<div id='area'></div>
<div id='content'>
<div class='bg'>
<div id='rc-log-c'>
<h3>Recent changes</h3>
<ul id='rc-log'>
</ul>
<div class="note">
<p id="edit_counter"></p>
<p>For more, see Wikipedia's RecentChanges pages for <a href="http://www.wikipedia.org/">each language</a>.</p>
</div>
</div>
</div>
</div>
<div class="foot">
<h3>Settings</h3>
<p><input type="checkbox" name="welcome" id="welcome">
<label for='welcome'>Hide new user announcements</label></p>
<p><input type="checkbox" name="titles" id="titles">
<label for='titles'>Hide article titles</label></p>
<h3>Languages</h3>
<div id='lang-boxes'> </div>
<div class='clear'><br/></div>
<h3>About</h3>
<p><a href='http://blog.hatnote.com/post/56856315107/listen-to-wikipedia'>Read more</a> about this project.</p>
<p>Listen to the sound of Wikipedia's recent changes feed. Bells indicate additions and string plucks indicate subtractions. Pitch changes according to the size of the edit; the larger the edit, the deeper the note. Green circles show edits from <a href='http://en.wikipedia.org/wiki/Wikipedia:User_access_levels#Unregistered_users'>unregistered contributors</a>, and purple circles mark edits performed by <a href='http://en.wikipedia.org/wiki/Wikipedia:Bots'>automated bots</a>. You may see announcements for new users as they join the site, punctuated by a string swell. You can welcome him or her by clicking the blue banner and adding a note on their talk page.</p>
<p>This project is built using <a href='http://d3js.org'>D3</a> and <a href='https://github.com/goldfire/howler.js'>HowlerJS</a>. It is based on <a href='http://www.listentobitcoin.com/'>Listen to Bitcoin</a> by <a href='https://github.com/MaxLaumeister'>Maximillian Laumeister</a>. Our source is <a href='https://github.com/hatnote/listen-to-wikipedia'>available on GitHub</a>, and you can read more about this project.</p>
<p>Built by <a href='http://github.com/slaporte'>Stephen LaPorte</a> and <a href='http://github.com/mahmoud'>Mahmoud Hashemi</a>.
</div>
<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','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-40320359-1', 'hatnote.com');
ga('send', 'pageview');
</script>
</body>
</html>