Skip to content

Commit

Permalink
OS-specific code
Browse files Browse the repository at this point in the history
  • Loading branch information
sporeball committed Dec 17, 2024
1 parent 99bd37f commit 14f1ce1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
9 changes: 5 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,17 @@ <h1>kicad-wakatime</h1>
<p>
<b>kicad-wakatime</b> is a WakaTime plugin for KiCAD 8.99.
<br>
current version: <b>0.1.1</b>
current version: <b id="kicad-wakatime-version">0.1.1</b>
</p>
<p><i>installation video coming soon...</i></p>
<!-- <iframe width="560" height="315" src="https://www.youtube.com/embed/ScMzIvxBSi4?si=A9bapybv7nWouqH0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> -->
<p><a href="https://github.com/hackclub/kicad-wakatime/releases/download/0.1.1/kicad-wakatime-0.1.1-windows.zip">install for Windows</a></p>
<p><a href="https://github.com/hackclub/kicad-wakatime/releases/download/0.1.1/kicad-wakatime-0.1.1-macos.zip">install for macOS</a></p>
<p><a href="https://github.com/hackclub/kicad-wakatime/releases/download/0.1.1/kicad-wakatime-0.1.1-linux.zip">install for Linux</a></p>
<p id="download-kicad"></p>
<p id="download-kicad-wakatime"></p>
<p><small>(detected os: <span id="os">unknown</span>)</small></p>
</main>
<footer>
<p><small>(c) 2024 <a href="https://hackclub.com">Hack Club</a></small></p>
</footer>
<script src="script.js"></script>
</body>
</html>
28 changes: 28 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const ua = navigator?.userAgent.toLowerCase();
// const os = 'unknown';
const os = ua.includes('win') ? 'windows'
: ua.includes('mac') ? 'macos'
: ua.includes('linux') ? 'linux'
: 'unknown';

const kicad_wakatime_version = document.getElementById('kicad-wakatime-version').innerHTML;

const e_download_kicad = document.getElementById('download-kicad');
const e_download_kicad_wakatime = document.getElementById('download-kicad-wakatime');
const e_download_kicad_href = os == 'windows' ? 'https://downloads.kicad.org/kicad/windows/explore/nightlies'
: os == 'macos' ? 'https://downloads.kicad.org/kicad/macos/explore/nightlies'
: os == 'linux' ? 'https://www.kicad.org/download/linux'
: null;
const e_download_kicad_wakatime_href = os == 'windows' ? 'https://github.com/hackclub/kicad-wakatime/releases/download/0.1.1/kicad-wakatime-0.1.1-windows.zip'
: os == 'macos' ? 'https://github.com/hackclub/kicad-wakatime/releases/download/0.1.1/kicad-wakatime-0.1.1-macos.zip'
: os == 'linux' ? 'https://github.com/hackclub/kicad-wakatime/releases/download/0.1.1/kicad-wakatime-0.1.1-linux.zip'
: 'https://github.com/hackclub/kicad-wakatime/releases/tag/0.1.1'

document.getElementById('os').innerHTML = os;

e_download_kicad.innerHTML = os == 'windows' ? `<a href="${e_download_kicad_href}" target="_blank">download KiCAD 8.99 (.exe)</a>`
: os == 'macos' ? `<a href="${e_download_kicad_href}" target="_blank">download KiCAD 8.99 (.dmg)</a>`
: os == 'linux' ? `<a href="${e_download_kicad_href}" target="_blank">download KiCAD 8.99 (instructions)</a>`
: `download KiCAD 8.99: <a href="https://www.kicad.org/download/linux" target="_blank">Linux</a> or <a href="https://downloads.kicad.org/kicad" target="_blank">not Linux</a>`;

e_download_kicad_wakatime.innerHTML = `<a href="${e_download_kicad_wakatime_href}" target="_blank">download kicad-wakatime (.zip)</a>`;

0 comments on commit 14f1ce1

Please sign in to comment.