<commit_before><%= form_for([:admin,@mobile_app]) do |f| %>
  <% if @mobile_app.errors.any? %>
    <div id="error_explanation">
      <div class="error"> <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
          <span class="sr-only">Error:</span><%= pluralize(@mobile_app.errors.count, "error") %> prohibited this mobile app from being saved</div>

      <ul class="inlineErrorMsgs">
      <% @mobile_app.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>
  <% @mobile_app.mobile_app_versions.each_with_index do |version, index|%>
    <% if version.errors.any? %>
      <div id="error_explanation">
        <div class="error"> <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
            <span class="sr-only">Error:</span><%= pluralize(version.errors.count, "error") %> prohibited mobile app version <%= index + 1 %> from being saved</div>

        <ul class="inlineErrorMsgs">
        <% version.errors.full_messages.each do |message| %>
          <li><%= message %></li>
        <% end %>
        </ul>
      </div>
    <% end %>
  <% end %>
  <div class="form_intro">
    <p>Please provide the following information on your mobile product (app or website) for the registry: * denotes a required field</p>
  </div>

  <div class="field">
    <%= f.label :name , "Name of App/Website*"%> </br>
    <%= f.text_field :name, :class => "form-control formwidth" %>
  </div>
  <div class="field">
    <%= f.label :short_description, "Short Description*  - Tagline description; not more than one sentence
" %> </br>
    <%= f.text_field :short_description, :class => "form-control formwidth" %>
  </div>
  <div class="field">
    <%= f.label :long_description, "Long Description* - Should be the same or similar to your app store description" %> </br>
    <%= f.text_area :long_description, :class => "form-control formwidth" %>
  </div>
  </br>
  <div class="field">
    <%= f.label :icon_url, "Icon URL - Please provide the URL of the app or website’s icon" %> </br>
    <%= f.text_field :icon_url, :class => "form-control formwidth" %>
  </div>
  <div class="field">
    <%= f.label :language %> </br>
    <%= f.select :language, options_for_select(language_select_options, @mobile_app.language),{include_blank: "Select"}, {:class => "form-control formwidth"} %>
  </div>
  <div class="field agencies">
    <%= f.label :agency_tokens, "Sponsoring Agencies*" %> </br>
    <%= f.text_field :agency_tokens, {:class => "form-control formwidth", :value => ""} %>
  </div>
  <div class="field">
    <%= f.label :tag_tokens, "Tags" %> </br>
    <%= f.text_field :tag_tokens, {:class => "form-control formwidth", :value => "" }%>
  </div>
  <div class="contacts">
    <div class="field">
      <%= f.label :user_tokens, "Contacts* - please provide two contact names" %></br>
      <%= f.text_field :user_tokens, {:class => "form-control formwidth", :value => ""} %>
    </div>
  </div>
  <div class="versions">
    <p>At least one version of the product must be given.</p>
    <%= f.fields_for :mobile_app_versions do |mobile_app_version| %>
      <%= render "mobile_app_version_fields",{ f: mobile_app_version, mav: mobile_app_version } %>
    <% end %>

    <div class="buttonRow">
      <%= link_to_add_association "Add Platform Details", f, :mobile_app_versions , {:class => "fa fa-plus"} %>
    </div>
  </div>
  <div class="actions">
    <%= f.submit :class => "btn btn-primary" %>
    <%= link_to 'Cancel', admin_mobile_apps_path, :class => "btn btn-default" %>
  </div>

<% end %>


