<commit_before>// configuration object
var clockifyConfig = {
    whatToDo: function boing() {
        console.log("boing");
    },
    timeToWait: 1500
};

var clockify = function (theOptions) {
    var alreadyPlayed = false;

    if (theOptions === undefined || !theOptions.hasOwnProperty("whatToDo") || !theOptions.hasOwnProperty("timeToWait")) {
        console.log("Not enough information. Cannot continu.");
        return;
    }

    // repeat a function a certain number of times, with a certain interval
    function repeater(theFunction, numberOfTimes, timeToWait) {
        var i = 1;
        function t() {
            theFunction();
            if (i < numberOfTimes) {
                i++;
                setTimeout(t, timeToWait);
            }
        }
        t();
    }

    function createNewDate() {
        var now = new Date();
        var hour = now.getHours();
        var minute = now.getMinutes();

        if (hour > 12) {
            hour = hour - 12;
        } else {
            if (hour === 0) {
                hour = 12;
            }
        }
        return {
            hour: hour,
            minute: minute
        };
    }

    function playActualHour() {
        switch (createNewDate().hour) {
            case 1:
                repeater(theOptions.whatToDo, 1, theOptions.timeToWait);
                break;
            case 2:
                repeater(theOptions.whatToDo, 2, theOptions.timeToWait);
                break;
            case 3:
                repeater(theOptions.whatToDo, 3, theOptions.timeToWait);
                break;
            case 4:
                repeater(theOptions.whatToDo, 4, theOptions.timeToWait);
                break;
            case 5:
                repeater(theOptions.whatToDo, 5, theOptions.timeToWait);
                break;
            case 6:
                repeater(theOptions.whatToDo, 6, theOptions.timeToWait);
                break;
            case 7:
                repeater(theOptions.whatToDo, 7, theOptions.timeToWait);
                break;
            case 8:
                repeater(theOptions.whatToDo, 8, theOptions.timeToWait);
                break;
            case 9:
                repeater(theOptions.whatToDo, 9, theOptions.timeToWait);
                break;
            case 10:
                repeater(theOptions.whatToDo, 10, theOptions.timeToWait);
                break;
            case 11:
                repeater(theOptions.whatToDo, 11, theOptions.timeToWait);
                break;
            case 12:
                repeater(theOptions.whatToDo, 12, theOptions.timeToWait);
                break;
            default:
        }
    }

    function checkTime() {
        var actualMinute = createNewDate().minute;
        if ((actualMinute === 0) && (alreadyPlayed === false)) {
            playActualHour();
            alreadyPlayed = true;
        } else if (actualMinute !== 0) {
            alreadyPlayed = false;
        }
        setTimeout(checkTime, 10000); // every 10 seconds the system clock will be checked
    }
    checkTime();
};

clockify(clockifyConfig);<commit_msg>added explanation to config object<commit_after>// configuration object
var clockifyConfig = {
    whatToDo: function boing() { // write your own function
        console.log("boing");
    },
    timeToWait: 1500 // time between two function calls, in miliseconds
};

var clockify = function (theOptions) {
    var alreadyPlayed = false;

    if (theOptions === undefined || !theOptions.hasOwnProperty("whatToDo") || !theOptions.hasOwnProperty("timeToWait")) {
        console.log("Not enough information. Cannot continu.");
        return;
    }

    // repeat a function a certain number of times, with a certain interval
    function repeater(theFunction, numberOfTimes, timeToWait) {
        var i = 1;
        function t() {
            theFunction();
            if (i < numberOfTimes) {
                i++;
                setTimeout(t, timeToWait);
            }
        }
        t();
    }

    function createNewDate() {
        var now = new Date();
        var hour = now.getHours();
        var minute = now.getMinutes();

        if (hour > 12) {
            hour = hour - 12;
        } else {
            if (hour === 0) {
                hour = 12;
            }
        }
        return {
            hour: hour,
            minute: minute
        };
    }

    function playActualHour() {
        switch (createNewDate().hour) {
            case 1:
                repeater(theOptions.whatToDo, 1, theOptions.timeToWait);
                break;
            case 2:
                repeater(theOptions.whatToDo, 2, theOptions.timeToWait);
                break;
            case 3:
                repeater(theOptions.whatToDo, 3, theOptions.timeToWait);
                break;
            case 4:
                repeater(theOptions.whatToDo, 4, theOptions.timeToWait);
                break;
            case 5:
                repeater(theOptions.whatToDo, 5, theOptions.timeToWait);
                break;
            case 6:
                repeater(theOptions.whatToDo, 6, theOptions.timeToWait);
                break;
            case 7:
                repeater(theOptions.whatToDo, 7, theOptions.timeToWait);
                break;
            case 8:
                repeater(theOptions.whatToDo, 8, theOptions.timeToWait);
                break;
            case 9:
                repeater(theOptions.whatToDo, 9, theOptions.timeToWait);
                break;
            case 10:
                repeater(theOptions.whatToDo, 10, theOptions.timeToWait);
                break;
            case 11:
                repeater(theOptions.whatToDo, 11, theOptions.timeToWait);
                break;
            case 12:
                repeater(theOptions.whatToDo, 12, theOptions.timeToWait);
                break;
            default:
        }
    }

    function checkTime() {
        var actualMinute = createNewDate().minute;
        if ((actualMinute === 0) && (alreadyPlayed === false)) {
            playActualHour();
            alreadyPlayed = true;
        } else if (actualMinute !== 0) {
            alreadyPlayed = false;
        }
        setTimeout(checkTime, 10000); // every 10 seconds the system clock will be checked
    }
    checkTime();
};

clockify(clockifyConfig);
{'fraction_non_alphanumeric': 0.09821850859214883, 'fraction_numerical': 0.016080718902727414, 'mean_word_length': 1.489795918367347, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6831323', 'n_tokens_mistral': 1840, 'n_tokens_neox': 1699, 'n_words': 408}