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, 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 this.grid.innerHTML = ''; var dbKeys = Object.keys(db); var i = 0; while (i < dbKeys.length) { this.buildEntry(db, dbKeys[i]); i++; } // LAYOUT if (SETTINGS.USEMASONRY) { this.msnry.reloadItems(); this.msnry.layout(); } var imgLoad = imagesLoaded( container ); // When all images finish: redo mansonry layout imgLoad.on( 'always', function() { parent.msnry.layout(); } ); } this.isDefined = function(value) { return (typeof value !== 'undefined'); } 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 (typeof value.QOTE !== 'undefined') { if (Array.isArray(value.QOTE) && value.QOTE.length > 4) { itemClass += " griditem-wide"; } } } if (SETTINGS.SHOWIMAG) { if (this.isDefined(value.TYPE) && value.TYPE == 'image') { itemClass += " griditem-image"; } } let entry = ``; // ITEM DIV entry += `