Qrious/docs/_includes/appstoreimages.html

67 lines
2.3 KiB
HTML
Raw Permalink Normal View History

2020-07-24 07:27:23 +01:00
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
{% if site.ios_app_id %}
<script>
$(function() {
var apiURL = "https://itunes.apple.com/lookup?id={{ site.ios_app_id }}&callback=?";
$.getJSON(apiURL, function(json) {
if (json.results && json.results.length) {
console.info("Image strings loaded from Apple API.");
var appInfo = json.results[0];
// Set favicon
$('link[rel="shortcut icon"]').attr("href", appInfo.artworkUrl512);
// Set page title using the iOS app ID if it is not set manually in _config.yml
var $pageTitle = $(".pageTitle");
if ($.trim($($pageTitle).text()).length == 0) {
$($pageTitle).html(appInfo.trackName);
}
// Set large app icon using the iOS app ID if it is not set manually in _config.yml
var $appIconLarge = $(".appIconLarge");
if (!$appIconLarge.attr('src')) {
$($appIconLarge).attr("src", appInfo.artworkUrl512);
}
// Set header app icon using the iOS app ID if it is not set manually in _config.yml
var $appIconHeader = $(".headerIcon");
if (!$appIconHeader.attr('src')) {
$($appIconHeader).attr("src", appInfo.artworkUrl512);
}
// Set app name using the iOS app ID if it is not set manually in _config.yml
var $appName = $(".appName");
var $headerName = $(".headerName");
if ($.trim($($appName).text()).length == 0) {
$($appName).html(appInfo.trackName);
$($headerName).html(appInfo.trackName);
}
// Set price using the iOS app ID if it is not set manually in _config.yml
var $appPrice = $(".appPrice");
if ($.trim($($appPrice).text()).length == 0) {
$($appPrice).html(appInfo.formattedPrice);
}
// Set App Store link using the iOS app ID if it is not set manually in _config.yml
var $appStoreLink = $(".appStoreLink");
if ($.trim($appStoreLink.attr('href')).length == 0) {
$($appStoreLink).attr("href", appInfo.trackViewUrl);
}
console.info(appInfo);
}
});
});
</script>
{% endif %}