<commit_before>//= require knockout.min
//= require knockout-mapping
//= require knockout-onenter
//= require knockout-foreachprop
//= require knockout-node-filter-link
//= require ko/binding-popover
//= require ko/binding-message-template
/*
 Copyright 2014 SimplifyOps Inc, <http://simplifyops.com>

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */
var NODE_FILTER_ALL='.*';
function NodeSummary(data){
    var self=this;
    self.error=ko.observable();
    self.tags=ko.observableArray();
    self.filters=ko.observableArray();
    self.defaultFilter=ko.observable();
    self.totalCount=ko.observable(0);
    self.baseUrl=data.baseUrl?data.baseUrl:'';
    self.filterToDelete=ko.observable();
    
    self.reload=function(){
      jQuery.ajax({
          url:_genUrl(appLinks.frameworkNodeSummaryAjax),
          type:'GET',

          error:function(data,jqxhr,err){
              self.error('Recent commands list: request failed for '+requrl+': '+err+", "+jqxhr);
          }
      }).success(function(data){
          ko.mapping.fromJS(data,{},self);
      });
    };
    self.linkForTagFilter=function(tag){
        return _genUrl(self.baseUrl,{filter: 'tags:'+tag.tag()});
    };
    self.linkForFilterName=function(filter){
        return _genUrl(self.baseUrl,{filterName: filter.name()});
    };
    /**
     * Generate URL for the NodeFilters object
     * @param nodefilters
     * @returns {*}
     */
    self.linkForNodeFilters=function(nodefilters){
        return _genUrl(self.baseUrl,nodefilters.getPageParams());
    };
    self.findFilterByName=function(name){
        var found=ko.utils.arrayFilter(self.filters(),function(e){return e.name()==name;});
        if(found && found.length==1){
            return found[0];
        }else{
            return null;
        }
    };
    self.removeDefault=function(){
        setFilter('nodes','!').success(function(data, status, jqxhr){
            self.defaultFilter(null);
        });
    };
    self.setDefaultAll=function(){
        self.setDefault(NODE_FILTER_ALL);
    };

    self.setDefault=function(filter){
        var fname=null;
        if(typeof(filter)=='string'){
            if(filter==NODE_FILTER_ALL){
                fname=filter;
            }else {
                filter = self.findFilterByName(filter);
                if (!filter) {
                    return;
                }
                fname = filter.name();
            }
        }else{
            fname=filter.name();
        }
        setFilter('nodes',fname).success(function(data, status, jqxhr){
            self.defaultFilter(fname);
        });
    };
    self.deleteFilterConfirm=function(filter){
        if(typeof(filter)=='string'){
            filter = self.findFilterByName(filter);
            if(!filter){
                return;
            }
        }
        self.filterToDelete(filter);
        jQuery('#deleteFilterKOModal').modal('show');
    };
    self.deleteFilter=function(filter){

        jQuery('#deleteFilterKOModal').modal('hide');
        jQuery.ajax({
            url:_genUrl(appLinks.frameworkDeleteNodeFilterAjax,{filtername:filter.name()}),
            beforeSend: _ajaxSendTokens.curry('ajaxDeleteFilterTokens')
        }).success(function (resp, status, jqxhr) {
            self.filterToDelete(null);
            self.filters.remove(filter);
        }).success(_ajaxReceiveTokens.curry('ajaxDeleteFilterTokens'));
    };
    if(data) {
        ko.mapping.fromJS(data, {}, self);
    }
}
var CSSColors='aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkturquoise darkviolet deeppink deepskyblue dimgray dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen'.split(' ');
function NodeEntry(data){
    var self=this;
    self.expanded=ko.observable(false);
    self.expandedNs=ko.observable({});

    self.toggleExpanded=function(){
        self.expanded(!self.expanded());
    };
    self.toggleExpandedNs=function(ns){
        var obj=self.expandedNs();
        if(null==obj[ns]){
            obj[ns]=ko.observable(true);
        }else{
            obj[ns](!obj[ns]());
        }

    };
    self.isExpandedNs=function(ns){
        var obj=self.expandedNs();
        if(null==obj[ns]){
            obj[ns]=ko.observable(false);
        }
        return obj[ns];
    };
    if(data) {
        ko.mapping.fromJS(data, {}, self);
    }
}
/**
 * The set of node results
 * @param data
 * @constructor
 */
