-
Notifications
You must be signed in to change notification settings - Fork 19
/
blacklist.js
56 lines (47 loc) · 1.24 KB
/
blacklist.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* jshint node: true */
/* jshint jquery: true */
/* jshint esversion: 6 */
"use strict";
/**
* Blacklist class
*
* Manage a list of entries
* @param Entry list
* @return BlackList object
*/
var fs = require( "fs" );
const {app} = require( "electron" ).remote;
const path = require( "path" );
var BlacklistedEntry = require( "./blacklisted-entry" );
class BlackList {
constructor( blacklistName, entries ) {
this.blacklistName = blacklistName;
this.entries = entries;
}
add( entry ) {
this.entries[entry.factor] = new BlacklistedEntry( entry );
}
toggle( entry ) {
this.entries[entry.factor].active = !this.entries[entry.factor].active;
}
revoke( entry ) {
delete this.entries[entry.factor];
}
check( factor ) {
if ( this.entries[factor] && this.entries[factor].active ) {
return true;
} else {
return false;
}
}
/**
* Write the blacklist to disk
*
* @param Nothing
* @return Nothing
*/
save() {
fs.writeFileSync( app.getPath( "userData" ) + path.sep + this.blacklistName + ".json", JSON.stringify( this ));
}
}
module.exports = BlackList;