Funny that someone had problems with this just as I had come up with a solution
I edited my original code because I noticed that it was having problems when wanting to specify a version of an item or spell. So I added this in:
BBCode Usage:
Code:
[mmoitem]{TEXT}[/mmoitem]
HTML Replacement:
Code:
<script type="text/javascript">
var a = -1;
var b = -1;
var itemnum = null;
var itemname = null;
var str = null;
var myNewString = null;
var myOldString = "{TEXT}";
str = myOldString;
a = str.indexOf("{");
if (a != -1)
{
b = str.indexOf("}");
itemnum = str.substr((a + 1), (b - a - 1));
itemname = str.substr(0, (a));
if (itemname.substr(itemname.length - 1, itemname.length) == " ")
{
itemname = itemname.substr(0, (itemname.length - 1));
}
}
else
{
itemname = myOldString;
}
myNewString = itemname.replace(/&#39;s/g, "s"); //removes '
myNewString = myNewString.replace(/&#39;/g, "-"); //replaces ' with -
myNewString = myNewString.replace(/ /g, "-"); //replaces space with -
myNewString = myNewString.replace(/,/g, ""); //removes ,
myNewString = myNewString.replace(/&#40;/g, ""); //removes (
myNewString = myNewString.replace(/&#41;/g, ""); //removes )
if (myNewString.length > 50)
{
myNewString = myNewString.substr(0, 50);
}
if (itemnum == null)
{
var lnk = "<a href=http://mmo-champion.com target='_blank' title='mmo-champion.com'><img src='http://www.mmo-champion.com/favicon.ico'></a><a href=http://db.mmo-champion.com/i/" + myNewString + " target='_blank'>" + myOldString + "</a>";
}
else
{
var lnk = "<a href=http://mmo-champion.com target='_blank' title='mmo-champion.com'><img src='http://www.mmo-champion.com/favicon.ico'></a><a href=http://db.mmo-champion.com/i/" + itemnum + "/" + myNewString + " target='_blank'>" + itemname + "</a>";
}
document.write(lnk);
if (typeof(mmotip) == "undefined")
{
var mmotip = "http://db.mmo-champion.com/tt.js";
//if Internet Explorer:
if (document.all)
{
var lnk = '<script src="'+ mmotip + '" type="text/JavaScript"><\/script>';
document.write(lnk);
}
//if Not Internet Explorer:
else
{
var th = document.getElementsByTagName("body")[0];
var s = document.createElement('script');
s.type = "text/javascript";
s.src = mmotip;
th.appendChild(s);
}
}
</script>
What this basically allows is specifying an item number. Please note that I have my website set to allow people to select the difference between items/spells/quest/achievs/etc. by using different tags (so the code above is for items only). So, when [mmoitem]Perdition[/mmoitem] will automatically result in the heroic version of Perdition, now users can enter [mmoitem]Perdition {47900}[/mmoitem] to specify the lower version of the item.