diff options
Diffstat (limited to 'static/js')
| -rwxr-xr-x | static/js/jquery.easing.min.js | 20 | ||||
| -rw-r--r-- | static/js/jquery.lavalamp.js | 192 | ||||
| -rwxr-xr-x | static/js/pichat.js | 97 |
3 files changed, 179 insertions, 130 deletions
diff --git a/static/js/jquery.easing.min.js b/static/js/jquery.easing.min.js index 1a7b42d..8d4e2f2 100755 --- a/static/js/jquery.easing.min.js +++ b/static/js/jquery.easing.min.js @@ -1,11 +1,11 @@ -/*
- * jQuery Easing v1.1 - http://gsgd.co.uk/sandbox/jquery.easing.php
- *
- * Uses the built in easing capabilities added in jQuery 1.1
- * to offer multiple easing options
- *
- * Copyright (c) 2007 George Smith
- * Licensed under the MIT License:
- * http://www.opensource.org/licenses/mit-license.php
- */
+/* + * jQuery Easing v1.1 - http://gsgd.co.uk/sandbox/jquery.easing.php + * + * Uses the built in easing capabilities added in jQuery 1.1 + * to offer multiple easing options + * + * Copyright (c) 2007 George Smith + * Licensed under the MIT License: + * http://www.opensource.org/licenses/mit-license.php + */ jQuery.easing={easein:function(x,t,b,c,d){return c*(t/=d)*t+b},easeinout:function(x,t,b,c,d){if(t<d/2)return 2*c*t*t/(d*d)+b;var a=t-d/2;return-2*c*a*a/(d*d)+2*c*a/d+c/2+b},easeout:function(x,t,b,c,d){return-c*t*t/(d*d)+2*c*t/d+b},expoin:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}return a*(Math.exp(Math.log(c)/d*t))+b},expoout:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}return a*(-Math.exp(-Math.log(c)/d*(t-d))+c+1)+b},expoinout:function(x,t,b,c,d){var a=1;if(c<0){a*=-1;c*=-1}if(t<d/2)return a*(Math.exp(Math.log(c/2)/(d/2)*t))+b;return a*(-Math.exp(-2*Math.log(c/2)/d*(t-d))+c+1)+b},bouncein:function(x,t,b,c,d){return c-jQuery.easing['bounceout'](x,d-t,0,c,d)+b},bounceout:function(x,t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b}},bounceinout:function(x,t,b,c,d){if(t<d/2)return jQuery.easing['bouncein'](x,t*2,0,c,d)*.5+b;return jQuery.easing['bounceout'](x,t*2-d,0,c,d)*.5+c*.5+b},elasin:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b},elasout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b},elasinout:function(x,t,b,c,d){var s=1.70158;var p=0;var a=c;if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(a<Math.abs(c)){a=c;var s=p/4}else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b},backin:function(x,t,b,c,d){var s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b},backout:function(x,t,b,c,d){var s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b},backinout:function(x,t,b,c,d){var s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b},linear:function(x,t,b,c,d){return c*t/d+b}};
\ No newline at end of file diff --git a/static/js/jquery.lavalamp.js b/static/js/jquery.lavalamp.js index 1edf4b4..c35d7ac 100644 --- a/static/js/jquery.lavalamp.js +++ b/static/js/jquery.lavalamp.js @@ -1,96 +1,96 @@ -/**
- * LavaLamp - A menu plugin for jQuery with cool hover effects.
- * @requires jQuery v1.1.3.1 or above
- *
- * http://gmarwaha.com/blog/?p=7
- *
- * Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com)
- * Dual licensed under the MIT and GPL licenses:
- * http://www.opensource.org/licenses/mit-license.php
- * http://www.gnu.org/licenses/gpl.html
- *
- * Version: 0.2.0
- * Requires Jquery 1.2.1 from version 0.2.0 onwards.
- * For jquery 1.1.x, use version 0.1.0 of lavalamp
- */
-
-/**
- * Creates a menu with an unordered list of menu-items. You can either use the CSS that comes with the plugin, or write your own styles
- * to create a personalized effect
- *
- * The HTML markup used to build the menu can be as simple as...
- *
- * <ul class="lavaLamp">
- * <li><a href="#">Home</a></li>
- * <li><a href="#">Plant a tree</a></li>
- * <li><a href="#">Travel</a></li>
- * <li><a href="#">Ride an elephant</a></li>
- * </ul>
- *
- * Once you have included the style sheet that comes with the plugin, you will have to include
- * a reference to jquery library, easing plugin(optional) and the LavaLamp(this) plugin.
- *
- * Use the following snippet to initialize the menu.
- * $(function() { $(".lavaLamp").lavaLamp({ fx: "backout", speed: 700}) });
- *
- * Thats it. Now you should have a working lavalamp menu.
- *
- * @param an options object - You can specify all the options shown below as an options object param.
- *
- * @option fx - default is "linear"
- * @example
- * $(".lavaLamp").lavaLamp({ fx: "backout" });
- * @desc Creates a menu with "backout" easing effect. You need to include the easing plugin for this to work.
- *
- * @option speed - default is 500 ms
- * @example
- * $(".lavaLamp").lavaLamp({ speed: 500 });
- * @desc Creates a menu with an animation speed of 500 ms.
- *
- * @option click - no defaults
- * @example
- * $(".lavaLamp").lavaLamp({ click: function(event, menuItem) { return false; } });
- * @desc You can supply a callback to be executed when the menu item is clicked.
- * The event object and the menu-item that was clicked will be passed in as arguments.
- */
-(function($) {
-$.fn.lavaLamp = function(o) {
- o = $.extend({ fx: "linear", speed: 500, click: function(){} }, o || {});
-
- return this.each(function() {
- var me = $(this), noop = function(){},
- $back = $('<li class="back"><div class="left"></div></li>').appendTo(me),
- $li = $("li", this), curr = $("li.current", this)[0] || $($li[0]).addClass("current")[0];
-
- $li.not(".back").hover(function() {
- move(this);
- }, noop);
-
- $(this).hover(noop, function() {
- move(curr);
- });
-
- $li.click(function(e) {
- setCurr(this);
- return o.click.apply(this, [e, this]);
- });
-
- setCurr(curr);
-
- function setCurr(el) {
- $back.css({ "left": el.offsetLeft+"px", "width": el.offsetWidth+"px" });
- curr = el;
- };
-
- function move(el) {
- $back.each(function() {
- $(this).dequeue(); }
- ).animate({
- width: el.offsetWidth,
- left: el.offsetLeft
- }, o.speed, o.fx);
- };
-
- });
-};
-})(jQuery);
+/** + * LavaLamp - A menu plugin for jQuery with cool hover effects. + * @requires jQuery v1.1.3.1 or above + * + * http://gmarwaha.com/blog/?p=7 + * + * Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com) + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Version: 0.2.0 + * Requires Jquery 1.2.1 from version 0.2.0 onwards. + * For jquery 1.1.x, use version 0.1.0 of lavalamp + */ + +/** + * Creates a menu with an unordered list of menu-items. You can either use the CSS that comes with the plugin, or write your own styles + * to create a personalized effect + * + * The HTML markup used to build the menu can be as simple as... + * + * <ul class="lavaLamp"> + * <li><a href="#">Home</a></li> + * <li><a href="#">Plant a tree</a></li> + * <li><a href="#">Travel</a></li> + * <li><a href="#">Ride an elephant</a></li> + * </ul> + * + * Once you have included the style sheet that comes with the plugin, you will have to include + * a reference to jquery library, easing plugin(optional) and the LavaLamp(this) plugin. + * + * Use the following snippet to initialize the menu. + * $(function() { $(".lavaLamp").lavaLamp({ fx: "backout", speed: 700}) }); + * + * Thats it. Now you should have a working lavalamp menu. + * + * @param an options object - You can specify all the options shown below as an options object param. + * + * @option fx - default is "linear" + * @example + * $(".lavaLamp").lavaLamp({ fx: "backout" }); + * @desc Creates a menu with "backout" easing effect. You need to include the easing plugin for this to work. + * + * @option speed - default is 500 ms + * @example + * $(".lavaLamp").lavaLamp({ speed: 500 }); + * @desc Creates a menu with an animation speed of 500 ms. + * + * @option click - no defaults + * @example + * $(".lavaLamp").lavaLamp({ click: function(event, menuItem) { return false; } }); + * @desc You can supply a callback to be executed when the menu item is clicked. + * The event object and the menu-item that was clicked will be passed in as arguments. + */ +(function($) { +$.fn.lavaLamp = function(o) { + o = $.extend({ fx: "linear", speed: 500, click: function(){} }, o || {}); + + return this.each(function() { + var me = $(this), noop = function(){}, + $back = $('<li class="back"><div class="left"></div></li>').appendTo(me), + $li = $("li", this), curr = $("li.current", this)[0] || $($li[0]).addClass("current")[0]; + + $li.not(".back").hover(function() { + move(this); + }, noop); + + $(this).hover(noop, function() { + move(curr); + }); + + $li.click(function(e) { + setCurr(this); + return o.click.apply(this, [e, this]); + }); + + setCurr(curr); + + function setCurr(el) { + $back.css({ "left": el.offsetLeft+"px", "width": el.offsetWidth+"px" }); + curr = el; + }; + + function move(el) { + $back.each(function() { + $(this).dequeue(); } + ).animate({ + width: el.offsetWidth, + left: el.offsetLeft + }, o.speed, o.fx); + }; + + }); +}; +})(jQuery); diff --git a/static/js/pichat.js b/static/js/pichat.js index 985715d..dbc110b 100755 --- a/static/js/pichat.js +++ b/static/js/pichat.js @@ -1,8 +1,11 @@ var cache = {} -var pendingMessages = {} +var PendingMessages = {} var MaxImagePosts = 40 +// Utils + + function escapeHtml(txt) { if (!txt) { return ""; } else { return $("<span>").text(txt).html(); } @@ -29,6 +32,8 @@ function linkReplace(url){ } } +// Message Handling + var ImageMsgCount = 0 function removeOldMessages(){ // don't count posts that are all text @@ -72,6 +77,8 @@ function buildUserDiv(user) { } } +// Growl + function buildGrowlDataAndPopDatShit(msg) { var nick = escapeHtml(msg.nick); nick = '<a href="/u/' + nick + ' " style="color:pink">' + nick + '</a>:' @@ -94,11 +101,13 @@ function handleMsgError(resp) { } } +// Messages + function submitMessage() { var content = $.trim($('#msgInput').val()); $('#msgInput').val(''); if (content == '') { return; } - pendingMessages[content] = true; + PendingMessages[content] = true; var msg = { 'nick': Nick, 'content': content }; var div = addNewMessage(msg, true); @@ -172,14 +181,34 @@ function updateUI(msgs, users) { } function isDuplicateMessage(m) { - if (m.nick == Nick && m.content in pendingMessages) { - delete pendingMessages[m.content]; + if (m.nick == Nick && m.content in PendingMessages) { + delete PendingMessages[m.content]; return true; } else { return false; } } +var CurrentTopic = null; + +function isSameTopic(curTopic, newTopic) { + if (!!curTopic != !!newTopic) { return false; } + else if (!curTopic) { return false; } // => !newTopic also + else { + return curTopic.topic == newTopic.topic && + curTopic.deadline == newTopic.deadline && + curTopic.maker == newTopic.maker; + } +} + +function updateTopic(newTopic) { + if (isSameTopic(CurrentTopic, newTopic)) { return; } + alert('new topic'); + CurrentTopic = newTopic; + $('#topic').text(topic.topic); + +} + function refresh() { var onSuccess = function(json) { try { @@ -191,6 +220,9 @@ function refresh() { if (typeof UnseenMsgCounter !== 'undefined' && !HasFocus) { UnseenMsgCounter += messages.length; } + if (json.topic) { + updateTopic(json.topic); + } } catch(e) { if (IsAdmin && window.console) { console.error(e); @@ -237,22 +269,16 @@ function initChat() { setTimeout(refresh, 1000); } -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())); - }); +function makePlainText() { + var j = $(this); + j.text(j.text()); +} +function activateProfileEditable() { var onSubmit = function(attr, newVal, oldVal) { newVal = $.trim(newVal); if (newVal == oldVal) { return oldVal }; - + $.ajax({ type: "POST", timeout: 5000, @@ -270,22 +296,45 @@ function initProfile() { return escapeHtml(newVal); }; - var avatarOpts = { 'default_text': 'Enter here!', + var avatarOpts = { 'default_text': 'Paste URL here!', 'callback': onSubmit, 'field_type': 'text', 'callbackShowErrors': false }; - $('#avatar.editable').editInPlace(avatarOpts); + if ($('#avatar.editable').length > 0) { + $('#avatar.editable').editInPlace(avatarOpts); + setupUploadAvatar('upload'); + } var textareaOpts = { 'default_text': 'Enter here!', 'callback': onSubmit, 'field_type': 'textarea', 'callbackShowErrors': false }; - $('#contact.editable, #bio.editable').editInPlace(textareaOpts); + $('#contact.editable, #bio.editable') + .editInPlace(textareaOpts) + .each(makePlainText); +} - if ($('#upload').length > 0) { - setupUploadAvatar('upload'); - } +function enableProfileEdit() { + $('#contact, #bio, #avatar').addClass('editable'); + $('#avatar-editing').show(); + var resetPage = function() { location.reload() }; + $('#edit-toggle a').text('--> Done editing <--').click(resetPage); + activateProfileEditable(); +} +function initProfile() { + $(".linkify").each(function() { + var text = jQuery(this).text(); + jQuery(this).html(linkify(text)); + }); + + $('#edit-toggle').click(enableProfileEdit); + activateProfileEditable(); + + $('.logged-dump .content').each(function() { + var t = $(this); + t.html(buildMsgContent(t.text())); + }); }; function initLog() { @@ -328,9 +377,9 @@ function setupUploadAvatar(elementId) { var onComplete = function(file, resp) { $('#spinner').hide(); if (resp == 'INVALID_REQUEST') { - location.href = location.href; + location.reload(); } else if (resp == 'NOT_LOGGED_IN') { - location.href = location.href; + location.reload(); } else if (resp == 'INVALID_IMAGE') { alert("Sorry, dump.fm can't deal with your image. Pick another :("); return; |