<% content_for :additional_javascript do %>
  <script>
    $("#mobile_app_agency_tokens").tokenInput("/admin/agencies/tokeninput.json", {
      crossDomain: false,
      prePopulate: <%= raw @mobile_app.agencies.map(&:attributes).to_json %>,
      preventDuplicates: true
    });
    <% user_json = []
      @mobile_app.users.each do |user|
        user_json << {id: user.id, name: user_list_format(user)}
      end%>
    $("#mobile_app_user_tokens").tokenInput("/admin/users/tokeninput.json", {
      crossDomain: false,
      prePopulate: <%= raw user_json.to_json %>,
      preventDuplicates: true
    });

    var tags = [];
    var official_tags = <%= raw @mobile_app.official_tags.to_json %>;
    for(var i =0; i< official_tags.length; i++){
      tags.push({id: official_tags[i]["tag_text"], name: official_tags[i]["tag_text"]})
    }
    $("#mobile_app_tag_tokens").tokenInput("/admin/official_tags/tokeninput.json", {
      crossDomain: false,
      prePopulate: tags,
      preventDuplicates: true
    });

    $('form ').on('click','.version-details',function(e){
      e.preventDefault();
      version_parent = $(this).parent().parent();
      store_url = version_parent.find("input[name$='store_url]']").val();
      version_parent.find(".version-retrieving").removeClass('hidden');
      $.get('/admin/mobile_apps/version_details_for_url',
        { store_url: store_url },
        function(data){
          populate_version_details(data,version_parent);
          version_parent.find(".version-retrieving").addClass('hidden');
        }
      );
    });

    function populate_version_details(data, el){
      if(data["platform"]){
        el.find("[name$='platform]']").val(data["platform"]);
      }
      if(data["version"]){
        el.find("[name$='version_number]']").val(data["version"]);
      }
      // if(data["language"]){
      //   el.find("[name$='language]']").val(data["language"]);
      // }
      if(data["average_rating"]){
        el.find("[name$='average_rating]']").val(data["average_rating"]);
      }
      if(data["number_of_ratings"]){
        el.find("[name$='number_of_ratings]']").val(data["number_of_ratings"]);
      }
      if(data["screenshot"]){
        el.find("[name$='screenshot]']").val(data["screenshot"]);
      }
      if(data["publish_day"]){
        el.find("[name$='publish_date(3i)]']").val(data["publish_day"]);
      }
      if(data["publish_month"]){
        el.find("[name$='publish_date(2i)]']").val(data["publish_month"]);
      }
      if(data["publish_year"]){
       el.find("[name$='publish_date(1i)]']").val(data["publish_year"]);
      }
      if(!data["platform"]){
        version_parent.find(".version-messages").text("No details found for given URL.")
      }else{
        version_parent.find(".version-messages").text("Updated retrieved attributes.")
      }
    }
  </script>
<% end %>
<commit_msg>changing language slightly on front page<commit_after><%= form_for([:admin,@mobile_app]) do |f| %>
  <% if @mobile_app.errors.any? %>
    <div id="error_explanation">
      <div class="error"> <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
          <span class="sr-only">Error:</span><%= pluralize(@mobile_app.errors.count, "error") %> prohibited this mobile app from being saved</div>

      <ul class="inlineErrorMsgs">
      <% @mobile_app.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>
  <% @mobile_app.mobile_app_versions.each_with_index do |version, index|%>
    <% if version.errors.any? %>
      <div id="error_explanation">
        <div class="error"> <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
            <span class="sr-only">Error:</span><%= pluralize(version.errors.count, "error") %> prohibited mobile app version <%= index + 1 %> from being saved</div>

        <ul class="inlineErrorMsgs">
        <% version.errors.full_messages.each do |message| %>
          <li><%= message %></li>
        <% end %>
        </ul>
      </div>
    <% end %>
  <% end %>
  <div class="form_intro">
    <p>Please provide the following information on your mobile product (app or website) for the registry: * denotes a required field</p>
  </div>

  <div class="field">
    <%= f.label :name , "Name of App/Website*"%> </br>
    <%= f.text_field :name, :class => "form-control formwidth" %>
  </div>
  <div class="field">
    <%= f.label :short_description, "Short Description*  - Tagline description; not more than one sentence
