Post by Peter on Jun 7, 2005 0:10:12 GMT -8
This script will prevent people from double posting by disabling everything on the reply page. You have the option to allow certain members to double post, just include them into the array.
<script type="text/javascript">
// Created by PopThosePringles
// Array of usernames that can double post, ie ["admin", "peter"];
var double_post_allowed = ["admin"];
// Message you want displayed
var double_post_message = "You are not allowed to double post.";
({
allowed: [],
user: pb_username,
message: "",
init: function(){
this.allowed = double_post_allowed;
this.message = double_post_message;
if(document.postForm && location.href.match("action=post")){
if(!this.check_permission()){
this.check_last_user();
}
}
},
check_last_user: function(){
var table = document.getElementsByTagName("table");
var re = new RegExp("user=" + this.user + "$");
for(var t = 0, l = table.length; t < l; t ++){
if(table.item(t).cellPadding == "4" && table.item(t).cellSpacing == "1" && table.item(t).innerHTML.match(/>Topic Summary<\//)){
var last = table.item(t).rows.item(table.item(t).rows.length - 2).cells.item(0);
if(last && last.getElementsByTagName("a").item(0).href.match(re)){
this.disable_post_form();
}
}
}
},
disable_post_form: function(){
document.postForm.message.value = this.message;
for(var e = 0, l = document.postForm.elements.length; e < l; e ++){
document.postForm.elements[e].disabled = true;
}
},
check_permission: function(){
if(this.user && this.allowed.length){
for(var a = 0, l = this.allowed.length; a < l; a ++){
if(this.allowed == this.user){
return true;
}
}
}
return false;
}
}).init();
</script>
Global footers
Edit - Code updated
<script type="text/javascript">
// Created by PopThosePringles
// Array of usernames that can double post, ie ["admin", "peter"];
var double_post_allowed = ["admin"];
// Message you want displayed
var double_post_message = "You are not allowed to double post.";
({
allowed: [],
user: pb_username,
message: "",
init: function(){
this.allowed = double_post_allowed;
this.message = double_post_message;
if(document.postForm && location.href.match("action=post")){
if(!this.check_permission()){
this.check_last_user();
}
}
},
check_last_user: function(){
var table = document.getElementsByTagName("table");
var re = new RegExp("user=" + this.user + "$");
for(var t = 0, l = table.length; t < l; t ++){
if(table.item(t).cellPadding == "4" && table.item(t).cellSpacing == "1" && table.item(t).innerHTML.match(/>Topic Summary<\//)){
var last = table.item(t).rows.item(table.item(t).rows.length - 2).cells.item(0);
if(last && last.getElementsByTagName("a").item(0).href.match(re)){
this.disable_post_form();
}
}
}
},
disable_post_form: function(){
document.postForm.message.value = this.message;
for(var e = 0, l = document.postForm.elements.length; e < l; e ++){
document.postForm.elements[e].disabled = true;
}
},
check_permission: function(){
if(this.user && this.allowed.length){
for(var a = 0, l = this.allowed.length; a < l; a ++){
if(this.allowed == this.user){
return true;
}
}
}
return false;
}
}).init();
</script>
Global footers
Edit - Code updated