-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdata.js
37 lines (33 loc) · 943 Bytes
/
data.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
34
35
36
37
var fs = require('fs');
var blacklistPath = "./data/blacklist.txt";
var whitelistPath = "./data/whitelist.txt";
// holds the data for white and black lists
function Data() {
var self = this, lines;
self.stations = require('./data/stations');
self.blacklist = [];
self.whitelist = [];
fs.readFile(blacklistPath, 'utf8', function(err,data) {
if( ! err ) {
self.blacklist = data.split("\n");
}
});
fs.readFile(whitelistPath, 'utf8', function(err,data) {
if( ! err ) {
self.whitelist = data.split("\n");
}
});
}
// adds another line to the blacklist
Data.prototype.addToBlackList = function(str) {
this.blacklist.push(str);
fs.appendFile(blacklistPath, "\n" + str, function (err) {
});
}
// adds another line to the whitelist
Data.prototype.addToWhiteList = function(str) {
this.whitelist.push(str);
fs.appendFile(whitelistPath, "\n" + str, function (err) {
});
}
module.exports = Data;