|
Post by Wormopolis on Oct 23, 2011 15:23:30 GMT -8
<script type="text/javascript"> <!-- // convert certain links to images in posts // v1.1 // request by dragon // code by Wormopolis
var imageChangeArray=[ // [url - link must match entire string, 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 ];
var firstPostOnly=true;
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 (((!location.href.match(/page=/) || location.href.match(/page=1($|&|#)/)) && firstPostOnly) || !firstPostOnly) { 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; } } } if (firstPostOnly) break; } } } // --> </script>
|
|
|
Post by Dragon on Oct 24, 2011 17:36:54 GMT -8
<script type="text/javascript"> <!-- // convert certain links to images in posts // request by dragon // code by Wormopolis var imageChangeArray=[ // ['http://www.imdb.com/','http://img848.imageshack.us/img848/7614/spbuttonimdb.png'], ['http://en.wikipedia.org/','http://img684.imageshack.us/img684/6599/spbuttonwikipedia.png'], ['http://www.tv-links.eu/','http://img42.imageshack.us/img42/2087/spbuttontvl.png'], ['http://itunes.apple.com/','http://img577.imageshack.us/img577/465/spbuttonitunes.png'] //no comma last entry ];
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.width=='80%' && td.className.match(/windowbg/) && td.getElementsByTagName('hr')[0]) { var postSpot=td.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>
I put that into the tvlinks board: spatialpublics.com/index.cgi?board=tvlocations
Doesnt seem work ?
|
|
|
Post by Wormopolis on Oct 24, 2011 18:04:11 GMT -8
footer. not header.
|
|
|
Post by Dragon on Oct 25, 2011 20:27:54 GMT -8
Ah, ok.
The code works splendidly, though you were right about the problem of it showing up in every post.
I'd ask if it could be changed so that only the first post would do the magic of the code ?
If not, we can endure, not the biggest deal. Worst case scenario isnt so bad in this.
To the real problem for me: the music sections. While it is able to differentiate the youtube links through ending in user and artist, the code would not be able to work with the music artists official web page because they are all different in their names.
Like: hiliaryduffoffical.com or aliciakeys.com that sort of thing. Impossible to set a standard for the code to work it.
Do you think theres a way around that ?
The only solution I can think of if not is to manually code it onto each page with the html in posts instead. Which would noteably take a while.
In case I'm coming off ungrateful or anything, THANK YOU so much for the code. If you were here I would kiss you, no homo. It will literally save me days and weeks worth of hours over time that I would have spent coding into each page to get the same result.
Thank you, thank you. *starts jumping up and down like a kid*
|
|
|
Post by Wormopolis on Oct 25, 2011 21:33:33 GMT -8
first post of the thread or first post of each page of a thread?
if you add into the array "hillaryduffoficial.com" and an image it would convert it, but it indeed would have to be added manually for every entry. otherwise making a special tag is sort of redundant when they can just do all that with regular UBBC tags anyways.
|
|
|
Post by Dragon on Oct 26, 2011 10:59:45 GMT -8
First post of a thread
Itd still be the same image for each artist, so kinda annoying that it cant be worked in for them.
You dont think theres another way around it ?
|
|
|
Post by Wormopolis on Oct 26, 2011 17:22:54 GMT -8
with the multitude of links to themultitude of artists, how would a code be able to differentiate between a link to an artists page and a link to anything else?
|
|
|
Post by Dragon on Oct 26, 2011 18:59:11 GMT -8
I dunno, it would just be great if it could Its almost like we should do it backward. The links are all different, but the images are all the same for each.
|
|
|
Post by Wormopolis on Oct 26, 2011 20:44:42 GMT -8
you would still have to list ALL the URLs that you wanted it to work on.
|
|
|
Post by Wormopolis on Oct 26, 2011 22:04:10 GMT -8
recopy the code
|
|
|
Post by Dragon on Oct 27, 2011 19:31:43 GMT -8
I understand wormo, and thank you.
Going on from my last thought though, is it possible that it could do it backwards? Right now the code will put the links to images, could it make a posted image into a clickable image link instead?
|
|
|
Post by Wormopolis on Oct 27, 2011 19:36:43 GMT -8
well the problem with that idea is that you never know where the image will be coming from. lets say someone moved an image into a personal folder, the code wouldnt be able to match to it anymore. URLs to pages are harder to change then URLs to images.
did the first page thing work?
|
|
|
Post by Dragon on Oct 27, 2011 19:53:16 GMT -8
Yeah I tested it on the tv locations board, so far no problems. It loads the images like before and it definitely doesnt convert images aside from the first post. I dont know if it causes any errors yet though.
Im not sure I understand this moving the images business.... I use imageshack only, so when I put it in as far as I know of the image never ever changes at all, if the image link changed even a little the image wouldnt show, I put up with it like that for the past year with no issues. Imageshack as far as I know wouldnt have this movement to folders and other stuff issues. Wouldnt it stay a static direct link ?
Heres what I understand: The stuff we put inside the thread is what we want to remain static, unchanging because its easier to edit under the footers in one area than under hundreds if not thousands of threads. So what we might eventually change at all would need to be under headers and footers. Links most definitely stay static, sometimes a person could change it but an official website for an artist or wikipedia for example are unlikely to change.
as far as I understand an image link should stay static as long as you dont edit, remove, or otherwise touch it.
Thinking out loud here.
|
|
|
Post by Wormopolis on Oct 27, 2011 20:05:25 GMT -8
I guess Im thinking of the code being used by more then just you. like if someone else wanted an image to automatically link.
but now we are back to the question of "why not just use regular UBBC"?
making a link into an image was a great idea.. it converted those ugly looking URLs to all the different links on youtube or whatever into a simple little clickable picture - automatically. going the other way limits that image to only one URL. you wouldnt ever be able to post the youtube image without it linking to a specific youtube page.
if you are looking at this as the ability to post an image of ella fitzgerald, and have it automatically link to ella's fansite, you might as well just use the built in UBBC to make the image linked. it would actually be LESS work then having to add in another line into the array to match that image to the fansite (forever).
your first idea was golden.. the revision is more dingy tan.
|
|
|
Post by Dragon on Oct 27, 2011 20:43:36 GMT -8
I see. Sortof makes sense. Hmmm, so what we should do then is make a UBBC button for the image link ?
Because theres going to be a bunch of variations of this problem where theres a whole bunch of different links with the one image. As much as I wish it would be sewpt under the rug, it refuses to.
Putting the image link through the [html] in posts codes I can see, and having a button to push then paste in the link would definitely make the issue easier to fix. Is it possible to make a button for this case then ?
heres what we had before for the html code:
[html]<a href='http://www.cucirca.com/2007/05/12/watch-lost-online/'><img src='http://img824.imageshack.us/img824/9461/spbuttoncucirca.png' border='0'></a>
|
|