2014-03-07 21:24:02 +00:00
|
|
|
var Backbone = require("backbone");
|
2014-03-06 23:17:08 +00:00
|
|
|
var moment = require("moment");
|
2014-03-06 18:02:43 +00:00
|
|
|
|
2014-03-07 21:24:02 +00:00
|
|
|
var models =
|
|
|
|
module.exports =
|
|
|
|
{};
|
|
|
|
|
2014-03-07 03:18:53 +00:00
|
|
|
var id = 1;
|
2014-03-06 15:11:25 +00:00
|
|
|
|
2014-03-07 21:24:02 +00:00
|
|
|
models.User = Backbone.Model.extend({
|
|
|
|
defaults: {
|
|
|
|
mode: "",
|
|
|
|
name: "user"
|
|
|
|
}
|
|
|
|
});
|
2014-03-06 15:11:25 +00:00
|
|
|
|
2014-03-07 21:24:02 +00:00
|
|
|
models.Message = Backbone.Model.extend({
|
|
|
|
defaults: {
|
|
|
|
time: moment().format("HH:mm"),
|
|
|
|
user: "user",
|
|
|
|
text: "text"
|
|
|
|
}
|
|
|
|
});
|
2014-03-06 18:02:43 +00:00
|
|
|
|
2014-03-07 21:24:02 +00:00
|
|
|
models.Channel = Backbone.Model.extend({
|
|
|
|
defaults: {
|
2014-03-06 22:36:56 +00:00
|
|
|
type: "channel",
|
2014-03-07 21:24:02 +00:00
|
|
|
name: "",
|
2014-03-06 22:36:56 +00:00
|
|
|
topic: "",
|
|
|
|
users: [],
|
|
|
|
messages: []
|
2014-03-07 21:24:02 +00:00
|
|
|
},
|
|
|
|
initialize: function() {
|
|
|
|
this.set({
|
|
|
|
id: id++
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2014-03-06 15:11:25 +00:00
|
|
|
|
2014-03-07 21:24:02 +00:00
|
|
|
models.ChannelCollection = Backbone.Collection.extend({
|
|
|
|
model: models.Channel
|
|
|
|
});
|
2014-03-06 15:11:25 +00:00
|
|
|
|
2014-03-07 21:24:02 +00:00
|
|
|
models.Network = Backbone.Model.extend({
|
|
|
|
defaults: {
|
|
|
|
host: "",
|
|
|
|
},
|
|
|
|
initialize: function() {
|
|
|
|
this.set({
|
|
|
|
id: id++,
|
|
|
|
channels: new models.ChannelCollection()
|
|
|
|
});
|
|
|
|
this.get("channels").add(new models.Channel({
|
|
|
|
type: "network",
|
|
|
|
name: this.get("host")
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
});
|
2014-03-07 03:18:53 +00:00
|
|
|
|
2014-03-07 21:24:02 +00:00
|
|
|
models.NetworkCollection = Backbone.Collection.extend({
|
|
|
|
model: models.Network,
|
|
|
|
initialize: function() {
|
|
|
|
this.add(new models.Network({
|
|
|
|
host: "Lobby"
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
});
|