Share platform-aware install markup and copy behavior between the landing page and authenticated dashboard.
- commit
- 10ec0c8b2d636311d70acfcb7669e7f1bcfcab22
- parent
- 8fe0e91e40f224ae578129bb862f71933b5dc1fa
- author
- Dami <dami.etoile@gmail.com>
| M | web/ | 63 | +++++++++++++++++++----------- |
@@ -453,13 +453,13 @@ function openService(item) {
453453 454454 // -- setup views ---------------------------------------------------------------455455 456-function renderSignedOut() {457- setPageTitle('home');458- clearTheme();459- document.querySelector('.brand strong').hidden = true;456+function prefersHomebrewInstall() {460457 const platform = navigator.userAgentData?.platform || navigator.platform || '';461- const isMacOS = /mac/i.test(platform) || /Macintosh|Mac OS X/i.test(navigator.userAgent);462- const installControl = isMacOS458+ return /mac/i.test(platform) || /Macintosh|Mac OS X/i.test(navigator.userAgent);459+}460+461+function installControlMarkup() {462+ return prefersHomebrewInstall()463463 ? `<fieldset role="group">464464 <input id="install-command" aria-label="Homebrew install command"465465 value="brew install FelineStateMachine/tap/devsite" readonly>@@ -471,6 +471,31 @@ function renderSignedOut() {
471471 <a href="https://github.com/FelineStateMachine/devsite/releases/latest"472472 role="button">Download</a>473473 </fieldset>`;474+}475+476+function bindInstallControl() {477+ const installCommand = $('install-command');478+ const copyInstall = $('copy-install');479+ if (!installCommand || !copyInstall) return;480+481+ let copyReset;482+ copyInstall.addEventListener('click', async () => {483+ try {484+ await navigator.clipboard.writeText(installCommand.value);485+ copyInstall.textContent = 'Copied';486+ clearTimeout(copyReset);487+ copyReset = setTimeout(() => { copyInstall.textContent = 'Copy'; }, 1400);488+ } catch {489+ copyInstall.textContent = 'Select';490+ installCommand.select();491+ }492+ });493+}494+495+function renderSignedOut() {496+ setPageTitle('home');497+ clearTheme();498+ document.querySelector('.brand strong').hidden = true;474499 main.innerHTML = `475500 <article>476501 <hgroup>@@ -504,7 +529,7 @@ function renderSignedOut() {
504529 505530 <section aria-labelledby="install-title">506531 <h2 id="install-title">Install</h2>507- ${installControl}532+ ${installControlMarkup()}508533 </section>509534 510535 <hr>@@ -544,23 +569,7 @@ function renderSignedOut() {
544569 target="_blank" rel="noopener">GitHub</a></li></ul>545570 </nav>`;546571 pageFooter.hidden = false;547-548- if (isMacOS) {549- const installCommand = $('install-command');550- const copyInstall = $('copy-install');551- let copyReset;552- copyInstall.addEventListener('click', async () => {553- try {554- await navigator.clipboard.writeText(installCommand.value);555- copyInstall.textContent = 'Copied';556- clearTimeout(copyReset);557- copyReset = setTimeout(() => { copyInstall.textContent = 'Copy'; }, 1400);558- } catch {559- copyInstall.textContent = 'Select';560- installCommand.select();561- }562- });563- }572+ bindInstallControl();564573 }565574 566575 function renderClaimHandle() {@@ -816,6 +825,11 @@ async function showDashboard(newCredential = null) {
816825 </details>817826 </article>818827 828+ <article aria-labelledby="install-title">829+ <header id="install-title">Install</header>830+ ${installControlMarkup()}831+ </article>832+819833 <article>820834 <header><strong>Session</strong></header>821835 <button id="logout" type="button" class="secondary outline">Log out</button>@@ -855,6 +869,7 @@ async function showDashboard(newCredential = null) {
855869 }856870 857871 $('logout').addEventListener('click', (event) => signOut(event.currentTarget));872+ bindInstallControl();858873 859874 $('private-only').addEventListener('change', async (event) => {860875 const input = event.currentTarget;