<commit_before>'use strict';

var ko = require('knockout');
var $ = require('jquery');
var bootbox = require('bootbox');
require('bootstrap.growl');
var History = require('exports?History!history');

var siteLicenses = require('js/licenses');
var licenses = siteLicenses.list;
var DEFAULT_LICENSE = siteLicenses.DEFAULT_LICENSE;
var OTHER_LICENSE = siteLicenses.OTHER_LICENSE;

var $osf = require('js/osfHelpers');
// Enable knockout punches
ko.punches.enableAll();

// Disable IE Caching of JSON
$.ajaxSetup({ cache: false });

var Category = function(name, count, display){
    var self = this;

    self.name = name;
    self.count = count;
    self.display = display;

    self.url = ko.computed(function() {
        if (self.name === 'total') {
            return '';
        }
        return self.name + '/';
    });
};

var Tag = function(tagInfo){
    var self = this;
    self.name = tagInfo.key;
    self.count = tagInfo.doc_count;
};

var License = function(name, count) {

    this.name = name;
    this.count = ko.observable(count);
    
    this.active = ko.observable(false);
};
License.prototype.toggleActive = function() {
    this.active(!this.active());
};

var User = function(result){
    var self = this;
    self.category = result.category;
    self.gravatarUrl = ko.observable('');
    self.social = result.social;
    self.job_title = result.job_title;
    self.job = result.job;
    self.degree = result.degree;
    self.school = result.school;
    self.url = result.url;
    self.user = result.user;

    $.ajax('/api/v1'+ result.url).success(function(data){
        if (typeof data.profile !== 'undefined') {
            self.gravatarUrl(data.profile.gravatar_url);
        }
    });
};

var ViewModel = function(params) {
    var self = this;
    self.params = params || {};
    self.queryUrl = self.params.url;
    self.appURL = self.params.appURL;

    self.tag = ko.observable('');
    self.stateJustPushed = true;
    self.query = ko.observable('');
    self.category = ko.observable({});
    self.tags = ko.observableArray([]);
    self.tagMaxCount = ko.observable(1);
    self.currentPage = ko.observable(1);
    self.totalResults = ko.observable(0);
    self.results = ko.observableArray([]);
    self.searching = ko.observable(false);
    self.resultsPerPage = ko.observable(10);
    self.categories = ko.observableArray([]);
    self.shareCategory = ko.observable('');
    self.searchStarted = ko.observable(false);
    self.showSearch = true;
    self.showClose = false;
    self.searchCSS = ko.observable('active');
    self.onSearchPage = true;

    self.licenses = ko.observableArray(
        $.map(licenses, function(license) {
            var l = new License(license.name, 0);
            l.active.subscribe(function() {
                self.search();
            });
            return l;
        })
    );
    self.licenseNames = ko.computed(function() {
        var sortedLicenses = self.licenses() || [];
        sortedLicenses.sort(function(a, b) {
            if (a.count() > b.count()) {
                return -1;
            }
            else if (b.count() > a.count()) {
                return 1;
            }
            else {
                if (a.name > b.name) {
                    return -1;
                }
                else {
                    return 1;
                }
                return a.name > b.name;
            }
        });
        return $.map(sortedLicenses, function(count, name) {
            return name;<commit_msg>Make search licenses a non-observable array<commit_after>'use strict';

var ko = require('knockout');
var $ = require('jquery');
var bootbox = require('bootbox');
require('bootstrap.growl');
var History = require('exports?History!history');

var siteLicenses = require('js/licenses');
var licenses = siteLicenses.list;
var DEFAULT_LICENSE = siteLicenses.DEFAULT_LICENSE;
var OTHER_LICENSE = siteLicenses.OTHER_LICENSE;

var $osf = require('js/osfHelpers');
// Enable knockout punches
ko.punches.enableAll();

// Disable IE Caching of JSON
$.ajaxSetup({ cache: false });

var Category = function(name, count, display){
    var self = this;

    self.name = name;
    self.count = count;
    self.display = display;

    self.url = ko.computed(function() {
        if (self.name === 'total') {
            return '';
        }
        return self.name + '/';
    });
};

var Tag = function(tagInfo){
    var self = this;
    self.name = tagInfo.key;
    self.count = tagInfo.doc_count;
};

var License = function(name, count) {

    this.name = name;
    this.count = ko.observable(count);
    
    this.active = ko.observable(false);
};
License.prototype.toggleActive = function() {
    this.active(!this.active());
};

var User = function(result){
    var self = this;
    self.category = result.category;
    self.gravatarUrl = ko.observable('');
    self.social = result.social;
    self.job_title = result.job_title;
    self.job = result.job;
    self.degree = result.degree;
    self.school = result.school;
    self.url = result.url;
    self.user = result.user;

    $.ajax('/api/v1'+ result.url).success(function(data){
        if (typeof data.profile !== 'undefined') {
            self.gravatarUrl(data.profile.gravatar_url);
        }
    });
};

var ViewModel = function(params) {
    var self = this;
    self.params = params || {};
    self.queryUrl = self.params.url;
    self.appURL = self.params.appURL;

    self.tag = ko.observable('');
    self.stateJustPushed = true;
    self.query = ko.observable('');
    self.category = ko.observable({});
    self.tags = ko.observableArray([]);
    self.tagMaxCount = ko.observable(1);
    self.currentPage = ko.observable(1);
    self.totalResults = ko.observable(0);
    self.results = ko.observableArray([]);
    self.searching = ko.observable(false);
    self.resultsPerPage = ko.observable(10);
    self.categories = ko.observableArray([]);
    self.shareCategory = ko.observable('');
    self.searchStarted = ko.observable(false);
    self.showSearch = true;
    self.showClose = false;
    self.searchCSS = ko.observable('active');
    self.onSearchPage = true;

    self.licenses = $.map(licenses, function(license) {
        var l = new License(license.name, 0);
        l.active.subscribe(function() {
            self.search();
        });
        return l;
    });
    self.licenseNames = ko.computed(function() {
        var sortedLicenses = self.licenses() || [];
        sortedLicenses.sort(function(a, b) {
            if (a.count() > b.count()) {
                return -1;
            }
            else if (b.count() > a.count()) {
                return 1;
            }
            else {
                if (a.name > b.name) {
                    return -1;
                }
                else {
                    return 1;
                }
                return a.name > b.name;
            }
        });
        return $.map(sortedLicenses, function(count, name) {
            return name;
{'fraction_non_alphanumeric': 0.14600629831090753, 'fraction_numerical': 0.0031491554537646724, 'mean_word_length': 2.283364661654135, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2460521', 'n_tokens_mistral': 2169, 'n_tokens_neox': 2110, 'n_words': 431}