2014-03-06 18:02:43 +00:00
|
|
|
var _ = require("lodash");
|
2014-03-06 23:17:08 +00:00
|
|
|
var moment = require("moment");
|
2014-03-06 18:02:43 +00:00
|
|
|
|
2014-03-06 15:11:25 +00:00
|
|
|
var models = exports;
|
2014-03-07 03:18:53 +00:00
|
|
|
var id = 1;
|
2014-03-06 15:11:25 +00:00
|
|
|
|
2014-03-06 22:36:56 +00:00
|
|
|
models.Network = function(attr) {
|
|
|
|
attr = attr || {};
|
|
|
|
_.extend(this, _.defaults(attr, {
|
|
|
|
id: id++,
|
|
|
|
address: "",
|
|
|
|
nick: "",
|
|
|
|
channels: []
|
|
|
|
}));
|
2014-03-06 15:11:25 +00:00
|
|
|
};
|
|
|
|
|
2014-03-06 18:02:43 +00:00
|
|
|
models.Network.prototype.toJSON = function() {
|
2014-03-06 22:36:56 +00:00
|
|
|
return _.omit(this, "client");
|
2014-03-06 18:02:43 +00:00
|
|
|
};
|
|
|
|
|
2014-03-06 22:36:56 +00:00
|
|
|
models.Channel = function(attr) {
|
|
|
|
attr = attr || {};
|
|
|
|
_.extend(this, _.defaults(attr, {
|
|
|
|
id: id++,
|
|
|
|
name: "",
|
|
|
|
type: "channel",
|
|
|
|
topic: "",
|
|
|
|
users: [],
|
|
|
|
messages: []
|
|
|
|
}));
|
2014-03-06 15:11:25 +00:00
|
|
|
};
|
|
|
|
|
2014-03-06 22:36:56 +00:00
|
|
|
models.User = function(attr) {
|
|
|
|
attr = attr || {};
|
|
|
|
_.extend(this, _.defaults(attr, {
|
|
|
|
id: id++,
|
|
|
|
name: ""
|
|
|
|
}));
|
2014-03-06 15:11:25 +00:00
|
|
|
};
|
|
|
|
|
2014-03-06 22:36:56 +00:00
|
|
|
models.Message = function(attr) {
|
|
|
|
attr = attr || {};
|
|
|
|
_.extend(this, _.defaults(attr, {
|
2014-03-06 23:17:08 +00:00
|
|
|
time: moment().format("HH:mm"),
|
|
|
|
user: "",
|
|
|
|
text: ""
|
2014-03-06 22:36:56 +00:00
|
|
|
}));
|
2014-03-06 15:11:25 +00:00
|
|
|
};
|
|
|
|
|
2014-03-06 22:36:56 +00:00
|
|
|
models.Event = function(attr) {
|
|
|
|
attr = attr || {};
|
|
|
|
_.extend(this, _.defaults(attr, {
|
|
|
|
action: "",
|
|
|
|
data: "",
|
|
|
|
target: "",
|
|
|
|
type: ""
|
|
|
|
}));
|
2014-03-06 15:11:25 +00:00
|
|
|
};
|
2014-03-07 03:18:53 +00:00
|
|
|
|
|
|
|
models.Target = function(attr) {
|
|
|
|
attr = attr || {};
|
|
|
|
_.extend(this, _.defaults(attr, {
|
|
|
|
network: "",
|
|
|
|
channel: ""
|
|
|
|
}));
|
|
|
|
};
|