<commit_before>jQuery(document).ready(function() {
    //jQuery('#woocommerce-product-data .type_box').html(jQuery('#woocommerce-product-data .type_box').html()+'<label class="show_if_simple tips" for="_use_edition_guard" style="display: inline;" data-tip="Enable to use EditionGuard DRM">Use EditionGuard DRM: <input type="checkbox" id="_use_edition_guard" name="_use_edition_guard"></label>');	
    if (woo_eg.on)
        var checked = 'checked ';
    else
        checked = '';

    if(woo_eg.title == "")
        var current = '<span id="_current_ebook">-</span>';
    else
        current = '<span id="_current_ebook">'+woo_eg.title+' ('+woo_eg.r_id+')</span>';
        
    var woo_fields = jQuery('.options_group.show_if_downloadable').html();

    var p1 = '<p class="form-field-both"><input type="checkbox" ' + checked + 'name="_use_edition_guard" style="width:auto" onclick="use_editionguard_drm_trigger(this)"/>&nbsp;Use EditionGuard eBook DRM</p><p class="form-field-drm"><label>Currently Used eBook:</label>'+current+'</p>';

    if (woo_eg.r_id == "")
        var value = '';
    else
        value = 'value="' + woo_eg.r_id + '" ';
    var input = '<input type="hidden" name="_eg_resource_id" id="_eg_resource_id" ' + value + 'placeholder="EditionGuard Resource ID" />'
               +'<input type="hidden" name="_eg_title" id="_eg_title"/>'
               +'<input type="hidden" name="_eg_drm_type" id="_eg_drm_type" value="' + woo_eg.drm_type+'"/>';
    var p2 = input;

    var label = '<label for="_file_paths">Choose eBook</label>';
    select = '<select style="width:410px" id="ebook_library">';
    if (woo_eg.library) jQuery.each(woo_eg.library, function(k, v) {
        select += '<option title="' + v.title + '" value="' + v.resource_id + '" data-drm-type="'+v.drm_type+'">' + v.title + ' (' + v.resource_id + ')' + '</option>';
    })
    select += '</select>';
    var button = '<input type="button" onclick="use_ebook()" class="use_button_edition_guard button" value="Use">';
    var p3 = '<p class="form-field-drm"><b>Use an existing eBook uploaded to your EditionGuard account</b></p><p class="form-field-drm">' + label + select + button + '</p><p class="form-field-drm"><b><i>--- OR ---</i></b></p>';

    var img = '<img class="eg_ajax" style="padding:2px 10px;display:none" src="' + woo_eg.plugin_dir + 'ajax-loader.gif" />';
    var label = '<label for="_file_paths">Choose eBook File</label>';
    if (woo_eg.r_id == "")
        var value = '';
    else
        value = 'value="' + woo_eg.r_id + '" ';
    var file_input = '<input type="button" onclick="use_editionguard_drm()" class="upload_file_button_edition_guard button" value="Choose a file">';
    var p4 = '<p class="form-field-drm"><b>Upload an eBook From My Computer</b></p><p class="form-field-drm"><label for="_use_edition_guard">eBook File Title: </label><input type="text" id="use_edition_guard_title" name="_use_edition_guard_title" style="width:auto"></p>';

    var p5 = '<p class="form-field-drm">' + label + file_input + img + '</p>';

    jQuery('.options_group.show_if_downloadable').html(p1 + woo_fields + p2 + p3 + p4 + p5);

    if (woo_eg.on)
    {
        jQuery('.options_group.show_if_downloadable .form-field').hide();
        jQuery('.options_group.show_if_downloadable .form-field-drm').show();
    }
    
});
var woo_eg_old_click_handler;
function use_ebook()
{
    var resource_id = jQuery('#ebook_library').val()
    jQuery('#_eg_resource_id').val(resource_id);
    jQuery('#_current_ebook').html(jQuery('#ebook_library option:selected').text());
    jQuery('#_eg_title').val(jQuery('#ebook_library option:selected').attr('title'));
    jQuery('#_eg_drm_type').val(jQuery('#ebook_library option:selected').attr('data-drm-type'));
    alert("eBook selection updated. Please update the product to save your changes.");
    
}
function use_editionguard_drm_trigger(object)
{
    if (object.checked)
    {
        if ((woo_eg.email == "") || (woo_eg.hash == ""))<commit_msg>close #5 Remove all eBook upload functionality<commit_after>jQuery(document).ready(function() {
    //jQuery('#woocommerce-product-data .type_box').html(jQuery('#woocommerce-product-data .type_box').html()+'<label class="show_if_simple tips" for="_use_edition_guard" style="display: inline;" data-tip="Enable to use EditionGuard DRM">Use EditionGuard DRM: <input type="checkbox" id="_use_edition_guard" name="_use_edition_guard"></label>');	
    if (woo_eg.on)
        var checked = 'checked ';
    else
        checked = '';

    if(woo_eg.title == "")
        var current = '<span id="_current_ebook">-</span>';
    else
        current = '<span id="_current_ebook">'+woo_eg.title+' ('+woo_eg.r_id+')</span>';
        
    var woo_fields = jQuery('.options_group.show_if_downloadable').html();

    var p1 = '<p class="form-field-both"><input type="checkbox" ' + checked + 'name="_use_edition_guard" style="width:auto" onclick="use_editionguard_drm_trigger(this)"/>&nbsp;Use EditionGuard eBook DRM</p><p class="form-field-drm"><label>Currently Used eBook:</label>'+current+'</p>';

    if (woo_eg.r_id == "")
        var value = '';
    else
        value = 'value="' + woo_eg.r_id + '" ';
    var input = '<input type="hidden" name="_eg_resource_id" id="_eg_resource_id" ' + value + 'placeholder="EditionGuard Resource ID" />'
               +'<input type="hidden" name="_eg_title" id="_eg_title"/>'
               +'<input type="hidden" name="_eg_drm_type" id="_eg_drm_type" value="' + woo_eg.drm_type+'"/>';
    var p2 = input;

    var label = '<label for="_file_paths">Choose eBook</label>';
    select = '<select style="width:410px" id="ebook_library">';
    if (woo_eg.library) jQuery.each(woo_eg.library, function(k, v) {
        select += '<option title="' + v.title + '" value="' + v.resource_id + '" data-drm-type="'+v.drm_type+'">' + v.title + ' (' + v.resource_id + ')' + '</option>';
    })
    select += '</select>';
    var button = '<input type="button" onclick="use_ebook()" class="use_button_edition_guard button" value="Use">';
    var p3 = '<p class="form-field-drm"><b>Use an existing eBook uploaded to your EditionGuard account</b></p><p class="form-field-drm">' + label + select + button + '</p>';

    var img = '<img class="eg_ajax" style="padding:2px 10px;display:none" src="' + woo_eg.plugin_dir + 'ajax-loader.gif" />';
    var label = '<label for="_file_paths">Choose eBook File</label>';
    if (woo_eg.r_id == "")
        var value = '';
    else
        value = 'value="' + woo_eg.r_id + '" ';


    jQuery('.options_group.show_if_downloadable').html(p1 + woo_fields + p2 + p3 /*+ p4 + p5*/);

    if (woo_eg.on)
    {
        jQuery('.options_group.show_if_downloadable .form-field').hide();
        jQuery('.options_group.show_if_downloadable .form-field-drm').show();
    }
    
});
var woo_eg_old_click_handler;
function use_ebook()
{
    var resource_id = jQuery('#ebook_library').val()
    jQuery('#_eg_resource_id').val(resource_id);
    jQuery('#_current_ebook').html(jQuery('#ebook_library option:selected').text());
    jQuery('#_eg_title').val(jQuery('#ebook_library option:selected').attr('title'));
    jQuery('#_eg_drm_type').val(jQuery('#ebook_library option:selected').attr('data-drm-type'));
    alert("eBook selection updated. Please update the product to save your changes.");
    
}
function use_editionguard_drm_trigger(object)
{
    if (object.checked)
    {
        if ((woo_eg.email == "") || (woo_eg.hash == ""))
{'fraction_non_alphanumeric': 0.19244170463682658, 'fraction_numerical': 0.004154382203162691, 'mean_word_length': 4.186240444753301, 'pattern_counts': {'":': 0, '<': 87, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1977346', 'n_tokens_mistral': 2542, 'n_tokens_neox': 2464, 'n_words': 453}