Compare commits

..

No commits in common. "5714519a2e84e0b03e6741a96118f58ebda15ece" and "5aaac71f6b27f4832940a8a19d3941469862578e" have entirely different histories.

5 changed files with 27 additions and 29 deletions

View File

@ -1,7 +1,9 @@
function jeanCloudContactMailerMessage (messageContainer, theme, level, text) { (function () {
function message (messageContainer, level, text) {
/* This function displays a message on top of the form */ /* This function displays a message on top of the form */
const messageElement = document.createElement('p') const messageElement = document.createElement('p')
const messageId = 'contact-mailer-' + theme + '-message-' + level const messageId = 'contact-mailer-message-' + level
messageContainer.appendChild(messageElement) messageContainer.appendChild(messageElement)
messageElement.textContent = text messageElement.textContent = text
messageElement.classList.add('contact-mailer-message') messageElement.classList.add('contact-mailer-message')
@ -24,12 +26,12 @@ function jeanCloudContactMailerMessage (messageContainer, theme, level, text) {
}, 10000) }, 10000)
} }
function jeanCloudContactFormIntercept (formId, theme) { function interceptForm (formId) {
/* /*
* This function intercepts a form submission and send it via XHR. * This function intercepts a form submission and send it via XHR.
* Param formId is the HTML id of the form * Param formId is the HTML id of the form
*/ */
const formElem = document.getElementById(formId) const formElem = document.getElementById(formId)
if (!formElem) { if (!formElem) {
console.error('You tried to intercept form id:"' + formId + '" but it was not found.') console.error('You tried to intercept form id:"' + formId + '" but it was not found.')
return return
@ -56,30 +58,31 @@ function jeanCloudContactFormIntercept (formId, theme) {
.then(data => { .then(data => {
loadingText.parentNode.removeChild(loadingText) loadingText.parentNode.removeChild(loadingText)
if (!data.ok || data.status == 500) { if (!data.ok || data.status == 500) {
jeanCloudContactMailerMessage (messageBox, theme, 'error', 'Erreur du service denvoi. Réessayez plus tard ou contactez https://jean-cloud.net') message(messageBox, 'error', 'Erreur du service denvoi. Réessayez plus tard ou contactez https://jean-cloud.net')
} else if (data.ok || data.status == 200) { } else if (data.ok || data.status == 200) {
jeanCloudContactMailerMessage (messageBox, theme, 'success', 'Le message a bien été envoyé !') message(messageBox, 'success', 'Le message a bien été envoyé !')
formElem.reset() formElem.reset()
} }
}) })
.catch((error) => { .catch((error) => {
loadingText.parentNode.removeChild(loadingText) loadingText.parentNode.removeChild(loadingText)
jeanCloudContactMailerMessage (messageBox, theme, 'error', 'Impossible denvoyer le formulaire. Vérifiez votre connexion internet ou réessayez plus tard.') message(messageBox, 'error', 'Impossible denvoyer le formulaire. Vérifiez votre connexion internet ou réessayez plus tard.')
}) })
} }
} }
(function () { /* Get the current js file location */
/* Get the current js file location */ const path = (document.currentScript.src[-1] == '/' ? document.currentScript.src : document.currentScript.src.replace(/\/[^\/]*$/, ''))
const path = (document.currentScript.src[-1] == '/' ? document.currentScript.src : document.currentScript.src.replace(/\/[^\/]*$/, ''))
/* Adding a css file */
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.crossOrigin = 'anonymous';
link.href = path + "/style.css";
link.integrity = 'sha384-9kSXtY4xhTP1f97JTT2J8tEHj1thIUfd9Ub7yOFsGLBQ/impvue07/UN1MhyCcyP'
document.head.appendChild(link);
interceptForm ('contact-mailer-form')
/* Adding a css file */
var link = document.createElement("link");
link.type = "text/css";
link.rel = "stylesheet";
link.crossOrigin = 'anonymous';
link.href = path + "/style.css";
link.integrity = 'sha384-8PWvFCRowSxssUyiGirvpq/Nh6TTzYrsbAmpC0cw/OUKkZibNdI5L1gFiHxfrTZT'
// cat style.css | openssl dgst -sha384 -binary | openssl base64 -A
document.head.appendChild(link);
})() })()

View File

@ -1,6 +1,6 @@
{ {
"name": "jean-cloud-contact-mailer-client", "name": "jean-cloud-contact-mailer-client",
"version": "1.0.15", "version": "1.0.8",
"description": "", "description": "",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {

View File

@ -9,13 +9,13 @@
cursor:pointer; cursor:pointer;
} }
.contact-mailer-plain-message-error { .contact-mailer-message-error {
color: white; color: white;
background-color: #ef4757; background-color: #ef4757;
border-color: #ef4757; border-color: #ef4757;
} }
.contact-mailer-plain-message-success { .contact-mailer-message-success {
color: white; color: white;
background-color: #00B06A; background-color: #00B06A;
border-color: #00B06A; border-color: #00B06A;

View File

@ -75,10 +75,6 @@ You can store them in a `.env` file. The python app will read it or you can pass
- `ADMIN_PASSWORD` password used to manage users - `ADMIN_PASSWORD` password used to manage users
- `UID` used to set the uwsg socket ownership in production - `UID` used to set the uwsg socket ownership in production
## Client
plain or light theme.
## Roadmap ## Roadmap
### Near future ### Near future
- go on docker hub - go on docker hub

View File

@ -27,6 +27,5 @@
<input type="submit" /> <input type="submit" />
</form> </form>
<script src="./client/index.js"></script> <script src="./client/index.js"></script>
<script> jeanCloudContactFormIntercept ('contact-mailer-form', 'light') </script>
</body> </body>
</html> </html>