This repository has been archived on 2024-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
termintool/termine.js

49 lines
1 KiB
JavaScript
Raw Normal View History

2013-01-15 22:32:31 +01:00
var config = require('./config');
var http = require('https');
var jsdom = require('jsdom');
var data = '';
function parseData() {
jsdom.env(
data,
["http://code.jquery.com/jquery.js"],
function (errors, window) {
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 match = null;
var events = [];
while (match = re.exec(wiki_text)) {
var event = {
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])
,text : match[8]
};
events.push(event);
}
//var matches = wiki_text.match();
//console.log(matches);
}
);
}
function processResponse(res) {
if (res.statusCode == 200) {
res.on('data', function(d) {
data = data + d;
});
res.on('end',parseData);
}
}
var req = http.request(config.url,processResponse);
req.end();
req.on('error', function(e) {
console.error(e);
});