Move pages.meet painting to a .paint() method
This commit is contained in:
parent
4c562ebaff
commit
4b494dcc7a
|
@ -1,55 +1,62 @@
|
|||
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 _;
|
||||
_ = function () {
|
||||
for (var i = 0; i < json.length; i++) {
|
||||
var tpl = app.template.fill(json[i], app.template.get('meet.item'),
|
||||
function (k,v) {
|
||||
if (k === 'text') return html2text(v);
|
||||
if (k === 'account.name') return capitalize(v);
|
||||
if (k === 'date') return dayjs(v).fromNow(true);
|
||||
});
|
||||
var item = json[i];
|
||||
if (item.props === undefined)
|
||||
item.props = { pcolors: {} }
|
||||
if (item.account.props.pcolors === undefined)
|
||||
item.account.props.pcolors = {};
|
||||
|
||||
var postFgColor = item.account.props.pcolors.fg
|
||||
|| app.vars.defaults.meet.item_pcolors.fg;
|
||||
var postBgColor = item.account.props.pcolors.bg
|
||||
|| app.vars.defaults.meet.item_pcolors.bg;
|
||||
if (item.props.pcolors.fg !== undefined)
|
||||
postFgColor = item.props.pcolors.fg;
|
||||
if (item.props.pcolors.bg !== undefined)
|
||||
postBgColor = item.props.pcolors.bg;
|
||||
|
||||
tpl = tpl.replaceAll('{actionsHeight}', '6em');
|
||||
tpl = tpl.replaceAll('{postFgColor}', htmlescape(postFgColor));
|
||||
tpl = tpl.replaceAll('{postBgColor}', htmlescape(postBgColor));
|
||||
dom.innerHTML += tpl;
|
||||
}
|
||||
}; _();
|
||||
_ = function () {
|
||||
const dom = document.querySelector('#page-meet #actions');
|
||||
dom.innerHTML = '';
|
||||
dom.style.height = '6em';
|
||||
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;
|
||||
app.pages.meet.carousel.set(parseInt(index));
|
||||
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) {
|
||||
if (k === 'text') return html2text(v);
|
||||
if (k === 'account.name') return capitalize(v);
|
||||
if (k === 'date') return dayjs(v).fromNow(true);
|
||||
});
|
||||
var item = json[i];
|
||||
if (item.props === undefined)
|
||||
item.props = { pcolors: {} }
|
||||
if (item.account.props.pcolors === undefined)
|
||||
item.account.props.pcolors = {};
|
||||
|
||||
var postFgColor = item.account.props.pcolors.fg
|
||||
|| app.vars.defaults.meet.item_pcolors.fg;
|
||||
var postBgColor = item.account.props.pcolors.bg
|
||||
|| app.vars.defaults.meet.item_pcolors.bg;
|
||||
if (item.props.pcolors.fg !== undefined)
|
||||
postFgColor = item.props.pcolors.fg;
|
||||
if (item.props.pcolors.bg !== undefined)
|
||||
postBgColor = item.props.pcolors.bg;
|
||||
|
||||
tpl = tpl.replaceAll('{actionsHeight}', '6em');
|
||||
tpl = tpl.replaceAll('{postFgColor}', htmlescape(postFgColor));
|
||||
tpl = tpl.replaceAll('{postBgColor}', htmlescape(postBgColor));
|
||||
dom.innerHTML += tpl;
|
||||
}
|
||||
}; _();
|
||||
_ = function () {
|
||||
const dom = document.querySelector('#page-meet #actions');
|
||||
dom.innerHTML = '';
|
||||
dom.style.height = '6em';
|
||||
var tpl = app.template.fill({}, app.template.get('meet.actions'));
|
||||
dom.innerHTML += tpl;
|
||||
}; _();
|
||||
var index = app.storage.get('status_meet_index') || 0;
|
||||
app.pages.meet.carousel.set(parseInt(index));
|
||||
},
|
||||
exit: function() {
|
||||
window.location.href = '#';
|
||||
app.overlay.hideAll();
|
||||
|
|
Loading…
Reference in New Issue