[Phpfreechat-svn] SF.net SVN: phpfreechat: [1181] trunk/data/public/js
Status: Beta
Brought to you by:
kerphi
From: <gpi...@us...> - 2007-09-06 17:08:59
|
Revision: 1181 http://phpfreechat.svn.sourceforge.net/phpfreechat/?rev=1181&view=rev Author: gpinzone Date: 2007-09-06 10:09:01 -0700 (Thu, 06 Sep 2007) Log Message: ----------- Move sort to loadSmileyBox(). Modified Paths: -------------- trunk/data/public/js/pfcclient.js trunk/data/public/js/pfcgui.js trunk/data/public/js/pfcresource.js Modified: trunk/data/public/js/pfcclient.js =================================================================== --- trunk/data/public/js/pfcclient.js 2007-09-06 15:39:43 UTC (rev 1180) +++ trunk/data/public/js/pfcclient.js 2007-09-06 17:09:01 UTC (rev 1181) @@ -1460,7 +1460,7 @@ // try to parse smileys var smileys = this.res.getSmileyHash(); - var sl = this.res.getSmileyKeysSorted(); + var sl = this.res.getSmileyKeys(); // Keys should be sorted by length from pfc.gui.loadSmileyBox() for(var i = 0; i < sl.length; i++) { // We don't want to replace smiley strings inside of tags. Modified: trunk/data/public/js/pfcgui.js =================================================================== --- trunk/data/public/js/pfcgui.js 2007-09-06 15:39:43 UTC (rev 1180) +++ trunk/data/public/js/pfcgui.js 2007-09-06 17:09:01 UTC (rev 1181) @@ -402,17 +402,17 @@ var container = $('pfc_smileys'); var smileys = pfc.res.getSmileyReverseHash();//getSmileyHash(); var sl = smileys.keys(); + pfc.res.sortSmileyKeys(); // Sort smiley keys once. for(var i = 0; i < sl.length; i++) { s_url = sl[i]; s_symbol = smileys[sl[i]]; s_symbol = s_symbol.unescapeHTML(); // Replace " with " for IE and Webkit browsers. - // The prototype.js version 1.5.1.1 does not do this. - // IE and Webkit detection from prototype.js - if (window.attachEvent && !window.opera || navigator.userAgent.indexOf('AppleWebKit/') > -1) + // The prototype.js version 1.5.1.1 unescapeHTML() function does not do this. + if (is_ie || is_webkit) s_symbol = s_symbol.replace(/"/g,'"'); - + var img = document.createElement('img'); img.setAttribute('src', s_url); img.setAttribute('alt', s_symbol); @@ -764,5 +764,5 @@ soundcontainerbox.setAttribute('id', 'pfc_sound_container'); container.appendChild(soundcontainerbox); */ - } + } }; Modified: trunk/data/public/js/pfcresource.js =================================================================== --- trunk/data/public/js/pfcresource.js 2007-09-06 15:39:43 UTC (rev 1180) +++ trunk/data/public/js/pfcresource.js 2007-09-06 17:09:01 UTC (rev 1181) @@ -12,7 +12,7 @@ this.fileurl = $H(); this.smileys = $H(); this.smileysreverse = $H(); - this.smileyskeyssorted = new Array(); + this.smileyskeys = new Array(); }, setLabel: function(key, value) @@ -49,9 +49,7 @@ { this.smileys[key] = value; this.smileysreverse[value] = key; - //this.smileyskeyssorted.push(key); - // Sort keys by longest to shortest. This prevents a smiley like :) from being used on >:) - this.smileyskeyssorted.sort(function (a,b){return (b.unescapeHTML().length - a.unescapeHTML().length);}) + this.smileyskeys.push(key); }, getSmiley: function(key) { @@ -68,11 +66,31 @@ { return this.smileysreverse; }, - getSmileyKeysSorted: function() + getSmileyKeys: function() { - return this.smileyskeyssorted; + return this.smileyskeys; + }, + sortSmileyKeys: function() + { + // Sort keys by longest to shortest. This prevents a smiley like :) from being used on >:) + return this.smileyskeys.sort( + function (a,b) + { + a = a.unescapeHTML(); + b = b.unescapeHTML(); + + // Replace " with " for IE and Webkit browsers. + // The prototype.js version 1.5.1.1 unescapeHTML() function does not do this. + if (is_ie || is_webkit) + { + a = a.replace(/"/g,'"'); + b = b.replace(/"/g,'"'); + } + + return (b.length - a.length); + } + ); } - }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |