apple.html 1.0 KB

123456789101112131415161718192021222324252627
  1. {% if site.app.ios_id %}
  2. <!-- iTunes Search API -->
  3. <script>
  4. $(function() {
  5. var API_URL = 'https://itunes.apple.com/lookup?id={{ site.app.ios_id }}&callback=?';
  6. $.getJSON(API_URL, function(res) {
  7. if (res.results && res.results.length) {
  8. console.info('App info successfully loaded from Apple');
  9. var appInfo = res.results[0];
  10. // App Icon
  11. var $appIcon = $('.app-icon');
  12. if ( $appIcon && !$appIcon.attr('src') && appInfo.artworkUrl512 ) {
  13. $appIcon.attr('src', appInfo.artworkUrl512);
  14. }
  15. // App Screenshot
  16. var $appScreenshot = $('.app-screenshot');
  17. if ( $appScreenshot && !$appScreenshot.attr('src') && appInfo.screenshotUrls && appInfo.screenshotUrls.length ) {
  18. $appScreenshot.attr('src', appInfo.screenshotUrls[0]);
  19. }
  20. } else {
  21. console.warn('Unable to load app info from Apple');
  22. }
  23. });
  24. });
  25. </script>
  26. <!-- End iTunes Search API -->
  27. {% endif %}