Post by Triad on Nov 16, 2008 16:14:02 GMT -5
Just like my other code that changes the member is online and member is offline messages, this code will allow each individual memer to edit their own messages by input fields on the modify profile page. Unfortunately, you cannot use HTML or UBBC as in the other code.
If you would only like the administrator to be able to edit each user's message, change the bold line in the code below to this.
Cross Browser: Tested in latest versions of FF, Safari, Opera, and IE.
Placement: Global Footers
Note for When Removing this Code: This code stores information in the "Personal Text" field of the users profile. If at some point you decide to remove this code or for whatever reason the code stops working then that information will remain visible in the personal text field until you or the user removes it. This information would look something like: [1:I'm here][0:I'm not here]
<script type="text/javascript"><!--
/*
* Custom Online/Offline Message For Individual Members
* Created By Triad
*/
var reg_0 = /(\[0:(.+?)\])/i;
var reg_1 = /(\[1:(.+?)\])/i;
if(location.href.match(/on=(displ|search2|viewpr|pmv|(user)?rece|cal\w+iew)/)){
var td = document.getElementsByTagName("td");
for(x=6; x<td.length; x++){
if(td[x].width == "20%" && td[x].innerHTML.match((reg_0|reg_1))){
var a = 0, br_split = td[x].innerHTML.split(/<br\s?\/?>/i);
while(a < br_split.length){
if(br_split.match(/(online|offline)/i))
break;
a++;
}
if(td[x].innerHTML.match(/is\soffline/i) && td[x].innerHTML.match(reg_0))
td[x].innerHTML = td[x].innerHTML.replace(br_split, RegExp.$2);
else if(td[x].innerHTML.match(/is\s<b>online/i) && td[x].innerHTML.match(reg_1))
td[x].innerHTML = td[x].innerHTML.replace(br_split, RegExp.$2);
td[x].innerHTML = td[x].innerHTML.replace(/\[\d:.+?\]/gi, "");
}
}
}
if(document.modifyForm){
for(var tb=document.getElementsByTagName("table"), a=4; a<tb.length; a++){
if(tb.width == "650" && tb.innerHTML.match(/location:/i)){
var _input_0 = document.createElement("input");
_input_0.type = "text";
_input_0.size = "35";
_input_0.id = "offlineMessage";
if(document.modifyForm.personaltext.value.match(reg_0)){
_input_0.value = RegExp.$2;
document.modifyForm.personaltext.value = document.modifyForm.personaltext.value.replace(RegExp.$1, "");
}
var _input_1 = document.createElement("input");
_input_1.type = "text";
_input_1.size = "35";
_input_1.id = "onlineMessage";
if(document.modifyForm.personaltext.value.match(reg_1)){
_input_1.value = RegExp.$2;
document.modifyForm.personaltext.value = document.modifyForm.personaltext.value.replace(RegExp.$1, "");
}
var _font_0 = document.createElement("font");
_font_0.size = "2";
_font_0.appendChild(document.createTextNode("Offline:"));
var _font_1 = document.createElement("font");
_font_1.size = "2";
_font_1.appendChild(document.createTextNode("Online:"));
var _font_2 = document.createElement("font");
_font_2.size= "1"
_font_2.appendChild(document.createTextNode("You may customize the default messages in your mini-profile that tell others if you are online or offline here."));
var main_row = tb.insertRow(tb.rows.length);
var main_cell = main_row.insertCell(0);
main_cell.colSpan = "3";
var _table = document.createElement("table");
_table.width = "100%";
_table.appendChild(document.createElement("tbody"));
var _row = document.createElement("tr");
var _cell = document.createElement("td");
_cell.width = "160";
_cell.appendChild(_font_1);
_row.appendChild(_cell);
_cell = document.createElement("td");
_cell.width = "245";
_cell.appendChild(_input_1);
_row.appendChild(_cell);
_cell = document.createElement("td");
_cell.width = "245";
_cell.rowSpan = "2";
_cell.appendChild(_font_2);
_row.appendChild(_cell);
_table.firstChild.appendChild(_row);
_row = document.createElement("tr");
_cell = document.createElement("td");
_cell.width = "160";
_cell.appendChild(_font_0);
_row.appendChild(_cell);
_cell = document.createElement("td");
_cell.width = "245";
_cell.appendChild(_input_0);
_row.appendChild(_cell);
_table.firstChild.appendChild(_row);
main_cell.appendChild(_table);
function init(){
var p = document.modifyForm.personaltext;
if(document.modifyForm.offlineMessage.value.length > 0){
p.maxLength = p.value.length + document.getElementById("offlineMessage").value.length + 4;
p.value += "[0:" + document.modifyForm.offlineMessage.value + "]";
}
if(document.modifyForm.onlineMessage.value.length > 0){
p.maxLength = p.value.length + document.getElementById("onlineMessage").value.length + 4;
p.value += "[1:" + document.modifyForm.onlineMessage.value + "]";
}
}
if(document.addEventListener)
document.modifyForm.addEventListener("submit", init, false);
else if(document.attachEvent)
document.modifyForm.attachEvent("onsubmit", init);
else
document.modifyForm.onsubmit = init;
break;
}
}
}
//--></script>
If you would only like the administrator to be able to edit each user's message, change the bold line in the code below to this.
if(document.modifyForm && pb_username == "admin"){Preview: Just look at my other codes preview.
Cross Browser: Tested in latest versions of FF, Safari, Opera, and IE.
Placement: Global Footers
Note for When Removing this Code: This code stores information in the "Personal Text" field of the users profile. If at some point you decide to remove this code or for whatever reason the code stops working then that information will remain visible in the personal text field until you or the user removes it. This information would look something like: [1:I'm here][0:I'm not here]
<script type="text/javascript"><!--
/*
* Custom Online/Offline Message For Individual Members
* Created By Triad
*/
var reg_0 = /(\[0:(.+?)\])/i;
var reg_1 = /(\[1:(.+?)\])/i;
if(location.href.match(/on=(displ|search2|viewpr|pmv|(user)?rece|cal\w+iew)/)){
var td = document.getElementsByTagName("td");
for(x=6; x<td.length; x++){
if(td[x].width == "20%" && td[x].innerHTML.match((reg_0|reg_1))){
var a = 0, br_split = td[x].innerHTML.split(/<br\s?\/?>/i);
while(a < br_split.length){
if(br_split.match(/(online|offline)/i))
break;
a++;
}
if(td[x].innerHTML.match(/is\soffline/i) && td[x].innerHTML.match(reg_0))
td[x].innerHTML = td[x].innerHTML.replace(br_split, RegExp.$2);
else if(td[x].innerHTML.match(/is\s<b>online/i) && td[x].innerHTML.match(reg_1))
td[x].innerHTML = td[x].innerHTML.replace(br_split, RegExp.$2);
td[x].innerHTML = td[x].innerHTML.replace(/\[\d:.+?\]/gi, "");
}
}
}
if(document.modifyForm){
for(var tb=document.getElementsByTagName("table"), a=4; a<tb.length; a++){
if(tb.width == "650" && tb.innerHTML.match(/location:/i)){
var _input_0 = document.createElement("input");
_input_0.type = "text";
_input_0.size = "35";
_input_0.id = "offlineMessage";
if(document.modifyForm.personaltext.value.match(reg_0)){
_input_0.value = RegExp.$2;
document.modifyForm.personaltext.value = document.modifyForm.personaltext.value.replace(RegExp.$1, "");
}
var _input_1 = document.createElement("input");
_input_1.type = "text";
_input_1.size = "35";
_input_1.id = "onlineMessage";
if(document.modifyForm.personaltext.value.match(reg_1)){
_input_1.value = RegExp.$2;
document.modifyForm.personaltext.value = document.modifyForm.personaltext.value.replace(RegExp.$1, "");
}
var _font_0 = document.createElement("font");
_font_0.size = "2";
_font_0.appendChild(document.createTextNode("Offline:"));
var _font_1 = document.createElement("font");
_font_1.size = "2";
_font_1.appendChild(document.createTextNode("Online:"));
var _font_2 = document.createElement("font");
_font_2.size= "1"
_font_2.appendChild(document.createTextNode("You may customize the default messages in your mini-profile that tell others if you are online or offline here."));
var main_row = tb.insertRow(tb.rows.length);
var main_cell = main_row.insertCell(0);
main_cell.colSpan = "3";
var _table = document.createElement("table");
_table.width = "100%";
_table.appendChild(document.createElement("tbody"));
var _row = document.createElement("tr");
var _cell = document.createElement("td");
_cell.width = "160";
_cell.appendChild(_font_1);
_row.appendChild(_cell);
_cell = document.createElement("td");
_cell.width = "245";
_cell.appendChild(_input_1);
_row.appendChild(_cell);
_cell = document.createElement("td");
_cell.width = "245";
_cell.rowSpan = "2";
_cell.appendChild(_font_2);
_row.appendChild(_cell);
_table.firstChild.appendChild(_row);
_row = document.createElement("tr");
_cell = document.createElement("td");
_cell.width = "160";
_cell.appendChild(_font_0);
_row.appendChild(_cell);
_cell = document.createElement("td");
_cell.width = "245";
_cell.appendChild(_input_0);
_row.appendChild(_cell);
_table.firstChild.appendChild(_row);
main_cell.appendChild(_table);
function init(){
var p = document.modifyForm.personaltext;
if(document.modifyForm.offlineMessage.value.length > 0){
p.maxLength = p.value.length + document.getElementById("offlineMessage").value.length + 4;
p.value += "[0:" + document.modifyForm.offlineMessage.value + "]";
}
if(document.modifyForm.onlineMessage.value.length > 0){
p.maxLength = p.value.length + document.getElementById("onlineMessage").value.length + 4;
p.value += "[1:" + document.modifyForm.onlineMessage.value + "]";
}
}
if(document.addEventListener)
document.modifyForm.addEventListener("submit", init, false);
else if(document.attachEvent)
document.modifyForm.attachEvent("onsubmit", init);
else
document.modifyForm.onsubmit = init;
break;
}
}
}
//--></script>