Refactoring. Client has no global names anymore, and no inline scripts
This commit is contained in:
parent
5b98424bc6
commit
be61601950
@ -1,3 +1,6 @@
|
|||||||
|
/* Executed after page loading */
|
||||||
|
(function () {
|
||||||
|
|
||||||
class JeanCloudContactFormNotifier {
|
class JeanCloudContactFormNotifier {
|
||||||
constructor (theme, messageContainer) {
|
constructor (theme, messageContainer) {
|
||||||
/* Choose the theme */
|
/* Choose the theme */
|
||||||
@ -112,7 +115,6 @@ function jeanCloudContactFormIntercept (formId, notifier) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
(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(/\/[^\/]*$/, ''))
|
||||||
|
|
||||||
@ -125,6 +127,15 @@ function jeanCloudContactFormIntercept (formId, notifier) {
|
|||||||
link.integrity = 'sha384-D12RSMaIURTgZZljhdQqYlQzgEfXvOFwtiqzkWnNcDbKFwMWXcmsCRFO5BNii0MB'
|
link.integrity = 'sha384-D12RSMaIURTgZZljhdQqYlQzgEfXvOFwtiqzkWnNcDbKFwMWXcmsCRFO5BNii0MB'
|
||||||
// cat style.css | openssl dgst -sha384 -binary | openssl base64 -A
|
// cat style.css | openssl dgst -sha384 -binary | openssl base64 -A
|
||||||
document.head.appendChild(link);
|
document.head.appendChild(link);
|
||||||
|
|
||||||
|
/* Load the targeted forms */
|
||||||
|
var configs = document.getElementsByClassName('contact-form-config')
|
||||||
|
for (var i=0; i<configs.length; i++) {
|
||||||
|
var formId = configs[i].getAttribute('form-id')
|
||||||
|
var theme = configs[i].getAttribute('notify-theme')
|
||||||
|
jeanCloudContactFormIntercept(formId, new JeanCloudContactFormNotifier(theme))
|
||||||
|
}
|
||||||
|
|
||||||
|
var contactMailerPageLoadedTime = Date.now()
|
||||||
})()
|
})()
|
||||||
|
|
||||||
var contactMailerPageLoadedTime = Date.now()
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "jean-cloud-contact-mailer-client",
|
"name": "jean-cloud-contact-mailer-client",
|
||||||
"version": "1.1.5",
|
"version": "1.1.6",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -6,9 +6,9 @@
|
|||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="contact-mailer-message"></div>
|
<div id="contact-mailer-message"></div>
|
||||||
<form action="http://localhost:8080/submit" method="POST" id="contact-mailer-form">
|
<form action="/api/submit" method="POST" id="contact-mailer-form">
|
||||||
<noscript>Les protections anti-spam, nécéssitent l’utilisation de javascript. Rien d’intrusif normalement.</noscript>
|
<noscript>Les protections anti-spam, nécéssitent l’utilisation de javascript. Rien d’intrusif normalement.</noscript>
|
||||||
<input type="hidden" name="token" value="PK8gQHDx9VoJ7yuEhbj5iCZkcUOAqTYlRSN14XFtdfr3LBs0zn" />
|
<input type="hidden" name="token" value="5NwE8KOzhinBLVloZrvfb71WJeQ6sXc4xgC0AqFPDHGMjIdmUk" />
|
||||||
<div>
|
<div>
|
||||||
<label for="nom">Votre nom :</label>
|
<label for="nom">Votre nom :</label>
|
||||||
<input type="text" name="nom" required="required"/>
|
<input type="text" name="nom" required="required"/>
|
||||||
@ -27,11 +27,10 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="objet">Votre message :</label>
|
<label for="objet">Votre message :</label>
|
||||||
<textarea name="message" required="required"></textarea>
|
<textarea name="message"></textarea>
|
||||||
</div>
|
</div>
|
||||||
<input type="submit" />
|
<input type="submit" />
|
||||||
</form>
|
</form>
|
||||||
<script src="./client/index.js"></script>
|
<script class="contact-form-config" form-id="contact-mailer-form" notify-theme="dark" src="./client/index.js"></script>
|
||||||
<script> jeanCloudContactFormIntercept ('contact-mailer-form', new JeanCloudContactFormNotifier()) </script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user