From 14f1ce1db2b174d41d76b4fc3bdbdc7d6f53ce03 Mon Sep 17 00:00:00 2001 From: sporeball Date: Tue, 17 Dec 2024 15:21:12 -0500 Subject: [PATCH] OS-specific code --- index.html | 9 +++++---- script.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 script.js diff --git a/index.html b/index.html index c400ed6..1a1c357 100644 --- a/index.html +++ b/index.html @@ -12,16 +12,17 @@

kicad-wakatime

kicad-wakatime is a WakaTime plugin for KiCAD 8.99.
- current version: 0.1.1 + current version: 0.1.1

installation video coming soon...

-

install for Windows

-

install for macOS

-

install for Linux

+

+

+

(detected os: unknown)

+ \ No newline at end of file diff --git a/script.js b/script.js new file mode 100644 index 0000000..2ea0fcd --- /dev/null +++ b/script.js @@ -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' ? `download KiCAD 8.99 (.exe)` + : os == 'macos' ? `download KiCAD 8.99 (.dmg)` + : os == 'linux' ? `download KiCAD 8.99 (instructions)` + : `download KiCAD 8.99: Linux or not Linux`; + +e_download_kicad_wakatime.innerHTML = `download kicad-wakatime (.zip)`; \ No newline at end of file