From: Jack Allnutt Date: Wed, 22 May 2013 09:04:51 +0000 (+0100) Subject: Replace manual DOM manipulation with one document.createElement and innerHTML X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=eb277015fe36788a745f53ee00871cb1071441d8;p=KiwiIRC.git Replace manual DOM manipulation with one document.createElement and innerHTML --- 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); });