let projects = [], languages = []; let antiCacheQuery = '?_=' + new Date().getTime(); function preload(){ loadJSON("index_data/projects.json" + antiCacheQuery, parseProjects); } function setup(){ noCanvas(); displayProjects(); } function parseProjects(projectObj){ for (let l of projectObj['languages']){ let language = {}; for (let key in l) language[key] = l[key]; languages.push(language); } for (let p of projectObj['projects']) { if (!p.visible) continue; let project = new Project(p); projects.push(project); } } function displayProjects(){ for (let p of projects){ let img = $(''); img.addClass('project-image'); p.putImage(img); let name = $('
'); name.addClass('project-name'); name.text(p.displayName); let version = $(''); version.addClass('project-version'); version.text(p.version); let info = $(''); info.addClass('project-info'); info.html(p.info); let start = $(''); start.addClass('project-start'); start.text('Start'); start.click(() => p.start()); let download = $(''); download.addClass('project-download'); download.text('Download'); download.click(() => p.download()); let description = $(''); description.addClass('project-description'); description.append(name, version, info, start, download); let dom = $(''); dom.addClass('project'); dom.append(img, description); $('#projects-container').append(dom); } } class Project{ constructor(p){ for (let key in p) this[key] = p[key]; for (let l of languages){ if (l.id === p['languageId']) this.language = l; } this.location = "projects/" + this.language.name + "/" + this['name']; } start(){ window.location = this.location; } download(){ window.location = this.location + '.zip'; } putImage(dom){ dom.attr("src", 'index_data/thumbnails/' + this['name'] + '.png'); } }