function NodeSet(data) {
    var self = this;
    self.nodes=ko.observableArray([]);
    self.tagsummary=ko.observable();

    var mapping = {

        'nodes': {

            key: function (data) {
                return ko.utils.unwrapObservable(data.nodename);
            }
            ,
            create: function (options) {
                return new NodeEntry(options.data);
            }
        }
    };

    self.glyphiconCss=function(name){
        if(name.match(/^glyphicon-[a-z-]+$/)){
            return 'glyphicon '+name;
        }
        return '';
    };
    self.glyphiconBadges=function(attributes){
        var badges=[];
        if(attributes['ui:badges']){
            var found=attributes['ui:badges']().split(/,\s*/g);
            for(var i=0;i<found.length;i++){
                if(found[i].match(/^glyphicon-[a-z-]+$/)){
                    badges.push(found[i]);
                }
            }
        }

        return badges;
    };
    self.isAnsiFg=function(str){
        return str!=null && typeof(str)=='string' && str.match(/^ansi-fg-(light-)?(black|green|red|yellow|blue|magenta|cyan|white)$/);
    };
    self.isStyleFg=function(str){
        return str!=null && typeof(str)=='string' && str.match(/^#[0-9a-fA-F]{3,6}$/) || CSSColors.indexOf(str)>=0;<commit_msg>don't reuse dom nodes for node entries<commit_after>//= require knockout.min
//= require knockout-mapping
//= require knockout-onenter
//= require knockout-foreachprop
//= require knockout-node-filter-link
//= require ko/binding-popover
//= require ko/binding-message-template
/*
 Copyright 2014 SimplifyOps Inc, <http://simplifyops.com>

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 */
var NODE_FILTER_ALL='.*';
function NodeSummary(data){
    var self=this;
    self.error=ko.observable();
    self.tags=ko.observableArray();
    self.filters=ko.observableArray();
    self.defaultFilter=ko.observable();
    self.totalCount=ko.observable(0);
    self.baseUrl=data.baseUrl?data.baseUrl:'';
    self.filterToDelete=ko.observable();
    
    self.reload=function(){
      jQuery.ajax({
          url:_genUrl(appLinks.frameworkNodeSummaryAjax),
          type:'GET',

          error:function(data,jqxhr,err){
              self.error('Recent commands list: request failed for '+requrl+': '+err+", "+jqxhr);
          }
      }).success(function(data){
          ko.mapping.fromJS(data,{},self);
      });
    };
    self.linkForTagFilter=function(tag){
        return _genUrl(self.baseUrl,{filter: 'tags:'+tag.tag()});
    };
    self.linkForFilterName=function(filter){
        return _genUrl(self.baseUrl,{filterName: filter.name()});
    };
    /**
     * Generate URL for the NodeFilters object
     * @param nodefilters
     * @returns {*}
     */
    self.linkForNodeFilters=function(nodefilters){
        return _genUrl(self.baseUrl,nodefilters.getPageParams());
    };
    self.findFilterByName=function(name){
        var found=ko.utils.arrayFilter(self.filters(),function(e){return e.name()==name;});
        if(found && found.length==1){
            return found[0];
        }else{
            return null;
        }
    };
    self.removeDefault=function(){
        setFilter('nodes','!').success(function(data, status, jqxhr){
            self.defaultFilter(null);
        });
    };
    self.setDefaultAll=function(){
        self.setDefault(NODE_FILTER_ALL);
    };

    self.setDefault=function(filter){
        var fname=null;
        if(typeof(filter)=='string'){
            if(filter==NODE_FILTER_ALL){
                fname=filter;
            }else {
                filter = self.findFilterByName(filter);
                if (!filter) {
                    return;
                }
                fname = filter.name();
            }
        }else{
            fname=filter.name();
        }
        setFilter('nodes',fname).success(function(data, status, jqxhr){
            self.defaultFilter(fname);
        });
    };
    self.deleteFilterConfirm=function(filter){
        if(typeof(filter)=='string'){
            filter = self.findFilterByName(filter);
            if(!filter){
                return;
            }
        }
        self.filterToDelete(filter);
        jQuery('#deleteFilterKOModal').modal('show');
    };
    self.deleteFilter=function(filter){

        jQuery('#deleteFilterKOModal').modal('hide');
        jQuery.ajax({
            url:_genUrl(appLinks.frameworkDeleteNodeFilterAjax,{filtername:filter.name()}),
            beforeSend: _ajaxSendTokens.curry('ajaxDeleteFilterTokens')
        }).success(function (resp, status, jqxhr) {
            self.filterToDelete(null);
            self.filters.remove(filter);
        }).success(_ajaxReceiveTokens.curry('ajaxDeleteFilterTokens'));
    };
    if(data) {
        ko.mapping.fromJS(data, {}, self);
    }
}
var CSSColors='aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkturquoise darkviolet deeppink deepskyblue dimgray dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen'.split(' ');
function NodeEntry(data){
    var self=this;
    self.expanded=ko.observable(false);
    self.expandedNs=ko.observable({});

    self.toggleExpanded=function(){
        self.expanded(!self.expanded());
    };
    self.toggleExpandedNs=function(ns){
        var obj=self.expandedNs();
        if(null==obj[ns]){
            obj[ns]=ko.observable(true);
        }else{
            obj[ns](!obj[ns]());
        }

    };
    self.isExpandedNs=function(ns){
        var obj=self.expandedNs();
        if(null==obj[ns]){
            obj[ns]=ko.observable(false);
        }
        return obj[ns];
    };
    if(data) {
        ko.mapping.fromJS(data, {}, self);
    }
}
/**
 * The set of node results
 * @param data
 * @constructor
 */
function NodeSet(data) {
    var self = this;
    self.nodes=ko.observableArray([]);
    self.tagsummary=ko.observable();

    var mapping = {

        'nodes': {
            //nb: don't use a key: function because in some cases
            //we need a new dom element every time we redraw nodes,
            //and a key function will cause re-use of the element

            create: function (options) {
                return new NodeEntry(options.data);
            }
        }
    };

    self.glyphiconCss=function(name){
        if(name.match(/^glyphicon-[a-z-]+$/)){
            return 'glyphicon '+name;
        }
        return '';
    };
    self.glyphiconBadges=function(attributes){
        var badges=[];
        if(attributes['ui:badges']){
            var found=attributes['ui:badges']().split(/,\s*/g);
            for(var i=0;i<found.length;i++){
                if(found[i].match(/^glyphicon-[a-z-]+$/)){
                    badges.push(found[i]);
                }
            }
        }

        return badges;
    };
    self.isAnsiFg=function(str){
        return str!=null && typeof(str)=='string' && str.match(/^ansi-fg-(light-)?(black|green|red|yellow|blue|magenta|cyan|white)$/);
    };
    self.isStyleFg=function(str){
        return str!=null && typeof(str)=='string' && str.match(/^#[0-9a-fA-F]{3,6}$/) || CSSColors.indexOf(str)>=0;
{'fraction_non_alphanumeric': 0.12184169961798808, 'fraction_numerical': 0.002278667649621339, 'mean_word_length': 2.8340184994861253, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4737466', 'n_tokens_mistral': 4464, 'n_tokens_neox': 4315, 'n_words': 897}