\r
\r
\r
- _kiwi.applets.Chanlist = Backbone.Model.extend({\r
+ var Applet = Backbone.Model.extend({\r
initialize: function () {\r
this.set('title', 'Channel List');\r
this.view = new View();\r
+\r
+ this.network = _kiwi.global.components.Network();\r
+ this.network.on('onlist_channel', this.onListChannel, this);\r
+ this.network.on('onlist_start', this.onListStart, this);\r
},\r
\r
\r
+ // New channels to add to our list\r
+ onListChannel: function (event) {\r
+ console.log(event);\r
+ this.addChannel(event.chans);\r
+ },\r
+\r
+ // A new, fresh channel list starting\r
+ onListStart: function (event) {\r
+ // TODO: clear out our existing list\r
+ },\r
+\r
addChannel: function (channels) {\r
var that = this;\r
\r
this.view.$el.html('');\r
this.view.remove();\r
this.view = null;\r
+\r
+ // Remove any network event bindings\r
+ this.network.off();\r
}\r
});\r
\r
\r
+\r
+ _kiwi.model.Applet.register('kiwi_chanlist', Applet);\r
})();
\ No newline at end of file
\r
\r
gw.on('onlist_start', function (data) {\r
- if (_kiwi.app.channel_list) {\r
- _kiwi.app.channel_list.close();\r
- delete _kiwi.app.channel_list;\r
- }\r
-\r
- var panel = new _kiwi.model.Applet(),\r
- applet = new _kiwi.applets.Chanlist();\r
-\r
- panel.load(applet);\r
- \r
- _kiwi.app.panels.add(panel);\r
- panel.view.show();\r
- \r
- _kiwi.app.channel_list = applet;\r
- });\r
-\r
-\r
- gw.on('onlist_channel', function (data) {\r
- // TODO: Put this listener within the applet itself\r
- _kiwi.app.channel_list.addChannel(data.chans);\r
- });\r
-\r
-\r
- gw.on('onlist_end', function (data) {\r
- // TODO: Put this listener within the applet itself\r
- delete _kiwi.app.channel_list;\r
+ var chanlist = _kiwi.model.Applet.loadOnce('kiwi_chanlist');\r
+ chanlist.view.show();\r
});\r
\r
\r