-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathtimextract.js
34 lines (28 loc) · 936 Bytes
/
timextract.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
$(function(){
var r = {};
$('.vevent').each(function(i,e){
var a = $('.dtstart').attr('title')
, b = $('.dtend').attr('title')
, s, e;
if(a||b) {
(r.mf=r.mf||[]).push([a,b]);
}
});
$('a[title^="Category:"]').each(function(i,e){
var m = /^([\d]{4}) (BC |)in /.exec($(e).text());
if(m) { (r.loc=r.loc||[]).push(m[1]*(m[2]==''?1:-1)); }
});
if( r.loc ) { // remove duplicate year numbers
var i,obj={};
for(i=0;i<r.loc.length;++i){ obj[r.loc[i]]=1; }
r.loc=[];
for(i in obj){ r.loc.push(i); }
}
$('a[title$=" births"],a[title$=" deaths"]').each(function(i,e){
var m = /^([\d]{1,4}) (BC |)(births|deaths)$/.exec($(e).text()), y;
if(m) { (r[m[3]]=r[m[3]]||[]).push(m[1]*(m[2]==''?1:-1)); }
});
var d = $('th:contains(Date)').parent().find('td').eq(0).text();
if(d) { (r.table=r.table||[]).push(d); }
console.log(wgTitle, JSON.stringify(r));
});