Added some clipboard copy functions.
This commit is contained in:
parent
ab9714241c
commit
6cdf54bf82
183
bwtc32key.htm
183
bwtc32key.htm
|
@ -6053,6 +6053,7 @@ abbr,acronym { border:0;}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<div>
|
<div>
|
||||||
<label for="filePicker">Choose or drag a (tar) file to encode:</label>
|
<label for="filePicker">Choose or drag a (tar) file to encode:</label>
|
||||||
|
@ -6063,7 +6064,10 @@ abbr,acronym { border:0;}
|
||||||
<p>Compression Level (1-9): <input type="number" min="1" max="9" value="9"id="complevel"></input></p>
|
<p>Compression Level (1-9): <input type="number" min="1" max="9" value="9"id="complevel"></input></p>
|
||||||
<div>
|
<div>
|
||||||
<h1>BWTC32Key-encoded version</h1>
|
<h1>BWTC32Key-encoded version</h1>
|
||||||
<textarea id="base64textarea" placeholder="Base32768 will appear here" cols="50" rows="15"></textarea><br>
|
<form name="BWTC32Key" action="">
|
||||||
|
<textarea id="base64textarea" name="base32768textarea" placeholder="Base32768 will appear here" cols="50" rows="15"></textarea><br>
|
||||||
|
<button id="copy" type="button" onclick="copyOutputToClipboard();">Copy the above string.</button>
|
||||||
|
</form>
|
||||||
<p>B3K filename:</p>
|
<p>B3K filename:</p>
|
||||||
|
|
||||||
<textarea id="B3Kfilename">myFile.B3K</textarea>
|
<textarea id="B3Kfilename">myFile.B3K</textarea>
|
||||||
|
@ -6074,12 +6078,11 @@ abbr,acronym { border:0;}
|
||||||
<p>Upload a B3K file here:</p>
|
<p>Upload a B3K file here:</p>
|
||||||
<input type="file" id="fileToRead">
|
<input type="file" id="fileToRead">
|
||||||
<br>
|
<br>
|
||||||
<textarea id="textbox" cols="25" >Type BWTC32Key-encoded text here to decode</textarea><button id="create">Click to decode file</button><br />
|
<!--<form name="b3k">--><textarea id="textbox" name="decinput" cols="25" >Type BWTC32Key-encoded text here to decode</textarea><button id="create">Click to decode file</button><br />
|
||||||
<p>Output's Filename & MIMEtype</p>
|
<p>Output's Filename & MIMEtype <button id="textextract" onclick="copyOutputToClipboard2();" type="button">Copy above box</button></p><!--</form>-->
|
||||||
<textarea id="filename">output.bin</textarea>
|
<textarea id="filename">output.bin</textarea>
|
||||||
<textarea id="filetype">application/octet-stream</textarea><br />
|
<textarea id="filetype">application/octet-stream</textarea><br />
|
||||||
<a download="output.bin" id="downloadlink" style="display: none">Download decoded file</a>
|
<a download="output.bin" id="downloadlink" style="display: none">Download decoded file</a>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// tell the embed parent frame the height of the content
|
// tell the embed parent frame the height of the content
|
||||||
if (window.parent && window.parent.parent){
|
if (window.parent && window.parent.parent){
|
||||||
|
@ -6283,7 +6286,7 @@ abbr,acronym { border:0;}
|
||||||
if (this.hashed) {
|
if (this.hashed) {
|
||||||
this.hashed = false;
|
this.hashed = false;
|
||||||
blocks[0] = this.block;
|
blocks[0] = this.block;
|
||||||
blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
this.block = blocks[16] = blocks[1] = blocks[2] = blocks[3] =
|
||||||
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
blocks[4] = blocks[5] = blocks[6] = blocks[7] =
|
||||||
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
blocks[8] = blocks[9] = blocks[10] = blocks[11] =
|
||||||
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
blocks[12] = blocks[13] = blocks[14] = blocks[15] = 0;
|
||||||
|
@ -6291,26 +6294,26 @@ abbr,acronym { border:0;}
|
||||||
|
|
||||||
if (notString) {
|
if (notString) {
|
||||||
for (i = this.start; index < length && i < 64; ++index) {
|
for (i = this.start; index < length && i < 64; ++index) {
|
||||||
blocks[i >> 2] |= message[index] << SHIFT[i++ & 3];
|
blocks[i >>> 2] |= message[index] << SHIFT[i++ & 3];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (i = this.start; index < length && i < 64; ++index) {
|
for (i = this.start; index < length && i < 64; ++index) {
|
||||||
code = message.charCodeAt(index);
|
code = message.charCodeAt(index);
|
||||||
if (code < 0x80) {
|
if (code < 0x80) {
|
||||||
blocks[i >> 2] |= code << SHIFT[i++ & 3];
|
blocks[i >>> 2] |= code << SHIFT[i++ & 3];
|
||||||
} else if (code < 0x800) {
|
} else if (code < 0x800) {
|
||||||
blocks[i >> 2] |= (0xc0 | (code >> 6)) << SHIFT[i++ & 3];
|
blocks[i >>> 2] |= (0xc0 | (code >>> 6)) << SHIFT[i++ & 3];
|
||||||
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
||||||
} else if (code < 0xd800 || code >= 0xe000) {
|
} else if (code < 0xd800 || code >= 0xe000) {
|
||||||
blocks[i >> 2] |= (0xe0 | (code >> 12)) << SHIFT[i++ & 3];
|
blocks[i >>> 2] |= (0xe0 | (code >>> 12)) << SHIFT[i++ & 3];
|
||||||
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
|
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
|
||||||
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
||||||
} else {
|
} else {
|
||||||
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
|
code = 0x10000 + (((code & 0x3ff) << 10) | (message.charCodeAt(++index) & 0x3ff));
|
||||||
blocks[i >> 2] |= (0xf0 | (code >> 18)) << SHIFT[i++ & 3];
|
blocks[i >>> 2] |= (0xf0 | (code >>> 18)) << SHIFT[i++ & 3];
|
||||||
blocks[i >> 2] |= (0x80 | ((code >> 12) & 0x3f)) << SHIFT[i++ & 3];
|
blocks[i >>> 2] |= (0x80 | ((code >>> 12) & 0x3f)) << SHIFT[i++ & 3];
|
||||||
blocks[i >> 2] |= (0x80 | ((code >> 6) & 0x3f)) << SHIFT[i++ & 3];
|
blocks[i >>> 2] |= (0x80 | ((code >>> 6) & 0x3f)) << SHIFT[i++ & 3];
|
||||||
blocks[i >> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
blocks[i >>> 2] |= (0x80 | (code & 0x3f)) << SHIFT[i++ & 3];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6340,7 +6343,7 @@ abbr,acronym { border:0;}
|
||||||
this.finalized = true;
|
this.finalized = true;
|
||||||
var blocks = this.blocks, i = this.lastByteIndex;
|
var blocks = this.blocks, i = this.lastByteIndex;
|
||||||
blocks[16] = this.block;
|
blocks[16] = this.block;
|
||||||
blocks[i >> 2] |= EXTRA[i & 3];
|
blocks[i >>> 2] |= EXTRA[i & 3];
|
||||||
this.block = blocks[16];
|
this.block = blocks[16];
|
||||||
if (i >= 56) {
|
if (i >= 56) {
|
||||||
if (!this.hashed) {
|
if (!this.hashed) {
|
||||||
|
@ -6441,39 +6444,39 @@ abbr,acronym { border:0;}
|
||||||
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
|
var h0 = this.h0, h1 = this.h1, h2 = this.h2, h3 = this.h3, h4 = this.h4, h5 = this.h5,
|
||||||
h6 = this.h6, h7 = this.h7;
|
h6 = this.h6, h7 = this.h7;
|
||||||
|
|
||||||
var hex = HEX_CHARS[(h0 >> 28) & 0x0F] + HEX_CHARS[(h0 >> 24) & 0x0F] +
|
var hex = HEX_CHARS[(h0 >>> 28) & 0x0F] + HEX_CHARS[(h0 >>> 24) & 0x0F] +
|
||||||
HEX_CHARS[(h0 >> 20) & 0x0F] + HEX_CHARS[(h0 >> 16) & 0x0F] +
|
HEX_CHARS[(h0 >>> 20) & 0x0F] + HEX_CHARS[(h0 >>> 16) & 0x0F] +
|
||||||
HEX_CHARS[(h0 >> 12) & 0x0F] + HEX_CHARS[(h0 >> 8) & 0x0F] +
|
HEX_CHARS[(h0 >>> 12) & 0x0F] + HEX_CHARS[(h0 >>> 8) & 0x0F] +
|
||||||
HEX_CHARS[(h0 >> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
|
HEX_CHARS[(h0 >>> 4) & 0x0F] + HEX_CHARS[h0 & 0x0F] +
|
||||||
HEX_CHARS[(h1 >> 28) & 0x0F] + HEX_CHARS[(h1 >> 24) & 0x0F] +
|
HEX_CHARS[(h1 >>> 28) & 0x0F] + HEX_CHARS[(h1 >>> 24) & 0x0F] +
|
||||||
HEX_CHARS[(h1 >> 20) & 0x0F] + HEX_CHARS[(h1 >> 16) & 0x0F] +
|
HEX_CHARS[(h1 >>> 20) & 0x0F] + HEX_CHARS[(h1 >>> 16) & 0x0F] +
|
||||||
HEX_CHARS[(h1 >> 12) & 0x0F] + HEX_CHARS[(h1 >> 8) & 0x0F] +
|
HEX_CHARS[(h1 >>> 12) & 0x0F] + HEX_CHARS[(h1 >>> 8) & 0x0F] +
|
||||||
HEX_CHARS[(h1 >> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
|
HEX_CHARS[(h1 >>> 4) & 0x0F] + HEX_CHARS[h1 & 0x0F] +
|
||||||
HEX_CHARS[(h2 >> 28) & 0x0F] + HEX_CHARS[(h2 >> 24) & 0x0F] +
|
HEX_CHARS[(h2 >>> 28) & 0x0F] + HEX_CHARS[(h2 >>> 24) & 0x0F] +
|
||||||
HEX_CHARS[(h2 >> 20) & 0x0F] + HEX_CHARS[(h2 >> 16) & 0x0F] +
|
HEX_CHARS[(h2 >>> 20) & 0x0F] + HEX_CHARS[(h2 >>> 16) & 0x0F] +
|
||||||
HEX_CHARS[(h2 >> 12) & 0x0F] + HEX_CHARS[(h2 >> 8) & 0x0F] +
|
HEX_CHARS[(h2 >>> 12) & 0x0F] + HEX_CHARS[(h2 >>> 8) & 0x0F] +
|
||||||
HEX_CHARS[(h2 >> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
|
HEX_CHARS[(h2 >>> 4) & 0x0F] + HEX_CHARS[h2 & 0x0F] +
|
||||||
HEX_CHARS[(h3 >> 28) & 0x0F] + HEX_CHARS[(h3 >> 24) & 0x0F] +
|
HEX_CHARS[(h3 >>> 28) & 0x0F] + HEX_CHARS[(h3 >>> 24) & 0x0F] +
|
||||||
HEX_CHARS[(h3 >> 20) & 0x0F] + HEX_CHARS[(h3 >> 16) & 0x0F] +
|
HEX_CHARS[(h3 >>> 20) & 0x0F] + HEX_CHARS[(h3 >>> 16) & 0x0F] +
|
||||||
HEX_CHARS[(h3 >> 12) & 0x0F] + HEX_CHARS[(h3 >> 8) & 0x0F] +
|
HEX_CHARS[(h3 >>> 12) & 0x0F] + HEX_CHARS[(h3 >>> 8) & 0x0F] +
|
||||||
HEX_CHARS[(h3 >> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
|
HEX_CHARS[(h3 >>> 4) & 0x0F] + HEX_CHARS[h3 & 0x0F] +
|
||||||
HEX_CHARS[(h4 >> 28) & 0x0F] + HEX_CHARS[(h4 >> 24) & 0x0F] +
|
HEX_CHARS[(h4 >>> 28) & 0x0F] + HEX_CHARS[(h4 >>> 24) & 0x0F] +
|
||||||
HEX_CHARS[(h4 >> 20) & 0x0F] + HEX_CHARS[(h4 >> 16) & 0x0F] +
|
HEX_CHARS[(h4 >>> 20) & 0x0F] + HEX_CHARS[(h4 >>> 16) & 0x0F] +
|
||||||
HEX_CHARS[(h4 >> 12) & 0x0F] + HEX_CHARS[(h4 >> 8) & 0x0F] +
|
HEX_CHARS[(h4 >>> 12) & 0x0F] + HEX_CHARS[(h4 >>> 8) & 0x0F] +
|
||||||
HEX_CHARS[(h4 >> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] +
|
HEX_CHARS[(h4 >>> 4) & 0x0F] + HEX_CHARS[h4 & 0x0F] +
|
||||||
HEX_CHARS[(h5 >> 28) & 0x0F] + HEX_CHARS[(h5 >> 24) & 0x0F] +
|
HEX_CHARS[(h5 >>> 28) & 0x0F] + HEX_CHARS[(h5 >>> 24) & 0x0F] +
|
||||||
HEX_CHARS[(h5 >> 20) & 0x0F] + HEX_CHARS[(h5 >> 16) & 0x0F] +
|
HEX_CHARS[(h5 >>> 20) & 0x0F] + HEX_CHARS[(h5 >>> 16) & 0x0F] +
|
||||||
HEX_CHARS[(h5 >> 12) & 0x0F] + HEX_CHARS[(h5 >> 8) & 0x0F] +
|
HEX_CHARS[(h5 >>> 12) & 0x0F] + HEX_CHARS[(h5 >>> 8) & 0x0F] +
|
||||||
HEX_CHARS[(h5 >> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] +
|
HEX_CHARS[(h5 >>> 4) & 0x0F] + HEX_CHARS[h5 & 0x0F] +
|
||||||
HEX_CHARS[(h6 >> 28) & 0x0F] + HEX_CHARS[(h6 >> 24) & 0x0F] +
|
HEX_CHARS[(h6 >>> 28) & 0x0F] + HEX_CHARS[(h6 >>> 24) & 0x0F] +
|
||||||
HEX_CHARS[(h6 >> 20) & 0x0F] + HEX_CHARS[(h6 >> 16) & 0x0F] +
|
HEX_CHARS[(h6 >>> 20) & 0x0F] + HEX_CHARS[(h6 >>> 16) & 0x0F] +
|
||||||
HEX_CHARS[(h6 >> 12) & 0x0F] + HEX_CHARS[(h6 >> 8) & 0x0F] +
|
HEX_CHARS[(h6 >>> 12) & 0x0F] + HEX_CHARS[(h6 >>> 8) & 0x0F] +
|
||||||
HEX_CHARS[(h6 >> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F];
|
HEX_CHARS[(h6 >>> 4) & 0x0F] + HEX_CHARS[h6 & 0x0F];
|
||||||
if (!this.is224) {
|
if (!this.is224) {
|
||||||
hex += HEX_CHARS[(h7 >> 28) & 0x0F] + HEX_CHARS[(h7 >> 24) & 0x0F] +
|
hex += HEX_CHARS[(h7 >>> 28) & 0x0F] + HEX_CHARS[(h7 >>> 24) & 0x0F] +
|
||||||
HEX_CHARS[(h7 >> 20) & 0x0F] + HEX_CHARS[(h7 >> 16) & 0x0F] +
|
HEX_CHARS[(h7 >>> 20) & 0x0F] + HEX_CHARS[(h7 >>> 16) & 0x0F] +
|
||||||
HEX_CHARS[(h7 >> 12) & 0x0F] + HEX_CHARS[(h7 >> 8) & 0x0F] +
|
HEX_CHARS[(h7 >>> 12) & 0x0F] + HEX_CHARS[(h7 >>> 8) & 0x0F] +
|
||||||
HEX_CHARS[(h7 >> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F];
|
HEX_CHARS[(h7 >>> 4) & 0x0F] + HEX_CHARS[h7 & 0x0F];
|
||||||
}
|
}
|
||||||
return hex;
|
return hex;
|
||||||
};
|
};
|
||||||
|
@ -6487,16 +6490,16 @@ abbr,acronym { border:0;}
|
||||||
h6 = this.h6, h7 = this.h7;
|
h6 = this.h6, h7 = this.h7;
|
||||||
|
|
||||||
var arr = [
|
var arr = [
|
||||||
(h0 >> 24) & 0xFF, (h0 >> 16) & 0xFF, (h0 >> 8) & 0xFF, h0 & 0xFF,
|
(h0 >>> 24) & 0xFF, (h0 >>> 16) & 0xFF, (h0 >>> 8) & 0xFF, h0 & 0xFF,
|
||||||
(h1 >> 24) & 0xFF, (h1 >> 16) & 0xFF, (h1 >> 8) & 0xFF, h1 & 0xFF,
|
(h1 >>> 24) & 0xFF, (h1 >>> 16) & 0xFF, (h1 >>> 8) & 0xFF, h1 & 0xFF,
|
||||||
(h2 >> 24) & 0xFF, (h2 >> 16) & 0xFF, (h2 >> 8) & 0xFF, h2 & 0xFF,
|
(h2 >>> 24) & 0xFF, (h2 >>> 16) & 0xFF, (h2 >>> 8) & 0xFF, h2 & 0xFF,
|
||||||
(h3 >> 24) & 0xFF, (h3 >> 16) & 0xFF, (h3 >> 8) & 0xFF, h3 & 0xFF,
|
(h3 >>> 24) & 0xFF, (h3 >>> 16) & 0xFF, (h3 >>> 8) & 0xFF, h3 & 0xFF,
|
||||||
(h4 >> 24) & 0xFF, (h4 >> 16) & 0xFF, (h4 >> 8) & 0xFF, h4 & 0xFF,
|
(h4 >>> 24) & 0xFF, (h4 >>> 16) & 0xFF, (h4 >>> 8) & 0xFF, h4 & 0xFF,
|
||||||
(h5 >> 24) & 0xFF, (h5 >> 16) & 0xFF, (h5 >> 8) & 0xFF, h5 & 0xFF,
|
(h5 >>> 24) & 0xFF, (h5 >>> 16) & 0xFF, (h5 >>> 8) & 0xFF, h5 & 0xFF,
|
||||||
(h6 >> 24) & 0xFF, (h6 >> 16) & 0xFF, (h6 >> 8) & 0xFF, h6 & 0xFF
|
(h6 >>> 24) & 0xFF, (h6 >>> 16) & 0xFF, (h6 >>> 8) & 0xFF, h6 & 0xFF
|
||||||
];
|
];
|
||||||
if (!this.is224) {
|
if (!this.is224) {
|
||||||
arr.push((h7 >> 24) & 0xFF, (h7 >> 16) & 0xFF, (h7 >> 8) & 0xFF, h7 & 0xFF);
|
arr.push((h7 >>> 24) & 0xFF, (h7 >>> 16) & 0xFF, (h7 >>> 8) & 0xFF, h7 & 0xFF);
|
||||||
}
|
}
|
||||||
return arr;
|
return arr;
|
||||||
};
|
};
|
||||||
|
@ -6530,17 +6533,17 @@ abbr,acronym { border:0;}
|
||||||
if (code < 0x80) {
|
if (code < 0x80) {
|
||||||
bytes[index++] = code;
|
bytes[index++] = code;
|
||||||
} else if (code < 0x800) {
|
} else if (code < 0x800) {
|
||||||
bytes[index++] = (0xc0 | (code >> 6));
|
bytes[index++] = (0xc0 | (code >>> 6));
|
||||||
bytes[index++] = (0x80 | (code & 0x3f));
|
bytes[index++] = (0x80 | (code & 0x3f));
|
||||||
} else if (code < 0xd800 || code >= 0xe000) {
|
} else if (code < 0xd800 || code >= 0xe000) {
|
||||||
bytes[index++] = (0xe0 | (code >> 12));
|
bytes[index++] = (0xe0 | (code >>> 12));
|
||||||
bytes[index++] = (0x80 | ((code >> 6) & 0x3f));
|
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
|
||||||
bytes[index++] = (0x80 | (code & 0x3f));
|
bytes[index++] = (0x80 | (code & 0x3f));
|
||||||
} else {
|
} else {
|
||||||
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff));
|
code = 0x10000 + (((code & 0x3ff) << 10) | (key.charCodeAt(++i) & 0x3ff));
|
||||||
bytes[index++] = (0xf0 | (code >> 18));
|
bytes[index++] = (0xf0 | (code >>> 18));
|
||||||
bytes[index++] = (0x80 | ((code >> 12) & 0x3f));
|
bytes[index++] = (0x80 | ((code >>> 12) & 0x3f));
|
||||||
bytes[index++] = (0x80 | ((code >> 6) & 0x3f));
|
bytes[index++] = (0x80 | ((code >>> 6) & 0x3f));
|
||||||
bytes[index++] = (0x80 | (code & 0x3f));
|
bytes[index++] = (0x80 | (code & 0x3f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9656,6 +9659,8 @@ function hex2uint8(h) {
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var textFile = null,
|
var textFile = null,
|
||||||
makeTextFile = function(text) {
|
makeTextFile = function(text) {
|
||||||
|
@ -9701,6 +9706,58 @@ else if (m2) {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function copyOutputToClipboard() {
|
||||||
|
var targetBox = document.BWTC32Key.base32768textarea;
|
||||||
|
// https://stackoverflow.com/questions/51158061/copy-data-to-clipboard-without-selecting-any-text
|
||||||
|
// - restoring original selection doesn't seem to work
|
||||||
|
var origSelectionStart, origSelectionEnd;
|
||||||
|
origSelectionStart = targetBox.selectionStart;
|
||||||
|
origSelectionEnd = targetBox.selectionEnd;
|
||||||
|
// select the content
|
||||||
|
var currentFocus = document.activeElement;
|
||||||
|
targetBox.focus();
|
||||||
|
targetBox.setSelectionRange(0, targetBox.value.length);
|
||||||
|
var succeed;
|
||||||
|
try {
|
||||||
|
succeed = document.execCommand("copy");
|
||||||
|
} catch(e) {
|
||||||
|
succeed = false;
|
||||||
|
}
|
||||||
|
// restore original focus
|
||||||
|
if (currentFocus && typeof currentFocus.focus === "function") {
|
||||||
|
currentFocus.focus();
|
||||||
|
}
|
||||||
|
// restore prior selection
|
||||||
|
targetBox.setSelectionRange(origSelectionStart, origSelectionEnd);
|
||||||
|
};
|
||||||
|
|
||||||
|
function copyOutputToClipboard2() {
|
||||||
|
var targetBox2 = document.getElementById('textbox');
|
||||||
|
// https://stackoverflow.com/questions/51158061/copy-data-to-clipboard-without-selecting-any-text
|
||||||
|
// - restoring original selection doesn't seem to work
|
||||||
|
var origSelectionStart, origSelectionEnd;
|
||||||
|
origSelectionStart = targetBox2.selectionStart;
|
||||||
|
origSelectionEnd = targetBox2.selectionEnd;
|
||||||
|
// select the content
|
||||||
|
var currentFocus = document.activeElement;
|
||||||
|
targetBox2.focus();
|
||||||
|
targetBox2.setSelectionRange(0, targetBox2.value.length);
|
||||||
|
var succeed;
|
||||||
|
try {
|
||||||
|
succeed = document.execCommand("copy");
|
||||||
|
} catch(e) {
|
||||||
|
succeed = false;
|
||||||
|
}
|
||||||
|
// restore original focus
|
||||||
|
if (currentFocus && typeof currentFocus.focus === "function") {
|
||||||
|
currentFocus.focus();
|
||||||
|
}
|
||||||
|
// restore prior selection
|
||||||
|
targetBox2.setSelectionRange(origSelectionStart, origSelectionEnd);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
//]]>
|
//]]>
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue