diff options
| author | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2010-09-05 05:55:47 -0400 |
|---|---|---|
| committer | dumpfmprod <dumpfmprod@ubuntu.(none)> | 2010-09-05 05:55:47 -0400 |
| commit | 2fcfd448fe0c28b41f14f7cd8c51abb5154e1bba (patch) | |
| tree | 7889d0e119788c0b1436596f323848a9f7fc53db /static/js | |
| parent | 6e54781979301dbec5886da2d9df94764197ff56 (diff) | |
| parent | 6faebbd3c1e253bd6e5797decfd945a389ddc347 (diff) | |
Merge branch 'master' of /pichat/repo
Diffstat (limited to 'static/js')
| -rw-r--r-- | static/js/pichat.js | 95 |
1 files changed, 64 insertions, 31 deletions
diff --git a/static/js/pichat.js b/static/js/pichat.js index 13cdeb0..72e82dd 100644 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -60,6 +60,42 @@ function escapeHtml(txt) { return $("<span>").text(txt).html() } +var Log = { + "Levels": ['info', 'warn', 'error'], + "AjaxSubmitLevels": ['warn', 'error'], + "AjaxSubmitPath": "/logerror", + + "SupplementalInfo": function() { + return { 'user': UserInfo && UserInfo.nick }; + }, + + "ajaxSubmit": function(level, component, msg) { + var info = Log.SupplementalInfo(); + var data = { 'level': level, 'component': component, 'msg': msg }; + $.extend(info, data); + + $.ajax({type: 'POST', + timeout: 5000, + url: Log.AjaxSubmitPath, + data: info + }); + }, + + "initialize": function() { + $.each(Log.Levels, function(i, level) { + Log[level] = function(component, msg) { + if (window.console && window.console[level]) + window.console[level](args); + if (Log.AjaxSubmitLevels.indexOf(level) != -1) + Log.ajaxSubmit(level, args); + }; + }); + } +}; + +Log.initialize(); + + URLRegex = /((\b(http\:\/\/|https\:\/\/|ftp\:\/\/)|(www\.))+(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi; PicRegex = /\.(jpg|jpeg|png|gif|bmp|svg|fid)$/i; @@ -1226,40 +1262,37 @@ function parseDomain(host){ return host.toLowerCase().replace(/^www\./, "") } -// Away notification +var Away = { + "UnseenMsgCounter": 0, + "OrigTitle": "", + "HasFocus": true, + "UpdateFrequency": 3000, -var UnseenMsgCounter = 0; -var OrigTitle = ""; -var HasFocus = true; + "onFocus": function() { + Away.HasFocus = true; + Away.UnseenMsgCounter = 0; + // Courtesy http://stackoverflow.com/questions/2952384/changing-the-window-title-when-focussing-the-window-doesnt-work-in-chrome + window.setTimeout(function () { $('title').text(Away.OrigTitle); }, 100); + }, + "onBlur": function() { + Away.HasFocus = false; + }, -function onFocus() { - HasFocus = true; - UnseenMsgCounter = 0; - // Courtesy http://stackoverflow.com/questions/2952384/changing-the-window-title-when-focussing-the-window-doesnt-work-in-chrome - window.setTimeout(function () { $('title').text(OrigTitle); }, 100); -} - -function onBlur() { - HasFocus = false; -} - -function titleUpdater() { - if (UnseenMsgCounter > 0) { - var plural = UnseenMsgCounter > 1 ? 's' : ''; - $('title').text(UnseenMsgCounter + ' new dump' + plural + '! | ' + OrigTitle); + "updateTitle": function () { + if (Away.UnseenMsgCounter > 0) { + var plural = Away.UnseenMsgCounter > 1 ? 's' : ''; + $('title').text(Away.UnseenMsgCounter + ' new dump' + plural + '! | ' + Away.OrigTitle); + } + setTimeout(Away.updateTitle, Away.UpdateFrequency); + + }, + "startTitleUpdater": function() { + Away.OrigTitle = $('title').text(); + $(window).blur(Away.onBlur); + $(window).focus(Away.onFocus); + setTimeout(Away.updateTitle, Away.UpdateFrequency); } - setTimeout(titleUpdater, 4000); -} - -function startTitleUpdater() { - $(window).blur(onBlur); - $(window).focus(onFocus); - setTimeout(titleUpdater, 2000); -} - -$(function() { - OrigTitle = $('title').text(); -}); +}; var imgZoomThreshhold = [125, 125]; |
