function View() { this.msnry = null; this.overlay = null; this.container = null; this.grid = null; this.menu = null; var parent = this; const SETTINGS = { STATSNUMTAGS: 5, STATSNUMTYPE: 10, WIDEGRIDITEM: true, USEMASONRY: true, GRIDITEMIDBASE: 'item', SHOWUPPER: true, SHOWTITLE: true, SHOWAUTH: true, SHOWTYPE: true, SHOWLINK: true, SHOWLOWER: true, SHOWTAGS: true, SHOWPROJ: true, SHOWNOTE: true, SHOWQOTE: true, SHOWTERM: true, SHOWPROG: true, SHOWIMAG: true, SHOWFILE: true, SHOWOVERLAY: true } this.install = function() { this.overlay = document.getElementById("overlay"); this.container = document.getElementById("container"); this.grid = document.getElementById("grid"); this.menu = document.getElementById("menu"); if (SETTINGS.USEMASONRY) { this.msnry = new Masonry('.grid', { itemSelector: '.griditem', columnWidth: 350, gutter: 20, fitWidth: true, transitionDuration: 0, }); } } this.display = function(db) { if (window.showAdd !== undefined && window.showAdd) { main.add.setOverlay(false); } // BUILD let dbKeys = Object.keys(db); let i = 0; let contentHtml = ''; while (i < dbKeys.length) { contentHtml += this.buildEntry(db, dbKeys[i]); i++; } this.grid.innerHTML = contentHtml; // LAYOUT if (SETTINGS.USEMASONRY) { this.msnry.reloadItems(); this.msnry.layout(); } let imgLoad = imagesLoaded( container ); // When all images finish: redo mansonry layout imgLoad.on( 'always', function() { parent.msnry.layout(); } ); } this.buildEntry = function(db, key) { let value = db[key]; let itemClass = "griditem"; if (SETTINGS.WIDEGRIDITEM) { if (this.isDefined(value.WIDE) && value.WIDE) { itemClass += " griditem-wide"; } else if (this.isDefined(value.QOTE)) { if (Array.isArray(value.QOTE) && value.QOTE.length > 4) { itemClass += " griditem-wide"; } } } if (SETTINGS.SHOWIMAG && this.isDefined(value.TYPE) && value.TYPE[0] === 'image') { itemClass += " griditem-image"; } let entry = ``; // ITEM DIV entry += `