PluginProbe
The WP Remote WordPress Plugin / 6.76
The WP Remote WordPress Plugin v6.76
6.76 6.72 6.69 6.65 6.62 6.48 6.47 4.87 4.97 5.05 5.09 5.16 5.22 5.24 5.25 5.38 5.41 5.42 5.45 5.47 5.53 5.56 5.65 5.68 5.72 All 54 releases
wpremote / js / connection-key.js

connection-key.js in The WP Remote WordPress Plugin 6.76, at js/connection-key.js

61 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function() {
2 document.addEventListener('DOMContentLoaded', function() {
3 var section = document.getElementById('wpr-show-connection-key');
4 var toggleLink = document.getElementById('wpr-show-connection-key-link');
5 var keyField = document.getElementById('wpr-connection-key');
6 var viewButton = document.getElementById('wpr-view-connection-key');
7 var copyButton = document.getElementById('wpr-copy-connection-key');
8 if (!section || !keyField || !viewButton || !copyButton) {
9 return;
10 }
11
12 if (toggleLink) {
13 toggleLink.addEventListener('click', function(event) {
14 event.preventDefault();
15 section.style.display = 'block';
16 toggleLink.style.display = 'none';
17 });
18 }
19
20 viewButton.addEventListener('click', function() {
21 if (keyField.type === 'password') {
22 keyField.type = 'text';
23 viewButton.textContent = 'Hide Key';
24 } else {
25 keyField.type = 'password';
26 viewButton.textContent = 'View Key';
27 }
28 });
29
30 copyButton.addEventListener('click', function() {
31 var previousType = keyField.type;
32 keyField.type = 'text';
33
34 var updateCopyState = function() {
35 copyButton.textContent = 'Copied!';
36 setTimeout(function() {
37 copyButton.textContent = 'Copy Key';
38 }, 2000);
39 };
40
41 var restoreField = function() {
42 keyField.type = previousType;
43 };
44
45 if (navigator.clipboard && navigator.clipboard.writeText) {
46 navigator.clipboard.writeText(keyField.value).then(function() {
47 updateCopyState();
48 }).finally(function() {
49 restoreField();
50 });
51 return;
52 }
53
54 keyField.select();
55 document.execCommand('copy');
56 updateCopyState();
57 restoreField();
58 });
59 });
60 })();
61