let mode        = 0;
let clicks      = 0;

const setMode = (value) => {
    mode = value;
}

document.addEventListener("click", function (eve) {
    let target = eve.target;

    if (target.className == "controls") {
        if (target.value == "line") {
            setMode(target.value);
        } else if (target.value == "clear") {
            clearCanvas();
        }
    } else if (target.id == "canvas") {
        switch (mode) {
            case "line": preDrawLine(eve);
                         break;
            default:
        }
    }
});
