var timeout;

$(document).ready(
        function () {
            var objBox = document.getElementById('console');
            objBox.scrollTop = objBox.scrollHeight;
            
            startAutoRefresh();
        });

function startAutoRefresh() {

    timeout = setTimeout(function () {
        window.location.reload();
    }, 1000);

    document.getElementById("refreshText").innerHTML = "AutoRefresh on.";
    document.getElementById("refreshText").style.color = "green";
}

function stopAutoRefresh() {

    clearTimeout(timeout);

    document.getElementById("refreshText").innerHTML = "AutoRefresh off.";
    document.getElementById("refreshText").style.color = "red";
}

//function refresh() {
//
//    clearTimeout(timeout);
//    
//    window.location.reload();
//    
//    clearTimeout(timeout);
//
//    document.getElementById("refreshText").innerHTML = "Page refreshed.";
//    document.getElementById("refreshText").style.color = "black";
//}

//$(document).ready(
//            function() {
//                setInterval(function() {
//                    var randomnumber = Math.floor(Math.random() * 100);
////                    $('#legende').html('<h1>hallo' + randomnumber + '</h1>');
//                    $('#consoleLog').text('<h1>hallo' + randomnumber + '</h1>');
//                }, 3000);
//            });