Buongiorno!
Ho adattato un codice che mi è stato segnalato su questo forum per mostrare determinate immagini differenti in base all'ora ed al giorno della settimana in una pagina web. Il che funziona senza problemi.
Quello che vorrei fare è, una volta individuato il giorno e l'ora ed essere entrato in un "if", vorrei mettere una condizione alla fine del ciclo delle immagini da mostrare, prima di iniziare a mostrarle da capo, che confronti nuovamente l'ora e la data in modo che, se si rientrasse nelle condizioni dell' "if" successivo si possa passare a quello.codice:<script type="text/javascript" language="JavaScript"> var now = new Date(); var day = now.getDay(); var hours = now.getHours(); var d = new Date(); var psj=0; //Nuova settimana didattica if (day == 5 && hours >= 13 || day == 6 || day == 0 || day == 1 && hours < 17){ adImages = new Array("ProgSett/5.jpg","ProgSett/1.jpg","ProgSett/2.jpg","ProgSett/3.jpg","ProgSett/4.jpg") thisAd = 0 imgCt = adImages.length function rotate() { if (document.images) { thisAd++ if (thisAd == imgCt) { thisAd = 0 } document.rotationImage.src=adImages[thisAd] setTimeout("rotate()", 5000) } } } //Dalle 17:00 del Lunedì alle 16:59 del Martedì if (day == 1 && hours >= 17 || day == 2 && hours < 17){ adImages = new Array("ProgSett/5.jpg","ProgSett/2.jpg","ProgSett/3.jpg","ProgSett/4.jpg") thisAd = 0 imgCt = adImages.length function rotate() { if (document.images) { thisAd++ if (thisAd == imgCt) { thisAd = 0 } document.rotationImage.src=adImages[thisAd] setTimeout("rotate()", 5000) } } } //Dalle 17:00 del Martedì alle 16:59 del Mercoledì if (day == 2 && hours >= 17 || day == 3 && hours < 17){ adImages = new Array("ProgSett/5.jpg","ProgSett/3.jpg","ProgSett/4.jpg") thisAd = 0 imgCt = adImages.length function rotate() { if (document.images) { thisAd++ if (thisAd == imgCt) { thisAd = 0 } document.rotationImage.src=adImages[thisAd] setTimeout("rotate()", 5000) } } } //Dalle 17:00 del Mercoledì alle 16:59 del Giovedì if (day == 3 && hours >= 17 || day == 4 && hours < 17){ adImages = new Array("ProgSett/5.jpg","ProgSett/4.jpg") thisAd = 0 imgCt = adImages.length function rotate() { if (document.images) { thisAd++ if (thisAd == imgCt) { thisAd = 0 } document.rotationImage.src=adImages[thisAd] setTimeout("rotate()", 5000) } } } //Dalle 17:00 del Giovedì alle 12:59 del Venerdì if (day == 4 && hours >= 17 || day == 5 && hours < 13){ adImages = new Array("ProgSett/5.jpg") thisAd = 0 imgCt = adImages.length function rotate() { if (document.images) { thisAd++ if (thisAd == imgCt) { thisAd = 0 } document.rotationImage.src=adImages[thisAd] setTimeout("rotate()", 5000) } } } //Dalle 13:00 del Venerdì if (day == 5 && hours >= 13){ adImages = new Array("ProgSett/6.jpg") thisAd = 0 imgCt = adImages.length function rotate() { if (document.images) { thisAd++ if (thisAd == imgCt) { thisAd = 0 } document.rotationImage.src=adImages[thisAd] setTimeout("rotate()", 5000) } } } </script>
La pagina che sto programmando deve essere pubblicata su dei monitor e, una volta avviata, viene aggiornata una volta a settimana.
Avrei anche l'esigenza non non refreshare l'intera pagina perché sotto avrei un testo a scorrimento che non dovrebbero essere aggiornato.
A proposito di testo a scorrimento, ho utilizzato il codice "crawler.js". Avrei l'esigenza di, invece di inserire il testo nel codice, di far pescare il testo da visualizzare da un file.txt... Ho cercato molto nel web ma non ho trovato nulla che fa al caso mio.
Ringrazio chiunque sia disposto ad aiutarmi!codice:<div class="marquee" id="mycrawler"> TESTO SCORREVOLE </div> <script type="text/javascript"> marqueeInit({ uniqueid: 'mycrawler', style: { 'font-family':'Arial', 'padding': '10px', 'width': '100%', 'height': '20px', 'font-size': '30px', 'color': '#FFF', 'background': '#4181C0', 'background-size': 'cover', }, inc: 20, //speed - pixel increment for each iteration of this marquee's movement mouse: 'cursor driven', //mouseover behavior ('pause' 'cursor driven' or false) moveatleast: 2, neutral: 150, persist: true, savedirection: true }); </script>
Ps. Magari sono cose semplici, ma ho visto per la prima volta un codice js l'altro ieri![]()


Rispondi quotando
