Post by Jordan on Mar 2, 2008 17:15:25 GMT -8
This cross browser script allows a user to highlight their post in a thread so it will stand out from the rest. Here are some previews so you can see how it works.
<script type="text/javascript"><!--
/*
Highlight Posts
Created By Triad
support.proboards.com
*/
var highlight_posts = {
cell_color: "4080B0",
staff: true,
init: function(){
if(document.postForm){
this.option();
if(document.title.split(/\s-\s/i)[1].match(/preview/i))
this.hideText();
} else if(location.href.match(/action=(display|(user)?recent)/i)){
this.color();
}
},
color: function(){
var tr = document.getElementsByTagName("tr");
for(x=4,y=tr.length; x<y; x++){
if(tr[x].cells[0].width == "20%" && tr[x].cells[1].innerHTML.match(/:highlighted:/gi)){
if(this.staff){
var version = (typeof pb_VersionNo == "undefined") ? 1 : 2;
if(!tr[x].cells[0].getElementsByTagName("a")[version] || !tr[x].cells[0].getElementsByTagName("a")[version].className)
continue;
}
tr[x].cells[1].innerHTML = tr[x].cells[1].innerHTML.replace(/:highlighted:/gi, "");
var td = tr[x].getElementsByTagName("td");
for(a=0; a<td.length; a++){
td.style.backgroundColor = "#" + this.cell_color;
}
}
}
},
hideText: function(){
var td = document.getElementsByTagName("td");
for(x=6,y=td.length; x<y; x++){
if(td[x].width == "80%" && td[x].innerHTML.match(/:highlighted:/gi)){
td[x].innerHTML = td[x].innerHTML.replace(/:highlighted:/gi, "");
break;
}
}
},
option: function(){
var tb = document.getElementsByTagName("table");
for(x=2,y=tb.length; x<y; x++){
if(tb[x].cellPadding == "4" && tb[x].rows[1] && tb[x].rows[1].cells[0].innerHTML.match(/subject:/i)){
if(this.staff){
if(!tb[x].rows[tb[x].rows.length-2].cells[0].innerHTML.match(/announcement:/i))
return;
}
var admin_row = tb[x].insertRow(tb[x].rows.length-1);
var admin_cell = admin_row.insertCell(0);
var check_box = document.createElement("input");
var font_1 = document.createElement("font");
var font_2 = document.createElement("font");
font_1.appendChild(document.createTextNode("Highlight Cell:"));
font_1.size = "2";
font_2.appendChild(document.createTextNode(" To highlight the cell color of this post, check this box."));
font_2.size = "1";
check_box.type = "checkbox";
check_box.id = "postHighlight";
admin_cell.appendChild(font_1);
admin_cell.className = "windowbg";
admin_cell = admin_row.insertCell(1);
admin_cell.appendChild(check_box);
admin_cell.appendChild(font_2);
admin_cell.className = "windowbg";
document.getElementById("postHighlight").checked = (document.postForm.message.value.match(/:highlighted:/gi)) ? true : false;
document.postForm.message.value = document.postForm.message.value.replace(/:highlighted:/gi, "");
function addText(){
if(document.getElementById("postHighlight")){
if(document.getElementById("postHighlight").checked && !document.postForm.message.value.match(/:highlighted:/gi)){
document.postForm.message.value += ":highlighted:";
} else if(!document.getElementById("postHighlight").checked && document.postForm.message.value.match(/:highlighted:/gi)){
document.postForm.message.value = document.postForm.message.value.replace(/:highlighted:/gi, "");
}
}
}
if(document.addEventListener){
document.postForm.addEventListener("submit", addText, false);
} else if(document.attachEvent){
document.postForm.attachEvent("onsubmit", addText);
} else {
document.postForm.onsubmit = addText;
}
break;
}
}
}
}.init();
//--></script>
The only editing that needs to be explained is the staff: true variable. If true, ONLY staff may use this feature.
You may notice the text :highlighted: being inserted into your post when you hit the "Post Message" button. This is because the script has to insert this into your message so it will know which posts to highlight. This means that if you remove the code, any posts that you had highlighted will have that at the end of the message since the script can no longer hide it. To fix this, just add :highlighted: to your censored words list.
Enjoy.
» Selecting the OptionPlace it in your Global Footers, but make sure it is ABOVE all mini-profile hacks.
» Highlighted Post
<script type="text/javascript"><!--
/*
Highlight Posts
Created By Triad
support.proboards.com
*/
var highlight_posts = {
cell_color: "4080B0",
staff: true,
init: function(){
if(document.postForm){
this.option();
if(document.title.split(/\s-\s/i)[1].match(/preview/i))
this.hideText();
} else if(location.href.match(/action=(display|(user)?recent)/i)){
this.color();
}
},
color: function(){
var tr = document.getElementsByTagName("tr");
for(x=4,y=tr.length; x<y; x++){
if(tr[x].cells[0].width == "20%" && tr[x].cells[1].innerHTML.match(/:highlighted:/gi)){
if(this.staff){
var version = (typeof pb_VersionNo == "undefined") ? 1 : 2;
if(!tr[x].cells[0].getElementsByTagName("a")[version] || !tr[x].cells[0].getElementsByTagName("a")[version].className)
continue;
}
tr[x].cells[1].innerHTML = tr[x].cells[1].innerHTML.replace(/:highlighted:/gi, "");
var td = tr[x].getElementsByTagName("td");
for(a=0; a<td.length; a++){
td.style.backgroundColor = "#" + this.cell_color;
}
}
}
},
hideText: function(){
var td = document.getElementsByTagName("td");
for(x=6,y=td.length; x<y; x++){
if(td[x].width == "80%" && td[x].innerHTML.match(/:highlighted:/gi)){
td[x].innerHTML = td[x].innerHTML.replace(/:highlighted:/gi, "");
break;
}
}
},
option: function(){
var tb = document.getElementsByTagName("table");
for(x=2,y=tb.length; x<y; x++){
if(tb[x].cellPadding == "4" && tb[x].rows[1] && tb[x].rows[1].cells[0].innerHTML.match(/subject:/i)){
if(this.staff){
if(!tb[x].rows[tb[x].rows.length-2].cells[0].innerHTML.match(/announcement:/i))
return;
}
var admin_row = tb[x].insertRow(tb[x].rows.length-1);
var admin_cell = admin_row.insertCell(0);
var check_box = document.createElement("input");
var font_1 = document.createElement("font");
var font_2 = document.createElement("font");
font_1.appendChild(document.createTextNode("Highlight Cell:"));
font_1.size = "2";
font_2.appendChild(document.createTextNode(" To highlight the cell color of this post, check this box."));
font_2.size = "1";
check_box.type = "checkbox";
check_box.id = "postHighlight";
admin_cell.appendChild(font_1);
admin_cell.className = "windowbg";
admin_cell = admin_row.insertCell(1);
admin_cell.appendChild(check_box);
admin_cell.appendChild(font_2);
admin_cell.className = "windowbg";
document.getElementById("postHighlight").checked = (document.postForm.message.value.match(/:highlighted:/gi)) ? true : false;
document.postForm.message.value = document.postForm.message.value.replace(/:highlighted:/gi, "");
function addText(){
if(document.getElementById("postHighlight")){
if(document.getElementById("postHighlight").checked && !document.postForm.message.value.match(/:highlighted:/gi)){
document.postForm.message.value += ":highlighted:";
} else if(!document.getElementById("postHighlight").checked && document.postForm.message.value.match(/:highlighted:/gi)){
document.postForm.message.value = document.postForm.message.value.replace(/:highlighted:/gi, "");
}
}
}
if(document.addEventListener){
document.postForm.addEventListener("submit", addText, false);
} else if(document.attachEvent){
document.postForm.attachEvent("onsubmit", addText);
} else {
document.postForm.onsubmit = addText;
}
break;
}
}
}
}.init();
//--></script>
The only editing that needs to be explained is the staff: true variable. If true, ONLY staff may use this feature.
You may notice the text :highlighted: being inserted into your post when you hit the "Post Message" button. This is because the script has to insert this into your message so it will know which posts to highlight. This means that if you remove the code, any posts that you had highlighted will have that at the end of the message since the script can no longer hide it. To fix this, just add :highlighted: to your censored words list.
Enjoy.