diff options
Diffstat (limited to 'static/js')
| -rwxr-xr-x | static/js/home.js | 3 | ||||
| -rwxr-xr-x | static/js/pichat.js | 38 | ||||
| -rwxr-xr-x | static/js/register.js | 17 |
3 files changed, 46 insertions, 12 deletions
diff --git a/static/js/home.js b/static/js/home.js index b37bc8d..107486c 100755 --- a/static/js/home.js +++ b/static/js/home.js @@ -152,6 +152,9 @@ function login() { var hash = hex_sha1(nick + '$' + password + '$dumpfm'); var onSuccess = function(json) { + if (typeof pageTracker !== 'undefined') { + pageTracker._setCustomVar(1, "logged-in", nick, 1); + } location.href = "/chat"; }; diff --git a/static/js/pichat.js b/static/js/pichat.js index 33788e2..3137ac4 100755 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -16,14 +16,17 @@ function linkify(text) { // durty hack to use a global to check this... but otherwise i'd have to rewrite the String.replace function? :/ var LastMsgContainsImage = false -function linkReplace(match){ +function linkReplace(url){ var PicRegex = /\.(jpg|jpeg|png|gif|bmp)$/i; - var matchWithoutParams = match.replace(/\?.*$/i, "") - if (PicRegex.test(matchWithoutParams)){ + var urlWithoutParams = url.replace(/\?.*$/i, ""); + + linkUrl = url.indexOf('http://') == 0 ? url : 'http://' + url; + + if (PicRegex.test(url)){ LastMsgContainsImage = true - return "<a target='_blank' href='" + match + "'><img src='" + match + "'></a>" + return "<a target='_blank' href='" + linkUrl + "'><img src='" + linkUrl + "'></a>" } else { - return "<a target='_blank' href='" + match + "'>" + match + "</a>" + return "<a target='_blank' href='" + linkUrl + "'>" + url + "</a>" } } @@ -102,6 +105,9 @@ function submitMessage() { var div = addNewMessage(msg, true); var onSuccess = function(json) { + if (typeof pageTracker !== 'undefined') { + pageTracker._trackEvent('Message', 'Submit', typeof Room !== 'undefined' ? Room : 'UnknownRoom'); + } div.attr('id', 'message-' + json) .removeClass('loading').addClass('loaded'); }; @@ -225,6 +231,13 @@ function initChat() { } function initProfile() { + + jQuery(".linkify").each(function() { + var text = jQuery(this).text(); + jQuery(this).html(linkify(text)); + }); + + $('.logged-dump .content').each(function() { var t = $(this); t.html(buildMsgContent(t.text())); @@ -277,11 +290,24 @@ function initLog() { function favoriteImage() {}; function setupUpload(elementId, roomKey) { + var onSubmit = function(file, ext) { + if (!(ext && /^(jpg|png|jpeg|gif)$/i.test(ext))) { + alert('Error: invalid file extension ' + ext); + return false; + } + }; + var onComplete = function(file, response) { + if (typeof pageTracker !== 'undefined') { + pageTracker._trackEvent('Message', 'Upload', typeof Room !== 'undefined' ? Room : 'UnknownRoom'); + } + } new AjaxUpload(elementId, { action: '/upload', autoSubmit: true, name: 'image', - data: { room: roomKey } + data: { room: roomKey }, + onSubmit: onSubmit, + onComplete: onComplete }); } diff --git a/static/js/register.js b/static/js/register.js index 682efcb..1739ed6 100755 --- a/static/js/register.js +++ b/static/js/register.js @@ -13,20 +13,25 @@ function submitRegistration() { var email = $('#emailInput').val(); var password = $('#passwordInput').val() || ""; var code = $('#codeInput').val(); - if ($.inArray(code.toUpperCase(), ValidCodes) == -1) { - alert("Bad registration code! Try again dude...." ); - return; - } - if (nick.length < 3) { - alert("Nicks must be at least 3 characters long."); + + if (nick.length < 3 || nick.length > 12) { + alert("Nicks must be between 3 and 12 characters long."); return; } else if (password.length < 5) { alert("Password must be at least 5 characters long."); return; } + if ($.inArray(code.toUpperCase(), ValidCodes) == -1) { + alert("Bad registration code! Try again dude...." ); + return; + } + var hash = hex_sha1(nick + '$' + password + '$dumpfm'); var onSuccess = function() { + if (typeof pageTracker !== 'undefined') { + pageTracker._trackEvent('User', 'Register', nick); + } location.href = "/"; }; |
