Sono stati aggiunti numerosi nuovi file JavaScript, CSS, SVG e PNG per migliorare la grafica, la responsività e le funzionalità delle pagine di aste, login, notifiche e player video. Introdotte nuove librerie (OneSignal, Bootstrap, Font Awesome, Vue.js, Slick Carousel, ProgressBar.js, CryptoJS, mCustomScrollbar, Switchery) e script per la gestione di notifiche push, tracciamento eventi (Facebook Pixel, TikTok Pixel, Google Ads, Smartech), pagamenti Ingenico, modali, banner promozionali, preferiti, auto-puntate, e gestione utente inattivo. Ampliata la logica del player embedded YouTube con nuovi hook, logging avanzato, gestione ciclo di vita, storage e challenge di attestation. Aggiunti nuovi stili CSS per layout responsive, componenti UI, modali, badge, bottoni, progress bar, e ottimizzazioni mobile. Integrate nuove immagini e icone per arricchire l’interfaccia grafica. Non sono state apportate modifiche al file `www-player.css` e ad altri file specificati. Queste modifiche migliorano la sicurezza, la tracciabilità, l’esperienza utente e la flessibilità dell’applicazione.
207 lines
6.2 KiB
Plaintext
207 lines
6.2 KiB
Plaintext
const AuctionsBidManage = (function() {
|
|
|
|
const _defaultPart = "divAsta";
|
|
let _nAstePerBonus = 10;
|
|
let _limiteAsteVinte = 10;
|
|
let _nAstePuntataVinte = 0;
|
|
let _percentualeBonus = 0;
|
|
let _nPuntateVinteOggi = 0;
|
|
let _nAsteConfermate = 0;
|
|
let _nPuntateRiscattate = 0;
|
|
let _nPuntateDaRiscattare = 0;
|
|
let _initialized = false;
|
|
let _defaultValidUntil = null;
|
|
let _viewSlot = false;
|
|
|
|
function _defaultObj() {
|
|
return {
|
|
auctions: {},
|
|
nAsteConfermate: 0,
|
|
percentualeBonus: 0,
|
|
limiteAsteVinte: 10,
|
|
nAstePerBonus: 10,
|
|
validUntil: getDefaultValidUntil()
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Aggiunge una nuova asta all'oggetto delle aste di puntata vinte in un giorno
|
|
* @param idAuction {int}
|
|
*/
|
|
function add(idAuction){
|
|
|
|
let result = get();
|
|
let retrievedObject = JSON.parse(result);
|
|
let auctionBidWin = retrievedObject === null ? _defaultObj() : retrievedObject ;
|
|
let auctionElement = document.getElementById(_defaultPart + idAuction);
|
|
let creditValue = parseInt(auctionElement.getAttribute('data-credit-value')) > 0 ? parseInt(auctionElement.getAttribute('data-credit-value')) : 0;
|
|
|
|
|
|
|
|
if(creditValue > 0 && Object.keys(auctionBidWin.auctions).length <= auctionBidWin.limiteAsteVinte){
|
|
|
|
// let obj =
|
|
// {
|
|
// idAuction: idAuction,
|
|
// value: creditValue
|
|
// }
|
|
// ;
|
|
//
|
|
// if(!auctionBidWin.auctions.hasOwnProperty(idAuction)){
|
|
// auctionBidWin.auctions[idAuction] = obj;
|
|
// }
|
|
// let newObj = JSON.stringify(auctionBidWin);
|
|
//
|
|
// localStorage.setItem("auctionBidWin", newObj);
|
|
getRemoteData();
|
|
}
|
|
return;
|
|
}
|
|
function getDefaultValidUntil(){
|
|
|
|
return _defaultValidUntil;
|
|
|
|
}
|
|
|
|
function setDefaultValidUntil(untilTimestamp){
|
|
_defaultValidUntil = untilTimestamp;
|
|
}
|
|
|
|
/**
|
|
* Ritornano le informazioni salvate nel localStorage
|
|
* @returns {string}
|
|
*/
|
|
function get(){
|
|
return localStorage.getItem('auctionBidWin');
|
|
}
|
|
|
|
/**
|
|
* Rimuove dal localStorage
|
|
*/
|
|
function remove(){
|
|
localStorage.removeItem('auctionBidWin');
|
|
}
|
|
|
|
|
|
function getRemoteData(callback = null){
|
|
|
|
fetch('./ajax/get_auction_bids_info_banner.php',{
|
|
method: "GET"
|
|
})
|
|
// gestisci il successo
|
|
.then(response => response.json()) // converti a json
|
|
.then(function (data) {
|
|
let obj = {
|
|
auctions: data.auctions,
|
|
nAsteConfermate: data.nAsteConfermate,
|
|
nAsteVinte: data.nAsteVinte,
|
|
nPuntateRiscattate: data.nPuntateRiscattate,
|
|
nPuntateDaRiscattare: data.nPuntateDaRiscattare,
|
|
limiteAsteVinte: data.limiteAsteVinte,
|
|
nAstePerBonus: data.nAstePerBonus,
|
|
percentualeBonus: data.percentualeBonus,
|
|
validUntil: data.validUntil,
|
|
viewSlot: data.viewSlot,
|
|
extraSlots: data.extraSlots, //un elenco degli slots non scaduti e non aperti
|
|
nPuntateBonus: data.nPuntateBonus
|
|
};
|
|
let newObj = JSON.stringify(obj);
|
|
|
|
localStorage.setItem("auctionBidWin", newObj);
|
|
if(callback !== null){
|
|
callback();
|
|
}
|
|
|
|
})
|
|
.catch(err => console.log('Request Failed', err)); // gestisci gli errori
|
|
}
|
|
|
|
function retriveInfoComponent(){
|
|
let result = JSON.parse(get());
|
|
|
|
if(result) {
|
|
|
|
_nAstePuntataVinte = result.nAsteVinte;
|
|
_limiteAsteVinte = result.limiteAsteVinte;
|
|
_nAsteConfermate = result.nAsteConfermate;
|
|
_nPuntateDaRiscattare = result.nPuntateDaRiscattare;
|
|
_nPuntateRiscattate = result.nPuntateRiscattate;
|
|
_nAstePerBonus = result.nAstePerBonus;
|
|
_percentualeBonus = result.percentualeBonus;
|
|
_viewSlot = result.viewSlot;
|
|
_nPuntateVinteOggi = result.nPuntateDaRiscattare + result.nPuntateRiscattate;
|
|
|
|
|
|
|
|
/*if (_percentualeBonus > 0) {
|
|
let valorePercentualeBonus = ((_nPuntateVinteOggi * _percentualeBonus) / 100);
|
|
_nPuntateVinteOggi = _nPuntateVinteOggi + valorePercentualeBonus;
|
|
}*/
|
|
|
|
|
|
let asteRimanentiPerBonus = _nAstePerBonus - _nAstePuntataVinte;
|
|
|
|
return {
|
|
auctions: result.auctions,
|
|
asteRimanentiPerBonus: asteRimanentiPerBonus,
|
|
nAstePerBonus: _nAstePerBonus,
|
|
nAstePuntataVinte: _nAstePuntataVinte,
|
|
percentualeBonus: _percentualeBonus,
|
|
nPuntateVinteOggi: parseInt(_nPuntateVinteOggi),
|
|
limiteAsteVinte: _limiteAsteVinte,
|
|
nAsteConfermate: _nAsteConfermate,
|
|
nPuntateDaRiscattare: _nPuntateDaRiscattare,
|
|
nPuntateRiscattate: _nPuntateRiscattate,
|
|
|
|
viewSlot: _viewSlot,
|
|
extraSlots: result.extraSlots,
|
|
nPuntateBonus: result.nPuntateBonus
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param auctionId
|
|
* @returns {boolean}
|
|
*/
|
|
function searchByAuctionId(auctionId){
|
|
let data = retriveInfoComponent();
|
|
let controllo = false;
|
|
if(data == undefined || data == null ){ return; }
|
|
|
|
let keys = Object.keys(data.auctions);
|
|
|
|
for(let i= 0; i <= keys.length; i++){
|
|
if(keys[i] === auctionId){
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function initRemoteData(){
|
|
if(!_initialized){
|
|
getRemoteData();
|
|
setInterval(function (){
|
|
getRemoteData();
|
|
}, 1000 * 60);
|
|
}
|
|
_initialized = true;
|
|
|
|
}
|
|
|
|
return {
|
|
add,
|
|
get,
|
|
remove,
|
|
getRemoteData,
|
|
retriveInfoComponent,
|
|
initRemoteData,
|
|
setDefaultValidUntil,
|
|
searchByAuctionId
|
|
}
|
|
})();
|
|
|
|
|