3 var View
= Backbone
.View
.extend({
9 initialize: function (options
) {
10 this.$el
= $($('#tmpl_channel_list').html());
14 // Sort the table by num. users?
17 // Waiting to add the table back into the DOM?
23 var table
= $('table', this.$el
),
24 tbody
= table
.children('tbody:first').detach();
25 /*tbody.children().each(function (child) {
28 chan = child.children('td:first').text();
29 for (i = 0; i < chanList.length; i++) {
30 if (chanList[i].channel === chan) {
31 chanList[i].html = child.detach();
38 this.channels
.sort(function (a
, b
) {
39 return b
.num_users
- a
.num_users
;
43 _
.each(this.channels
, function (chan
) {
44 tbody
.append(chan
.html
);
53 _kiwi
.applets
.Chanlist
= Backbone
.Model
.extend({
54 initialize: function () {
55 this.set('title', 'Channel List');
56 this.view
= new View();
60 addChannel: function (channels
) {
63 if (!_
.isArray(channels
)) {
64 channels
= [channels
];
66 _
.each(channels
, function (chan
) {
68 html
= '<tr><td><a class="chan">' + _
.escape(chan
.channel
) + '</a></td><td class="num_users" style="text-align: center;">' + chan
.num_users
+ '</td><td style="padding-left: 2em;">' + formatIRCMsg(_
.escape(chan
.topic
)) + '</td></tr>';
70 that
.view
.channels
.push(chan
);
73 if (!that
.view
.waiting
) {
74 that
.view
.waiting
= true;
77 that
.view
.waiting
= false;
83 dispose: function () {
84 this.view
.channels
= null;
86 this.view
.$el
.html('');