-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathindex.html
More file actions
215 lines (214 loc) · 10.4 KB
/
index.html
File metadata and controls
215 lines (214 loc) · 10.4 KB
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
<!doctype html>
<html>
<head>
<title>Hatnote Recent Changes Map</title>
<meta name="title" content="Hatnote Recent Changes Map">
<meta name="description" content="A map of recent contributions to Wikipedia from unregistered users.">
<meta name="keywords" content="hatnote, rcmap, recent changes, wikipedia, edits, visualization">
<meta name="author" content="Stephen LaPorte and Mahmoud Hashemi">
<link href='style.css' rel='stylesheet' type='text/css'>
<script src='jquery-1.9.1.min.js' type="text/javascript"></script>
<script src='datamaps-world.js' type="text/javascript"></script>
<script src="reconnecting-websocket.min.js" type="text/javascript"></script>
<script src="main.js" type="text/javascript" type="text/javascript"></script>
<script>
var RC_LOG_SIZE = 20;
var DEFAULT_LANG = 'en'
/* ================================================================ */
var SOCKETS = {}
$(document).ready(function() {
$('#about-link').click(function(){
// because we use window.location to set languages.
$('html, body').animate({scrollTop:$(document).height()}, 'slow');
return false;
});
$('body').append('<div id="loading"><p>Connecting ...</p></div>')
world_map = $("#map")
.datamap({scope: 'world',
bubbles:[],
geography_config: {
highlightOnHover: false,
popupOnHover: false
},
bubble_config: {
borderWidth: 0,
borderColor: '#000',
popupOnHover: true,
popupTemplate: _.template('<div class="hoverinfo"><%= data.page_title %> <span class="lang">(<%= data.lid %>)</span></div>'),
fillOpacity: 0.75,
animate: true,
highlightOnHover: true,
highlightBorderColor: '#667FAF',
highlightFillColor: '#667FAF',
highlightBorderWidth: 1,
highlightFillOpacity: 0.85
},
fills: {
defaultFill: '#ccc',
'add': '#306596',
'subtract': '#cc4731'
}
});
langs = {
'en': ['English', 'ws://wikimon.hatnote.com:9000'],
'de': ['German', 'ws://wikimon.hatnote.com:9010'],
'ru': ['Russian', 'ws://wikimon.hatnote.com:9020'],
'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'],
'id': ['Indonesian', 'ws://wikimon.hatnote.com:9100'],
'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'],
'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'],
'wikidata': ['Wikidata' , 'ws://wikimon.hatnote.com:9220']
}
var make_click_handler = function($box, lang) {
return function() {
if ($box.is(':checked')) {
enable(lang);
} else {
disable(lang);
}
}
};
var return_lang_list = function() {
var enabled_langs = window.location.hash.slice(1).split(',');
for (var i = 0; i < enabled_langs.length +1; i ++) {
if (enabled_langs[i] == '') {
enabled_langs.splice(i, 1);
}
}
return enabled_langs;
}
var set_lang_list = function (langs) {
if (langs[0] == '') {
langs.splice(0, 1);
}
window.location.hash = '#' + langs.join(',');
}
var enable = function(lang) {
var enabled_langs = return_lang_list();
if (enabled_langs.indexOf(lang) < 0) {
enabled_langs.push(lang);
set_lang_list(enabled_langs);
}
};
var disable = function(lang) {
var enabled_langs = return_lang_list();
var lang_index = enabled_langs.indexOf(lang);
if (lang_index >= 0) {
enabled_langs.splice(lang_index, 1);
}
set_lang_list(enabled_langs);
};
window.onhashchange = function () {
var enabled_langs = return_lang_list();
for (lang in SOCKETS) {
if (enabled_langs.indexOf(lang) >= 0) {
if (!SOCKETS[lang].connection || SOCKETS[lang].connection.readyState == 3) {
SOCKETS[lang].connect();
$('#' + lang + '-enable').prop('checked', true)
}
} else {
if ($('#' + lang + '-enable').is(':checked')) {
$('#' + lang + '-enable').prop('checked', false)
}
if (SOCKETS[lang].connection) {
SOCKETS[lang].close();
}
}
}
set_lang_list(enabled_langs);
}
for (lang in langs) {
if (langs.hasOwnProperty(lang)) {
$('#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);
var box = $('#' + lang + '-enable');
if (box.is(':checked')) {
enable(lang)
}
box.click(make_click_handler(box, lang));
}
}
var enabled_langs = return_lang_list();
console.log(enabled_langs)
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)
enable(lang)
}
world_map.addBubbles = addBubbles;
return;
});
</script>
</head>
<body>
<div id="header">
<span class="about-link"><a id="about-link" href="">about</a> & <a href="http://blog.hatnote.com/post/49342528753/wikipedia-recent-changes-map">blog</a></span>
<h1>Wikipedia Recent Changes Map</h1>
</div>
<div class="content">
<div id="wrapper">
<div id="map"></div>
</div>
<div class="bg">
<div class="rc-list">
<h3>Recent changes</h3>
<ul id="rc-list">
</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 class="foot">
<h3>Languages</h3>
<div id="lang-boxes"></div>
<div class='clear'><br/></div>
<br/>
<h3><a name="about"></a>What is this map?</h3>
<p><a href='http://blog.hatnote.com/post/49342528753/wikipedia-recent-changes-map'>Read more</a> about this project.</p>
<p>
When an <a href="http://en.wikipedia.org/wiki/Wikipedia:User_access_levels#Unregistered_users">unregistered user</a> edits Wikipedia,
he or she is identified by his or her <acronym title="Internet Protocol">IP</acronym> address. These IP addresses are translated to users' approximate geographic location. Unregistered users only make a fraction of total edits -- <b>only 15%</b> of the contributions to English Wikipedia are from unregistered users. Edits by registered users do not have associated IP information,
so the map actually represents only a small portion of the <a href="http://en.wikipedia.org/wiki/Special:RecentChanges">total
edit activity on Wikipedia</a>.
</p>
<p>
Built using <a href="http://d3js.org">d3</a>, <a href="http://datamaps.github.io">DataMaps</a>,
<a href="https://github.com/fiorix/freegeoip">freegeoip.net</a>, and
the <a href="http://meta.wikimedia.org/wiki/Research:Data#IRC_Feeds">Wikimedia RecentChanges IRC feed</a>,
broadcast through <a href="https://github.com/hatnote/wikimon">wikimon</a>.
Source <a href="https://github.com/hatnote/rcmap">available on github</a>.
</p>
<p>Built by <a href="https://github.com/slaporte">Stephen LaPorte</a> and <a href="https://github.com/mahmoud">Mahmoud Hashemi</a>.</p>
</div>
</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>