./webpack: remove some dead code

We haven't had DMG app builds for macOS for ages, so our download button
should always point to the /downloads/ page.
This commit is contained in:
Jakob Schnitzer 2022-12-17 08:47:53 +01:00
parent 279817f8df
commit c93bd86681
2 changed files with 34 additions and 67 deletions

View File

@ -1,5 +1,7 @@
require('bootstrap'); // @ts-check
var qs = require('query-string');
require("bootstrap");
var qs = require("query-string");
function selectText(text) { function selectText(text) {
if (document.body.createTextRange) { if (document.body.createTextRange) {
@ -16,100 +18,71 @@ function selectText(text) {
} }
function initBadges() { function initBadges() {
let badges = $('.badges li').hide(); let badges = $(".badges li").hide();
if (badges.length > 0) { if (badges.length > 0) {
window.setTimeout(function() { window.setTimeout(function () {
badges.fadeIn(500); badges.fadeIn(500);
}, 1500); }, 1500);
} }
} }
function initDownloadButton() { function initDownloadButton() {
let buttons = $('.download-btn'); const buttons = $(".download-btn");
if (buttons.length <= 0) { if (buttons.length <= 0) {
return; return;
} }
buttons.hide(); buttons.hide();
$.ajax({ $.ajax({
method: 'GET', method: "GET",
url: 'https://api.github.com/repos/lektor/lektor/releases', url: "https://api.github.com/repos/lektor/lektor/releases",
crossDomain: true crossDomain: true,
}).then((releases) => { }).then(
(releases) => {
updateDownloadButtons(buttons.toArray(), releases); updateDownloadButtons(buttons.toArray(), releases);
}, () => { },
() => {
buttons.show(); buttons.show();
});
}
function findBestTarget(assets) {
let matcher = null;
let note = null;
if (navigator.platform.match(/^mac/i)) {
matcher = /\.dmg$/;
note = 'For OSX 10.9 and later.';
} }
);
if (matcher != null) {
for (let i = 0; i < assets.length; i++) {
if (assets[i].name.match(matcher)) {
return {
url: assets[i].browser_download_url,
note: note
};
}
}
}
return null;
} }
function updateDownloadButtons(buttons, releases) { function updateDownloadButtons(buttons, releases) {
let tag = releases[0].tag_name; let tag = releases[0].tag_name;
let selectTarget = '/downloads/';
let assetTarget = findBestTarget(releases[0].assets);
buttons.forEach((button) => { buttons.forEach((button) => {
let note = $('<div class="note"></div>').appendTo(button); let link = $("a", button);
let link = $('a', button);
if (assetTarget) {
link.attr('href', assetTarget.url);
note.append($('<span></span>').text(assetTarget.note + ' '));
note.append(
$('<a>Other platforms</a>')
.attr('href', selectTarget));
} else {
link.attr('href', selectTarget);
}
link.attr("href", "/downloads/");
link.append($('<span class="version"></span>').text(tag)); link.append($('<span class="version"></span>').text(tag));
$(button).fadeIn('slow'); $(button).fadeIn("slow");
}); });
} }
function initInstallRow() { function initInstallRow() {
let code = $('.install-row pre'); let code = $(".install-row pre");
if (code.length > 0) { if (code.length > 0) {
code.on('dblclick', function() { code.on("dblclick", function () {
selectText(this); selectText(this);
}); });
} }
} }
function initGoogleSearch() { function initGoogleSearch() {
var container = $('.google-custom-search'); var container = $(".google-custom-search");
if (container.length == 0) { if (container.length == 0) {
return; return;
} }
var cx = '012722186170730423054:utwznhnrrmi'; var cx = "012722186170730423054:utwznhnrrmi";
var gcse = document.createElement('script'); var gcse = document.createElement("script");
gcse.type = 'text/javascript'; gcse.type = "text/javascript";
gcse.async = true; gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + gcse.src =
'//cse.google.com/cse.js?cx=' + cx; (document.location.protocol == "https:" ? "https:" : "http:") +
var s = document.getElementsByTagName('script')[0]; "//cse.google.com/cse.js?cx=" +
cx;
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(gcse, s); s.parentNode.insertBefore(gcse, s);
$(` $(`
@ -146,12 +119,12 @@ function initGoogleSearch() {
} }
function hideThingsForWindows() { function hideThingsForWindows() {
if (navigator.appVersion.indexOf('Win') >= 0) { if (navigator.appVersion.indexOf("Win") >= 0) {
$('.hide-for-windows').hide(); $(".hide-for-windows").hide();
} }
} }
$(function() { $(function () {
initBadges(); initBadges();
initDownloadButton(); initDownloadButton();
initInstallRow(); initInstallRow();

View File

@ -589,12 +589,6 @@ div.download-btn {
content: " "; content: " ";
} }
} }
div.note {
margin-top: 10px;
color: white;
font-size: 0.8em;
}
} }
p.meta { p.meta {