frontend linting

This commit is contained in:
Thomas Rudin 2019-12-07 17:56:18 +01:00
parent 9b0e6edae4
commit 920fa47e72
11 changed files with 37 additions and 37 deletions

2
.jshintignore Normal file
View File

@ -0,0 +1,2 @@
public/js/bundle.js
public/js/lib/*

View File

@ -4,7 +4,7 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "jshint src/"
"test": "jshint public/js/ src/"
},
"author": "",
"license": "ISC",

View File

@ -1,2 +0,0 @@
bundle.js
lib/*

View File

@ -4,7 +4,8 @@
"esversion": 6,
"browser": true,
"globals": {
"L": true,
"webmail": true,
"moment": true,
"m": true
}
}

View File

@ -7,7 +7,7 @@ api.fetchMails = function(){
url: "api/inbox",
headers: { "authorization": webmail.token }
});
}
};
api.deleteMail = function(index){
return m.request({
@ -15,7 +15,7 @@ api.deleteMail = function(index){
url: "api/inbox/" + index,
headers: { "authorization": webmail.token }
});
}
};
api.markRead = function(index){
return m.request({
@ -24,7 +24,7 @@ api.markRead = function(index){
data: { index: index },
headers: { "authorization": webmail.token }
});
}
};
api.sendMail = function(recipient, subject, text){
return m.request({
@ -37,14 +37,14 @@ api.sendMail = function(recipient, subject, text){
},
headers: { "authorization": webmail.token }
});
}
};
api.verifyToken = function(){
return m.request({
url: "api/verify",
headers: { "authorization": webmail.token }
});
}
};
api.login = function(username, password){
return m.request({
@ -52,11 +52,11 @@ api.login = function(username, password){
url: "api/login",
data: { username: username, password: password }
});
}
};
//publish
window.webmail.api = api;
})();
})();

View File

@ -3,7 +3,7 @@
var state = webmail.compose;
var Compose = {
view: function(vnode){
view: function(){
return [
m("div", {class:"row"}, [
m("input[type=text]", {
@ -49,7 +49,7 @@
m("div", {class:"col-md-2"}),
m("form", {class:"col-md-8"}, m(Compose)),
m("div", {class:"col-md-2"})
])
]);
else
return null;
@ -58,4 +58,4 @@
})();
})();

View File

@ -12,17 +12,17 @@
disabled: !state.username || !state.password,
onclick: function(){ webmail.service.login(state.username, state.password); }
}, [spinner, " Login ", infoText]);
}
};
var LogoutButton = function(){
return m("button[type=submit]", {
class:"btn btn-sm btn-block btn-secondary",
onclick: webmail.service.logout
}, "Logout");
}
};
var LoginForm = {
view: function(vnode){
view: function(){
return [
m("div", {class:"row"}, [
m("h3", "Webmail login")
@ -50,7 +50,7 @@
])
];
}
}
};
webmail.routes["/login"] = {
view: function(){
@ -64,4 +64,4 @@
}
};
})();
})();

View File

@ -33,10 +33,9 @@
m("h2", mail.subject),
m("h5", [ "From: ", m("b", mail.sender), replyBtn ]),
m("h5", [ "Sent: ", m("b", timeStr) ]),
m("div", body),
]
m("div", body)
];
}
};
})();
})();

View File

@ -43,7 +43,7 @@
};
var InboxTable = {
view: function(vnode){
view: function(){
if (!webmail.mails){
return m("div", "Loading...");
}
@ -76,4 +76,4 @@
}
};
})();
})();

View File

@ -28,7 +28,7 @@
}
m.mount(document.getElementById("nav"), {
view: function(vnode){
view: function(){
return m("nav", {class:"navbar navbar-dark bg-dark fixed-top navbar-expand-lg"}, NavBarContent());
}
});

View File

@ -40,20 +40,20 @@ service.login = function(username, password){
state.errorMsg = "Login failed: " + result.message;
}
})
.catch(function(err){
.catch(function(){
state.errorMsg = "System error!";
state.busy = false;
});
}
};
service.logout = function(){
state.loggedIn = false;
webmail.mails = [];
//clear token
webmail.token = null;
delete localStorage["webmail-token"];
}
};
service.fetchMails = function(){
if (!webmail.mails || !webmail.mails.length){
@ -62,7 +62,7 @@ service.fetchMails = function(){
webmail.mails = result;
});
}
}
};
service.countUnread = function(){
var count = 0;
@ -74,14 +74,14 @@ service.countUnread = function(){
}
return count;
}
};
service.sendMail = function(){
webmail.api.sendMail(webmail.compose.recipient, webmail.compose.subject, webmail.compose.body);
webmail.compose.recipient = "";
webmail.compose.subject = "";
webmail.compose.body = "";
}
};
service.reply = function(index){
var mail = service.readMail(index);
@ -89,7 +89,7 @@ service.reply = function(index){
webmail.compose.subject = "Re: " + mail.subject;
webmail.compose.body = "\n---- Original message ----\n" + mail.body;
m.route.set("/compose");
}
};
service.readMail = function(index){
if (webmail.mails && webmail.mails.length){
@ -106,7 +106,7 @@ service.readMail = function(index){
return mail;
}
}
};
service.deleteMail = function(index){
return webmail.api.deleteMail(index)
@ -119,10 +119,10 @@ service.deleteMail = function(index){
return mail;
});
});
}
};
webmail.service = service;
})(webmail.loginState);
})(webmail.loginState);