-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
34 lines (32 loc) · 1.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(()=>{
const template = Handlebars.compile($('#painting-template').html());
const base_url = window.location.origin + (window.location.pathname.replace(/[^\\\/]*$/, '') || '/');
const apainter_url = 'https://aframe.io/a-painter/';
const $paintings = $('.paintings');
let $currow = null;
let c = 0;
const load_painting = (name) => {
$.get('./paintings/'+name+'/about.json').done(about=>{
if(c%3 == 0){
$currow = $('<div class="row"></div>');
$paintings.append($currow);
}
c++;
let context = {
name: about.name,
authors: about.authors,
created: moment(about.created).format('llll'),
imageurl: `${base_url}paintings/${name}/Screenshot.png`,
url: `${apainter_url}?url=${about.url}`,
desc: about.desc || ""
};
$currow.append(template(context));
});
};
$.get('./paintings/files.json').done(files=>{
files.forEach(file=>{
load_painting(file);
});
});
$(".button-collapse").sideNav();
})();