From 21827075cc1deafc72d1729627643e15a0a0cca5 Mon Sep 17 00:00:00 2001 From: teramako Date: Tue, 10 Aug 2010 13:55:20 +0000 Subject: ツイート内容はXHTMLに変更 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38245 d0d07461-0603-4401-acd4-de1884942a52 --- twittperator/twlist-tab.tw | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/twittperator/twlist-tab.tw b/twittperator/twlist-tab.tw index 3331f29..42d41ac 100644 --- a/twittperator/twlist-tab.tw +++ b/twittperator/twlist-tab.tw @@ -64,7 +64,7 @@ function setStyleSheet() { padding: 2px 5px; margin: 0; -moz-border-radius: 4px; } - TwlistText,.twlist-text,chrome://browser/content/browser.xul + TwlistText,.twlist-text,chrome://browser/content/browser.xul margin: 2px 1em; TwlistTextLabel,.twlist-text>label,chrome://browser/content/browser.xul margin: 1px 2px 2px 2px !important; TwlistMetaInfo,.twlist-metainfo,chrome://browser/content/browser.xul TwlistScreenName,.twlist-screenname,chrome://browser/content/browser.xul font-weight: bold; @@ -80,15 +80,15 @@ function add (msg, target) { if (!target) target = timelineBox; let isRT = ("retweeted_status" in msg); - let text = formatText(isRT ? msg.retweeted_status.text : msg.text); + let domContent = formatText(isRT ? msg.retweeted_status.text : msg.text); + XML.ignoreWhitespace = true; let xml = isRT ? - - + - {text} : - + - - + @@ -115,10 +113,10 @@ function add (msg, target) { - {text} ; let dom = xmlToDom(xml, XUL); + dom.querySelector(".twlist-content").appendChild(domContent); target.insertBefore(dom, target.firstChild); if (target.getRowCount() > 50) { target.removeChild(target.lastChild); @@ -145,8 +143,8 @@ function onLoad () { options.add(["showtwlist"], "expand/collapse twittperator list", "boolean", true, { setter: function (value) { - document.getElementById(ID_SPLITTER) - .setAttribute("state", value ? "open" : "collapsed"); + let elm = document.getElementById(ID_SPLITTER); + elm.setAttribute("state", value ? "open" : "collapsed"); return value; }, getter: function() document.getElementById(ID_SPLITTER).getAttribute("state") != "collapsed" @@ -186,11 +184,12 @@ function streamListener(msg, raw) { function formatText (str) { str = str.trim(); let reg = /https?:\/\/[^\s]+|[#@]\w+/g; - let m, i = 0, buf = "", x = ; + XML.ignoreWhitespace = false; + let m, i = 0, buf = "", x = ; while((m=reg.exec(str))){ - buf = str.substring(i, m.index).trim(); + buf = str.substring(i, m.index); if (buf) - x.appendChild(); + x.appendChild(buf); let class = "twlist-link", href = ""; switch (m[0].charAt(0)){ case "@": @@ -205,14 +204,14 @@ function formatText (str) { class += " twlist-url"; href = m[0]; } - x.appendChild(); + x.appendChild({m[0]}); i=reg.lastIndex; } - buf = str.substr(i).trim(); + buf = str.substr(i); if (buf) - x.appendChild(); - return x; + x.appendChild(buf); + return xmlToDom(x, "http://www.w3.org/1999/xhtml"); } function onClick (evt) { evt.preventDefault(); -- cgit v1.2.3