Add message and close link to HTML form
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Nicolas COMPAIN 2024-01-28 11:47:55 +00:00
parent 714c84b35d
commit ae611fd970
2 changed files with 34 additions and 3 deletions

View File

@ -2,7 +2,7 @@
"name": "nwb/multi-downloader-client",
"description": "Client for multi-downloader-service",
"type": "library",
"version": "0.0.9",
"version": "0.1.9",
"autoload": {
"psr-4": {
"Nwb\\MultiDownloaderClient\\": "src/"

View File

@ -19,6 +19,17 @@ use Nwb\MultiDownloaderClient\MultiDownloaderClient;
body {
display: inline;
}
#message {
text-align: center;
margin-top: 20px;
}
#close-link {
display: block;
text-align: center;
margin-top: 10px;
}
</style>
</head>
@ -26,18 +37,38 @@ use Nwb\MultiDownloaderClient\MultiDownloaderClient;
<div id="button_div" class="modal-dialog-buttons">
<form name="f" id="f" method="POST" action="<?= $this->url ?>/v2/form/zip<?= $zipName ?>" enctype="multipart/form-data">
<input type="hidden" name="json" value='<?= json_encode($this->buildRequest()) ?>' />
<noscript>
<button id="submit_approve_access" type="submit" tabindex="1" style="overflow:visible;">Continue</button>
</noscript>
</form>
</div>
<div id="message"></div>
<div id="close-link">
<a href="javascript:void(0);" onclick="window.close();">Close this tab</a>
</div>
<script type="text/javascript">
var messages = {
'en': 'Your download will begin shortly. This page will close automatically.',
'fr': 'Votre téléchargement va commencer. Cette page se fermera automatiquement.'
};
var closeLinkMessages = {
'en': 'Close this page',
'fr': 'Fermer cette page'
};
var userLang = navigator.language || navigator.userLanguage;
userLang = userLang.split('-')[0];
document.getElementById('message').innerText = messages[userLang] || messages['en'];
document.getElementById('close-link').getElementsByTagName('a')[0].innerText = closeLinkMessages[userLang] || closeLinkMessages['en'];
document.forms['f'].submit();
window.setTimeout(function() {
window.close();
}, 2000); // Attend 2 secondes avant de fermer la fenêtre
}, 2000); // 2 secondes
</script>
</body>