<commit_before>/**
 * Created by duncan on 6/6/16.
 */

var app = app || {}; 

(function (hex) { // jshint ignore: line
CheckLayerBox = (function () { // jshint ignore: line
 
    var LayerPostOffice = new Mongo.Collection('LayerPostOffice');
    var last_layer_names = []; // list of layer names from the last update

    function jsonLayer(layer){
        //puts together two parallel arrays and makes a single Json data layer
        var vals = layer.data.values;
        var nodes = layer.data.node_ids;

        var Json = {};
        for (var i = 0 ; i < vals.length; i++){
            Json[nodes[i]] = vals[i];
        }
        return Json;
    }
    

    function remove_layer(layer_name) {
        var user = Meteor.user();
        if (user) {
            console.log('checkLayerBox.js: remove_layer(', layer_name, ')');
            Meteor.subscribe(
                'deleteLayer', user.username, ctx.project, layer_name);
        }
    }

    function receive_layers (layers) {
        
        //iterate through layers and place them in the shortlist
        _.each(layers, function (layerIn){
            var layer = {
                data: jsonLayer(layerIn),
                n: layerIn.n,
                dataType: 'categorical',
                removeFx: remove_layer,
                reflection: true,
                colormap: layerIn.colormap,
            }
            
            var dynLayers = {};
            dynLayers[layerIn.layer_name] = layer;
            
            // Add the layer to the global layer objects
            Layer.with_layer(layerIn.layer_name, function(){}, dynLayers);
        });
    }
        
    function layers_received (layers) {
        // Find and handle new layers and removed layers

        // Find any new layers and add them to the shortlist
        var doc_layer_names = [];
        var new_layers = _.filter(layers, function (layer) {
            doc_layer_names.push(layer.layer_name);
            return (last_layer_names.indexOf(layer.layer_name) < 0);
        });

        receive_layers(new_layers);

        // Find any layers removed and remove them from the shortlist
        _.each(last_layer_names, function (layer_name) {<commit_msg>replaced hard coding of reflection datatype<commit_after>/**
 * Created by duncan on 6/6/16.
 */

var app = app || {}; 

(function (hex) { // jshint ignore: line
CheckLayerBox = (function () { // jshint ignore: line
 
    var LayerPostOffice = new Mongo.Collection('LayerPostOffice');
    var last_layer_names = []; // list of layer names from the last update

    function jsonLayer(layer){
        //puts together two parallel arrays and makes a single Json data layer
        var vals = layer.data.values;
        var nodes = layer.data.node_ids;

        var Json = {};
        for (var i = 0 ; i < vals.length; i++){
            Json[nodes[i]] = vals[i];
        }
        return Json;
    }
    

    function remove_layer(layer_name) {
        var user = Meteor.user();
        if (user) {
            console.log('checkLayerBox.js: remove_layer(', layer_name, ')');
            Meteor.subscribe(
                'deleteLayer', user.username, ctx.project, layer_name);
        }
    }

    function receive_layers (layers) {
        
        //iterate through layers and place them in the shortlist
        _.each(layers, function (layerIn){
            var layer = {
                data: jsonLayer(layerIn),
                n: layerIn.n,
                dataType: layerIn.dataType,
                removeFx: remove_layer,
                reflection: true,
                colormap: layerIn.colormap,
            }
            
            var dynLayers = {};
            dynLayers[layerIn.layer_name] = layer;
            
            // Add the layer to the global layer objects
            Layer.with_layer(layerIn.layer_name, function(){}, dynLayers);
        });
    }
        
    function layers_received (layers) {
        // Find and handle new layers and removed layers

        // Find any new layers and add them to the shortlist
        var doc_layer_names = [];
        var new_layers = _.filter(layers, function (layer) {
            doc_layer_names.push(layer.layer_name);
            return (last_layer_names.indexOf(layer.layer_name) < 0);
        });

        receive_layers(new_layers);

        // Find any layers removed and remove them from the shortlist
        _.each(last_layer_names, function (layer_name) {
{'fraction_non_alphanumeric': 0.10087620759379914, 'fraction_numerical': 0.0026960233655358348, 'mean_word_length': 1.8410976388002553, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, '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': '3716177', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1208, 'n_words': 347}