|
Post by Wormopolis on Nov 21, 2011 0:53:20 GMT -8
browsers tested: IE and FF placement: global footer
This code has 2 functions:
1. will convert long links in a post that contain a particular domain (like yahoo.com or youtube.com) into a linked image of your choosing.
2. will put new ubbc buttons in the tray that will preformat links with image UBBC tags inside them.
<script type="text/javascript"> <!-- // DragonLinks v1.2 // convert certain links to images in posts // predefined image links in UBBC table // request by dragon // code by Wormopolis
// this array is for converting linksinto preset images var imageChangeArray=[ // ['link for domain match', 'url to image'] ['www.youtube.com','http://www2.mssociety.org.uk/images/youtube_logo_small.jpg'], ['www.google.com','http://www.score.org/sites/default/files/Google_small2.png'], ['www.proboards.com','http://images.proboards.com/hotlink/proboards_orange_36x36.png'] //no comma last entry ];
// this array is for UBBC images in tray for posting links var ubbcImageButtonArray=[ // ['url to button image', 'url to post image (doesnt have to be same)', 'hovertitle'] ['http://www2.mssociety.org.uk/images/youtube_logo_small.jpg', 'http://www2.mssociety.org.uk/images/youtube_logo_small.jpg ', 'Youtube'], ['http://www.score.org/sites/default/files/Google_small2.png', 'http://www.score.org/sites/default/files/Google_small2.png ', 'Google'], ['http://images.proboards.com/hotlink/proboards_orange_36x36.png', 'http://images.proboards.com/hotlink/proboards_orange_36x36.png', 'ProBoards'] //no comma last entry ]; var ubbcBtnHeight=36; var ubbcBtnWidth=36;
if (document.postForm) { var trayTable=document.postForm.color.parentNode; trayTable.appendChild(document.createElement('br')); for (ub=0; ub<ubbcImageButtonArray.length; ub++) { var nwbtn=document.createElement('a'); nwbtn.href='javascript: add("[url=","][img]'+ubbcImageButtonArray[ub][1]+ '[/img][/url]");'; nwimg=document.createElement('img'); nwimg.border=0; nwimg.src=ubbcImageButtonArray[ub][0]; nwimg.title=ubbcImageButtonArray[ub][2]; nwimg.height=ubbcBtnHeight; nwimg.width=ubbcBtnWidth; nwbtn.appendChild(nwimg); trayTable.appendChild(nwbtn); } } for (ic=0; ic<imageChangeArray.length; ic++) imageChangeArray[ic][0]=new RegExp(imageChangeArray[ic][0],'i'); for (td=document.getElementsByTagName('td'), tt=0; tt<td.length; tt++) { if (td[tt].width=='80%' && td[tt].className.match(/windowbg/) && td[tt].getElementsByTagName('hr')[0]) { var postSpot=td[tt].getElementsByTagName('hr')[0].nextSibling; for (lnks=postSpot.getElementsByTagName('a'), ll=0; ll<lnks.length; ll++) { for (ic=0; ic<imageChangeArray.length; ic++) { if (lnks[ll].href.match(imageChangeArray[ic][0])) { lnks[ll].innerHTML='<img border="0" src="' + imageChangeArray[ic][1] + '">'; break; } } } } }
// --> </script>
|
|