Post by Todge on Dec 7, 2010 11:44:20 GMT -8
This code gives you the option to have images as thread titles.
When creating a new thread, you should get an option to add an image URL beneath the subject field. If you do, the image should be displayed in the thread listings page, with the original title being displayed in the thread itself.
Global Footer.. No editing is required.
When creating a new thread, you should get an option to add an image URL beneath the subject field. If you do, the image should be displayed in the thread listings page, with the original title being displayed in the thread itself.
Global Footer.. No editing is required.
<script type="text/javascript">
<!--
/*
Thread Title Images
Global or Board Footer
by Todge
Copyright © 2010
Please keep this header intact
*/
// Add option in posting page to title thread with an image..
if(document.postForm && (!location.href.match(/&thread=/) || document.postForm.message.value.match(/\[url=title\]/)))
{
var subJ = document.postForm.subject.parentNode.parentNode;
var titleIMG = document.createElement('tr');
var td1 = document.createElement('td');
var td2 = document.createElement('td');
with(td1){
innerHTML = '<font size="2">Title Image:</font>';
className = 'windowbg2';}
with(td2){
innerHTML = '<input type="text" tabindex="1" maxlength="100" size="40" name="titleimg">';
innerHTML +='<font size="1"> If you\'d like to use an image as the title, add the full URL here.</font>';
className = 'windowbg2';}
with(titleIMG){appendChild(td1); appendChild(td2);}
subJ.parentNode.insertBefore(titleIMG,subJ.nextSibling);
if(document.postForm.message.value.match(/\[url=title\]/))
{
document.postForm.titleimg.value = document.postForm.message.value.split('[/url]')[0].split('title]')[1];
document.postForm.message.value = document.postForm.message.value.replace(/^\[url=title\]http:\/\/(\w+\.?\/?-?)+\[\/url\]/,'');
}
function titleImage()
{
if(document.postForm.titleimg.value.match(/^http:\/\/(\w+\.?\/?-?)+\.(png|jpg|jpeg|gif)$/))
{
var url = '[url=title]'+encodeURI(document.postForm.titleimg.value)+'[/url] ';
document.postForm.message.value = url+document.postForm.message.value;
}
return;
}
if(window.addEventListener)
{
document.postForm.addEventListener('submit', titleImage, false);
}
else if(window.attachEvent)
{
document.postForm.attachEvent('onsubmit', titleImage);
}
else
{
document.postForm.onsubmit = titleImage();
}}
// Add image to thread title and remove image from post..
if(pb_action == 'display')
{
var titleimg = document.getElementsByTagName('a');
for(t=0; t<titleimg.length; t++)
{
if(titleimg[t].href.match(/http:\/\/title/))
{
titleimg[t].style.display = 'none';
titleimg = titleimg[t].innerHTML;
break;
}}}
if(pb_action == 'boardindex')
{
var td = document.getElementsByTagName('td');
for(t=0; t<td.length; t++)
{
if(td[t].className.match(/windowbg/) && td[t].title && td[t].title.match(/^http:\/\/([^\W]+?)\.(png|jpg|jpeg|gif)/i))
{
var titleimg = td[t].title.split(' ')[0];
td[t].title = td[t].title.replace(titleimg,'');
var threadTitle = td[t].getElementsByTagName('b')[0].firstChild;
titleimg = '<img src="'+titleimg+'" title="'+threadTitle.innerHTML+'" alt="'+threadTitle.innerHTML+'" " border="0">';
threadTitle.innerHTML = titleimg;
}}}
// -->
</script>