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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
| const PronoUserModal = document.getElementById('ModalAddP')//Modal ajout prono
const PronoUserModalForm = document.getElementById('formAddP')//Form ajout prono
let Inputpronodom = document.getElementById('modalappronodom')
let Inputpronodext = document.getElementById('modalappronoext')
let Inputiduser = document.getElementById("modalappiduser")
let Inputidmatch = document.getElementById("modalappidmatch")
let Inputaction = document.getElementById("modalapaction")
let chome = document.getElementById('modalapequipedom')//DIV équipe DOM
let caway = document.getElementById('modalapequipeext')//DIV équipe EXT
let chome_flag = document.getElementById('modalapimagedom')//IMG Flag équipe DOM
let caway_flag = document.getElementById('modalapimageext')//IMG Flag équipe EXT
let cmatch_date = document.getElementById('modalapdate')//DIV Date
let ctitle = document.getElementById('modaltitleap')//modal-title
let IMGlogo = document.getElementById('ponomodallogo')
let DIVmodaltype = document.getElementById('modalaptype')
const listbuts = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
const logoArrayModal = ['img/94fl_logo_720.png', 'img/eclair_bleu_720.png', 'img/fifa94_720.png']
const defaultIMG = 'img/TBD.webp'
//Logo
let randomElement = logoArrayModal[Math.floor(Math.random() * logoArrayModal.length)];
IMGlogo.innerHTML = '<img src="' + randomElement + '" class="img-fluid rounded mx-auto d-block" width="100"/>'
PronoUserModal.addEventListener('shown.bs.modal', (e) => {
chome_flag.src = caway_flag.src = defaultIMG
let matchid = $(e.relatedTarget).data('bs-matchid')
let userid = $(e.relatedTarget).data('bs-userid')
//Récupération des données du matchs
let url = jsurl + 'match/' + matchid
toAPI("GET", url, jstournoi)
.then(response => response.json()).then((data) => {
if (data.success == true) {
let messageType = ''
let vtype = data.results.type_nom
if (vtype.search("(Super Bonus)") > 0) {
DIVmodaltype.style.color = '#f00'
messageType = '<br>Match Super Bonus'
} else if (vtype.search("(Bonus)") > 0) {
DIVmodaltype.style.color = '#f00'
messageType = '<br>Match Bonus'
} else {messageType = ''}
DIVmodaltype.innerHTML = 'MatchWeek ' + data.results.MatchWeek + messageType
//Affichage du match
chome.innerHTML = data.results.home
caway.innerHTML = data.results.away
chome_flag.src = data.results.home_flag
caway_flag.src = data.results.away_flag
Inputidmatch.value = matchid
Inputiduser.value = userid
cmatch_date = datefrlong(data.results.play_date).replace(':', 'h')
ctitle.innerHTML = data.results.type_nom
//Récupération prono
let url2 = jsurl + 'prono/' + matchid + '/' + userid
toAPI("GET", url2, jstournoi)
.then(response2 => response2.json()).then((data2) => {
if (data2.success == true) {
Inputpronodom.value = data2.results.home_score
Inputpronodext.value = data2.results.away_score
Inputaction.value = "PATCH"
} else {
Inputpronodom.value = '-'
Inputpronodext.value = '-'
Inputaction.value = 'POST'
}
return
})
.catch(error => alert("Erreur2 : " + error))
return
}
})
.catch(error => alert("Erreur (match): " + error))
}) |
Partager