js/mobile: fix eslint and enable linting on build

lint the build file, as else eslint does not has the full picture.

Add a prelude to define globals once at the top

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-10-30 14:20:26 +01:00
parent f1bb77563c
commit f07b75b056
7 changed files with 25 additions and 15 deletions

View File

@ -56,7 +56,7 @@ distclean: clean
.PHONY: lint .PHONY: lint
lint: lint:
$(MAKE) -C js/ lint $(MAKE) -C js/ lint
#$(MAKE) -C js/mobile lint $(MAKE) -C js/mobile lint
clean: clean:
make -C js clean make -C js clean

View File

@ -1,6 +1,7 @@
# caution: order is important # caution: order is important
MOBILESRC= \ MOBILESRC= \
prelude.js \
component.js \ component.js \
loginscreen.js \ loginscreen.js \
mailview.js \ mailview.js \
@ -8,6 +9,9 @@ MOBILESRC= \
utils.js \ utils.js \
app.js \ app.js \
lint: pmgmanagerlib-mobile.js
eslint $^
pmgmanagerlib-mobile.js: ${MOBILESRC} pmgmanagerlib-mobile.js: ${MOBILESRC}
cat $^ >$@.tmp cat $^ >$@.tmp
mv $@.tmp $@ mv $@.tmp $@

View File

@ -1,5 +1,5 @@
var $$ = Dom7; $$ = Dom7;
var app = new Framework7({ app = new Framework7({
root: '#app', root: '#app',
init: false, init: false,
name: 'Proxmox Mail Gateway', name: 'Proxmox Mail Gateway',
@ -73,6 +73,6 @@ var app = new Framework7({
], ],
}); });
let quarlist = new QuarantineView(); let _quarantine_view = new QuarantineView();
app.init(); app.init();

View File

@ -52,7 +52,8 @@ class MailView extends Component {
</div> </div>
</div> </div>
<div class="page-content"> <div class="page-content">
<iframe frameborder=0 width="100%" height="100%" sandbox="allow-same-origin" src="/api2/htmlmail/quarantine/content?id={{mailid}}"></iframe> <iframe frameborder=0 width="100%" height="100%" sandbox="allow-same-origin"
src="/api2/htmlmail/quarantine/content?id={{mailid}}"></iframe>
</div> </div>
</div> </div>
`; `;

4
js/mobile/prelude.js Normal file
View File

@ -0,0 +1,4 @@
/* global Framework7, Template7, Dom7 */
var $$ = Dom7;
var app, PMG; // set in app.js

View File

@ -6,7 +6,8 @@ class QuarantineView extends Component {
<div class="navbar"> <div class="navbar">
<div class="navbar-inner"> <div class="navbar-inner">
<div class="left"> <div class="left">
<img class="logo-navbar" style="padding: 0 10px" src="pve2/images/logo-128.png" height=32 /> <img class="logo-navbar" style="padding: 0 10px"
src="pve2/images/logo-128.png" height=32 />
</div> </div>
<div class="title">Mail Gateway</div> <div class="title">Mail Gateway</div>
</div> </div>
@ -142,7 +143,7 @@ class QuarantineView extends Component {
}); });
// setup pull to refresh // setup pull to refresh
$$('.ptr-content').on('ptr:refresh', (e) => { $$('.ptr-content').on('ptr:refresh', (ev) => {
me.setItems([ me.setItems([
{ skel: true, divider: true }, { skel: true, divider: true },
{ skel: true }, { skel: true },
@ -167,7 +168,7 @@ class QuarantineView extends Component {
grouperFn: (val) => PMG.Utils.unixToIso(val.time), grouperFn: (val) => PMG.Utils.unixToIso(val.time),
}); });
}).catch(PMG.Utils.showError).then(() => { }).catch(PMG.Utils.showError).then(() => {
e.detail(); ev.detail();
}); });
}); });
@ -220,8 +221,8 @@ class QuarantineView extends Component {
let date = starttime; let date = starttime;
if (!(starttime instanceof Date)) { if (!(starttime instanceof Date)) {
// we assume an ISO string // we assume an ISO string
if (starttime == '') { if (starttime === '') {
return; return null;
} }
date = new Date(PMG.Utils.isoToUnix(starttime)*1000); date = new Date(PMG.Utils.isoToUnix(starttime)*1000);
} }
@ -238,8 +239,8 @@ class QuarantineView extends Component {
var me = this; var me = this;
let date = endtime; let date = endtime;
if (!(endtime instanceof Date)) { if (!(endtime instanceof Date)) {
if (endtime == '') { if (endtime === '') {
return; return null;
} }
// we assume an ISO string // we assume an ISO string
date = new Date(PMG.Utils.isoToUnix(endtime)*1000); date = new Date(PMG.Utils.isoToUnix(endtime)*1000);
@ -323,7 +324,7 @@ class QuarantineView extends Component {
for (let i = 0; i+offset < items.length; i++) { for (let i = 0; i+offset < items.length; i++) {
let item = items[i+offset]; let item = items[i+offset];
let curgroup = options.grouperFn(item); let curgroup = options.grouperFn(item);
if (curgroup != lastgroup) { if (curgroup !== lastgroup) {
me.vList.insertItemBefore(i+offset++, { me.vList.insertItemBefore(i+offset++, {
divider: true, divider: true,
group: curgroup, group: curgroup,

View File

@ -1,4 +1,4 @@
var PMG = { PMG = {
Utils: { Utils: {
getCookie(name) { getCookie(name) {
let cookies = document.cookie.split(/;\s*/); let cookies = document.cookie.split(/;\s*/);
@ -73,7 +73,7 @@ var PMG = {
let mail, action, date, username, ticket; let mail, action, date, username, ticket;
if (queryObj.ticket) { if (queryObj.ticket) {
let tocheck = decodeURIComponent(queryObj.ticket); let tocheck = decodeURIComponent(queryObj.ticket);
let match = tocheck.match(/^PMGQUAR:([^\s\:]+):/); let match = tocheck.match(/^PMGQUAR:([^\s:]+):/);
if (match) { if (match) {
ticket = tocheck; ticket = tocheck;
username = match[1]; username = match[1];