<commit_before>function run(device_in, action_in){
    $.get("v1", { device : device_in, action : action_in});
}

function create_job(){
    var job = {
        device: $("#device").val(),
        action: $("#action").val(),
        hour: $("#hour").val(),
        min: $("#min").val(),
        sec: $("#sec").val(),
    }
    $.get("job/create", job, update_schedule);
}

function cancel_job(id){
    job_id = {id: id}
    $.get("job/cancel", job_id, update_schedule);
}

function job_list(){
    $.get("job/list", update_schedule);
}

function get_devices(){
    $.get("devices", update_devices);
}

function update_schedule(data){
    // transform json to li elements
    $("#job-list").html(function(){
        var new_list = "";
        for(var i = 0; i < data.length; i++){
            new_list += "<li class=\"list-group-item clearfix\"" + "job_id=" + data[i]["id"]+">" +
             "<span class=\"pull-right\">" +
                "<button class=\"btn btn-sm btn-danger btn-circle\"" + 
                         "onclick=\"cancel_job(" + data[i]["id"] + ")\">" +
                    "<span class=\"glyphicon glyphicon-remove\"></span>" + 
                "</button>" +
             "</span>" +
             "<span class=\"glyphicon glyphicon-time job-icon\"></span>" + data[i]["end_time"] +
             "</br>" +
             "<span class=\"glyphicon glyphicon-phone job-icon\"></span>" + data[i]["device"] +
             "</br>" +
             "<span class=\"glyphicon glyphicon-random job-icon\"></span>" + data[i]["action"] +
             "</li>";
        }
        return new_list;
    });
}

function update_devices(data){
    $("#device").html(function(){
        var options = "";
        var devices = [];
        for(var device in data){
            if(data.hasOwnProperty(device)){
                devices.push(device);
            }
        }
        for(var i=0; i<devices.length; i++){
            options += "<option value=" + devices[i] + ">" + devices[i] + "</option>\n";
        }
        return options;
    });
}

function update_actions(data){
    $("#action").html(function(){<commit_msg>get actions of preselected device on load<commit_after>function run(device_in, action_in){
    $.get("v1", { device : device_in, action : action_in});
}

function create_job(){
    var job = {
        device: $("#device").val(),
        action: $("#action").val(),
        hour: $("#hour").val(),
        min: $("#min").val(),
        sec: $("#sec").val(),
    }
    $.get("job/create", job, update_schedule);
}

function cancel_job(id){
    job_id = {id: id}
    $.get("job/cancel", job_id, update_schedule);
}

function job_list(){
    $.get("job/list", update_schedule);
}

function get_devices(){
    $.get("devices", update_devices);
}

function update_schedule(data){
    // transform json to li elements
    $("#job-list").html(function(){
        var new_list = "";
        for(var i = 0; i < data.length; i++){
            new_list += "<li class=\"list-group-item clearfix\"" + "job_id=" + data[i]["id"]+">" +
             "<span class=\"pull-right\">" +
                "<button class=\"btn btn-sm btn-danger btn-circle\"" + 
                         "onclick=\"cancel_job(" + data[i]["id"] + ")\">" +
                    "<span class=\"glyphicon glyphicon-remove\"></span>" + 
                "</button>" +
             "</span>" +
             "<span class=\"glyphicon glyphicon-time job-icon\"></span>" + data[i]["end_time"] +
             "</br>" +
             "<span class=\"glyphicon glyphicon-phone job-icon\"></span>" + data[i]["device"] +
             "</br>" +
             "<span class=\"glyphicon glyphicon-random job-icon\"></span>" + data[i]["action"] +
             "</li>";
        }
        return new_list;
    });
}

function update_devices(data){
    $("#device").html(function(){
        console.log("ud: start")
        var options = "";
        var devices = [];
        for(var device in data){
            if(data.hasOwnProperty(device)){
                devices.push(device);
            }
        }
        for(var i=0; i<devices.length; i++){
            options += "<option value=" + devices[i] + ">" + devices[i] + "</option>\n";
        }
        return options;
    });
    var device = {device :$("#device").first().val()}
    $.get("actions", device, update_actions);
}

function update_actions(data){
    $("#action").html(function(){
{'fraction_non_alphanumeric': 0.20982041373039328, 'fraction_numerical': 0.00136394635144351, 'mean_word_length': 2.1451036454610435, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 39, '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': '2310316', 'n_tokens_mistral': 1344, 'n_tokens_neox': 1327, 'n_words': 264}