$(document).ready(function() {
  // Create the list of image divs with papers using galpy
  $.getJSON("http://www.galpy.org.s3-website.us-east-2.amazonaws.com/data/papers-using-galpy.json")
    .done(function(data) {
    // First update the number of papers using galpy listed on the page
    let paperSpan= document.getElementById("span-number-of-papers-using-galpy");
    paperSpan.innerHTML= (Math.floor((Object.keys(data).length-1)/50)*50).toFixed(0);
    // randomize array to create random starting point, https://stackoverflow.com/a/56448185/10195320
      function shuffle(obj){
        // new obj to return
        let newObj = {};
        // create keys array
        var keys = Object.keys(obj);
        // randomize keys array
        keys.sort(function(a,b){return Math.random()- 0.5;});
        // save in new array
        keys.forEach(function(k) {
          newObj[k] = obj[k];
        });
        return newObj;
      }
      $.each(shuffle(data),function(key,bibentry) {
        if ( key != "_template" && bibentry.hasOwnProperty("img")) {
	    $("<div>").attr("id",`${key}-div1`).addClass("responsive").appendTo("#papers-gallery");
	    $("<div>").attr("id",`${key}-div2`).addClass("gallery").appendTo(`#${key}-div1`);
	    $("<a>").attr("id",`${key}-link`).attr("href",bibentry.url).attr("target","_blank")
		.attr("alt",`Figure from ${bibentry.title}, ${bibentry.author} (${bibentry.year}), ${bibentry.journal} ${bibentry.volume}, ${bibentry.pages}`)
		.attr("title",`Figure from ${bibentry.title}, ${bibentry.author} (${bibentry.year}), ${bibentry.journal} ${bibentry.volume}, ${bibentry.pages}`).appendTo(`#${key}-div2`);
	    $("<div>").attr("id",key).addClass("papers-gallery-item").appendTo(`#${key}-link`);
	    $("<img>").attr("src","http://www.galpy.org.s3-website.us-east-2.amazonaws.com/data/paper-figs/"+bibentry.img).appendTo(`#${key}`);
	    $("<div>"+`<font size="-3"><i>${bibentry.title}</i>, ${bibentry.author} (${bibentry.year}), ${bibentry.journal} ${bibentry.volume}, ${bibentry.pages}</font>`+"</div>").addClass("desc").appendTo(`#${key}-div2`);
	}
	  });
      })
      .fail(function(jqxhr, textStatus, error ) {
        console.log( "Failed to load JSON gallery file");
	$("#gallery-intro").remove();
        $("#gallery-div").remove();
	  });
});

@@ -2213,75 +2213,404 @@
 );%0A%09
-$(%22#gallery-intro%22).remove();%0A        $(%22#gallery-div%22).remove();%0A%09
+// Add div with warning that the gallery failed to load%0A%09$(%22%3Cdiv%3E%22).attr(%22id%22,%22papers-warning%22).addClass(%22admonition warning%22).appendTo(%22#papers-gallery%22);%0A%09$(%22%3Cp%3EWarning%3C/p%3E%22).addClass(%22admonition-title%22).appendTo(%22#papers-warning%22);%0A%09$(%22%3Cp%3EFailed to load papers gallery.%3C/p%3E%22).appendTo(%22#papers-warning%22);%0A%09// Make sure the warning spans the page%0A%09$(%22#papers-gallery%22).css(%22width%22,%22100%25%22);%0A    
   %7D)

Put warning when papers gallery fails to load [ci skip]