Move pages.meet painting to a .paint() method

This commit is contained in:
Niko 2022-02-16 21:22:51 +01:00
parent 4c562ebaff
commit 4b494dcc7a
1 changed files with 49 additions and 42 deletions

View File

@ -1,13 +1,24 @@
app.pages.meet = {
data: [],
load: function(args) {
document.querySelector('#page-meet').removeAttribute('style');
const dom = document.querySelector('#page-meet #content');
dom.innerHTML = '';
document.querySelector('#page-meet').removeAttribute('style');
http.get('/api/v1/feed/meet', {}, function(json) {
if (json === undefined) return;
app.pages.meet.data = json;
app.template.loadMany(['meet.item','meet.actions'], function(_) {
var _;
app.pages.meet.paint(json);
});
});
},
paint: function(json) {
json = json || app.pages.meet.data;
let _;
_ = function () {
const dom = document.querySelector('#page-meet #content');
dom.innerHTML = '';
for (var i = 0; i < json.length; i++) {
var tpl = app.template.fill(json[i], app.template.get('meet.item'),
function (k,v) {
@ -43,12 +54,8 @@ app.pages.meet = {
var tpl = app.template.fill({}, app.template.get('meet.actions'));
dom.innerHTML += tpl;
}; _();
var index = app.storage.get('status_meet_index');
if (index === undefined)
index = 0;
var index = app.storage.get('status_meet_index') || 0;
app.pages.meet.carousel.set(parseInt(index));
});
});
},
exit: function() {
window.location.href = '#';