<commit_before>/*jslint browser: true ,undef: true *//*global Ext*/
Ext.define('SlateAdmin.API', {
    extend: 'Emergence.util.AbstractAPI',
    singleton: true,

    // example function
    getMySections: function(callback, scope) {
        this.request({
            url: '/sections/json',
            method: 'GET',
            params: {
                AllCourses: 'false'
            },
            success: callback,
            scope: scope
        });
    },
    downloadFile: function(url, callback, scope, options) {
        options = options || {};

        // create and append downloadToken
        var apiHost = SlateAdmin.API.getHost(),
            downloadToken = Math.random(),
            downloadInterval;

        url = this.buildUrl(Ext.urlAppend(url, 'downloadToken=' + downloadToken));

        // get or create iframe el
        this.downloadFrame = this.downloadFrame || Ext.getBody().createChild({
            tag: 'iframe',
            style: {
                display: 'none'
            }
        });

        if(apiHost) {
            // setup token monitor
            downloadInterval = setInterval(function() {
                if(Ext.util.Cookies.get('downloadToken') == downloadToken)
                {
                    clearInterval(downloadInterval);
                    Ext.util.Cookies.clear('downloadToken');
                    Ext.callback(callback, scope, [url, options]);
                }
            }, options.pollingInterval || 500);
        }

        // launch download
        if(options.openWindow)
        {
            window.open(url);
        }
        else
        {
            // use iframe for loading, setting window.location cancels current network ops
            this.downloadFrame.dom.src = url;
        }
    }
}, function(API) {
    var pageParams = Ext.Object.fromQueryString(location.search);

    // allow API host to be overridden via apiHost param
    if (pageParams.apiHost) {
        API.setHostname(pageParams.apiHost);
        API.setUseSSL(false);
    }
});<commit_msg>Add support for apiSSL query param<commit_after>/*jslint browser: true ,undef: true *//*global Ext*/
Ext.define('SlateAdmin.API', {
    extend: 'Emergence.util.AbstractAPI',
    singleton: true,

    // example function
    getMySections: function(callback, scope) {
        this.request({
            url: '/sections/json',
            method: 'GET',
            params: {
                AllCourses: 'false'
            },
            success: callback,
            scope: scope
        });
    },
    downloadFile: function(url, callback, scope, options) {
        options = options || {};

        // create and append downloadToken
        var apiHost = SlateAdmin.API.getHost(),
            downloadToken = <PASSWORD>(),
            downloadInterval;

        url = this.buildUrl(Ext.urlAppend(url, 'downloadToken=' + downloadToken));

        // get or create iframe el
        this.downloadFrame = this.downloadFrame || Ext.getBody().createChild({
            tag: 'iframe',
            style: {
                display: 'none'
            }
        });

        if(apiHost) {
            // setup token monitor
            downloadInterval = setInterval(function() {
                if(Ext.util.Cookies.get('downloadToken') == downloadToken)
                {
                    clearInterval(downloadInterval);
                    Ext.util.Cookies.clear('downloadToken');
                    Ext.callback(callback, scope, [url, options]);
                }
            }, options.pollingInterval || 500);
        }

        // launch download
        if(options.openWindow)
        {
            window.open(url);
        }
        else
        {
            // use iframe for loading, setting window.location cancels current network ops
            this.downloadFrame.dom.src = url;
        }
    }
}, function(API) {
    var pageParams = Ext.Object.fromQueryString(location.search);

    // allow API host to be overridden via apiHost param
    if (pageParams.apiHost) {
        API.setHostname(pageParams.apiHost);
        API.setUseSSL(!!pageParams.apiSSL);
    }
});
{'fraction_non_alphanumeric': 0.11476997578692494, 'fraction_numerical': 0.0014527845036319612, 'mean_word_length': 1.6755181347150259, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 30, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1443238', 'n_tokens_mistral': 1109, 'n_tokens_neox': 1056, 'n_words': 231}