On-air script

Joined
Jun 14, 2018
Messages
109
Reaction score
1
ok ta
Try this

JavaScript:
(function(d) {
    function onair() {
        const dj = d.querySelector('#dj'),
            nd = new Date(),
            dy = nd.getDay(),
            hr = nd.getHours(),
            mn = nd.getMinutes();
        let txt = null;

        switch (dy) {
        case 1: // Monday
            if (hr === 8) // 8:00 - 8:59 - 60 minutes - 1 hour
                dj.src = 'djimages/kayley.jpg';

            if (hr === 13) { // 13:00 - 13:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Monday at 1 PM<br>Auto<br>With Bunny';
            }

            if (hr === 21) // 21:00 - 21:59 - 60 minutes - 1 hour
                dj.src = 'djimages/billy.jpg';
            break;
        case 2: // Tuesday
            if (hr === 8 && (mn >= 0 && mn <= 15)) // 8:00 - 8:15 - 15 minutes
                dj.src = 'djimages/kayley.jpg';

            if (hr === 13) { // 13:00 - 13:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Tuesday at 1 PM<br>Auto<br>With Bunny';
            }

            if (hr === 17) // 17:00 - 17:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
            break;
        case 3: // Wednesday
            if (hr === 8 && (mn >= 0 && mn <= 15)) // 8:00 - 8:15 - 15 minutes
                dj.src = 'djimages/off-air.jpg';

            if (hr === 15) // 15:00 - 15:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
            break;
        case 4: // Thursday
            if (hr === 21) // 21:00 - 21:59 - 60 minutes - 1 hour
                dj.src = 'djimages/strawbs.jpg';

            if (hr === 16) { // 16:00 - 16:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Monday at 1 PM<br>Auto<br>With Bunny';
            }
            break;
        case 5: // Friday
            if (hr === 13 || hr === 14) { // 13:00 - 14:59 - 2 hours
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Saturday at 8 AM<br>Christian Music<br>with Dj Bunny';
            }
            break;
        case 6: // Saturday
            if (hr === 2 || hr === 3) { // 2:00 - 3:59 - 2 hours
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Saturday at 8 AM<br>Christian Music<br>with Dj Bunny';
            }
            break;
        case 0: // Sunday
            if (hr === 21) // 21:00 - 21:59 - 60 minutes - 1 hour
                dj.src = 'djimages/strawbs.jpg';
            break;
        default:
            dj.src = 'djimages/strawbs.jpg';
            break;
        }

        if (txt) {
            if (document.querySelector('#who-on-air-txt'))
                document.querySelector('#who-on-air-txt').innerHTML = txt;
            else {
                tx = document.createElement('div');
                tx.style.color = 'white';
                tx.id = 'who-on-air-txt';
                tx.innerHTML = txt;
                dj.insertAdjacentElement('afterend', tx);
            }
        }
    }

    setInterval(function() { onair(); }, 1000);
})(document);

don't forget after re-loaded file showdj.js use on your computer CTRL+F5 ;)
I'll wait till someone's on-air to see the change, is there any video's similar to this so i can get my head round this
 
Joined
Jun 14, 2018
Messages
109
Reaction score
1
i'v been just recently getting my head around javascript and watching a few videos
also from w3schools and learning the meaning of code?

now i'm trying to add a link underneath the djbunny when it's on-air
now tell me is this rite

you're looking where the let statements are?

