Mercurial > public > sg101
comparison media/js/shoutbox.js @ 12:f408971657b9
Changed the shoutbox: posts are now made by Ajax. The smiley farm is loaded only on demand. jQuery is now in the base template. May add scrolling later.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 15 Apr 2009 01:13:17 +0000 |
parents | dbd703f7d63a |
children | 03144b0d470d |
comparison
equal
deleted
inserted
replaced
11:cc8eb028def1 | 12:f408971657b9 |
---|---|
1 /*********************************************** | 1 $(document).ready(function() { |
2 * Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com) | 2 var submit = $('#shoutbox-submit'); |
3 * This notice MUST stay intact for legal use | 3 submit.click(function () { |
4 * Visit http://www.dynamicdrive.com/ for this script and 100s more. | 4 var input = $('#shoutbox-smiley-input'); |
5 ***********************************************/ | 5 var msg = input.val(); |
6 | 6 msg = msg.replace(/^\s+/, ''); |
7 var delayb4scroll=2000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds) | 7 msg = msg.replace(/\s+$/, ''); |
8 var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10) | 8 if (msg.length == 0) { |
9 var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)? | 9 return false; |
10 | 10 } |
11 ////NO NEED TO EDIT BELOW THIS LINE//////////// | 11 submit.attr('disabled', 'disabled'); |
12 | 12 $.post('/shout/shout/', { |
13 var copyspeed=marqueespeed | 13 msg: msg |
14 var pausespeed=(pauseit==0)? copyspeed: 0 | 14 }, |
15 var actualheight='' | 15 function (data, textStatus) { |
16 | 16 input.val(''); |
17 function scrollmarquee(){ | 17 if (data != '') { |
18 if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8)) | 18 $('#shoutbox-shout-container').prepend(data); |
19 cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px" | 19 $('#shoutbox-shout-container p:first').fadeIn(2500); |
20 else | 20 } |
21 cross_marquee.style.top=parseInt(marqueeheight)+8+"px" | 21 submit.removeAttr('disabled'); |
22 } | 22 }, |
23 | 23 'html'); |
24 function initializemarquee(){ | 24 return false; |
25 cross_marquee=document.getElementById("vmarquee") | 25 }); |
26 cross_marquee.style.top=0 | 26 var smilies_loaded = false; |
27 marqueeheight=document.getElementById("marqueecontainer").offsetHeight | 27 var smiley_frame = $('#shoutbox-smiley-frame'); |
28 actualheight=cross_marquee.offsetHeight | 28 $('#shoutbox-smilies').click(function () { |
29 if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit | 29 smiley_frame.toggle(); |
30 cross_marquee.style.height=marqueeheight+"px" | 30 if (!smilies_loaded) { |
31 cross_marquee.style.overflow="scroll" | 31 smiley_frame.load('/smiley/farm/', function () { |
32 return | 32 $('#shoutbox-busy-icon').hide(); |
33 } | 33 smilies_loaded = true; |
34 setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll) | 34 }); |
35 } | 35 } |
36 | 36 }); |
37 if (window.addEventListener) | 37 }); |
38 window.addEventListener("load", initializemarquee, false) | |
39 else if (window.attachEvent) | |
40 window.attachEvent("onload", initializemarquee) | |
41 else if (document.getElementById) | |
42 window.onload=initializemarquee | |
43 | |
44 /////////////////////////////// | |
45 | |
46 function sb_toggle_smilies() | |
47 { | |
48 var d = document.getElementById("shoutbox-smiley-frame"); | |
49 d.style.display = d.style.display == "none" ? "block" : "none"; | |
50 } | |
51 | 38 |
52 function sb_smiley_click(code) | 39 function sb_smiley_click(code) |
53 { | 40 { |
54 var txt = document.getElementById("shoutbox-smiley-input"); | 41 var txt = document.getElementById("shoutbox-smiley-input"); |
55 txt.value += code; | 42 txt.value += code; |