|
Post by Wormopolis on Feb 1, 2009 18:42:44 GMT -8
Browsers checked: IE and FF placement: board footer or global footer
Allows a user to put a secret message to another user in the middle of a post.
its as simple as putting [secret:username]message to user[/secret] in the post.
variables include: adminSees: can admin see all secrets senderSees: sender sees the secret he posted as well as recipient encryptMsg: encrypt the messages before posting for added security (no.. Im not a cryptologist.. this isnt 100% unbreakable).
this could be useful to send a secret in the middle of a RPG post without having to send a PM.
<script type="text/javascript"> <!-- /* Secret message in post By Wormopolis Keep header intact, do not repost v 1.4 wormocodes.proboards.com */
var adminSees=true; var senderSees=true; var encryptMsg=true;
function garble(text, param1, param2) { var endStr = new String; mod1=param1.length + param2.length; for (g=0; g<text.length; g++) { hold=text.charCodeAt(g); if ((hold>=65 && hold<=90) || (hold>=97 && hold<=122)) { res=(hold<91 ? 65 : 97); hold2=hold-res+mod1+g; res+=(hold2%26); res2=Math.floor(hold2/26)+32; endStr=endStr.concat(String.fromCharCode(res)); endStr=endStr.concat(String.fromCharCode(res2)); } else { endStr=endStr.concat(text.charAt(g)); } } return endStr; }
function ungarble(text, param1, param2) { var endStr = new String; mod1=param1.length + param2.length; h=0; for (g=0; g<text.length; g++) { hold=text.charCodeAt(g); if ((hold>=65 && hold<=90) || (hold>=97 && hold<=122)) { endStr=endStr.concat(String.fromCharCode(hold+((text.charCodeAt(g+1)-32)*26)-mod1-h)); g++; } else { endStr=endStr.concat(text.charAt(g)); } h++; } return endStr; } if (!location.href.match(/headersfooters/)) { tds=document.getElementsByTagName('td'); for (i=0; i<tds.length; i++) { if (tds[i].innerHTML.match(/\[secret:(.+?)\](.+?)\[\/secret(.*?)\]/i)) { recip=RegExp.$1; msg=RegExp.$2; orig=RegExp.$3; orig=orig.substr(1,orig.length-1); if ((pb_username==recip || (senderSees && orig==pb_username) || (pb_username=='admin' && adminSees)) && !location.href.match(/quote=/)) { secTbl=document.createElement('table'); secTbl.width="100%"; secTbl.insertRow(0); secCell=secTbl.rows[0].insertCell(0); secTbl.style.backgroundColor="000000"; secTbl.style.backgroundImage="url('http://i197.photobucket.com/albums/aa250/WORMOPOLIS/secMgBG.jpg')"; secTbl.style.backgroundRepeat="no-repeat"; if (orig.length) { msg=ungarble(msg, recip, orig); } secCell.innerHTML="<br><br>TO: "+recip+"<br><br>"+msg+"<br>"; tempDiv=document.createElement('div'); tempDiv.appendChild(document.createElement('hr')); tempDiv.appendChild(secTbl); tempDiv.appendChild(document.createElement('hr')); if (tds[i].innerHTML.match(/textarea/i)) { putback="[secret:"+recip+"]"+msg+"[/secret]"; tds[i].getElementsByTagName('textarea')[0].value=tds[i].getElementsByTagName('textarea')[0].value.replace(/\[secret:(.+?)\](.+?)\[\/secret(.*?)\]/i, putback ); } else { tds[i].innerHTML=tds[i].innerHTML.replace(/\[secret:(.+?)\](.+?)\[\/secret(.*?)\]/i, tempDiv.innerHTML); } } else { if (tds[i].getElementsByTagName('textarea')[0]) { tds[i].getElementsByTagName('textarea')[0].value=tds[i].getElementsByTagName('textarea')[0].value.replace(/\[secret:(.+?)\](.+?)\[\/secret(.*?)\]/i, ''); } else { tds[i].innerHTML=tds[i].innerHTML.replace(/\[secret:(.+?)\](.+?)\[\/secret(.*?)\]/i, ''); } } } } function enc() { if (document.postForm) { if (document.postForm.message.value.match(/\[secret:(.+?)\](.+?)\[\/secret\]/i)) { recip=RegExp.$1; msg=RegExp.$2; ms2=garble(msg, recip, pb_username); document.postForm.message.value=document.postForm.message.value.replace(/\[secret:(.+?)\](.+?)\[\/secret\]/i, "[secret:"+recip+"]"+ms2+"[/secret:"+pb_username+"]"); } } } if (document.postForm && encryptMsg) { if(document.addEventListener){ postForm.addEventListener('submit',enc,false); } else { postForm.attachEvent('onsubmit',enc); } }
/* btns=document.getElementsByTagName('input'); for (b=0; b<btns.length; b++) { if (btns[b].type=='submit') { if (document.postForm && encryptMsg) { if(document.addEventListener){ btns[b].addEventListener('click',enc,false); } else { btns[b].attachEvent('onclick',enc); } } } } */ } // --> </script>
Preview: coming soon
|
|
|
Post by Wormopolis on Feb 6, 2009 19:30:18 GMT -8
well I just learned Todge wrote a code similar called "Whisper Tags" on PBS site. I swear I didnt know that...
Well this one adds the benefit of encrypted messages at least... and the person who posted the secret can see it if the variable is set to true.
|
|
|
Post by Wormopolis on Feb 12, 2009 15:02:09 GMT -8
updated with bug fix during Preview.
|
|
|
Post by Wormopolis on Feb 15, 2009 11:34:44 GMT -8
well.. apparently there are a few more bugs I need to work out. you can beta test it if you like, but Im not guaranteeing anything.
If you modify your post, it erases the secret message.. which I thought was ok.. but have since changed my mind.
and randomly.. the encryption fails. so I have to re-examine that as well.
|
|
daniel
Not New Member
Posts: 7
daniel said 0 great things
|
Post by daniel on May 29, 2010 17:54:46 GMT -8
are these bugs worked out yet?
|
|
|
Post by Wormopolis on May 29, 2010 19:10:29 GMT -8
pfft no. I basically moved this code to here because Todge's code was way better. This one had an encryption method that I tried to use and occasionaly it went bonkers anyway.
If I ever get a wild hair up my ass I might give it shot again, but I have so many other code requests that I never have the time.
|
|