1
0

Merge branch 'add-attachment' of DTux/avion-poeme into master

This commit is contained in:
DTux 2021-11-03 08:22:07 +00:00 committed by Gogs
commit 8d8ea7adf3
7 changed files with 109 additions and 98 deletions

View File

@ -1,37 +1,31 @@
<?php <?php
require_once 'session_init.php'; require_once 'session_init.php';
require_once 'config.inc.php'; require_once 'config.inc.php';
require_once 'db.class.php'; require_once 'db.class.php';
require_once 'log.php'; require_once 'log.php';
require_once 'fonctions.inc.php'; require_once 'fonctions.inc.php';
$table=array("message", "expeMail", "expeKnown", "expeLang", "destLang", "startLat", "startLon", "startName", "startTime", "startTZ", "destMail", "destLat", "destLon", "destName", "public", "color", "deliveryTime", "deliveryTZ", "deliveryTimeServer", "deliveryMethod"); $table = array("message", "expeMail", "expeKnown", "expeLang", "destLang", "startLat", "startLon", "startName", "startTime", "startTZ", "destMail", "destLat", "destLon", "destName", "public", "color", "deliveryTime", "deliveryTZ", "deliveryTimeServer", "deliveryMethod");
$db = new db(); $db = new db();
//$db->open(); //$db->open();
foreach ($table as $var) foreach ($table as $var) {
{ if (getpost($var) != null) {
if ( getpost( $var ) != null ) $r = getpost($var);
{
$r = getpost( $var );
/*if ( $r == "true") /*if ( $r == "true")
{ {
$r = 1; $r = 1;
}elseif( $r ="false")*/ }elseif( $r ="false")*/
$db->$var = trim($r, ' \"'); $db->$var = trim($r, ' \"');
}else } else {
{
$erreur[] = $var; $erreur[] = $var;
} }
} }
if (!empty ($erreur)) if (!empty($erreur)) {
{
echo json_encode($erreur); echo json_encode($erreur);
log_error("erreur lors de l'acquisition des données:" . EOLH . print_r($erreur, true)); log_error("erreur lors de l'acquisition des données:" . EOLH . print_r($erreur, true));
}else } else {
{
$db->newPlane(); $db->newPlane();
} }
$db->close(); $db->close();
?>

View File

@ -213,4 +213,3 @@
} }
} }
$db->close(); $db->close();
?>

View File

@ -54,6 +54,13 @@
<br> <br>
<div class="form-control rounded-0" id="messageTextArea"></div> <div class="form-control rounded-0" id="messageTextArea"></div>
</div> </div>
<div class="form-group">
<label class="bold">Ajouter une piève jointe</label>
<div class="custom-file">
<input type="file" class="custom-file-input" id="attachmentPlane" aria-describedby="inputGroupFileAddon01">
<label class="custom-file-label" for="attachmentPlane"></label>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="bold" for="selectTime" id="flightTime">Temps de vol</label> <label class="bold" for="selectTime" id="flightTime">Temps de vol</label>
<select class="form-control" id="selectTime"> <select class="form-control" id="selectTime">

View File

@ -336,3 +336,7 @@ a#navbarDropdownLang.nav-link.dropdown-toggle::after {
text-align: center; text-align: center;
} }
} }
.custom-file-label::after {
content: "Parcourir";
}

View File

