Post by ⓦ৹₪deⓡ on Apr 16, 2006 23:21:07 GMT -8
This code will add a new UBBC button () which will allow your users to add a link to a Wikipedia article. The syntax follows Wikipedia's link syntax.
Examples:
[[Wikipedia]] => Wikipedia
[[Wikipedia|Free Online Encyclopedia]] => Free Online Encyclopedia
The new tag will work in PMs and Posts. Do NOT PM me for support or requests, that's what the coding boards are for. Edit where indicated.
Enjoy,
~Wonder
Global Footer:
Examples:
[[Wikipedia]] => Wikipedia
[[Wikipedia|Free Online Encyclopedia]] => Free Online Encyclopedia
The new tag will work in PMs and Posts. Do NOT PM me for support or requests, that's what the coding boards are for. Edit where indicated.
Enjoy,
~Wonder
Global Footer:
<script>
//Wikipedia Links v1.0 [CB]
//Copyright 04-17-2006 ~Wonder
//May be reposted|modified anywhere as long as this header remains in tact
//URL to Wikipedia UBBC Icon
wikiIcon="http://img20.imageshack.us/img20/3482/wikiicon6bb.gif";
if(document.postForm && document.postForm.color)
{
document.postForm.color.parentNode.innerHTML+="<a href=javascript:add(\"[[\",\"]]\")><img src=\""+wikiIcon+"\" alt=\"Wikipedia Link\" border=\"0\"></a>";
}
if(location.href.match(/action\=(display|pmview|recent|userrecentposts|gotopost|search|calendarview)/) || (!location.href.match(/action\=/) && document.postForm))
{
hrs=document.getElementsByTagName("hr");
for(i=0;i<hrs.length;i++)
{
if(typeof(hrs[i].nextSibling.innerHTML)=="string")
{
matches=hrs[i].nextSibling.innerHTML.match(/\[\[(.+?)\]\]/ig);
if(matches)
{
temp=hrs[i].nextSibling.innerHTML;
for(j=0;j<matches.length;j++)
{
if(matches[j].match(/(\[\[.+?)\|(.+?\]\])/))
{
split=[RegExp.$1,RegExp.$2];
temp=temp.replace(matches[j],"<a href=\"http://en.wikipedia.org/wiki/"+escape(split[0].replace(/^\[\[|\]\]$/g,"").replace(/ /g,"_")).replace(/%23/ig,"#")+"\" target=\"_blank\">"+split[1].replace(/^\[\[|\]\]$/g,"")+"</a>");
}
else
temp=temp.replace(matches[j],"<a href=\"http://en.wikipedia.org/wiki/"+escape(matches[j].replace(/^\[\[|\]\]$/g,"").replace(/ /g,"_")).replace(/%23/ig,"#")+"\" target=\"_blank\">"+matches[j].replace(/^\[\[|\]\]$/g,"")+"</a>");
}
hrs[i].nextSibling.innerHTML=temp;
}
}
}
}
</script>