2021-07-10 12:16:13 +02:00
|
|
|
function getOs() {
|
|
|
|
if (navigator.appVersion.indexOf("Win")!=-1) return "windows";
|
|
|
|
if (navigator.appVersion.indexOf("Mac")!=-1) return "macOs";
|
|
|
|
if (navigator.appVersion.indexOf("X11")!=-1) return "linux";
|
|
|
|
if (navigator.appVersion.indexOf("Linux")!=-1) return "linux";
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2021-07-10 13:40:48 +02:00
|
|
|
function getMobileOs() {
|
|
|
|
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
|
|
|
|
|
|
|
|
// Windows Phone must come first because its UA also contains "Android"
|
|
|
|
if (/windows phone/i.test(userAgent)) {
|
|
|
|
return "windowsPhone";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (/android/i.test(userAgent)) {
|
|
|
|
return "android";
|
|
|
|
}
|
|
|
|
|
|
|
|
// iOS detection from: http://stackoverflow.com/a/9039885/177710
|
|
|
|
if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
|
|
|
|
return "ios";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-07-10 12:16:13 +02:00
|
|
|
function setupMobileMenu() {
|
|
|
|
$("#open-menu-mobile").click(function () {
|
|
|
|
$("#menu-mobile").animate({ "margin-right": "0px" }, 300);
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#close-menu-mobile").click(function () {
|
|
|
|
$("#menu-mobile").animate({ "margin-right": "-300px" }, 300);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function setupDownloadPage() {
|
|
|
|
if (!$('.page-download').length) return;
|
|
|
|
|
|
|
|
const downloadLinks = {};
|
|
|
|
|
|
|
|
$('.page-download .get-it-desktop a').each(function() {
|
|
|
|
const href = $(this).attr('href');
|
|
|
|
|
|
|
|
if (href.indexOf('-Setup') > 0) downloadLinks['windows'] = href;
|
|
|
|
if (href.indexOf('.dmg') > 0) downloadLinks['macOs'] = href;
|
|
|
|
if (href.indexOf('.AppImage') > 0) downloadLinks['linux'] = href;
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.page-download .get-it-desktop').hide();
|
|
|
|
|
|
|
|
$('.page-download .download-click-here').click((event) => {
|
|
|
|
event.preventDefault();
|
|
|
|
$('.page-download .get-it-desktop').show(500);
|
|
|
|
});
|
|
|
|
|
2021-07-10 13:40:48 +02:00
|
|
|
const mobileOs = getMobileOs();
|
|
|
|
|
|
|
|
if (mobileOs) {
|
|
|
|
$('.page-download .intro').hide();
|
2021-07-10 12:16:13 +02:00
|
|
|
} else {
|
2021-07-10 13:40:48 +02:00
|
|
|
const os = getOs();
|
|
|
|
if (!os || !downloadLinks[os]) {
|
2021-07-11 20:20:18 +02:00
|
|
|
// If we don't know, display the section to manually download the app
|
2021-07-10 13:40:48 +02:00
|
|
|
$('.page-download .get-it-desktop').show();
|
2021-07-11 20:20:18 +02:00
|
|
|
} else if (os === 'linux') {
|
|
|
|
// If it's Linux, the user should probably install it using the
|
|
|
|
// install script so we redirect to the install section
|
|
|
|
window.location = 'https://joplinapp.org/help/#desktop-applications';
|
2021-07-10 13:40:48 +02:00
|
|
|
} else {
|
2021-07-11 20:20:18 +02:00
|
|
|
// Otherwise, start the download
|
2021-07-10 13:40:48 +02:00
|
|
|
window.location = downloadLinks[os];
|
|
|
|
}
|
2021-07-10 12:16:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-04 19:14:32 +02:00
|
|
|
$(function () {
|
2021-07-10 12:16:13 +02:00
|
|
|
setupMobileMenu();
|
|
|
|
setupDownloadPage();
|
2021-07-04 19:14:32 +02:00
|
|
|
});
|