document.addEventListener("DOMContentLoaded", function() {
    const PI = 3.14;
    let y = 10, x = 5;

    x = 100;

    console.log(x);

    document.getElementById("allertask").onclick = function(){
        let username = window.prompt("Whats your name?");
        console.log(username);
    };

    document.getElementById("submit").onclick = function(){                     //simple input output
        let text = document.getElementById("mytext").value;
        console.log(text);
        document.getElementById("welc").textContent = `Helllo ${text}`;
    };

    document.getElementById("numcalc").onclick = function(){                    //Data conversion
        let a = document.getElementById("numa").value;
        let b = document.getElementById("numb").value;
        document.getElementById("calcout").textContent = Number(a) + Number(b) +"  Type of input: "+ typeof(a) + "   Type of converion: " + typeof(Number(a));
        //Other conversons:
        String(a);
        Boolean(a);     //When empty string is given it will turn false every other case it will be true
        Number(a);
    }


    document.getElementById("circumcal").onclick = function(){              //Just for constant Values
        document.getElementById("circumcalout").textContent = "The circumference of a circle is: " + 2 * PI * Number(document.getElementById("numrad").value) + "cm";
    };


    document.getElementById("countdecrease").onclick = function(){          //Counter thingy
        document.getElementById("counterlab").textContent = Number(document.getElementById("counterlab").textContent) - 1;
    };
    document.getElementById("countincrease").onclick = function(){
        document.getElementById("counterlab").textContent = Number(document.getElementById("counterlab").textContent) + 1;
    };
    document.getElementById("countreset").onclick = function(){
        document.getElementById("counterlab").textContent = 0;
    }


    document.getElementById("gimmeapie").onclick = function(){          //Most of the math I'll need!
        document.getElementById("mathouput").textContent = Math.PI;
    };
    document.getElementById("mathefloor").onclick = function(){
        document.getElementById("mathouput").textContent = Math.floor(Math.PI);
    };
    document.getElementById("matheceil").onclick = function(){
        document.getElementById("mathouput").textContent = Math.ceil(Math.PI);
    };
    document.getElementById("mathetrunc").onclick = function(){
        document.getElementById("mathouput").textContent = Math.trunc(Math.PI);
    };
    document.getElementById("mathepower").onclick = function(){
        document.getElementById("mathouput").textContent = Math.pow(Math.PI, 2);
    };
    document.getElementById("matheroot").onclick = function(){
        document.getElementById("mathouput").textContent = Math.sqrt(Math.PI);
    };
    document.getElementById("mathelog").onclick = function(){
        document.getElementById("mathouput").textContent = Math.log(Math.PI);
    };


    document.getElementById("gimerandom").onclick = function(){
        document.getElementById("randomoutput").textContent = Math.random();
    };
    document.getElementById("rollthedice").onclick = function(){
        document.getElementById("randomoutput").textContent = Math.trunc(Math.random()*6) + 1;
    };
    document.getElementById("biggerrandom").onclick = function(){
        let max = 100, min = 50;
        document.getElementById("randomoutput").textContent = Math.trunc(Math.random()*(max-min)) + min;
    };

    
});
