Post by Ross on Jan 7, 2006 16:06:31 GMT -8
What it does is allows you to use [hide]Message[/hide] tags in your posts that will hide that text from any member/guest until they reply to that thread.
However, there are some downsides. The main one being that the information being displayed isn't permanent. That is, when the user clears their cookies or their cookies get full, the message will become hidden again. Other than that, I believe I have got rid of the remaining bugs, at the expense of needing two sections, one for the Header and one for the Footer.
So, here's the actual code. You can edit any of the blue to change the style of the box around the hidden message. The red is the text that will appear in place of the message when it is hidden. If you want to use a ' apostrophe in this message, put a \ backslash before it. The green are the usernames of special users allowed to view all hidden messages, each separated with a '|' line. Put it in the Global Header/Footer Or Board Header/Footers to only affect certain boards (recommended)
Header
<style type="text/css">
.unhid
{
border-width: 1px;
border-style: solid;
border-color: #000000;
width: 90%;
}
.hid
{
border-width: 1px;
border-style: solid;
border-color: #000000;
width: 90%;
text-align: center;
font-weight: bold;
}
#threadListing
{
display: none;
}
</style>
<script type="text/javascript">
<!--
/*
hidden message in posts - v1 - Header
*/
if(location.href.match(/(&thread=|ion=(search|(user)?recent))/) && !location.href.match(/ion=((modify)?post|searchmembers)/))
document.write('<div id="threadListing">');
//-->
</script>
Footer
<script type="text/javascript">
<!--
/*
hidden message in posts - v1 - Footer
created by ross - support.proboards.com
please do not redistribute without permission
Note: if remvoing the code, Remember to remove BOTH sections
*/
// Users other than the main admin who are allowed to view hidden messages
var isAllowed = /^(user1|user2|user3)$/;
// Error/Hidden message
var mes = 'Please Reply to View this Message';
if(!location.href.match(/ion=(headersfooters|searchmembers)/)) {
function setCookie(y)
{
var d = new Date();
d.setYear('2020');
var t = location.href.match(/&thread=(.+?)($|&)/)? RegExp.$1 : getCookie();
if(t)
document.cookie = 'h'+ t +'='+ y +';Expires='+ d+';';
}
function checkCookie()
{
var t = location.href.match(/&thread=(.+?)($|&)/)? RegExp.$1 : 'NA';
if(document.cookie.match(new RegExp(t+'=r')))
return true;
}
function getCookie()
{
var t = (document.cookie.match(/h(.+?)=p/))? RegExp.$1 : false;
return t;
}
var re = /\[hide\](.+?)\[\/hide\]/gi
var td = document.getElementsByTagName('td');
if(location.href.match(/(&thread=|ion=(search|(user)?recent))/) && !location.href.match(/ion=((modify)?post|searchmembers)/)) {
if(!checkCookie() && pb_username != 'admin' && !pb_username.match(isAllowed)) {
for(i=0; i<td.length; i++) {
if(td.item(i).width == '20%' && td.item(i).innerHTML.match(new RegExp('user='+pb_username + '("|\s|>)', 'i'))) {
setCookie('r');
}
}
}
for(i=0; i<td.length; i++) {
if(((td.item(i).colSpan == '3' && td.item(i).firstChild.width == '100%') || (td.item(i).width == '100%' && td.item(i).className == 'windowbg2')) && td.item(i).innerHTML.match(re)) {
if(checkCookie() || pb_username == 'admin' || pb_username.match(isAllowed))
td.item(i).innerHTML = td.item(i).innerHTML.replace(re, '<div class=unhid>$1</div>');
else
td.item(i).innerHTML = td.item(i).innerHTML.replace(re, '<div class=hid>'+ mes +'</div>');
}
}
document.write('</div>');
document.getElementById('threadListing').style.display = 'block';
}
var font = document.getElementsByTagName('font');
for(f=0; f<font.length; f++) {
if(font.item(f).innerHTML.match(re) && !font.item(f).innerHTML.match(/<(textarea|select)/i))
font.item(f).innerHTML = font.item(f).innerHTML.replace(re, '<div class=hid>'+ mes +'</div>');
}
if(document.postForm) {
if(document.postForm.message.value.match(/\[quot.+?\](.|\n|\r)*(\[hide\](.|\n|\r)*\[\/hide\])(.|\n|\r)*\[\/quote\]/)) {
document.postForm.message.value = document.postForm.message.value.replace(RegExp.$2,'');
}
document.postForm.onsubmit = function() {
if(document.postForm.nextaction.value == 'post')
setCookie('r');
else
setCookie('p');
}
}
else if(document.getElementsByName('message').item(0)) {
if(document.forms.item(0).message) {
document.forms.item(0).onsubmit = function() {
setCookie('r');
}
}
else if(document.forms.item(1)) {
document.forms.item(1).onsubmit = function() {
setCookie('r');
}
}
}
}
//-->
</script>
Edit: 'Quoting' Bug Fix. 15th Jan '06
Edit: Another bug with quoting fixed. 22nd May '06
Edit: New Feature where Cookies are refreshed when the code sees a post by you.
However, there are some downsides. The main one being that the information being displayed isn't permanent. That is, when the user clears their cookies or their cookies get full, the message will become hidden again. Other than that, I believe I have got rid of the remaining bugs, at the expense of needing two sections, one for the Header and one for the Footer.
So, here's the actual code. You can edit any of the blue to change the style of the box around the hidden message. The red is the text that will appear in place of the message when it is hidden. If you want to use a ' apostrophe in this message, put a \ backslash before it. The green are the usernames of special users allowed to view all hidden messages, each separated with a '|' line. Put it in the Global Header/Footer Or Board Header/Footers to only affect certain boards (recommended)
Header
<style type="text/css">
.unhid
{
border-width: 1px;
border-style: solid;
border-color: #000000;
width: 90%;
}
.hid
{
border-width: 1px;
border-style: solid;
border-color: #000000;
width: 90%;
text-align: center;
font-weight: bold;
}
#threadListing
{
display: none;
}
</style>
<script type="text/javascript">
<!--
/*
hidden message in posts - v1 - Header
*/
if(location.href.match(/(&thread=|ion=(search|(user)?recent))/) && !location.href.match(/ion=((modify)?post|searchmembers)/))
document.write('<div id="threadListing">');
//-->
</script>
Footer
<script type="text/javascript">
<!--
/*
hidden message in posts - v1 - Footer
created by ross - support.proboards.com
please do not redistribute without permission
Note: if remvoing the code, Remember to remove BOTH sections
*/
// Users other than the main admin who are allowed to view hidden messages
var isAllowed = /^(user1|user2|user3)$/;
// Error/Hidden message
var mes = 'Please Reply to View this Message';
if(!location.href.match(/ion=(headersfooters|searchmembers)/)) {
function setCookie(y)
{
var d = new Date();
d.setYear('2020');
var t = location.href.match(/&thread=(.+?)($|&)/)? RegExp.$1 : getCookie();
if(t)
document.cookie = 'h'+ t +'='+ y +';Expires='+ d+';';
}
function checkCookie()
{
var t = location.href.match(/&thread=(.+?)($|&)/)? RegExp.$1 : 'NA';
if(document.cookie.match(new RegExp(t+'=r')))
return true;
}
function getCookie()
{
var t = (document.cookie.match(/h(.+?)=p/))? RegExp.$1 : false;
return t;
}
var re = /\[hide\](.+?)\[\/hide\]/gi
var td = document.getElementsByTagName('td');
if(location.href.match(/(&thread=|ion=(search|(user)?recent))/) && !location.href.match(/ion=((modify)?post|searchmembers)/)) {
if(!checkCookie() && pb_username != 'admin' && !pb_username.match(isAllowed)) {
for(i=0; i<td.length; i++) {
if(td.item(i).width == '20%' && td.item(i).innerHTML.match(new RegExp('user='+pb_username + '("|\s|>)', 'i'))) {
setCookie('r');
}
}
}
for(i=0; i<td.length; i++) {
if(((td.item(i).colSpan == '3' && td.item(i).firstChild.width == '100%') || (td.item(i).width == '100%' && td.item(i).className == 'windowbg2')) && td.item(i).innerHTML.match(re)) {
if(checkCookie() || pb_username == 'admin' || pb_username.match(isAllowed))
td.item(i).innerHTML = td.item(i).innerHTML.replace(re, '<div class=unhid>$1</div>');
else
td.item(i).innerHTML = td.item(i).innerHTML.replace(re, '<div class=hid>'+ mes +'</div>');
}
}
document.write('</div>');
document.getElementById('threadListing').style.display = 'block';
}
var font = document.getElementsByTagName('font');
for(f=0; f<font.length; f++) {
if(font.item(f).innerHTML.match(re) && !font.item(f).innerHTML.match(/<(textarea|select)/i))
font.item(f).innerHTML = font.item(f).innerHTML.replace(re, '<div class=hid>'+ mes +'</div>');
}
if(document.postForm) {
if(document.postForm.message.value.match(/\[quot.+?\](.|\n|\r)*(\[hide\](.|\n|\r)*\[\/hide\])(.|\n|\r)*\[\/quote\]/)) {
document.postForm.message.value = document.postForm.message.value.replace(RegExp.$2,'');
}
document.postForm.onsubmit = function() {
if(document.postForm.nextaction.value == 'post')
setCookie('r');
else
setCookie('p');
}
}
else if(document.getElementsByName('message').item(0)) {
if(document.forms.item(0).message) {
document.forms.item(0).onsubmit = function() {
setCookie('r');
}
}
else if(document.forms.item(1)) {
document.forms.item(1).onsubmit = function() {
setCookie('r');
}
}
}
}
//-->
</script>
Edit: 'Quoting' Bug Fix. 15th Jan '06
Edit: Another bug with quoting fixed. 22nd May '06
Edit: New Feature where Cookies are refreshed when the code sees a post by you.