MyBB Community Forums

Full Version: Smilie inserter.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Okay so i almost have the smilie inserter done. http://i.imgur.com/y9lN5.png

And mostly working, except one thing:

http://i.imgur.com/1JVEn.png

It currently gives as output the normal names of the images (which are of course is needed to show them because things like:

 :-/.gif

are not allowed soToungue )

So i have an array at the top:

// An array of Smileys
		this.smileys = new Object();
		this.smileys[":angel:"] = "angel";
		this.smileys[":@"] = "angry";
		this.smileys[":blush:"] = "blush";
		this.smileys[":s"] = "confused";
		this.smileys[":dodgy:"] = "dodgy";
		this.smileys[":exclamation:"] = "exclamation";
		this.smileys[":heart:"] = "heart";
		this.smileys[":huh:"] = "huh";
		this.smileys[":idea:"] = "idea";
		this.smileys[":sleepy:"] = "sleepy";
		this.smileys[":-/"] = "undecided";
		this.smileys[":)"] = "smile";
		this.smileys[";)"] = "wink";
		this.smileys[":cool:"] = "cool";
		this.smileys[":D"] = "biggrin";
		this.smileys[":P"] = "tongue";
		this.smileys[":rolleyes:"] = "rolleyes";
		this.smileys[":shy:"] = "shy";
		this.smileys[":("] = "sad";
		this.smileys[":at:"] = "at";

How do i get the information between the [ ] ? instead of the information like = "shy".

This is my insert smiley code:
insertSmiley: function(type)
	{
		this.performInsert(""+type+"", "", true, false);
	},

And the case exception looks like this:

case "smiley":
				this.insertSmiley(extra);
				break;

If anybody would be able to help me out i would greatly appreciate that.
If you need any other information please ask.
I am still looking for help regarding this issue.

Is their any easy doable way to handle this. Or would the only real option be with a switch statement?
this.smileys.indexOf("heart") -> "Heart"? for x in this.smileys?

Or simply turn the array around, so you could use this.smileys["heart"].

Or (simpler yet) make the button pop up MyBB's standard smiley inserter that's already there Toungue
Nevermind went for the easy way:

insertSmiley: function(type)
	{
		switch(type)
		{
			case "angel":
				code = ":angel:";
				break;
			case "angry":
				code = ":@";
				break;
			case "blush":
				code = ":blush:";
				break;
			case "confused":
				code = ":s";
				break;
			case "dodgy":
				code = ":dodgy:";
				break;
			case "exclamation":
				code = ":exclamation:";
				break;
			case "heart":
				code = ":heart:";
				break;
			case "huh":
				code = ":huh:";
				break;
			case "idea":
				code = ":idea:";
				break;
			case "sleepy":
				code = ":sleepy:";
				break;
			case "undecided":
				code = ":-/";
				break;
			case "smile":
				code = ":)";
				break;
			case "wink":
				code = ";)";
				break;
			case "cool":
				code = ":cool:";
				break;
			case "biggrin":
				code = ":D";
				break;
			case "tongue":
				code = ":P";
				break;
			case "rolleyes":
				code = ":rolleyes:";
				break;
			case "shy":
				code = ":shy:";
				break;
			case "sad":
				code = ":(";
				break;
			case "at":
				code = ":at:";
				break;
		
		}
		if(code)
		{
			this.performInsert(""+code+"", "", true, false);
		}
	},