From 030d63a4cf6f9eeb2d812e058985c6bbdb913986 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=B6nch?= Date: Fri, 26 Jun 2020 10:40:01 +0200 Subject: [PATCH] NF: handle overrides in main.js --- assets/js/main.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/assets/js/main.js b/assets/js/main.js index ae9d7154..5ea6c051 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -125,7 +125,6 @@ function errorMsg(jQuery, msg) { * @param {object} jQuery jQuery library object * @param {object} md5 md5 library object * @param {string} url leaf url to start caching from upto root - * @param {object} json metadata json object * @return {string} returns the type of the node at path */ function getNodeType(jQuery, md5, url) { @@ -179,7 +178,6 @@ function getNodeType(jQuery, md5, url) { /** * render the datatable interface based on current node metadata * @param {object} jQuery jQuery library object - * @param {object} md5 md5 library object * @return {object} returns the rendered DataTable object */ function directory(jQuery) { @@ -198,9 +196,9 @@ function directory(jQuery) { let table = jQuery('#directory').DataTable({ //async: true, // async get json - paging: true, // ensure scrolling instead of pages + paging: true, rowId: 'id', - columns: [ + columns: [ {data: "number", title: "#", width: "5%"}, {data: "title", title: "Title", className: "dt-left", width: "42%"}, {data: "presenter", title: "Presenter", className: "dt-center", width: "15%"}, @@ -245,7 +243,7 @@ function directory(jQuery) { return 'PDF'; //return 'PDF'; //return 'PDF'; - } + } }, } ], @@ -254,6 +252,19 @@ function directory(jQuery) { //load posters fetch("posters.json").then(res=>res.json()).then(data=>{ + // Synchronously fetch the overrides, in order to modify posters before adding rows to the table + $.ajax({ + async: false, + type: 'GET', + url: "posters-overrides.json", + success: function (overrides) { + data.posters.map( + function (e, i) { + Object.assign(e, overrides.posters[i]); + }); + } + }); + data.posters.forEach(p=>{ p.id = 'p'+p.number; //cannot be number (or string of number) p.people = 0;