Post by Wormopolis on Oct 31, 2008 22:50:27 GMT -8
This code will allow you to put an image behind the text in a post. keep in mind that certain font colors dont look good when placed on a background of similar color.
I added in switches to control the background.
image repeating:
nr = no repeat
rx = repeat horiz only
ry = repeat vertically only
image position:
cx = center horiz
cy = center vertically
(you can use both together to put image in center of post)
simply type
[PBG:]URL OF IMAGE[/PBG:] into your post to add a background.
switches come right after [PBG: and before ]. like:
[PBG:nr,cx,cy]
seperate switches with commas. use lowercase for switches.
here is the code for global footer or board footer:
UPDATES TO THIS CODE FOUND ON wormocodes.proboards.com
I added in switches to control the background.
image repeating:
nr = no repeat
rx = repeat horiz only
ry = repeat vertically only
image position:
cx = center horiz
cy = center vertically
(you can use both together to put image in center of post)
simply type
[PBG:]URL OF IMAGE[/PBG:] into your post to add a background.
switches come right after [PBG: and before ]. like:
[PBG:nr,cx,cy]
seperate switches with commas. use lowercase for switches.
here is the code for global footer or board footer:
<script type="text/javascript">
<!--
// Background image in posts. By Wormopolis.
// Version 1.2
var cellHeight=100; //dont change unless you find a reason to
// Dont edit below unless you know what you are doing
if (location.href.match(/board=/i) && location.href.match(/thread=/i)) {
if (location.href.match(/quote=/i)) {
msgarea=document.getElementsByTagName('textarea');
if (msgarea.length==1 && msgarea[0].name=='message') {
if (msgarea[0].value.match(/\[PBG:\](.+?)\[\/PBG:\]/)) {
msgarea[0].value=msgarea[0].value.replace(/\[PBG:\](.+?)\[\/PBG:\]/,'')
}
}
} else {
img=document.getElementsByTagName('img');
for (a=0;a<img.length; a++) {
if (img[a].src.match(/ip.gif/i)) {
stuffCell=img[a].parentNode.parentNode.parentNode.parentNode.parentNode;
msgCell=stuffCell.parentNode.parentNode.parentNode.firstChild.nextSibling.firstChild;
if (msgCell.innerHTML.match(/\[PBG:(.*?)\](.+?)\[\/PBG:\]/)) {
switches=RegExp.$1;
keep=RegExp.$2;
keep=(keep.replace(/ /g,''))
msgCell.innerHTML=msgCell.innerHTML.replace(/\[PBG:(.*?)\](.+?)\[\/PBG:\]/,'')
hasHR=stuffCell.parentNode.getElementsByTagName('hr');
if (hasHR.length>0) {
stuffCell.parentNode.height=cellHeight;
} else {
stuffCell.parentNode.height="10";
}
msgCell.style.backgroundImage='url("'+keep+'")';
if (switches!='') {
// nr = no repeat
// rx = repeat x only
// ry = repeat y only
// cx = center horizontally
// cy = center vertically
// maybe more in the future
if (switches.match('nr')) msgCell.style.backgroundRepeat='no-repeat';
if (switches.match('rx')) msgCell.style.backgroundRepeat='repeat-x';
if (switches.match('ry')) msgCell.style.backgroundRepeat='repeat-y';
if (switches.match('cx')) msgCell.style.backgroundPosition='top center';
if (switches.match('cy')) msgCell.style.backgroundPosition='center left';
if (switches.match('cx') && switches.match('cy')) msgCell.style.backgroundPosition='center center';
}
}
}
}
}
}
// -->
</script>
UPDATES TO THIS CODE FOUND ON wormocodes.proboards.com