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, SHOWTYPE: true, SHOWLINK: true, SHOWLOWER: true, SHOWTAGS: 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: '.grid-item', 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 = ''; 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.buildEntry = function(db, key) { let value = db[key]; let itemClass = "grid-item"; if (SETTINGS.WIDEGRIDITEM) { if (typeof value.WIDE !== 'undefined' && value.WIDE) { itemClass += " grid-item--width2"; } else if (typeof value.QOTE !== 'undefined') { if (Array.isArray(value.QOTE) && value.QOTE.length > 4) { itemClass += " grid-item--width2"; } } } if (SETTINGS.SHOWIMAG) { if (typeof value.TYPE !== 'undefined' && value.TYPE == 'image') { itemClass += " grid-item-image"; } } let entry = ``; // ITEM DIV entry += `