" %> </br>
    <%= f.text_field :short_description, :class => "form-control formwidth" %>
  </div>
  <div class="field">
    <%= f.label :long_description, "Long Description* - Should be the same or similar to your app store description" %> </br>
    <%= f.text_area :long_description, :class => "form-control formwidth" %>
  </div>
  </br>
  <div class="field">
    <%= f.label :icon_url, "Icon URL - Please provide the URL of the app or website’s icon" %> </br>
    <%= f.text_field :icon_url, :class => "form-control formwidth" %>
  </div>
  <div class="field">
    <%= f.label :language %> </br>
    <%= f.select :language, options_for_select(language_select_options, @mobile_app.language),{include_blank: "Select"}, {:class => "form-control formwidth"} %>
  </div>
  <div class="field agencies">
    <%= f.label :agency_tokens, "Sponsoring Agencies*" %> </br>
    <%= f.text_field :agency_tokens, {:class => "form-control formwidth", :value => ""} %>
  </div>
  <div class="field">
    <%= f.label :tag_tokens, "Tags" %> </br>
    <%= f.text_field :tag_tokens, {:class => "form-control formwidth", :value => "" }%>
  </div>
  <div class="contacts">
    <div class="field">
      <%= f.label :user_tokens, "Contacts* - please provide two contact names" %></br>
      <%= f.text_field :user_tokens, {:class => "form-control formwidth", :value => ""} %>
    </div>
  </div>
  <div class="versions">
    <p>At least one set of platform details of the product must be given.</p>
    <%= f.fields_for :mobile_app_versions do |mobile_app_version| %>
      <%= render "mobile_app_version_fields",{ f: mobile_app_version, mav: mobile_app_version } %>
    <% end %>

    <div class="buttonRow">
      <%= link_to_add_association "Add Platform Details", f, :mobile_app_versions , {:class => "fa fa-plus"} %>
    </div>
  </div>
  <div class="actions">
    <%= f.submit :class => "btn btn-primary" %>
    <%= link_to 'Cancel', admin_mobile_apps_path, :class => "btn btn-default" %>
  </div>

<% end %>


<% content_for :additional_javascript do %>
  <script>
    $("#mobile_app_agency_tokens").tokenInput("/admin/agencies/tokeninput.json", {
      crossDomain: false,
      prePopulate: <%= raw @mobile_app.agencies.map(&:attributes).to_json %>,
      preventDuplicates: true
    });
    <% user_json = []
      @mobile_app.users.each do |user|
        user_json << {id: user.id, name: user_list_format(user)}
      end%>
    $("#mobile_app_user_tokens").tokenInput("/admin/users/tokeninput.json", {
      crossDomain: false,
      prePopulate: <%= raw user_json.to_json %>,
      preventDuplicates: true
    });

    var tags = [];
    var official_tags = <%= raw @mobile_app.official_tags.to_json %>;
    for(var i =0; i< official_tags.length; i++){
      tags.push({id: official_tags[i]["tag_text"], name: official_tags[i]["tag_text"]})
    }
    $("#mobile_app_tag_tokens").tokenInput("/admin/official_tags/tokeninput.json", {
      crossDomain: false,
      prePopulate: tags,
      preventDuplicates: true
    });

    $('form ').on('click','.version-details',function(e){
      e.preventDefault();
      version_parent = $(this).parent().parent();
      store_url = version_parent.find("input[name$='store_url]']").val();
      version_parent.find(".version-retrieving").removeClass('hidden');
      $.get('/admin/mobile_apps/version_details_for_url',
        { store_url: store_url },
        function(data){
          populate_version_details(data,version_parent);
          version_parent.find(".version-retrieving").addClass('hidden');
        }
      );
    });

    function populate_version_details(data, el){
      if(data["platform"]){
        el.find("[name$='platform]']").val(data["platform"]);
      }
      if(data["version"]){
        el.find("[name$='version_number]']").val(data["version"]);
      }
      // if(data["language"]){
      //   el.find("[name$='language]']").val(data["language"]);
      // }
      if(data["average_rating"]){
        el.find("[name$='average_rating]']").val(data["average_rating"]);
      }
      if(data["number_of_ratings"]){
        el.find("[name$='number_of_ratings]']").val(data["number_of_ratings"]);
      }
      if(data["screenshot"]){
        el.find("[name$='screenshot]']").val(data["screenshot"]);
      }
      if(data["publish_day"]){
        el.find("[name$='publish_date(3i)]']").val(data["publish_day"]);
      }
      if(data["publish_month"]){
        el.find("[name$='publish_date(2i)]']").val(data["publish_month"]);
      }
      if(data["publish_year"]){
       el.find("[name$='publish_date(1i)]']").val(data["publish_year"]);
      }
      if(!data["platform"]){
        version_parent.find(".version-messages").text("No details found for given URL.")
      }else{
        version_parent.find(".version-messages").text("Updated retrieved attributes.")
      }
    }
  </script>
<% end %>

{'fraction_non_alphanumeric': 0.19476632645230604, 'fraction_numerical': 0.0007674008134448623, 'mean_word_length': 3.4131391804944125, 'pattern_counts': {'":': 0, '<': 229, '<?xml version=': 0, '>': 251, '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': '3213589', 'n_tokens_mistral': 4463, 'n_tokens_neox': 4250, 'n_words': 798}