I am trying to add a button that will "Copy contents to clipboard".
Unfortunately I am not getting the result I want. Any ideas what I should modify/add?
Here is what I am currently working with:
Whoops. Forgot we can't post links, anyways, here is the code (sorry it is rather long) heh:
Code:var DQUOTE = '"';
var APOSTROPHE= "'";
var ATSIGN = "@";
var ANGLEO = "<";
var ANGLEC = ">";
var PLUS = "+";
var strEncrypt;
var txtEncrypt;
var typEncrypt;
var begEncrypt;
var lenEncrypt;
var javEncrypted;
var numArray;
var outLines;
function makeDisplayable(str)
{
i = str.indexOf(DQUOTE);
while (i >= 0)
{
str = str.substr(0,i) + """ + str.substr(i+1);
i = str.indexOf(DQUOTE);
}
i = str.indexOf(APOSTROPHE);
while (i >= 0)
{
str = str.substr(0,i) + "'" + str.substr(i+1);
i = str.indexOf(APOSTROPHE);
}
i = str.indexOf(ANGLEO);
while (i >= 0)
{
str = str.substr(0,i) + "<" + str.substr(i+1);
i = str.indexOf(ANGLEO);
}
i = str.indexOf(ANGLEC);
while (i >= 0)
{
str = str.substr(0,i) + ">" + str.substr(i+1);
i = str.indexOf(ANGLEC);
}
return str;
}
function isEmailChar(ch)
{
if (ch == '-') return 1;
if (ch == '.') return 1;
if (ch == ':') return 1;
if (ch < '0') return 0;
if (ch > 'z') return 0;
if (ch > '9' && ch < 'A') return 0;
if (ch > 'Z' && ch < 'a') return 0;
return 1;
}
function FindEncryptPoint(str)
{
var p1, p2, ln;
typEncrypt = 0;
p1 = str.indexOf(DQUOTE);
if (p1 >= 0)
{
p2 = str.indexOf(DQUOTE, ++p1);
if (p2)
{
ln = p2 - p1;
typEncrypt = 1;
}
else
{
ln = 0;
p1 = -1;
alert("Unpaired double quotes... ");
}
}
else
{
ln = 0;
}
begEncrypt = p1;
lenEncrypt= ln;
//*******************************************
p1 = str.indexOf(ATSIGN);
if (p1 >= 0)
{
p2 = p1;
do
{
p1--;
if (!isEmailChar(str.charAt(p1)))
{
p1++;
break;
}
} while (p1 >= 0);
p2++;
do
{
if (!isEmailChar(str.charAt(p2)))
{
break;
}
} while (++p2 < str.length);
ln = p2 - p1;
if ((begEncrypt < 0) || (begEncrypt > p1))
{
begEncrypt = p1;
lenEncrypt= ln;
typEncrypt = 2;
}
}
//*******************************************
p1 = str.indexOf(ANGLEC);
if (p1)
{
p1++;
p2 = str.indexOf(ANGLEO, p1);
if (p2) ln = p2 - p1;
else ln = str.length() - p1;
if (((begEncrypt < 0) || (begEncrypt > p1)) && ln > 0)
{
begEncrypt = p1;
lenEncrypt= ln;
typEncrypt = 3;
}
}
}
function Encrypt(strEncrypt)
{
javEncrypted = "<script language=\"javascript\" type=\"text/javascript\">\n<!--\n";
outLines = 10;
FindEncryptPoint(strEncrypt);
while (begEncrypt >= 0)
{
if (begEncrypt > 0)
{
javEncrypted += " document.write('" + strEncrypt.substr(0, begEncrypt) + "');\n";
outLines++;
}
txtEncrypt = strEncrypt.substr(begEncrypt, lenEncrypt);
javEncrypted += " var by" + numArray + " = new Array(";
for (i = 0; i < lenEncrypt; i++)
{
if (i > 0) javEncrypted += ",";
if ((i % 10) == 0)
{
javEncrypted += "\n ";
outLines++;
}
c = txtEncrypt.charCodeAt(i);
c = -(c ^ lenEncrypt);
javEncrypted += c;
}
javEncrypted += " );\n";
javEncrypted += " var ix;\n";
javEncrypted += " var ln = by" + numArray + ".length;\n";
javEncrypted += " for (ix = 0; ix < ln; ix++) \n";
javEncrypted += " { document.write('&');\n";
javEncrypted += " document.write('#' + (-by" + numArray + "[ix] ^ ln) + ';'); }\n";
outLines += 5;
strEncrypt = strEncrypt.substr(begEncrypt+ lenEncrypt);
if (typEncrypt == 1)
{
strEncrypt = strEncrypt.substr(1);
javEncrypted += " document.write('" + DQUOTE + "');\n";
outLines++;
}
FindEncryptPoint(strEncrypt);
}
if (strEncrypt.length > 0)
{
javEncrypted += " document.write('" + strEncrypt + "');\n";
outLines++;
}
javEncrypted += "// -->\n</script>\n";
outLines += 2;
if (outLines > 25) outLines = 25;
}
function ProcessEncryption()
{
qs = location.search.substring(1);
i = qs.indexOf("numarray=");
if (i >= 0)
{
numArray = parseInt(qs.substring(i+9));
}
else
{
numArray = 0;
}
i = qs.indexOf("encode=");
value = qs.substring(i+7);
i = value.indexOf("&");
if (i >= 0)
{
value = value.substring(0, i);
}
value = unescape(value);
i = value.indexOf(PLUS);
while (i >= 0)
{
value = value.substr(0,i) + " " + value.substr(i+1);
i = value.indexOf(PLUS);
}
valueDisplay = makeDisplayable(value);
i = value.indexOf(APOSTROPHE);
while (i >= 0)
{
value = value.substr(0,i) + "\\'" + value.substr(i+1);
i = value.indexOf(APOSTROPHE,i+2);
}
Encrypt(value);
numArray++;
document.write ("<table border='0' cellpadding='3' width='80%' align='center'>");
document.write (" <form action='email_encryption_test.php' method='get' name='emailencrypt'>");
document.write (" <tr><td valign='bottom'>");
document.write (" <input type='submit' class='input' name='submit' value='Submit' />");
document.write (" <input name='grab' value='Copy Code' onclick='form.encrypted.focus();form.encrypted.select()' type='button' class='input' />");
document.write (" </td>");
document.write (" <td>");
document.write (" <i>Enter info to encode</i> <br />");
document.write (" <input type='text' class='input' name='encode' size='55' value='");
document.write (valueDisplay);
document.write ("' /> ");
document.write (" <input type='text' class='input' name='numarray' size='3' value='");
document.write (numArray);
document.write ("' />");
document.write (" </td>");
document.write (" </tr>");
document.write (" </form>");
document.write (" <tr><td></td>");
document.write (" <td valign='bottom'>");
document.write (" <form name='encryptedemail'>");
document.write (" <textarea class='input' name='encrypted' rows='" + outLines + "' cols='64'>");
document.write (javEncrypted);
document.write ("</textarea>");
document.write (" </form>");
document.write (" </td>");
document.write (" </tr>");
document.write ("</table>");
}
And to display it:
Code:<html>
<head>
<script src="email.js" type="text/javascript"></script>
</head>
<body>
Please follow the following instructions for this method:
<br>
<script>
<!--
ProcessEncryption();
// -->
</script>
<p>Copy the generated info below and place it in the source code to display the text entered in the first box. Each encrypted piece placed on the same webpage should have a different array encryption name as shown by the var byX = new Array line where X is a numerical value. The numbered box above shows the next array to be created. The value may be modified if needed.</p>
</body>
</html>
Haven't been here for awhile. Sure hope Craven is still around