blob: 7fac8226ac4297f22e07edf80cb1fd5064ee8bc7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<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 %}
|