<commit_before>"use strict";

var ORG = (ORG) ? ORG : {};
ORG.NETMELODY = {};

ORG.NETMELODY.newBuildWidget = function(buildJson) {
    var buildDiv = $('<div></div>').addClass('progress-bar'),
        barDiv   = $('<div></div>');
        
    function updateProgress(percent) {
        barDiv.setAttribute('style', 'width: ' + percent + '%');
    }
    
    function refresh(newBuildJson) {
        updateProgress(newBuildJson.progress);
    }
    
    function initialise() {
        buildDiv.appendChild(barDiv);
        refresh(buildJson);
    }
    
    initialise();
    
    return {
        updateFrom: refresh,
        getContent: function() { return buildDiv; },
        getId: function() { return "buildId"; }
    };
};

ORG.NETMELODY.newTargetWidget = function(targetJson) {
    var currentTargetJson = {},
        targetDiv = $('<div></div>').addClass('target'),
        buildsDiv = $('<div></div>');
    
    function refresh(newTargetJson) {
        var lastTargetJson = currentTargetJson;
        
        currentTargetJson = newTargetJson;
        if (lastTargetJson.status !== newTargetJson.status) {
            targetDiv.removeClass(lastTargetJson.status);
            targetDiv.addClass(newTargetJson.status);
        }
        
        $(buildsDiv).empty();
        $.each(newTargetJson.builds, function(buildJson) {
            buildsDiv.appendChild(ORG.NETMELODY.newBuildWidget(buildJson).getContent());
        });
    }
    
    function initialise() {
        targetDiv.innerHTML = '<span>' + targetJson.name + '</span>';
        targetDiv.appendChild(buildsDiv);
        refresh(targetJson);
    }
    
    initialise();
    
    return {
        updateFrom: refresh,
        getContent: function() { return targetDiv; },
        getId: function() { return targetJson.id; }
    };
};

ORG.NETMELODY.newRadiatorWidget = function() {
    var radiatorDiv = $('<div></div>');
    
    function refresh(targetGroupJson) {
        var targets = targetGroupJson.targets.sort(function(a, b) {
            if (a.status === b.status) {
                return (a.builds.length > b.builds.length) ? -1 : (a.builds.length < b.builds.length) ? 1 : 0;
            }
            if (a.status === 'BROKEN') {
                return -1;
            }
            return 1;
        });
        
        $(radiatorDiv).empty();
        $.each(targets, function(targetJson) {
            radiatorDiv.appendChild(ORG.NETMELODY.newTargetWidget(targetJson).getContent());
        });
    }
    
    return {
        updateFrom: refresh,
        getContent: function() { return radiatorDiv; }
    };
};

ORG.NETMELODY.newRadiator = function(radiatorDiv, repeatingTaskProvider) {
    var radiatorWidget = ORG.NETMELODY.newRadiatorWidget();
    
    function refresh() {
        $.getJSON('landscapeobservation.json', { landscapeName: 'HIP' }, function(targetList) {
            radiatorWidget.updateFrom(targetList);
        });
    }
    
    function startup() {
        radiatorDiv.appendChild(radiatorWidget.getContent());
    
        refresh();
        repeatingTaskProvider.setInterval(refresh, 1000);
    }
    
    return {
        start: startup
    };
};

window.onload = ORG.NETMELODY.newRadiator(document.getElementById('radiator'), window).start();<commit_msg>fix bugs in cieye.js<commit_after>"use strict";

var ORG = (ORG) ? ORG : {};
ORG.NETMELODY = {};

ORG.NETMELODY.newBuildWidget = function(buildJson) {
    var buildDiv = $('<div></div>').addClass('progress-bar'),
        barDiv   = $('<div></div>');
        
    function updateProgress(percent) {
        barDiv.attr('style', 'width: ' + percent + '%');
    }
    
    function refresh(newBuildJson) {
        updateProgress(newBuildJson.progress);
    }
    
    function initialise() {
        buildDiv.append(barDiv);
        refresh(buildJson);
    }
    
    initialise();
    
    return {
        updateFrom: refresh,
        getContent: function() { return buildDiv; },
        getId: function() { return "buildId"; }
    };
};

ORG.NETMELODY.newTargetWidget = function(targetJson) {
    var currentTargetJson = { builds:[] },
        targetDiv = $('<div></div>'),
        buildsDiv = $('<div></div>');
    
    function refresh(newTargetJson) {
        var lastTargetJson = currentTargetJson;
        
        currentTargetJson = newTargetJson;
        if (lastTargetJson.status !== newTargetJson.status) {
            if (lastTargetJson.status) {
                targetDiv.removeClass(lastTargetJson.status);
            }
            targetDiv.addClass(newTargetJson.status);
        }
        
        buildsDiv.empty();
        $.each(newTargetJson.builds, function(index, buildJson) {
            buildsDiv.append(ORG.NETMELODY.newBuildWidget(buildJson).getContent());
        });
    }
    
    function initialise() {
        var titleSpan = $('<span></span>');
        
        titleSpan.text(targetJson.name);
        targetDiv.append(titleSpan);
        targetDiv.append(buildsDiv);
        targetDiv.addClass('target');
        refresh(targetJson);
    }
    
    initialise();
    
    return {
        updateFrom: refresh,
        getContent: function() { return targetDiv; },
        getId: function() { return targetJson.id; }
    };
};

ORG.NETMELODY.newRadiatorWidget = function() {
    var radiatorDiv = $('<div></div>');
    
    function refresh(targetGroupJson) {
        var targets = targetGroupJson.targets.sort(function(a, b) {
            if (a.status === b.status) {
                return (a.builds.length > b.builds.length) ? -1 : (a.builds.length < b.builds.length) ? 1 : 0;
            }
            if (a.status === 'BROKEN') {
                return -1;
            }
            return 1;
        });
        
        radiatorDiv.empty();
        $.each(targets, function(index, targetJson) {
            radiatorDiv.append(ORG.NETMELODY.newTargetWidget(targetJson).getContent());
        });
    }
    
    return {
        updateFrom: refresh,
        getContent: function() { return radiatorDiv; }
    };
};

ORG.NETMELODY.newRadiator = function(radiatorDiv, repeatingTaskProvider) {
    var radiatorWidget = ORG.NETMELODY.newRadiatorWidget();
    
    function refresh() {
        $.getJSON('landscapeobservation.json', { landscapeName: 'HIP' }, function(targetList) {
            radiatorWidget.updateFrom(targetList);
        });
    }
    
    function startup() {
        $(radiatorDiv).append(radiatorWidget.getContent());
    
        refresh();
        repeatingTaskProvider.setInterval(refresh, 1000);
    }
    
    return {
        start: startup
    };
};

window.onload = function() {
    ORG.NETMELODY.newRadiator(document.getElementById('radiator'), window).start();
}
{'fraction_non_alphanumeric': 0.1400238592305398, 'fraction_numerical': 0.0026841634357291978, 'mean_word_length': 2.2574065080135988, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 29, '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': '6108027', 'n_tokens_mistral': 2033, 'n_tokens_neox': 1991, 'n_words': 304}