<commit_before><%
upload_field = controller_name.downcase.singularize.underscore
upload_field = 'content_blob'  if resource.respond_to?(:content_blobs)
%>
<script>
    function validateUploadFormFields(form){
        if ($('<%= "#{upload_field}_data" -%>').value.length == 0 && $('<%= "#{upload_field}_data_url" -%>').value.length == 0) {
            alert("Please specify the name of the file to upload or provide a URL	");
            $('<%= "#{upload_field}_data" -%>').focus();
            return (false);
        }
        $('new_version_submit_btn').disabled = true;
        $('new_version_submit_btn').value = "Uploading ...";
        $('new_version_submit_btn').form.submit();
        return (true);
    }
</script>
<% if logged_in? && current_user.person.member? -%>
<div id="upload_new_version_form" style="display:none">
    <% form_tag({:action=>"new_version", :id=>resource}, :multipart => true) do -%>
        <div style="width:95%;margin-top:0.75em; margin-left: 2em">
           <% locals = resource.respond_to?(:content_blobs) ? {:resource=>resource, :new_version=>true} : {:new_version=>true}  %>
           <%= render :partial=>"assets/upload_box" ,:locals=>locals-%>

            <p>
                <b>Revision comments (optional)</b>
                <br/>
                <%= text_area_tag :revision_comment, nil, :size=>"55x4" -%>
                <br/>
                <%= submit_tag "Upload", :id => "new_version_submit_btn", :onclick => "javascript: validateUploadFormFields(this.form); return(false);" -%>
            </p>
        </div>
    <% end -%>
</div>
<%end%><commit_msg>modify javascript validation for uploading new version<commit_after><%
upload_field = controller_name.downcase.singularize.underscore
upload_field = 'content_blob'  if resource.respond_to?(:content_blobs)
%>
<script>
    function validateUploadFormFields(form){
        if (<%= resource.respond_to?(:content_blobs) %>){
            if ($('pending_files').children.length == 0 && $('<%= "#{controller_name.singularize}_image_image_file" -%>') == null){
                alert("Please specify at least a file to upload or provide a URL.");
                return (false);
            }else if ($('pending_files').children.length == 0 && $('<%= "#{controller_name.singularize}_image_image_file" -%>') != null && $('<%= "#{controller_name.singularize}_image_image_file" -%>').value == ''){
               alert("Please specify at least a file/image to upload or provide a URL.");
               return (false);
            }
        }else{
            if ($('<%= "#{upload_field}_data" -%>').value.length == 0 && $('<%= "#{upload_field}_data_url" -%>').value.length == 0){
                alert("Please specify at least a file to upload or provide a URL.");
                $('<%= "#{upload_field}_data" -%>').focus();
                return (false);

            }
        }

        $('new_version_submit_btn').disabled = true;
        $('new_version_submit_btn').value = "Uploading ...";
        $('new_version_submit_btn').form.submit();
        return (true);
    }
</script>
<% if logged_in? && current_user.person.member? -%>
<div id="upload_new_version_form" style="display:none">
    <% form_tag({:action=>"new_version", :id=>resource}, :multipart => true) do -%>
        <div style="width:95%;margin-top:0.75em; margin-left: 2em">
           <% locals = resource.respond_to?(:content_blobs) ? {:resource=>resource, :new_version=>true} : {:new_version=>true}  %>
           <%= render :partial=>"assets/upload_box" ,:locals=>locals-%>

            <p>
                <b>Revision comments (optional)</b>
                <br/>
                <%= text_area_tag :revision_comment, nil, :size=>"55x4" -%>
                <br/>
                <%= submit_tag "Upload", :id => "new_version_submit_btn", :onclick => "javascript: validateUploadFormFields(this.form); return(false);" -%>
            </p>
        </div>
    <% end -%>
</div>
<%end%>
{'fraction_non_alphanumeric': 0.1888607594936709, 'fraction_numerical': 0.0060759493670886075, 'mean_word_length': 2.791746641074856, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 77, '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': '3864821', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1213, 'n_words': 224}