Post by Ross on Dec 20, 2005 15:43:47 GMT -8
This code enables you to mark certain sticky threads as 'Must Read' by putting certain text in their title. These threads must then be read before members are allowed to post on that board. Goes in the Global or Board Footer.
<script type="text/javascript">
<!--
/* 'Must Read' topics before being able to post - by ross */
var readTxt = /\[Must Read\]/i; // Text that must be in the threads title for it to be a 'Must Read' thread. Remember to escape special characters by putting a '\' before them.
var errorTxt = 'Please ensure you have read all sticky threads marked as "Must Read" before posting.'; // Error message when trying to post
var allowPosts = true; // Allow members to reply to threads but not start them? true or false
// No editing below this line please
var n = 0;
var images = /\/(.+?)?(sticky|stickylock)(.+?)?\.(gif|png|jpe?g)$/i;
var a = document.getElementsByTagName('a');
if(location.href.match(/board=\w+(&page=\d+)?(&moderationmode=\d+)?$/)) {
for(i=0; i<a.length; i++) {
if(a.item(i).innerHTML.match(readTxt) && a.item(i).href.match(/^http:\/\/\w+\.proboards\.com\/index.cgi\?board=\w+&action=display&thread=\d+$/)) {
var img = a.item(i).parentNode.parentNode.parentNode.parentNode.getElementsByTagName('img');
if(img.item(0).src.match(images) && img.length == 3) {
n++;
}
}
}
if(n == 0)
document.cookie = 'nread=no';
else
document.cookie = 'nread='+n;
}
else if(!allowPosts || location.href.match(/ion=(post|createpoll)$/) && document.postForm && document.cookie.match(/nread=(\d+)(.+?)?$/)) {
document.postForm.message.value = errorTxt +' There are currently '+ RegExp.$1 +' unread threads.';
document.postForm.message.disabled = true;
disable(document.postForm);
}
//-->
</script>
Edit, 22nd Dec: Bug fix in Firefox
<script type="text/javascript">
<!--
/* 'Must Read' topics before being able to post - by ross */
var readTxt = /\[Must Read\]/i; // Text that must be in the threads title for it to be a 'Must Read' thread. Remember to escape special characters by putting a '\' before them.
var errorTxt = 'Please ensure you have read all sticky threads marked as "Must Read" before posting.'; // Error message when trying to post
var allowPosts = true; // Allow members to reply to threads but not start them? true or false
// No editing below this line please
var n = 0;
var images = /\/(.+?)?(sticky|stickylock)(.+?)?\.(gif|png|jpe?g)$/i;
var a = document.getElementsByTagName('a');
if(location.href.match(/board=\w+(&page=\d+)?(&moderationmode=\d+)?$/)) {
for(i=0; i<a.length; i++) {
if(a.item(i).innerHTML.match(readTxt) && a.item(i).href.match(/^http:\/\/\w+\.proboards\.com\/index.cgi\?board=\w+&action=display&thread=\d+$/)) {
var img = a.item(i).parentNode.parentNode.parentNode.parentNode.getElementsByTagName('img');
if(img.item(0).src.match(images) && img.length == 3) {
n++;
}
}
}
if(n == 0)
document.cookie = 'nread=no';
else
document.cookie = 'nread='+n;
}
else if(!allowPosts || location.href.match(/ion=(post|createpoll)$/) && document.postForm && document.cookie.match(/nread=(\d+)(.+?)?$/)) {
document.postForm.message.value = errorTxt +' There are currently '+ RegExp.$1 +' unread threads.';
document.postForm.message.disabled = true;
disable(document.postForm);
}
//-->
</script>
Edit, 22nd Dec: Bug fix in Firefox