[Phpfreechat-svn] SF.net SVN: phpfreechat: [880] trunk
Status: Beta
Brought to you by:
kerphi
From: <ke...@us...> - 2006-11-28 17:50:28
|
Revision: 880 http://svn.sourceforge.net/phpfreechat/?rev=880&view=rev Author: kerphi Date: 2006-11-28 09:50:20 -0800 (Tue, 28 Nov 2006) Log Message: ----------- [en] Add the sound notification using a small flash applet. It's possible to enable/disable the sound notification at startup with the 'startwithsound' parameter. (thanks to neohunter) [1h00] [fr] Ajoute la notification sonore par le biais d'une petite applet flash. Il est possible d'activer/d?\195?\169sactiver le son au d?\195?\169marrage grace au param?\195?\168tre 'startwithsound'. (merci ?\195?\160 neohunter) [1h00] Modified Paths: -------------- trunk/src/client/chat.js.tpl.php trunk/src/client/pfcclient.js trunk/src/client/pfcgui.js trunk/src/pfcglobalconfig.class.php trunk/themes/default/style.css Added Paths: ----------- trunk/themes/default/images/sound-off.gif trunk/themes/default/images/sound-on.gif trunk/themes/default/sound.swf Modified: trunk/src/client/chat.js.tpl.php =================================================================== --- trunk/src/client/chat.js.tpl.php 2006-11-28 16:52:37 UTC (rev 879) +++ trunk/src/client/chat.js.tpl.php 2006-11-28 17:50:20 UTC (rev 880) @@ -10,10 +10,11 @@ var pfc_clientid = <?php echo $json->encode(md5(uniqid(rand(), true))); ?>; var pfc_title = <?php echo $json->encode($title); ?>; var pfc_refresh_delay = <?php echo $json->encode($refresh_delay); ?>; -var pfc_max_refresh_delay = <?php echo $json->encode($max_refresh_delay); ?>; +var pfc_max_refresh_delay = <?php echo $json->encode($max_refresh_delay); ?>; var pfc_start_minimized = <?php echo $json->encode($start_minimized); ?>; var pfc_nickmarker = <?php echo $json->encode($nickmarker); ?>; var pfc_clock = <?php echo $json->encode($clock); ?>; +var pfc_startwithsound = <?php echo $json->encode($startwithsound); ?>; var pfc_showsmileys = <?php echo $json->encode($showsmileys); ?>; var pfc_showwhosonline = <?php echo $json->encode($showwhosonline); ?>; var pfc_focus_on_connect = <?php echo $json->encode($focus_on_connect); ?>; @@ -78,6 +79,8 @@ "You are not allowed to speak to yourself", // _pfc "Close", // _pfc "Choosen nickname is not allowed", // _pfc + "Play sound", // _pfc + "Mute sound", // _pfc ); foreach($labels_to_load as $l) { @@ -114,6 +117,9 @@ 'images/close-whoisbox.gif', 'images/openpv.gif', 'images/user-admin.gif', + 'images/sound-on.gif', + 'images/sound-off.gif', + 'sound.swf', ); foreach($fileurl_to_load as $f) Modified: trunk/src/client/pfcclient.js =================================================================== --- trunk/src/client/pfcclient.js 2006-11-28 16:52:37 UTC (rev 879) +++ trunk/src/client/pfcclient.js 2006-11-28 17:50:20 UTC (rev 880) @@ -117,6 +117,11 @@ if (cookie != null) this.switch_text_color(cookie); + cookie = getCookie('pfc_issoundenable'); + this.issoundenable = (cookie == 'true'); + if (cookie == '' || cookie == null) + this.issoundenable = pfc_startwithsound; + this.refresh_loginlogout(); this.refresh_minimize_maximize(); this.refresh_Smileys(); @@ -1389,6 +1394,36 @@ }, /** + * Sound button + */ + sound_swap: function() + { + if (this.issoundenable) { + this.issoundenable = false; + } else { + this.issoundenable = true; + } + this.refresh_sound(); + setCookie('pfc_issoundenable', this.issoundenable); + }, + refresh_sound: function( root ) + { + var snd_icon = $('pfc_sound'); + if (this.issoundenable) + { + snd_icon.src = this.res.getFileUrl('images/sound-on.gif'); + snd_icon.alt = this.res.getLabel('Play sound'); + snd_icon.title = snd_icon.alt; + } + else + { + snd_icon.src = this.res.getFileUrl('images/sound-off.gif'); + snd_icon.alt = this.res.getLabel('Mute sound'); + snd_icon.title = snd_icon.alt; + } + }, + + /** * Connect/disconnect button */ connect_disconnect: function() Modified: trunk/src/client/pfcgui.js =================================================================== --- trunk/src/client/pfcgui.js 2006-11-28 16:52:37 UTC (rev 879) +++ trunk/src/client/pfcgui.js 2006-11-28 17:50:20 UTC (rev 880) @@ -301,12 +301,29 @@ var rx = new RegExp('^\\[[0-9]+\\](.*)','ig'); document.title = document.title.replace(rx,'$1'); document.title = '['+this.windownotifynb+']'+document.title; + + // play the sound + var soundcontainer = document.getElementById('pfc_sound_container'); + if (pfc.issoundenable) + { + var flash = '<object style="visibility:hidden" classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0">'; + flash += '<param name="movie" value="' + pfc.res.getFileUrl('sound.swf') + '">'; + flash += '<param name="quality" value="High">'; + flash += '<embed src="' + pfc.res.getFileUrl('sound.swf') + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj1">'; + flash += '</object>'; + soundcontainer.innerHTML = flash; + } }, unnotifyWindow: function() { this.windownotifynb = 0; var rx = new RegExp('^\\[[0-9]+\\](.*)','ig'); document.title = document.title.replace(rx,'$1'); + + // stop the sound + var soundcontainer = document.getElementById('pfc_sound_container'); + if (pfc.issoundenable) + soundcontainer.innerHTML = ''; }, /** @@ -537,6 +554,17 @@ btn.appendChild(img); cmdcontainer.appendChild(btn); + // button sound on/off + var btn = document.createElement('div'); + btn.setAttribute('class', 'pfc_btn'); + btn.setAttribute('className', 'pfc_btn'); // for IE6 + var img = document.createElement('img'); + img.setAttribute('id', 'pfc_sound'); + img.setAttribute('src', pfc.res.getFileUrl('images/sound-on.gif')); + img.onclick = function(){ pfc.sound_swap(); } + btn.appendChild(img); + cmdcontainer.appendChild(btn); + // button smileys on/off if (pfc_btn_sh_smileys) { @@ -677,6 +705,11 @@ smileybox.setAttribute('id', 'pfc_smileys'); inputcontainer.appendChild(smileybox); this.loadSmileyBox(); + + // sound container box : <div id="pfc_sound_container"> + var soundcontainerbox = document.createElement('div'); + soundcontainerbox.setAttribute('id', 'pfc_sound_container'); + inputcontainer.appendChild(soundcontainerbox); } }; Modified: trunk/src/pfcglobalconfig.class.php =================================================================== --- trunk/src/pfcglobalconfig.class.php 2006-11-28 16:52:37 UTC (rev 879) +++ trunk/src/pfcglobalconfig.class.php 2006-11-28 17:50:20 UTC (rev 880) @@ -82,6 +82,7 @@ var $shownotice = 3; // show: 0 = nothing, 1 = just nickname changes, 2 = join/quit, 3 = 1+2 var $nickmarker = true; // show/hide nicknames colors var $clock = true; // show/hide dates and hours + var $startwithsound = true; // start with sound enabled var $openlinknewwindow = true; // used to open the links in a new window var $notify_window = true; // true : appends a prefix to the window title with the number of new posted messages Added: trunk/themes/default/images/sound-off.gif =================================================================== (Binary files differ) Property changes on: trunk/themes/default/images/sound-off.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/themes/default/images/sound-on.gif =================================================================== (Binary files differ) Property changes on: trunk/themes/default/images/sound-on.gif ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/themes/default/sound.swf =================================================================== (Binary files differ) Property changes on: trunk/themes/default/sound.swf ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Modified: trunk/themes/default/style.css =================================================================== --- trunk/themes/default/style.css 2006-11-28 16:52:37 UTC (rev 879) +++ trunk/themes/default/style.css 2006-11-28 17:50:20 UTC (rev 880) @@ -346,4 +346,9 @@ div#pfc_debug { font-size: 11px; +} +div#pfc_sound_container { + visibility:hidden; /* this box is hidden because it contains a flash sound media (sound.swf)*/ + width: 0; + height: 0; } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |