mirror of
https://github.com/hensm/fx_cast.git
synced 2026-06-08 08:39:59 +00:00
Fetch releases from GitHub API
This commit is contained in:
56
docs/index.js
Normal file
56
docs/index.js
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
const ENDPOINT_URL = "https://api.github.com/repos/hensm/fx_cast/releases/14720978";
|
||||
|
||||
fetch(ENDPOINT_URL)
|
||||
.then(res => res.json())
|
||||
.then(onResponse)
|
||||
.catch(onError);
|
||||
|
||||
function onResponse (res) {
|
||||
for (const asset of res.assets) {
|
||||
const { browser_download_url } = asset;
|
||||
|
||||
// Ext download button
|
||||
const downloadExtBtn = document.querySelector(".download__ext");
|
||||
|
||||
// App download buttons
|
||||
const appListMacBtn = document.querySelector(".app-list__mac");
|
||||
const appListDebBtn = document.querySelector(".app-list__deb");
|
||||
const appListRpmBtn = document.querySelector(".app-list__rpm");
|
||||
|
||||
|
||||
switch (asset.name.match(/.*\.(.*)$/).pop()) {
|
||||
case "xpi":
|
||||
downloadExtBtn.href = browser_download_url;
|
||||
downloadExtBtn.removeAttribute("disabled");
|
||||
downloadExtBtn.removeAttribute("title");
|
||||
break;
|
||||
|
||||
case "exe":
|
||||
appListWinBtn.href = browser_download_url;
|
||||
appListWinBtn.removeAttribute("disabled");
|
||||
appListWinBtn.removeAttribute("title");
|
||||
break;
|
||||
case "pkg":
|
||||
appListMacBtn.href = browser_download_url;
|
||||
appListMacBtn.removeAttribute("disabled");
|
||||
appListMacBtn.removeAttribute("title");
|
||||
break;
|
||||
case "deb":
|
||||
appListDebBtn.href = browser_download_url;
|
||||
appListDebBtn.removeAttribute("disabled");
|
||||
appListDebBtn.removeAttribute("title");
|
||||
break;
|
||||
case "rpm":
|
||||
appListRpmBtn.href = browser_download_url;
|
||||
appListRpmBtn.removeAttribute("disabled");
|
||||
appListRpmBtn.removeAttribute("title");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onError (err) {
|
||||
console.error("Failed to fetch download links");
|
||||
}
|
||||
Reference in New Issue
Block a user