From eb277015fe36788a745f53ee00871cb1071441d8 Mon Sep 17 00:00:00 2001 From: Jack Allnutt Date: Wed, 22 May 2013 10:04:51 +0100 Subject: [PATCH] Replace manual DOM manipulation with one document.createElement and innerHTML --- client/assets/dev/applet_chanlist.js | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) diff --git a/client/assets/dev/applet_chanlist.js b/client/assets/dev/applet_chanlist.js index 3e1f8ab..698d857 100644 --- a/client/assets/dev/applet_chanlist.js +++ b/client/assets/dev/applet_chanlist.js @@ -85,32 +85,10 @@ channels = [channels]; } _.each(channels, function (chan) { - var frag, row, name, chanlink, num_users, topic; - frag = document.createDocumentFragment(); + var row; row = document.createElement("tr"); - name = document.createElement("td"); - chanlink = document.createElement("a"); - if (typeof chanlink.dataset !== "undefined") { - chanlink.dataset.channel = chan.channel; - } else { - chanlink.setAttribute('data-channel', chan.channel); - } - chanlink.textContent = _.escape(chan.channel); - chanlink.classList.add('chan'); - name.appendChild(chanlink); - row.appendChild(name); - num_users = document.createElement("td"); - num_users.textContent = chan.num_users; - num_users.classList.add("num_users"); - num_users.style.textAlign = 'center'; - row.appendChild(num_users); - topic = document.createElement("td"); - topic.style.paddingLeft = '2em'; - topic.innerHTML = formatIRCMsg(_.escape(chan.topic)); - row.appendChild(topic); - frag.appendChild(row); - - chan.dom = frag; + row.innerHTML = '' + _.escape(chan.channel) + '' + chan.num_users + '' + formatIRCMsg(_.escape(chan.topic)) + ''; + chan.dom = row; that.view.channels.push(chan); }); -- 2.25.1