Die Termine werden jetzt am ende auch ausgegeben, damit man sieht das was geht :)

This commit is contained in:
Tim Schumacher 2013-01-16 13:58:11 +01:00
parent da6724e1f7
commit f0ba7e05a8

View file

@ -7,35 +7,33 @@ var data = '';
function parseData() { function parseData() {
jsdom.env( jsdom.env(
data, data,
["http://code.jquery.com/jquery.js"], ["http://code.jquery.com/jquery.js"],
function (errors, window) { function (errors, window) {
var wiki_text = window.$("#wiki__text").val(); var wiki_text = window.$("#wiki__text").val();
var re = /\s\* (\d{4})\-(\d{2})\-(\d{2}) (\d{2})\:(\d{2}) - (\d{2})\:(\d{2}) (.*)/g; var re = /\s\* (\d{4})\-(\d{2})\-(\d{2}) (\d{2})\:(\d{2}) - (\d{2})\:(\d{2}) (.*)/g;
var match = null; var match = null;
var events = []; var events = [];
while (match = re.exec(wiki_text)) { while (match = re.exec(wiki_text)) {
var event = { var event = {
startdate : new Date(match[1], match[2], match[3], match[4], match[5]) startdate : new Date(match[1], match[2], match[3], match[4], match[5])
,enddate : new Date(match[1], match[2], match[3], match[6], match[7]) ,enddate : new Date(match[1], match[2], match[3], match[6], match[7])
,text : match[8] ,text : match[8]
}; };
events.push(event); events.push(event);
} }
console.log(events);
//var matches = wiki_text.match(); }
//console.log(matches);
}
); );
} }
function processResponse(res) { function processResponse(res) {
if (res.statusCode == 200) { if (res.statusCode == 200) {
res.on('data', function(d) { res.on('data', function(d) {
data = data + d; data = data + d;
}); });
res.on('end',parseData); res.on('end',parseData);
} }
} }