-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyKoyomiItem.js
50 lines (50 loc) · 1.12 KB
/
MyKoyomiItem.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
function MyKoyomiItem(aName, aMonth) {
this._json = {
'name': aName,
'month': aMonth,
'visible': true,
}
}
MyKoyomiItem.fromJSON = function (aJSON) {
var item = new MyKoyomiItem(null , 0);
item._json = aJSON;
return item;
};
MyKoyomiItem.prototype = {
toJSON: function () {
return this._json;
},
setName: function (aName) {
this._json.name = aName;
this._changed();
},
getName: function () {
return this._json.name;
},
setMonth: function (aMonth) {
this._json.month = aMonth;
this._changed();
},
getMonth: function () {
return parseInt(this._json.month);
},
getMuke: function () {
var m = this.getMonth();
return {
from: (m + 7) % 12,
to: m,
};
},
setVisible: function (aVisible) {
this._json.visible = aVisible;
this._changed();
},
isVisible: function () {
return this._json.visible;
},
_changed: function () {
if (this.listener) {
this.listener.onChange();
}
},
};