Code:
(function(d) {
  function onair() {
    const dj = d.querySelector('#dj'),
          tx = document.createElement('div'),
          nd = new Date(),
          dy = nd.getDay(),
          hr = nd.getHours(),                          
          mn = nd.getMinutes();
          let text = "Bunny's Requests!";
          let result = text.link;
 
Joined
Jul 4, 2023
Messages
475
Reaction score
58
let text = "Bunny's Requests!"; let result = text.link;
is better way with <a> element.

I have check code: https://coolvibes-reloaded.com/scripts/showdj.js
the code is a little bit incorrect.

Try this way
JavaScript:
(function(d) {
    function onair() {
        const dj = d.querySelector('#dj'),
            nd = new Date(),
            dy = nd.getDay(),
            hr = nd.getHours(),
            mn = nd.getMinutes();
        let txt = null;

        switch (dy) {
        case 1: // Monday
            if (hr === 8) // 8:00 - 8:59 - 60 minutes - 1 hour
                dj.src = 'djimages/kayley.jpg';

            if (hr === 13) { // 13:00 - 13:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
                txt = '<a href="https://YOURLINK.COM" target="_blank">Monday at 1 PM<br>Auto<br>With Bunny</a>';
            }

            if (hr === 21) // 21:00 - 21:59 - 60 minutes - 1 hour
                dj.src = 'djimages/billy.jpg';
            break;
        case 2: // Tuesday
            if (hr === 8 && (mn >= 0 && mn <= 15)) // 8:00 - 8:15 - 15 minutes
                dj.src = 'djimages/kayley.jpg';

            if (hr === 13) { // 13:00 - 13:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Tuesday at 1 PM<br>Auto<br>With Bunny';
            }

            if (hr === 17) // 17:00 - 17:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
            break;
        case 3: // Wednesday
            if (hr === 8 && (mn >= 0 && mn <= 15)) // 8:00 - 8:15 - 15 minutes
                dj.src = 'djimages/off-air.jpg';

            if (hr === 15) // 15:00 - 15:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
            break;
        case 4: // Thursday
            if (hr === 21) // 21:00 - 21:59 - 60 minutes - 1 hour
                dj.src = 'djimages/strawbs.jpg';

            if (hr === 16) { // 16:00 - 16:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Monday at 1 PM<br>Auto<br>With Bunny';
            }
            break;
        case 5: // Friday
            if (hr === 13 || hr === 14) { // 13:00 - 14:59 - 2 hours
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Saturday at 8 AM<br>Christian Music<br>with Dj Bunny';
            }
            break;
        case 6: // Saturday
            if (hr === 2 || hr === 3) { // 2:00 - 3:59 - 2 hours
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Saturday at 8 AM<br>Christian Music<br>with Dj Bunny';
            }
            break;
        case 0: // Sunday
            if (hr === 21) // 21:00 - 21:59 - 60 minutes - 1 hour
                dj.src = 'djimages/strawbs.jpg';
            break;
        default:
            dj.src = 'djimages/strawbs.jpg';
            break;
        }

        // this code is necessary, do not change --------- 
        if (txt) {
            if (document.querySelector('#who-on-air-txt'))
                document.querySelector('#who-on-air-txt').innerHTML = txt;
            else {
                tx = document.createElement('div');
                tx.style.color = 'white';
                tx.id = 'who-on-air-txt';
                tx.innerHTML = txt;
                dj.insertAdjacentElement('afterend', tx);
            }
        }
        // -----------------------------------------------
    }

    setInterval(function() { onair(); }, 1000);
})(document);
 
Joined
Jun 14, 2018
Messages
109
Reaction score
1
is better way with <a> element.

I have check code: https://coolvibes-reloaded.com/scripts/showdj.js
the code is a little bit incorrect.

Try this way
JavaScript:
(function(d) {
    function onair() {
        const dj = d.querySelector('#dj'),
            nd = new Date(),
            dy = nd.getDay(),
            hr = nd.getHours(),
            mn = nd.getMinutes();
        let txt = null;

        switch (dy) {
        case 1: // Monday
            if (hr === 8) // 8:00 - 8:59 - 60 minutes - 1 hour
                dj.src = 'djimages/kayley.jpg';

            if (hr === 13) { // 13:00 - 13:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
                txt = '<a href="https://YOURLINK.COM" target="_blank">Monday at 1 PM<br>Auto<br>With Bunny</a>';
            }

            if (hr === 21) // 21:00 - 21:59 - 60 minutes - 1 hour
                dj.src = 'djimages/billy.jpg';
            break;
        case 2: // Tuesday
            if (hr === 8 && (mn >= 0 && mn <= 15)) // 8:00 - 8:15 - 15 minutes
                dj.src = 'djimages/kayley.jpg';

            if (hr === 13) { // 13:00 - 13:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Tuesday at 1 PM<br>Auto<br>With Bunny';
            }

            if (hr === 17) // 17:00 - 17:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
            break;
        case 3: // Wednesday
            if (hr === 8 && (mn >= 0 && mn <= 15)) // 8:00 - 8:15 - 15 minutes
                dj.src = 'djimages/off-air.jpg';

            if (hr === 15) // 15:00 - 15:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
            break;
        case 4: // Thursday
            if (hr === 21) // 21:00 - 21:59 - 60 minutes - 1 hour
                dj.src = 'djimages/strawbs.jpg';

            if (hr === 16) { // 16:00 - 16:59 - 60 minutes - 1 hour
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Monday at 1 PM<br>Auto<br>With Bunny';
            }
            break;
        case 5: // Friday
            if (hr === 13 || hr === 14) { // 13:00 - 14:59 - 2 hours
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Saturday at 8 AM<br>Christian Music<br>with Dj Bunny';
            }
            break;
        case 6: // Saturday
            if (hr === 2 || hr === 3) { // 2:00 - 3:59 - 2 hours
                dj.src = 'djimages/djbunny.jpg';
                txt = 'Saturday at 8 AM<br>Christian Music<br>with Dj Bunny';
            }
            break;
        case 0: // Sunday
            if (hr === 21) // 21:00 - 21:59 - 60 minutes - 1 hour
                dj.src = 'djimages/strawbs.jpg';
            break;
        default:
            dj.src = 'djimages/strawbs.jpg';
            break;
        }

        // this code is necessary, do not change ---------
        if (txt) {
            if (document.querySelector('#who-on-air-txt'))
                document.querySelector('#who-on-air-txt').innerHTML = txt;
            else {
                tx = document.createElement('div');
                tx.style.color = 'white';
                tx.id = 'who-on-air-txt';
                tx.innerHTML = txt;
                dj.insertAdjacentElement('afterend', tx);
            }
        }
        // -----------------------------------------------
    }

    setInterval(function() { onair(); }, 1000);
})(document);
thank you so much, just out of spite
"where are you getting you're code from?"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top