Init
This commit is contained in:
commit
273d3c2729
3 changed files with 66 additions and 0 deletions
6
config.js
Normal file
6
config.js
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
exports.url = {
|
||||||
|
hostname: 'www.krautspace.de',
|
||||||
|
port: 443,
|
||||||
|
path: '/user:0xaffe?do=edit&rev=0',
|
||||||
|
method: 'GET'
|
||||||
|
};
|
12
package.json
Normal file
12
package.json
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{ "name": "termintool"
|
||||||
|
, "version": "0.0.1"
|
||||||
|
, "engines": ["node >= 0.8.0"]
|
||||||
|
, "main": "termine.js"
|
||||||
|
, "dependencies":
|
||||||
|
{ "ejs": "*"
|
||||||
|
, "ejs-ext": "latest"
|
||||||
|
, "jsdom": "latest"
|
||||||
|
, "email-templates": "latest"
|
||||||
|
, "nodemailer": "latest"
|
||||||
|
}
|
||||||
|
}
|
48
termine.js
Normal file
48
termine.js
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
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);
|
||||||
|
});
|
Reference in a new issue