-
Notifications
You must be signed in to change notification settings - Fork 1
/
newArticle.js
34 lines (30 loc) · 1.09 KB
/
newArticle.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
/*
Emux Website
Copyright (C) Emux Technologies. All Rights Reserved.
https://emux.app
Licenced by the Emux Closed-Source Licence, which can be found at LICENCE.md.
*/
function postArticle() {
if (
$("#title").val().trim() != "" &&
$("#thumbnailUrl").val().trim() != "" &&
$("#thumbnailAlt").val().trim() != "" &&
$(".articleContents").html().trim() != ""
) {
$("#postArticleButton").prop("disabled", true);
firebaseEmux.database().ref("blog").push().set({
title: $("#title").val().trim(),
thumbnailSrc: $("#thumbnailUrl").val().trim(),
thumbnailAlt: $("#thumbnailAlt").val().trim(),
contents: $(".articleContents").html().trim(),
date: new Date().getTime(),
author: currentUser.uid,
authorName: currentUser.fullName,
authorJobTitle: currentUser.jobTitle
}).then(function() {
window.location.href = "/blog.html";
});
} else {
$("#error").text(_("Please fill in all of the required fields."));
}
}