<commit_before>// save-resource-as.js
/*
   Copyright (c) 2011 3 Round Stones Inc, Some Rights Reserved
   Licensed under the Apache License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0
*/

(function($){

if (!window.calli) {
    window.calli = {};
}

window.calli.slugify = function(label) {
    if (!label)
        return label;
    if (label.lastIndexOf('\\') > 0) {
        // IE file input
        label = label.substring(label.lastIndexOf('\\') + 1);
    }
    return removeDiacritics(label).toLowerCase().replace(/\s+/g, '+').replace(/[^\w\+\-\_\.\!\~\*\'\(\);\,\&\=\$\[\]]+/g,'_');
};

window.calli.saveFormAs = function(event, fileName, create) {
    return calli.saveResourceAs(event, fileName, create);
};
var nestedSubmit = false;
window.calli.saveResourceAs = function(event, fileName, create) {
    event = calli.fixEvent(event);
    var form = event.target;
    if(!$(form).is('form')) form = $(form).closest('form')[0];

    $(form).find("input").change(); // IE may not have called onchange before onsubmit
    var resource = $(form).attr('about') || $(form).attr('resource');
    if (event.type == 'submit') {
        if (fileName && !nestedSubmit) {
            // set resource attribute and go
            var ns = calli.listResourceIRIs(calli.getPageUrl())[0];
            if (resource) {
                ns = resource.replace(/[^\/]*\/?$/, ''); // get parent folder
            } else if (ns.lastIndexOf('/') != ns.length - 1
                    && window.location.search.indexOf('?create=') == 0) {
                ns += '/';
            } else if (window.location.search != '?create') {
                ns = ns.replace(/[^\/]*$/, ''); // get folder
            }
            if (ns) {
                var local = encodeURI(fileName).replace(/%25(\w\w)/g, '%$1').replace(/%20/g, '+');
                resource = ns + local;
                $(form).removeAttr('about');
                $(form).attr('resource', resource);
            }
        }
        if (resource) {
            // resource attribute ready set, let's go
            overrideLocation(form, resource);
            return true;
        }
    }
    // prompt for a new resource URI<commit_msg>Always show save as dialogue when resource is created from class page<commit_after>// save-resource-as.js
/*
   Copyright (c) 2011 3 Round Stones Inc, Some Rights Reserved
   Licensed under the Apache License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0
*/

(function($){

if (!window.calli) {
    window.calli = {};
}

window.calli.slugify = function(label) {
    if (!label)
        return label;
    if (label.lastIndexOf('\\') > 0) {
        // IE file input
        label = label.substring(label.lastIndexOf('\\') + 1);
    }
    return removeDiacritics(label).toLowerCase().replace(/\s+/g, '+').replace(/[^\w\+\-\_\.\!\~\*\'\(\);\,\&\=\$\[\]]+/g,'_');
};

window.calli.saveFormAs = function(event, fileName, create) {
    return calli.saveResourceAs(event, fileName, create);
};
var nestedSubmit = false;
window.calli.saveResourceAs = function(event, fileName, create) {
    event = calli.fixEvent(event);
    var form = event.target;
    if(!$(form).is('form')) form = $(form).closest('form')[0];

    $(form).find("input").change(); // IE may not have called onchange before onsubmit
    var resource = $(form).attr('about') || $(form).attr('resource');
    if (event.type == 'submit') {
        if (fileName && !nestedSubmit) {
            // set resource attribute and go
            var ns = calli.listResourceIRIs(calli.getPageUrl())[0];
            if (resource) {
                ns = resource.replace(/[^\/]*\/?$/, ''); // get parent folder
            } else if (ns.lastIndexOf('/') != ns.length - 1
                    && window.location.search.indexOf('?create=') == 0) {
                ns += '/';
            } else if (window.location.search == '?create') {
                ns = null; // no location available
            } else {
                ns = ns.replace(/[^\/]*$/, ''); // get folder
            }
            if (ns) {
                var local = encodeURI(fileName).replace(/%25(\w\w)/g, '%$1').replace(/%20/g, '+');
                resource = ns + local;
                $(form).removeAttr('about');
                $(form).attr('resource', resource);
            }
        }
        if (resource) {
            // resource attribute ready set, let's go
            overrideLocation(form, resource);
            return true;
        }
    }
    // prompt for a new resource URI
{'fraction_non_alphanumeric': 0.18826135105204872, 'fraction_numerical': 0.008859357696566999, 'mean_word_length': 2.0637720488466758, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7652243', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1350, 'n_words': 306}