Post by Peter on Jul 15, 2005 5:09:28 GMT -8
I would appreciate it if you could host the 4 images yourself please
This code will allow you to select from a drop down of houses to put the user in.
<script type="text/javascript">
<!--
// Created by PopThosePringles
// Url to the folder where the images are stored
var imgHPBase = "http://www.pixeldepth.elixant.com/ProBoards/Harry_Potter/";
// Houses and images
var theHouses = [
["Slytherin", "slytherin.gif"],
["Hufflepuff", "hufflepuff.gif"],
["Gryffindor", "gryffindor.gif"],
["Ravenclaw", "ravenclaw.gif"]
];
// House text
var iHouse = "House";
// Who can pick which user goes into a house? Put the username in...ie..["admin", "Peter"];
var iHAllowed = ["admin"];
var curhou = {
house: 0,
rownum: 1
};
var iHDesTxt = "Select a " + iHouse.toLowerCase() + " you wish this member to be in.";
var iHDes;
var iHFont = document.createElement("font");
var mHTxt = document.createTextNode(iHouse + ":");
var iTable = document.getElementsByTagName("table");
var iCell = document.getElementsByTagName("td");
iHFont.size = "-2";
iHDes = iHFont.cloneNode(true).appendChild(document.createTextNode(iHDesTxt));
iHFont.size = "-1";
iHFont.appendChild(mHTxt);
function sortHouse(){
switch(arguments[0]){
case 1 :
document.modifyForm.personaltext.value += " [H:" + arguments[1] + "]";
break;
case 0 :
if(document.modifyForm.personaltext.value.match(/ \[H:(\d+)\]/)){
document.getElementById("hphouse").selectedIndex = RegExp.$1;
document.modifyForm.personaltext.value = document.modifyForm.personaltext.value.replace(/ \[H:\d+\]/, "");
}
break;
}
}
function setHPersonalTxt(){
var perTxt = document.modifyForm.personaltext;
if(perTxt.value.length >= 94 && !/\[H:\d+\]/.exec(perTxt.value)){
perTxt.value = perTxt.value.substr(0, 94);
}
}
function createSelect(){
var nSel = document.createElement("select");
nSel.id = "hphouse";
nSel.options[0] = new Option("Select House", 0);
for(h = 0; h < theHouses.length; h ++){
nSel.options[nSel.options.length] = new Option(theHouses[h][0], (h + 1));
}
for(t = 0; t < iTable.length; t ++){
if(iTable.item(t).width == "650" && iTable.item(t).innerHTML.match(/Disable Account:/)){
var nRow = iTable.item(t).insertRow(iTable.item(t).rows.length);
for(a = 0; a < iHAllowed.length; a ++){
if(pb_username.match(new RegExp(iHAllowed))){
nRow.style.display = "";
break;
} else {
nRow.style.display = "none";
}
}
var nCell = nRow.insertCell(0);
nCell.appendChild(iHFont);
nCell = nRow.insertCell(1);
nCell.appendChild(nSel);
nCell = nRow.insertCell(2).appendChild(iHDes);
}
}
}
function doHMiniProfile(){
var mHFx = document.createElement("center");
var hpImg = document.createElement("img");
for(c = 0; c < iCell.length; c ++){
if(iCell.item(c).width == "20%" && iCell.item(c).className.match(/windowbg/) && iCell.item(c).innerHTML.match(/member is/)){
if(iCell.item(c).innerHTML.match(/(\s|>)\[H:(\d+)\]/)){
if(RegExp.$2 != 0){
curhou.house = parseInt(RegExp.$2);
}
iCell.item(c).innerHTML = iCell.item(c).innerHTML.replace(/(\s|>)\[H:\d+\]/, "");
}
if(curhou.house != 0){
if(iCell.item(c).innerHTML.match(/Posts: (\d+,\d+|\d+)/)){
hpImg.src = imgHPBase + theHouses[(curhou.house - 1)][1];
hpImg.title = "This user is in the " + theHouses[(curhou.house - 1)][0] + " house";
mHFx.appendChild(document.createElement("br"));
mHFx.appendChild(hpImg);
if(iCell.item(c).lastChild.nodeName.toLowerCase() != "br"){
iCell.item(c).appendChild(document.createElement("br"));
}
iCell.item(c).appendChild(mHFx);
}
}
}
}
}
function doHMemberBio(){
var bHFont = document.createElement("font");
var hpImg = document.createElement("img");
var re = />Member's Bio( -)?/;
bHFont.size = "2";
for(t = 0; t < iTable.length; t ++){
if(iTable.item(t).cellPadding == "4" && iTable.item(t).rows.item(0).innerHTML.match(re)){
var iRow = iTable.item(t).getElementsByTagName("tr");
for(r = 0; r < iRow.length; r ++){
if(iRow.item(r).innerHTML.match(/>Posts:</)){
curhou.rownum = (iRow.item(r).rowIndex + 1);
}
}
if(curhou.house != 0){
hpImg.src = imgHPBase + theHouses[(curhou.house - 1)][1];
hpImg.title = "This user is in the " + theHouses[(curhou.house - 1)][0] + " house";
var nRow = iTable.item(t).insertRow(curhou.rownum);
var nCell = nRow.insertCell(0);
var cBFont = bHFont.cloneNode(true);
bHFont.appendChild(document.createTextNode(iHouse + ":"));
nCell.appendChild(bHFont);
nCell = nRow.insertCell(1);
nCell.appendChild(hpImg);
}
}
}
}
if(location.href.match(/=modifyprofile&user=/) && document.modifyForm){
createSelect();
document.modifyForm.onsubmit = function(){
if(Boolean(typeof usingMoneyCode != "undefined") && usingMoneyCode){
setPersonalTxt(82);
document.getElementById("money").value.sortMoney(1);
}
setHPersonalTxt();
sortHouse(1, document.getElementById("hphouse").selectedIndex);
}
sortHouse(0);
}
if(!location.href.match(/\/index.cgi$/)){
doHMiniProfile();
}
if(location.href.match(/=viewprofile/)){
doHMemberBio();
}
//-->
</script>
Main footer.
Goto modify a members profile, and you will be able to select which house to put the member in.
<script type="text/javascript">
<!--
/*
Harry Potter - Put members into houses (image version)
Created by Peter
This code cannot be reposted at anywhere other than SSDesigns or ProBoards, without permission.
This header must stay intact at all times.
*/
// Url to the folder where the images are stored
var imgHPBase = "http://www.ssdsitetest.elixant.com/pb/hp/";
// Houses and images
var theHouses = [
["Slytherin", "slytherin.gif"],
["Hufflepuff", "hufflepuff.gif"],
["Gryffindor", "gryffindor.gif"],
["Ravenclaw", "ravenclaw.gif"]
];
// House text
var iHouse = "House";
var curhou = {
house: 0,
rownum: 1
};
var iCell = document.getElementsByTagName("td");
function doHMiniProfile(){
for(c = 0; c < iCell.length; c ++){
var mHFx = document.createElement("center");
var hpImg = document.createElement("img");
if(iCell.item(c).width == "20%" && iCell.item(c).className.match(/^windowbg/) && iCell.item(c).innerHTML.match(/member is/)){
if(iCell.item(c).innerHTML.match(/(\s|>)\[H:(\d+)\]/)){
if(RegExp.$2 != 0){
curhou.house = parseInt(RegExp.$2);
} else {
curhou.house = 0;
}
iCell.item(c).innerHTML = iCell.item(c).innerHTML.replace(/(\s|>)\[H:\d+\]/, "");
} else {
curhou.house = 0;
}
if(iCell.item(c).innerHTML.match(/Posts: (\d+,\d+)|(\d+)/)){
if(curhou.house != 0){
hpImg.src = imgHPBase + theHouses[(curhou.house - 1)][1];
hpImg.title = "This user is in the " + theHouses[(curhou.house - 1)][0] + " house";
mHFx.appendChild(document.createElement("br"));
mHFx.appendChild(hpImg);
if(iCell.item(c).lastChild.nodeName.toLowerCase() != "br"){
iCell.item(c).appendChild(document.createElement("br"));
}
iCell.item(c).appendChild(mHFx);
}
}
}
}
}
if(location.href.match(/(=display|\/index.cgi$)/)){
doHMiniProfile();
}
//-->
</script>
Add that to global footers
Updates:
7th Jan 2008: Mini Profile ClassName Check Updated
25th March 2009: Updated to work off pb_username and not cookie
This code will allow you to select from a drop down of houses to put the user in.
<script type="text/javascript">
<!--
// Created by PopThosePringles
// Url to the folder where the images are stored
var imgHPBase = "http://www.pixeldepth.elixant.com/ProBoards/Harry_Potter/";
// Houses and images
var theHouses = [
["Slytherin", "slytherin.gif"],
["Hufflepuff", "hufflepuff.gif"],
["Gryffindor", "gryffindor.gif"],
["Ravenclaw", "ravenclaw.gif"]
];
// House text
var iHouse = "House";
// Who can pick which user goes into a house? Put the username in...ie..["admin", "Peter"];
var iHAllowed = ["admin"];
var curhou = {
house: 0,
rownum: 1
};
var iHDesTxt = "Select a " + iHouse.toLowerCase() + " you wish this member to be in.";
var iHDes;
var iHFont = document.createElement("font");
var mHTxt = document.createTextNode(iHouse + ":");
var iTable = document.getElementsByTagName("table");
var iCell = document.getElementsByTagName("td");
iHFont.size = "-2";
iHDes = iHFont.cloneNode(true).appendChild(document.createTextNode(iHDesTxt));
iHFont.size = "-1";
iHFont.appendChild(mHTxt);
function sortHouse(){
switch(arguments[0]){
case 1 :
document.modifyForm.personaltext.value += " [H:" + arguments[1] + "]";
break;
case 0 :
if(document.modifyForm.personaltext.value.match(/ \[H:(\d+)\]/)){
document.getElementById("hphouse").selectedIndex = RegExp.$1;
document.modifyForm.personaltext.value = document.modifyForm.personaltext.value.replace(/ \[H:\d+\]/, "");
}
break;
}
}
function setHPersonalTxt(){
var perTxt = document.modifyForm.personaltext;
if(perTxt.value.length >= 94 && !/\[H:\d+\]/.exec(perTxt.value)){
perTxt.value = perTxt.value.substr(0, 94);
}
}
function createSelect(){
var nSel = document.createElement("select");
nSel.id = "hphouse";
nSel.options[0] = new Option("Select House", 0);
for(h = 0; h < theHouses.length; h ++){
nSel.options[nSel.options.length] = new Option(theHouses[h][0], (h + 1));
}
for(t = 0; t < iTable.length; t ++){
if(iTable.item(t).width == "650" && iTable.item(t).innerHTML.match(/Disable Account:/)){
var nRow = iTable.item(t).insertRow(iTable.item(t).rows.length);
for(a = 0; a < iHAllowed.length; a ++){
if(pb_username.match(new RegExp(iHAllowed))){
nRow.style.display = "";
break;
} else {
nRow.style.display = "none";
}
}
var nCell = nRow.insertCell(0);
nCell.appendChild(iHFont);
nCell = nRow.insertCell(1);
nCell.appendChild(nSel);
nCell = nRow.insertCell(2).appendChild(iHDes);
}
}
}
function doHMiniProfile(){
var mHFx = document.createElement("center");
var hpImg = document.createElement("img");
for(c = 0; c < iCell.length; c ++){
if(iCell.item(c).width == "20%" && iCell.item(c).className.match(/windowbg/) && iCell.item(c).innerHTML.match(/member is/)){
if(iCell.item(c).innerHTML.match(/(\s|>)\[H:(\d+)\]/)){
if(RegExp.$2 != 0){
curhou.house = parseInt(RegExp.$2);
}
iCell.item(c).innerHTML = iCell.item(c).innerHTML.replace(/(\s|>)\[H:\d+\]/, "");
}
if(curhou.house != 0){
if(iCell.item(c).innerHTML.match(/Posts: (\d+,\d+|\d+)/)){
hpImg.src = imgHPBase + theHouses[(curhou.house - 1)][1];
hpImg.title = "This user is in the " + theHouses[(curhou.house - 1)][0] + " house";
mHFx.appendChild(document.createElement("br"));
mHFx.appendChild(hpImg);
if(iCell.item(c).lastChild.nodeName.toLowerCase() != "br"){
iCell.item(c).appendChild(document.createElement("br"));
}
iCell.item(c).appendChild(mHFx);
}
}
}
}
}
function doHMemberBio(){
var bHFont = document.createElement("font");
var hpImg = document.createElement("img");
var re = />Member's Bio( -)?/;
bHFont.size = "2";
for(t = 0; t < iTable.length; t ++){
if(iTable.item(t).cellPadding == "4" && iTable.item(t).rows.item(0).innerHTML.match(re)){
var iRow = iTable.item(t).getElementsByTagName("tr");
for(r = 0; r < iRow.length; r ++){
if(iRow.item(r).innerHTML.match(/>Posts:</)){
curhou.rownum = (iRow.item(r).rowIndex + 1);
}
}
if(curhou.house != 0){
hpImg.src = imgHPBase + theHouses[(curhou.house - 1)][1];
hpImg.title = "This user is in the " + theHouses[(curhou.house - 1)][0] + " house";
var nRow = iTable.item(t).insertRow(curhou.rownum);
var nCell = nRow.insertCell(0);
var cBFont = bHFont.cloneNode(true);
bHFont.appendChild(document.createTextNode(iHouse + ":"));
nCell.appendChild(bHFont);
nCell = nRow.insertCell(1);
nCell.appendChild(hpImg);
}
}
}
}
if(location.href.match(/=modifyprofile&user=/) && document.modifyForm){
createSelect();
document.modifyForm.onsubmit = function(){
if(Boolean(typeof usingMoneyCode != "undefined") && usingMoneyCode){
setPersonalTxt(82);
document.getElementById("money").value.sortMoney(1);
}
setHPersonalTxt();
sortHouse(1, document.getElementById("hphouse").selectedIndex);
}
sortHouse(0);
}
if(!location.href.match(/\/index.cgi$/)){
doHMiniProfile();
}
if(location.href.match(/=viewprofile/)){
doHMemberBio();
}
//-->
</script>
Main footer.
Goto modify a members profile, and you will be able to select which house to put the member in.
<script type="text/javascript">
<!--
/*
Harry Potter - Put members into houses (image version)
Created by Peter
This code cannot be reposted at anywhere other than SSDesigns or ProBoards, without permission.
This header must stay intact at all times.
*/
// Url to the folder where the images are stored
var imgHPBase = "http://www.ssdsitetest.elixant.com/pb/hp/";
// Houses and images
var theHouses = [
["Slytherin", "slytherin.gif"],
["Hufflepuff", "hufflepuff.gif"],
["Gryffindor", "gryffindor.gif"],
["Ravenclaw", "ravenclaw.gif"]
];
// House text
var iHouse = "House";
var curhou = {
house: 0,
rownum: 1
};
var iCell = document.getElementsByTagName("td");
function doHMiniProfile(){
for(c = 0; c < iCell.length; c ++){
var mHFx = document.createElement("center");
var hpImg = document.createElement("img");
if(iCell.item(c).width == "20%" && iCell.item(c).className.match(/^windowbg/) && iCell.item(c).innerHTML.match(/member is/)){
if(iCell.item(c).innerHTML.match(/(\s|>)\[H:(\d+)\]/)){
if(RegExp.$2 != 0){
curhou.house = parseInt(RegExp.$2);
} else {
curhou.house = 0;
}
iCell.item(c).innerHTML = iCell.item(c).innerHTML.replace(/(\s|>)\[H:\d+\]/, "");
} else {
curhou.house = 0;
}
if(iCell.item(c).innerHTML.match(/Posts: (\d+,\d+)|(\d+)/)){
if(curhou.house != 0){
hpImg.src = imgHPBase + theHouses[(curhou.house - 1)][1];
hpImg.title = "This user is in the " + theHouses[(curhou.house - 1)][0] + " house";
mHFx.appendChild(document.createElement("br"));
mHFx.appendChild(hpImg);
if(iCell.item(c).lastChild.nodeName.toLowerCase() != "br"){
iCell.item(c).appendChild(document.createElement("br"));
}
iCell.item(c).appendChild(mHFx);
}
}
}
}
}
if(location.href.match(/(=display|\/index.cgi$)/)){
doHMiniProfile();
}
//-->
</script>
Add that to global footers
Updates:
7th Jan 2008: Mini Profile ClassName Check Updated
25th March 2009: Updated to work off pb_username and not cookie