Post by Jay on Aug 19, 2005 10:48:31 GMT -8
Preview: View Profile Screen, Abilties Screen, Saved Abilties Screen
Placement: global footers
Compatability: PBv4 / cross-browser
Notes: read below
What this code does is set a certain posting style that fits your needs. Let's say you want to post in bold red characters without having the hassle of clicking or entering in ubbc code. This does it automatically.
100% user-profile editable. No code editing is required.
Thanks to Eric for a few pointers.
Placement: global footers
Compatability: PBv4 / cross-browser
Notes: read below
<script type="text/javascript">
<!--
/* Created by Jay.
Cookie Set Posting Abilities
http://ngmaster.proboards21.com
This code may not be redistributed without permission.
Please leave this header intact at all times. */
function saveAbil() {
var cookie = '';
eval("((document.getElementById('bo').checked)? cookie += 'bo/' : '')");
eval("((document.getElementById('it').checked)? cookie += 'it/' : '')");
eval("((document.getElementById('un').checked)? cookie += 'un/' : '')");
if ((document.getElementById('col2').value == '' || document.getElementById('col2').value == null) && document.getElementById('col1').checked) {
window.alert('Please enter a valid hex color.');
return false;
}
else {
eval("((document.getElementById('col1').checked)? cookie += 'col1/hex-' + document.getElementById('col2').value + '/' : '')");
}
var expWhen = new Date();
expWhen.setTime(expWhen.getTime() + (100 * 24 * 3600 * 1000));
window.location = window.location.href.replace(/s$/i, 's2');
return document.cookie = 'option=' + escape(cookie) + '; expires=' + expWhen.toGMTString();
}
function updateCookie() {
if (document.cookie.length > 0) {
if (/col1\//i.test(document.cookie)) {
var hexsplit = document.cookie.split('hex-');
document.getElementById('col2').value = hexsplit[1].split('/')[0];
document.getElementById('colrow').style.display = '';
}
if (/option\=(.*?)(;|$)/i.test(document.cookie)) {
var ids = RegExp.$1;
var actualID = ids.split('/');
for (var c = 0; c < actualID.length; c ++) {
if (actualID[c].match(/^(bo|it|un|col1){1}$/i)) {
document.getElementById(RegExp.$1.substring(RegExp.$1.length, 0)).checked = true;
}
else {
return null;
}
}
}
}
}
function dispCol() {
if (document.getElementById('colrow').style.display != 'none' && !document.getElementById('col1').checked) {
document.getElementById('colrow').style.display = 'none';
}
else {
document.getElementById('colrow').style.display = '';
}
}
var getTD = document.getElementsByTagName('td');
var prefixes = '';
var suffixes = '';
if (document.cookie.match('bo/')) {
prefixes += '[b]'; suffixes += '[/b]';
}
if (document.cookie.match('it/')) {
prefixes += '[i]'; suffixes += '[/i]';
}
if (document.cookie.match('un/')) {
prefixes += '[u]'; suffixes += '[/u]';
}
if (document.cookie.match('col1/')) {
prefixes += '[color=' + document.cookie.split('hex-')[1].split('/')[0] + ']'; suffixes += '[/color]';
}
if (window.location.href.match(/\=abilitie/)) {
switch (RegExp["$'"]) {
case 's' :
for (var i = 0; i < getTD.length; i ++) {
document.title = document.images.item(0).alt + ' - Posting Abilities';
if (getTD.item(i).innerHTML.match(/An Error Has Occurred/)) {
getTD.item(i).innerHTML = getTD.item(i).innerHTML.replace(/An Error Has Occurred/i, 'Posting Abilities');
}
if (getTD.item(i).width == '100%' && getTD.item(i).firstChild.size && getTD.item(i).innerHTML.match('addModule')) {
var tab = '';
tab += '<table width="500" cellpadding="1" cellspacing="1" align="left">';
tab += '<tr><td colspan="3" style="padding-bottom: 15px;">';
tab += 'Check the boxes that apply to your posting style. Remember, if you decide to delete your browser cookies, you\'ll have to re-check the boxes before your style is re-applied. These settings will also apply automatically each time you login.';
tab += '</td></tr><tr><td width="0">';
tab += '<input type="checkbox" id="bo">';
tab += '</td><td width="10"><b>Bold</b>';
tab += '</td><td style="padding-left: 30px;">';
tab += 'Do you wish to post in bold characters? If so, check this box.';
tab += '</td></tr><tr><td width="0">';
tab += '<input type="checkbox" id="it">';
tab += '</td><td width="10" align="left"><i>Italic</i>';
tab += '</td><td style="padding-left: 30px;">';
tab += 'Do you wish to post in italicized characters? If so, check this box.';
tab += '</td></tr><tr><td width="0">';
tab += '<input type="checkbox" id="un">';
tab += '</td><td width="10" align="left"><u>Underline</u>';
tab += '</td><td style="padding-left: 30px;">';
tab += 'Do you wish to post in underlined characters? If so, check this box.';
tab += '</td></tr><tr><td widht="0">';
tab += '<input type="checkbox" id="col1" onclick="dispCol();">';
tab += '</td><td width="10" align="left"><font color="#FF0000">Color</font>';
tab += '</td><td style="padding-left: 30px;">';
tab += 'If you wish to post in color, check this box and an area will appear where you can choose a color.';
tab += '</td></tr><tr id="colrow" style="display: none;"><td colspan="3">';
tab += '\# <input type="text" size="10" id="col2">';
tab += '</td></tr><tr><td colspan="3">';
tab += '<input type="button" value="Save Abilities" onclick="saveAbil();">';
tab += '</td></tr></table>';
getTD.item(i).innerHTML = tab;
}
}
updateCookie();
break;
case 's2' :
for (var i = 0; i < getTD.length; i ++) {
document.title = document.images.item(0).alt + ' - Posting Abilities';
if (getTD.item(i).innerHTML.match(/An Error Has Occurred/)) {
getTD.item(i).innerHTML = getTD.item(i).innerHTML.replace(/An Error Has Occurred/i, 'Posting Abilities');
}
if (getTD.item(i).width == '100%' && getTD.item(i).firstChild.size && getTD.item(i).className.match(/window/) && getTD.item(i).innerHTML.match('addModule')) {
var divdata = '';
divdata += '[<b>b</b>] - disabled<br />';
divdata += '[<i>i</i>] - disabled<br />';
divdata += '[<u>u</u>] - disabled<br />';
divdata += '[<font color="#FF0000">color</font>] - disabled<br />';
var newDiv = document.createElement('div');
newDiv.style.paddingTop = 15 + 'px';
newDiv.style.fontSize = 10 + 'px';
(prefixes.match(/\[b\]/))? divdata = divdata.replace('b>] - disabled', 'b>] - enabled') : '';
(prefixes.match(/\[i\]/))? divdata = divdata.replace('i>] - disabled', 'i>] - enabled') : '';
(prefixes.match(/\[u\]/))? divdata = divdata.replace('u>] - disabled', 'u>] - enabled') : '';
(prefixes.match(/\[col/))? divdata = divdata.replace('t>] - disabled', 't>] - enabled') : '';
newDiv.innerHTML = divdata;
getTD.item(i).firstChild.innerHTML = 'Your new posting abilities have been set. They will activate automatically each time you make a new post.';
getTD.item(i).firstChild.appendChild(newDiv);
}
}
break;
}
}
if (window.location.href.match(/=viewprofile($)?/)) {
var newSpace = document.createTextNode(' - ');
var newLink = document.createElement('a');
newLink.href = '/index.cgi?action=abilities';
newLink.innerHTML = 'Posting Abilities';
for (var d = 0; d < document.links.length; d ++) {
if (document.links.item(d).href.match('=bookmarks')) {
document.links.item(d).parentNode.insertBefore(newLink, document.links.item(d));
document.links.item(d).parentNode.insertBefore(newSpace, document.links.item(d));
}
}
}
if (document.postForm) {
var dfM = document.postForm.message;
document.postForm.onsubmit = function() {
var totalVal = prefixes + dfM.value + suffixes;
return dfM.value = (!document.title.match(/Preview|Modify/)? totalVal : dfM.value);
}
}
//-->
</script>
What this code does is set a certain posting style that fits your needs. Let's say you want to post in bold red characters without having the hassle of clicking or entering in ubbc code. This does it automatically.
100% user-profile editable. No code editing is required.
Thanks to Eric for a few pointers.