diff options
Diffstat (limited to 'static/js')
| -rw-r--r-- | static/js/pichat.js | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/static/js/pichat.js b/static/js/pichat.js index c19ff6b..62cf52e 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -47,7 +47,8 @@ function isCSSPropertySupported(prop){ return prop in document.body.style } function escapeHtml(txt) { if (!txt) { return ""; } - else { return $("<span>").text(txt).html(); } +// txt = annoyingCaps(txt) + return $("<span>").text(txt).html() } URLRegex = /((\b(http\:\/\/|https\:\/\/|ftp\:\/\/)|(www\.))+(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi; @@ -68,7 +69,23 @@ function getImagesAsArray(text) { function linkify(text) { LastMsgContainsImage = false - return text.replace(URLRegex, linkReplace); + text = text.replace(URLRegex, linkReplace); + return text +} + +function annoyingCaps(text){ + var chunks = text.split(" ") + for(var i=0; i<chunks.length; i++){ + var chunk = chunks[i] + if (!chunk.length || chunk.substr(0,4) == 'http') continue; + var letters=chunk.split("") + for(var j = 0; j<letters.length; j++){ + if (j % 2) letters[j] = letters[j].toUpperCase() + else letters[j] = letters[j].toLowerCase() + } + chunks[i] = letters.join("") + } + return chunks.join(" ") } // durty hack to use a global to check this... but otherwise i'd have to rewrite the String.replace function? :/ |
