function decodeEntry(myInput, myOutput, prefix) {
control1 = document.getElementById(myInput);
control2 = document.getElementById(myOutput);
if (!control1 || !control2) {
alert('I/O read error. Make source that both the source and destination controls exist and are enabled.');
return false;
}
var key = prompt("Please supply decryption key:");
if (!key) return false;
var decodedText = doUnsecure(getValueByType(control1), key, "electricavenue");
if (decodedText == false) {
alert('Decryption failed. Either you supplied the wrong key, or the entry is not encrypted.');
} else {
decodedText = decodedText.replace(/\s+$/,''); // Removes trailing whitespace created by decryption algorithm
//decodedText = decodedText.replace(/\n/g,"
\n"); // nl2br() substitute
decodedText = decodedText.replace(/\[(b|i|u|strike)\](.*)\[\/\1\]/siug,"<$1>$2$1>");
decodedText = decodedText.replace(/\s*\[(\/?)(o|u)l\]\s*/siug," <$1$2l> ");
decodedText = decodedText.replace(/\[(\/?)li\]/siug,"<$1li>");
decodedText = decodedText.replace(/\s*\[blockquote\]\s*(.*)\s*\[\/blockquote\]\s*/siug,"
$1
");
decodedText = decodedText.replace(/\[sms\](.*)\[\/sms\]/siug,"$1");
decodedText = decodedText.replace(/\[code\](.*)\[\/code\]/siug,"$1");
decodedText = decodedText.replace(/\s*\[quote\](.*)\[\/quote\]\s*/siug,"");
decodedText = decodedText.replace(/\[color=([a-z0-9#]+?)\](.*)\[\/color\]/siug,"$2");
decodedText = decodedText.replace(/\[font=([a-z0-9 ]+?)\](.*)\[\/font\]/siug,"$2");
decodedText = decodedText.replace(/\[size=([0-9]+?)\](.*)\[\/size\]/siug,"$2");
decodedText = decodedText.replace(/\[time=(.+?)\]/siug,"$1");
decodedText = decodedText.replace(/\[(?:unicode=|x)([0-9A-Z]+)\s*\/?\]/siug,"$1;");
decodedText = decodedText.replace(/\s*\[hr\]\s*/siug,"
");
decodedText = decodedText.replace(/\[url=([[:alpha:]]+:\/\/[^<>[:space:]]+[[:alnum:]\/])\](.*)\[\/url\]/siug,"$2");
decodedText = decodedText.replace(/\[url\]([[:alpha:]]+:\/\/[^<>[:space:]]+[[:alnum:]\/])\[\/url\]/siug,"$1");
decodedText = decodedText.replace(/\[x\](.*)\[\/x\]/siug,"$1");
decodedText = decodedText.replace(/--/g,"—");
decodedText = decodedText.replace(/(\:oops\:|(\*oops\*))/ug,".");
decodedText = decodedText.replace(/(\:lol\:)|(\*lol\*)/ug,".");
decodedText = decodedText.replace(/\:roll\:/ug,".");
decodedText = decodedText.replace(/\:idea\:/ug,"");
decodedText = decodedText.replace(/\:arrow\:/ug,"");
decodedText = decodedText.replace(/\:wink\:/ug,".");
decodedText = decodedText.replace(/\:cry\:/ug,".");
decodedText = decodedText.replace(/\:shock\:/ug,".");
decodedText = decodedText.replace(/(\:twisted\:)|(\>\;\>\;\:(-?)\))/ug,".");
decodedText = decodedText.replace(/(\:evil\:)|(\>\;\:(-?)(\)|P))/ug,".");
decodedText = decodedText.replace(/\:(-?)\)/ug,".");
decodedText = decodedText.replace(/\:(-?)D+/ug,".");
decodedText = decodedText.replace(/(\s)\;(-?)D+/ug,"$1.");
decodedText = decodedText.replace(/\:(-?)\(+/ug,".");
decodedText = decodedText.replace(/\:(-?)o/ug,".");
decodedText = decodedText.replace(/\:(-?)\?/ug,".");
decodedText = decodedText.replace(/[^\w]8(-?)\)/ug,".");
decodedText = decodedText.replace(/(\s)\;(-?)\(+/ug,"$1.");
decodedText = decodedText.replace(/([^&]{5})\;(-?)\)/ug,"$1.");
decodedText = decodedText.replace(/(\:(-?)x)|(\>\;\.\<\;)/ug,".");
decodedText = decodedText.replace(/(\:|\;)(-?)P/ug,".");
decodedText = decodedText.replace(/(\:!\:)|(\(!\))/ug,"");
decodedText = decodedText.replace(/(\:\?\:)|(\(\?\))/ug,"");
decodedText = decodedText.replace(/()\.(\)|;|:|\.|,| —)/g,"$1$2");
decodedText = decodedText.replace(/()\.()/ug,"$1$2");
if (prefix == 1) decodedText = "Decoded entry:
" + decodedText;
setValueByType(control2, decodedText);
}
}
function encodeEntry(myInput, myOutput) {
control1 = document.getElementById(myInput);
control2 = document.getElementById(myOutput);
if (!control1 || !control2) {
alert('I/O read error. Make source that both the source and destination controls exist and are enabled.');
return false;
}
var key = prompt("Please supply encryption key:");
if (!key) return false;
var encodedText = doSecure(getValueByType(control1), key, "electricavenue");
setValueByType(control2, encodedText);
}
function getValueByType(obj) {
switch (obj.type) {
case 'textarea': return obj.value;
case 'input': return obj.value;
default: return obj.innerHTML;
}
}
function setValueByType(obj,val) {
switch (obj.type) {
case 'textarea': obj.value = val;
case 'input': obj.value = val;
default: obj.innerHTML = val.replace(/\n/,'
');
}
}