Post by Peter on Nov 8, 2006 4:56:26 GMT -8
Requested by Spike Axis - Link
This code will allow members or staff to select an alignment (good, evil, neutral etc) from the modify profile page which will show in the mini profile in posts.
There is an option to allow only staff to set the alignment for members, or allow members to set it them self.
There are 3 options already added, but you may add more to the options array if needed.
<script type="text/javascript">
<!--
/****************************************
*
* Alignment In Mini Profile - Global Footer
*
* Created By Peter
*
* This script can not be redistributed without
* permission from the creator.
*
* This header must stay intact at all times.
*
* Copyright © 2005 - 2006 pixelDepth.net
* All rights reserved
*
*****************************************/
// Should staff be the only ones to set this?
var staff = true;
// Change the options here, you can add more if needed
var options = ["Good", "Neutral", "Evil"];
var alignment = {
selected: 0,
field: ((staff)? "customtitle" : "location"),
init: function(){
if(location.href.match(/=modifyprofile/i) && document.modifyForm){
if(document.modifyForm[this.field]){
this.get_option();
this.setup_options();
if(document.addEventListener){
document.modifyForm.addEventListener("submit", alignment.save, false);
} else if(document.attachEvent){
document.modifyForm.attachEvent("onsubmit", alignment.save);
} else {
document.modifyForm.onsubmit = alignment.save;
}
}
}
this.mini_profile();
if(!staff && pb_action == "viewprofile"){ this.profile();}
},
profile: function(){
var cell = document.getElementsByTagName("td");
for(c = 0; c < cell.length; c ++){
if(cell.item(c).width == "25%"){
if(cell.item(c).innerHTML.match("Location:") && cell.item(c+1) && cell.item(c+1).innerHTML.match(/\[A:(\d+)\]/)){
cell.item(c+1).innerHTML = cell.item(c+1).innerHTML.replace(RegExp.lastMatch, "");
break;
}
if(cell.item(c).innerHTML.match("Date")){break;}
}
}
},
get_option: function(){
var field = document.modifyForm[this.field];
if(field.parentNode.innerHTML.match(/\[A:(\d+)\]/)){
this.selected = RegExp.$1;
field.value = field.value.replace(/\[A:(\d+)\]/, "");
field.parentNode.innerHTML = field.parentNode.innerHTML.replace(/\[A:(\d+)\]/g, "");
}
},
setup_options: function(){
var select = document.createElement("select");
var the_options = ["Alignment"].concat(options);
for(o = 0; o < the_options.length; o ++){
var opt = document.createElement("option");
opt.appendChild(document.createTextNode(the_options[o]));
opt.value = o;
opt.selected = ((this.selected == o)? true : false);
select.appendChild(opt);
}
var row = document.modifyForm[this.field].parentNode.parentNode.parentNode;
var font = document.createElement("font");
var font_2 = document.createElement("font");
var new_row = row.parentNode.insertRow(row.rowIndex + 1);
var new_cell = new_row.insertCell(0);
font.appendChild(document.createTextNode("Alignment:"));
font.size = "-1";
font_2.appendChild(document.createTextNode("Select your alignment from the drop down. This will be viewed by other members."));
font_2.size = "-2";
select.onchange = function(){
alignment.selected = this.options[this.options.selectedIndex].value;
}
new_cell.appendChild(font);
new_row.insertCell(1).appendChild(select);
new_row.insertCell(2).appendChild(font_2);
},
save: function(){
var field = document.modifyForm[alignment.field];
field.maxLength += 8;
field.value += "[A:" + alignment.selected + "]";
},
mini_profile: function(){
var cell = document.getElementsByTagName("td");
for(c = 0; c < cell.length; c ++){
if(cell.item(c).width == "20%" && cell.item(c).className.match("windowbg") && cell.item(c).innerHTML.match(/Posts: \d+/) && cell.item(c).innerHTML.match(/\[A:(\d+)\]/)){
if(RegExp.$1 != 0){
var text = document.createTextNode("Alignment: " + ((options[RegExp.$1 - 1])? options[RegExp.$1 - 1] : "n/a"));
cell.item(c).appendChild(document.createElement("br"));
cell.item(c).appendChild(text);
}
cell.item(c).innerHTML = cell.item(c).innerHTML.replace(RegExp.lastMatch, "");
}
}
}
};
alignment.init();
//-->
</script>
To allow staff to only edit the alignment, set..
var staff = true;
Add the code to your global footer, this should work with other profile codes.
Any problems, please post in the code support board.
08/17/11 - Added edit listed here to fix issue with using non-staff option. - Trublu
This code will allow members or staff to select an alignment (good, evil, neutral etc) from the modify profile page which will show in the mini profile in posts.
There is an option to allow only staff to set the alignment for members, or allow members to set it them self.
There are 3 options already added, but you may add more to the options array if needed.
<script type="text/javascript">
<!--
/****************************************
*
* Alignment In Mini Profile - Global Footer
*
* Created By Peter
*
* This script can not be redistributed without
* permission from the creator.
*
* This header must stay intact at all times.
*
* Copyright © 2005 - 2006 pixelDepth.net
* All rights reserved
*
*****************************************/
// Should staff be the only ones to set this?
var staff = true;
// Change the options here, you can add more if needed
var options = ["Good", "Neutral", "Evil"];
var alignment = {
selected: 0,
field: ((staff)? "customtitle" : "location"),
init: function(){
if(location.href.match(/=modifyprofile/i) && document.modifyForm){
if(document.modifyForm[this.field]){
this.get_option();
this.setup_options();
if(document.addEventListener){
document.modifyForm.addEventListener("submit", alignment.save, false);
} else if(document.attachEvent){
document.modifyForm.attachEvent("onsubmit", alignment.save);
} else {
document.modifyForm.onsubmit = alignment.save;
}
}
}
this.mini_profile();
if(!staff && pb_action == "viewprofile"){ this.profile();}
},
profile: function(){
var cell = document.getElementsByTagName("td");
for(c = 0; c < cell.length; c ++){
if(cell.item(c).width == "25%"){
if(cell.item(c).innerHTML.match("Location:") && cell.item(c+1) && cell.item(c+1).innerHTML.match(/\[A:(\d+)\]/)){
cell.item(c+1).innerHTML = cell.item(c+1).innerHTML.replace(RegExp.lastMatch, "");
break;
}
if(cell.item(c).innerHTML.match("Date")){break;}
}
}
},
get_option: function(){
var field = document.modifyForm[this.field];
if(field.parentNode.innerHTML.match(/\[A:(\d+)\]/)){
this.selected = RegExp.$1;
field.value = field.value.replace(/\[A:(\d+)\]/, "");
field.parentNode.innerHTML = field.parentNode.innerHTML.replace(/\[A:(\d+)\]/g, "");
}
},
setup_options: function(){
var select = document.createElement("select");
var the_options = ["Alignment"].concat(options);
for(o = 0; o < the_options.length; o ++){
var opt = document.createElement("option");
opt.appendChild(document.createTextNode(the_options[o]));
opt.value = o;
opt.selected = ((this.selected == o)? true : false);
select.appendChild(opt);
}
var row = document.modifyForm[this.field].parentNode.parentNode.parentNode;
var font = document.createElement("font");
var font_2 = document.createElement("font");
var new_row = row.parentNode.insertRow(row.rowIndex + 1);
var new_cell = new_row.insertCell(0);
font.appendChild(document.createTextNode("Alignment:"));
font.size = "-1";
font_2.appendChild(document.createTextNode("Select your alignment from the drop down. This will be viewed by other members."));
font_2.size = "-2";
select.onchange = function(){
alignment.selected = this.options[this.options.selectedIndex].value;
}
new_cell.appendChild(font);
new_row.insertCell(1).appendChild(select);
new_row.insertCell(2).appendChild(font_2);
},
save: function(){
var field = document.modifyForm[alignment.field];
field.maxLength += 8;
field.value += "[A:" + alignment.selected + "]";
},
mini_profile: function(){
var cell = document.getElementsByTagName("td");
for(c = 0; c < cell.length; c ++){
if(cell.item(c).width == "20%" && cell.item(c).className.match("windowbg") && cell.item(c).innerHTML.match(/Posts: \d+/) && cell.item(c).innerHTML.match(/\[A:(\d+)\]/)){
if(RegExp.$1 != 0){
var text = document.createTextNode("Alignment: " + ((options[RegExp.$1 - 1])? options[RegExp.$1 - 1] : "n/a"));
cell.item(c).appendChild(document.createElement("br"));
cell.item(c).appendChild(text);
}
cell.item(c).innerHTML = cell.item(c).innerHTML.replace(RegExp.lastMatch, "");
}
}
}
};
alignment.init();
//-->
</script>
To allow staff to only edit the alignment, set..
var staff = true;
Add the code to your global footer, this should work with other profile codes.
Any problems, please post in the code support board.
08/17/11 - Added edit listed here to fix issue with using non-staff option. - Trublu