From e27c2ea6a1a17c6b0e1008bf5bacafda15f5a1f3 Mon Sep 17 00:00:00 2001 From: anekos Date: Thu, 5 Aug 2010 15:08:20 +0000 Subject: unescapeBrackets を一元化 git-svn-id: http://svn.coderepos.org/share/lang/javascript/vimperator-plugins/trunk@38188 d0d07461-0603-4401-acd4-de1884942a52 --- twittperator.js | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) (limited to 'twittperator.js') diff --git a/twittperator.js b/twittperator.js index 2fb7d7a..4ef5b65 100755 --- a/twittperator.js +++ b/twittperator.js @@ -1133,8 +1133,8 @@ lines[0] = buf + lines[0]; for (let [, line] in Iterator(lines.slice(0, -1))) { try { - onMsg(JSON.parse(line), line); - } catch (e) {} + onMsg(fixStatusObject(JSON.parse(line)), line); + } catch (e) {liberator.log('E =>\n' + line);} } buf = lines.slice(-1)[0]; } else { @@ -1181,9 +1181,18 @@ } xhr.send(null); } // }}} - function unescapeBrakets(str) // {{{ - str.replace(/</g, "<").replace(/>/g, ">"); - // }}} + function fixStatusObject(st) { // {{{ + function unescapeBrakets(str) + str.replace(/</g, "<").replace(/>/g, ">"); + + let result = {}; + for (let [n, v] in Iterator(st)) { + result[n] = v && typeof v === 'object' ? fixStatusObject(v) : + n === 'text' ? unescapeBrakets(v) : + v; + } + return result; + } // }}} function showTL(s) { // {{{ let html =