thelounge/lib/models/network.js

26 lines
482 B
JavaScript
Raw Normal View History

var _ = require("lodash");
var Chan = require("./chan");
module.exports = Network;
function Network(attr) {
_.merge(this, _.extend({
id: global.id = ++global.id || 1,
client: null,
host: "",
nick: "",
channels: [],
}, attr));
// Add lobby
this.channels.unshift(
2014-05-02 21:54:31 +00:00
new Chan({name: this.host, type: "lobby"})
);
};
2014-04-30 15:14:22 +00:00
Network.prototype.toJSON = function() {
2014-05-02 17:46:18 +00:00
var clone = _.omit(this, "client");
clone.name = clone.host.split(".")[1] || clone.host;
return clone;
};