@ -18,6 +18,12 @@ $("#destMail").change(function() {
checkFormValid() checkFormValid()
}) })
document.querySelector('.custom-file-input').addEventListener('change',function(e){
var fileName = document.getElementById("attachmentPlane").files[0].name;
var nextSibling = e.target.nextElementSibling
nextSibling.innerText = fileName
})
function checkFormValid(){ function checkFormValid(){
if(validExpeMail && validExpeLoc && validDestMail && validDestLoc){ if(validExpeMail && validExpeLoc && validDestMail && validDestLoc){
$('#sendNewPlane').prop("disabled", false) $('#sendNewPlane').prop("disabled", false)

View File

@ -109,7 +109,29 @@ $("#sendNewPlane").on('click',function(){
var randomColor = getRandomColor() var randomColor = getRandomColor()
console.log(message) var formData = new FormData()
var attachment = $("#attachmentPlane").prop('files')[0];
formData.append('file', attachment);
formData.append('message', encodeURIComponent(message));
formData.append('expeMail', $("#expeMail").val());
formData.append('expeKnown', expeKnown);
formData.append('expeLang', lang);
formData.append('destLang', $("#selectDestLang").val());
formData.append('startLat', expeLoc.center[1]);
formData.append('startLon', expeLoc.center[0]);
formData.append('startName', expeLoc.name);
formData.append('startTime', sentDate);
formData.append('startTZ', expeTimezone);
formData.append('destMail', $("#destMail").val());
formData.append('destLat', destLoc.center[1]);
formData.append('destLon', destLoc.center[0]);
formData.append('destName', destLoc.name);
formData.append('public', publicMessage, );
formData.append('color', randomColor);
formData.append('deliveryTime', deliveryDate);
formData.append('deliveryTZ', destTimezone);
formData.append('deliveryTimeServer', deliverySecondsServer);
formData.append('deliveryMethod', $("#selectTime").val());
var data = { var data = {
'message':encodeURIComponent(message), 'message':encodeURIComponent(message),
@ -131,39 +153,22 @@ $("#sendNewPlane").on('click',function(){
'deliveryTime':deliveryDate, 'deliveryTime':deliveryDate,
'deliveryTZ':destTimezone, 'deliveryTZ':destTimezone,
'deliveryTimeServer':deliverySecondsServer, 'deliveryTimeServer':deliverySecondsServer,
'deliveryMethod':$("#selectTime").val() 'deliveryMethod':$("#selectTime").val(),
} }
$.ajax({
var query = 'avionpoeme.php?'+ url: 'avionpoeme.php',
'message='+data.message+'&'+ data: formData,
'expeMail='+data.expeMail+'&'+ processData: false,
'expeKnown='+data.expeKnown+'&'+ contentType: false,
'expeLang='+data.expeLang+'&'+ cache : false,
'destLang='+data.destLang+'&'+ type: 'POST',
'startLat='+data.startLat+'&'+ success: function(result){
'startLon='+data.startLon+'&'+
'startName='+data.startName+'&'+
'startTime='+data.startTime+'&'+
'startTZ='+data.startTZ+'&'+
'destMail='+data.destMail+'&'+
'destLat='+data.destLat+'&'+
'destLon='+data.destLon+'&'+
'destName='+data.destName+'&'+
'public='+data.public+'&'+
'color='+data.color+'&'+
'deliveryTime='+data.deliveryTime+'&'+
'deliveryTZ='+data.deliveryTZ+'&'+
'deliveryTimeServer='+data.deliveryTimeServer+'&'+
'deliveryMethod='+data.deliveryMethod+'';
$.post(query, function(result) {
result = result.replace(/'/g, '"'); result = result.replace(/'/g, '"');
console.log(result)
result = $.parseJSON(result) result = $.parseJSON(result)
var planeId = Number(result.uid); var planeId = Number(result.uid);
//selecting proper color for back //selecting proper color for back
$("#back").attr("src","src/img/back-"+data.color+".jpg"); $("#back").attr("src","src/img/back-"+randomColor+".jpg");
// creating image for plane, need to link it to the inputs tog et entered values. // creating image for plane, need to link it to the inputs tog et entered values.
var message = quill.root.innerHTML var message = quill.root.innerHTML
@ -193,14 +198,11 @@ $("#sendNewPlane").on('click',function(){
},4400); },4400);
//reloading page (to change) //reloading page (to change)
setInterval(function(){ setInterval(function(){
window.location.href ='https://avion-poe.me?avion='+planeId+''; window.location.href ='https://www.avion-poe.me/?avion='+planeId+'';
},5500); },5500);
}) })
}) }
});
}) })
}); });

View File

@ -46,7 +46,6 @@ var dictionnary = []
function translateUI(l){ function translateUI(l){
$.getJSON("lang/"+l+"", function(s){ $.getJSON("lang/"+l+"", function(s){
console.log(s)
dictionnary = s dictionnary = s
//if arabic : display left to right (ltr) + troubleshooting a lot of individual elements //if arabic : display left to right (ltr) + troubleshooting a lot of individual elements
if (lang == "ar"){ if (lang == "ar"){