blob: 4dfb91797de4d866f27ff22ec276e452566ddfc7 (
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
68
69
70
71
72
73
74
75
|
{% if site.ios_app_id %}
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function () {
const iosAppId = "{{ site.ios_app_id }}";
const iosAppCountry = "{{ site.ios_app_country }}";
if (iosAppId) {
$.ajax({
url: "https://itunes.apple.com/lookup",
dataType: "jsonp",
data: {
id: iosAppId,
country: iosAppCountry
},
success: function (json) {
if (json.results && json.results.length) {
console.info("Image strings loaded from Apple API.");
const appInfo = json.results[0];
const favicon = $('link[rel="shortcut icon"]');
if (favicon.length) favicon.attr("href", appInfo.artworkUrl512);
const pageTitle = $(".pageTitle");
if (pageTitle.length && pageTitle.text().trim().length === 0) {
pageTitle.text(appInfo.trackName);
}
const appIconLarge = $("#largeIcon");
if (appIconLarge.length && (!appIconLarge.attr("src") || appIconLarge.attr("src") === "{{ '/assets/placeholder-icon.png' | relative_url }}")) {
appIconLarge.attr("src", appInfo.artworkUrl512);
}
const appIconHeader = $("#headerIcon");
if (appIconHeader.length && (!appIconHeader.attr("src") || appIconHeader.attr("src") === "{{ '/assets/placeholder-icon.png' | relative_url }}")) {
appIconHeader.attr("src", appInfo.artworkUrl512);
console.log(appInfo.artworkUrl512);
}
const appName = $("#appName");
if (appName.length && (appName.text().trim().length === 0 || appName.text().trim() === "Your App Name")) {
appName.text(appInfo.trackName);
}
const headerName = $("#headerName");
if (headerName.length && (headerName.text().trim().length === 0 || headerName.text().trim() === "Your App Name")) {
headerName.text(appInfo.trackName);
}
const appPrice = $("#appPrice");
if (appPrice.length && appPrice.text().trim().length === 0) {
appPrice.text(appInfo.formattedPrice);
}
const appStoreLink = $("#appStoreLink");
if (appStoreLink.length && appStoreLink.attr("href").trim().length === 0) {
appStoreLink.attr("href", appInfo.trackViewUrl);
}
const appDescription = $("#appDescription");
if (appDescription.length && appDescription.text().trim().length === 0) {
appDescription.text(appInfo.description);
}
console.info(appInfo);
}
},
error: function (xhr, status, error) {
console.error("Error fetching App Store info:", error);
}
});
}
});
</script>
{% endif %}
|