diff --git a/assets/js/main.js b/assets/js/main.js index cadbbaa3..c3fb8e67 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -437,6 +437,7 @@ function getNodeType(jQuery, md5, url) { function directory(jQuery) { var parent = false; var md5Url = "posters.json"; + var md5OverrideUrl = "posters-overrides.json"; if (!urlExists(md5Url)) { errorMsg( @@ -446,6 +447,44 @@ function directory(jQuery) { return; } + if (!urlExists(md5OverrideUrl)) { + errorMsg( + jQuery, + "Could not find metadata overrides" + ); + return; + } + + let poster_json = null; + + $.ajax({ + async: false, + type: 'GET', + url: md5Url, + success: function(poster) { + $.ajax({ + async: false, + type: 'GET', + url: md5OverrideUrl, + success: function(overrides) { + poster["posters"].map( + function (e, i) { + Object.assign(e, overrides["posters"][i]); + }); + poster_json = poster; + } + }); + } + }); + + if (poster_json == null) { + errorMsg( + jQuery, + "Could not load metadata and/or metadata overrides" + ); + return; + } + // Embed the table placeholder jQuery('#content').prepend('
'); @@ -461,10 +500,11 @@ function directory(jQuery) { var table = jQuery('#directory').dataTable({ async: true, // async get json paging: false, // ensure scrolling instead of pages - ajax: { // specify url to get json from ajax - url: md5Url, - dataSrc: "posters" - }, + data: poster_json["posters"], + //ajax: { // specify url to get json from ajax + // url: md5Url, + // dataSrc: "posters" + //}, //order: [[6, "desc"], [0, 'asc']], columns: [ // select columns and their names from json {data: "number", title: "#", width: "5%"},