Fetch releases from GitHub API

This commit is contained in:
hensm
2019-01-13 21:27:44 +00:00
parent 836f0b6933
commit 3667a2ab8f
4 changed files with 86 additions and 8 deletions

View File

@@ -103,6 +103,11 @@ body {
color: var(--text-color-secondary);
font-size: 0.8em;
}
.discription__prerelease {
color: var(--red-50);
font-size: 0.8em;
font-weight: bolder;
}
.description p {
margin: 1rem 0;
@@ -140,6 +145,14 @@ body {
margin-right: 1rem;
}
.app-list__app-label {
color: var(--blue-40);
font-size: 0.8em;
font-variant: small-caps;
margin-left: 5px;
vertical-align: super;
}
.preview {
grid-area: preview;

View File

@@ -7,6 +7,8 @@
<link rel="stylesheet" href="photon-colors.css">
<link rel="stylesheet" href="photon.css">
<link rel="stylesheet" href="index.css">
<script src="index.js" defer></script>
</head>
<body>
<div class="container">
@@ -18,30 +20,36 @@
<main class="main-content">
<section class="description">
<p>
Enables Chromecast support for casting web apps (like Netflix, YouTube or BBC iPlayer), HTML5 video and screen/tab sharing.
Enables Chromecast support for casting web apps (like Netflix, <s>YouTube</s> or BBC iPlayer), HTML5 video and screen/tab sharing.
</p>
<p class="discription__disclaimer">
Requires a native bridge app to connect with receiver devices. Currently supported on Windows, macOS and Linux.
<br><br>
<strong>No public full release yet!</strong>
</p>
<p class="discription__prerelease">
No full public release yet! Pre-release beta version is incomplete and likely buggy.
</p>
</section>
<section class="download">
<a class="download__ext btn btn--puffy btn--primary" href="#" disabled>
<a class="download__ext btn btn--puffy btn--primary" disabled title="No available download found">
<img class="btn__icon" src="icons/extension_light.svg" alt="">
Firefox Extension
</a>
<div class="download__app">
<div class="app-list">
<div class="app-list__label">Bridge:</div>
<a class="app-list__app btn btn--puffy" href="#" disabled>
<a class="app-list__app app-list__win btn btn--puffy" disabled title="No available download found">
Windows
</a>
<a class="app-list__app app-list__mac btn btn--puffy" disabled title="No available download found">
macOS
</a>
<a class="app-list__app btn btn--puffy" href="#" disabled>
<a class="app-list__app app-list__deb btn btn--puffy" disabled title="No available download found">
Linux
<span class="app-list__app-label">deb</span>
</a>
<a class="app-list__app btn btn--puffy" href="#" disabled>
Windows
<a class="app-list__app app-list__rpm btn btn--puffy" disabled title="No available download found">
Linux
<span class="app-list__app-label">rpm</span>
</a>
</div>
</div>

56
docs/index.js Normal file
View 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");
}

View File

@@ -71,6 +71,7 @@ select.btn:-moz-focusring {
.btn[disabled] {
background-color: var(--btn-bg) !important;
box-shadow: initial;
cursor: default;
opacity: 0.4;
}