JSFiddle - React, Tailwind, and code Playground

by frogggeee McFrogggeee

JavaScript

let friday = ["2252723", "2252766", "2252745", "lunch", "2252787", "2252834", "2252878", "2252840", "2252977"];
    let monday = ["2252723", "lunch", "2252745", "2252834", "2252840"];
    let a = ["2252723", "2252928", "lunch", "2252745", "2252834", "2252840"];
    let b = ["2252766", "2252928", "lunch", "2252787", "2252878", "2252977"];
    let currentSched;
    let sched = [
        [575, 650, 650, 655, 655, 685, 685, 690, 690, 765, 765, 770, 770, 845, 845, 850, 850, 925],
        [575, 650, 650, 655, 655, 690, 690, 695, 695, 725, 725, 730, 730, 805, 805, 810, 810, 885, 885, 890, 890, 965],
        [575, 650, 650, 655, 655, 690, 690, 695, 695, 725, 725, 730, 730, 805, 805, 810, 810, 885, 885, 890, 890, 965],
        [575, 650, 650, 655, 655, 690, 690, 695, 695, 725, 725, 730, 730, 805, 805, 810, 810, 885, 885, 890, 890, 965],
        [575, 615, 615, 620, 620, 660, 660, 665, 665, 705, 705, 710, 710, 740, 740, 745, 745, 785, 785, 790, 790, 830, 830, 835, 835, 875, 875, 880, 880, 920, 920, 925, 925, 965]
    ];

    function getPeriod(schedule, minutes) {
        let i = 0;
        while (minutes > schedule[i]) {
            i++;
        }
        return i;
    }

    function update() {
        let today = new Date();
        let time = today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds();
        const d = new Date();
        let day = d.getDay() - 1;
        let per = getPeriod(sched[day], today.getHours() * 60 + today.getMinutes()) - 1;
        if (day == 0) {
            currentSched = monday;
        } else if (day == 1) {
            currentSched = b;
        } else if (day == 2) {
            currentSched = a;
        } else if (day == 3) {
            currentSched = b;
        } else if (day == 4) {
            currentSched = friday;
        }
        currentSched = currentSched.join(",passing,").split(",");
        if (currentSched[Math.floor(per / 2) + (per % 2)] == "passing") {
               ...