// download package list as soon as possible
$.get("/api/packages").done(function(json) {
var packageList = json.result;
// wait until the DOM has finished loading before rendering the results
$(function() {
const optpkgTemplate =
'
');
if (jqxhr.status == 502) {
swal({
icon: "error",
title: "Unavailable",
content: $content.html('Sorry, the build server is down for maintenance right now. You can try again later or
download pre-built Caddy binaries from GitHub.')[0]
});
} else {
swal({
icon: "error",
title: "Build failed",
content: $content.html('The two most common reasons are:
- A plugin is not compiling. The developer must release a new version that compiles.
- The build configuration is invalid. If you specified any versions, make sure they are correct and within the same major version as the path of the associated package.
In the meantime, you can
download Caddy from GitHub without any plugins.')[0]
});
}
}
function updatePage() {
$('#package-count').text($('.optpkg.selected').length);
$('#download').attr('href', getDownloadLink());
}
function disableFields(building) {
$('#download, #optional-packages').addClass('disabled');
$('.download-bar select, #optional-packages input').prop('disabled', true);
if (building) {
$('#download').html('
Building');
// prevent accidentally leaving the page during a build
window.onbeforeunload = function() {
return "Your custom build is in progress.";
};
} else {
$('#download').html('Builds Unavailable');
}
}
function enableFields() {
$('#download, #optional-packages').removeClass('disabled');
$('.download-bar select, #optional-packages input').prop('disabled', false);
$('#download').html(downloadButtonHtml);
// allow user to leave page easily
window.onbeforeunload = null;
}
var downloadButtonHtml; // to restore button to its original contents