umer-wasim commited on
Commit
f53b034
·
verified ·
1 Parent(s): 19b2935

Website: Copy button copies without a pop-up

Browse files
Files changed (2) hide show
  1. index.html +0 -9
  2. site/site.js +3 -15
index.html CHANGED
@@ -179,15 +179,6 @@
179
  <div class="foot-links"><a href="#install">Install</a><a href="https://huggingface.co/spaces/Devseis/Arx/tree/main">Source</a><a href="https://huggingface.co/datasets/Devseis/endpoint-auditor-releases">Releases</a><a href="https://huggingface.co/Devseis/endpoint-auditor-0.5b">AI model</a><a href="CITATION.cff">Cite</a></div>
180
  </div>
181
  </footer>
182
- <div class="modal-back hidden" id="dlModal" role="dialog" aria-modal="true" aria-labelledby="dlModalTitle">
183
- <div class="modal">
184
- <button type="button" class="icon-btn modal-x" id="dlModalClose" aria-label="Close">✕</button>
185
- <p class="eyebrow">✓ Command copied</p>
186
- <h2 id="dlModalTitle">Now paste it in Terminal</h2>
187
- <div id="dlModalBody"></div>
188
- <button type="button" class="btn btn-primary" id="dlModalOk">Got it</button>
189
- </div>
190
- </div>
191
  <div class="toast hidden" id="toast" role="status"></div>
192
  <script type="module" src="site/site.js"></script>
193
  </body>
 
179
  <div class="foot-links"><a href="#install">Install</a><a href="https://huggingface.co/spaces/Devseis/Arx/tree/main">Source</a><a href="https://huggingface.co/datasets/Devseis/endpoint-auditor-releases">Releases</a><a href="https://huggingface.co/Devseis/endpoint-auditor-0.5b">AI model</a><a href="CITATION.cff">Cite</a></div>
180
  </div>
181
  </footer>
 
 
 
 
 
 
 
 
 
182
  <div class="toast hidden" id="toast" role="status"></div>
183
  <script type="module" src="site/site.js"></script>
184
  </body>
site/site.js CHANGED
@@ -55,24 +55,12 @@ const COMMANDS = {
55
  };
56
  const WHERE = { mac: 'Paste in Terminal and press Return', linux: 'Paste in a terminal and press Enter', windows: 'Paste in PowerShell and press Enter' };
57
 
58
- function openPasteModal(os) {
59
- const steps = document.querySelector(`.dl-card[data-os="${os}"] .paste-steps`);
60
- $('dlModalTitle').textContent = `Now paste it in ${os === 'windows' ? 'PowerShell' : 'Terminal'}`;
61
- $('dlModalBody').innerHTML = `<div class="cmd-box"><code>${esc(COMMANDS[os])}</code></div>` + (steps ? steps.outerHTML : '');
62
- $('dlModal').classList.remove('hidden');
63
- $('dlModalOk').focus();
64
- }
65
- const closeDlModal = () => $('dlModal').classList.add('hidden');
66
- $('dlModalClose').addEventListener('click', closeDlModal);
67
- $('dlModalOk').addEventListener('click', closeDlModal);
68
- $('dlModal').addEventListener('click', e => { if (e.target === $('dlModal')) closeDlModal(); });
69
- addEventListener('keydown', e => { if (e.key === 'Escape') closeDlModal(); });
70
  document.addEventListener('click', async e => {
71
  const b = e.target.closest('[data-copy-cmd]'); if (!b) return;
72
  const os = b.dataset.copyCmd === 'hero' ? state.os : b.dataset.copyCmd;
73
- try { await navigator.clipboard.writeText(COMMANDS[os]); } catch { /* the modal shows the command to copy by hand */ }
74
- b.textContent = 'Copied ✓'; setTimeout(() => { b.textContent = 'Copy'; }, 2000);
75
- openPasteModal(os);
76
  });
77
 
78
  function chooseOs(os) {
 
55
  };
56
  const WHERE = { mac: 'Paste in Terminal and press Return', linux: 'Paste in a terminal and press Enter', windows: 'Paste in PowerShell and press Enter' };
57
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  document.addEventListener('click', async e => {
59
  const b = e.target.closest('[data-copy-cmd]'); if (!b) return;
60
  const os = b.dataset.copyCmd === 'hero' ? state.os : b.dataset.copyCmd;
61
+ try { await navigator.clipboard.writeText(COMMANDS[os]); b.textContent = 'Copied ✓'; }
62
+ catch { toast('Select the command and copy it'); return; }
63
+ setTimeout(() => { b.textContent = 'Copy'; }, 2000);
64
  });
65
 
66
  function chooseOs(os) {