<commit_before>
require 'labwiki/plugins/experiment/renderer/experiment_common_renderer'

module LabWiki::Plugin::Experiment

  class ExperimentSetupRenderer < ExperimentCommonRenderer

    def render_content
      render_start_form
    end

    def render_start_form
      fid = "f#{self.object_id}"
      properties = @experiment.properties
      #puts "EXP: #{@experiment}--#{properties}"
      form :id => fid, :class => 'start-form' do
        if properties
          table :class => 'experiment-setup', :style => 'width: auto' do
            render_field -1, :name => 'Name', :size => 24, :default => @experiment.name

            geni_projs = OMF::Web::SessionStore[:projects, :geni_portal]
            if geni_projs && !geni_projs.empty? && LabWiki::Configurator[:gimi] && LabWiki::Configurator[:gimi][:ges]
              render_field(-1, name: 'Project', type: :select, options: geni_projs.map {|v| v[:name]})
              render_field(-1, name: 'Experiment', type: :select)
              render_field(-1, name: 'Slice', type: :select)
            else
              render_field(-1, name: 'Slice', type: :text, default: "default_slice")
            end

            render_field_static :name => 'Script', :value => @experiment.url
            properties.each_with_index do |prop, i|
              render_field(i, prop)
            end
            tr :class => "buttons" do
              td :colspan => 3 do
                input :type => "hidden", :name => "name1",  :id => "id1", :value => "value1"
                button "Start Experiment", :class => 'btn btn-primary', :type => "submit", :id => "id_startExperiment"
                # input :id => "id_startExperiment", :name => "name_startExperient", :class => "submit button-text btn",
                  # :type => "submit", :value => "Start Experiment"
                  #:onmousedown => "doSubmitEvents();"
              end
            end
          end
        end
        render_javascript(fid)
      end

    end

    def render_javascript(fid)
      opts = {
        :properties => @experiment.properties,
        :widget_id => @widget.widget_id,
        :url => "lw:execute/experiment?url=#{@experiment.url}",
        :script => @experiment.url
      }

      if LabWiki::Configurator[:gimi] && LabWiki::Configurator[:gimi][:ges]
        javascript %{
          var geni_projects = #{OMF::Web::SessionStore[:projects, :geni_portal].to_json};

          if (typeof(window.exp_list) === "undefined") {
            window.exp_list = new ExpListView();
          }

          window.exp_list.setElement($('select[name="propExperiment"]'));
          window.exp_list.setupExpSelect();
        }
      end

      javascript %{
        $("\##{fid}").submit(function(event) {
          event.preventDefault();

          var form_el = $(this);
          var fopts = #{opts.to_json};
          var ec = $("\##{@data_id}").data('ec');
          ec.submit(form_el, fopts);
        });
      }
    end

    def render_properties
      properties = @experiment.properties
      #puts ">>>> #{properties}"
      div :class => 'experiment-status' do
        if properties
          table :class => 'experiment-status', :style => 'width: auto'  do
            render_field_static :name => 'Name', :value => @experiment.name
            render_field_static :name => 'Script', :value => @experiment.url
            properties.each_with_index do |prop, i|
              prop[:index] = i
              render_field_static(prop)
            end
          end
        end
      end
    end


  end # class
end # module
<commit_msg>Hide slice when using omf ec<commit_after>
require 'labwiki/plugins/experiment/renderer/experiment_common_renderer'

module LabWiki::Plugin::Experiment

  class ExperimentSetupRenderer < ExperimentCommonRenderer

    def render_content
      render_start_form
    end

    def render_start_form
      fid = "f#{self.object_id}"
      properties = @experiment.properties
      #puts "EXP: #{@experiment}--#{properties}"
      form :id => fid, :class => 'start-form' do
        if properties
          table :class => 'experiment-setup', :style => 'width: auto' do
            render_field -1, :name => 'Name', :size => 24, :default => @experiment.name

            geni_projs = OMF::Web::SessionStore[:projects, :geni_portal]
            if geni_projs && !geni_projs.empty? && LabWiki::Configurator[:gimi] && LabWiki::Configurator[:gimi][:ges]
              render_field(-1, name: 'Project', type: :select, options: geni_projs.map {|v| v[:name]})
              render_field(-1, name: 'Experiment', type: :select)
              render_field(-1, name: 'Slice', type: :select)
            else
              if LabWiki::Configurator[:plugins][:experiment][:ignore_slice]
                render_field(-1, name: 'Slice', type: :hidden, default: "default_slice")
              else
                render_field(-1, name: 'Slice', type: :text, default: "default_slice")
              end
            end

            render_field_static :name => 'Script', :value => @experiment.url
            properties.each_with_index do |prop, i|
              render_field(i, prop)
            end
            tr :class => "buttons" do
              td :colspan => 3 do
                input :type => "hidden", :name => "name1",  :id => "id1", :value => "value1"
                button "Start Experiment", :class => 'btn btn-primary', :type => "submit", :id => "id_startExperiment"
                # input :id => "id_startExperiment", :name => "name_startExperient", :class => "submit button-text btn",
                  # :type => "submit", :value => "Start Experiment"
                  #:onmousedown => "doSubmitEvents();"
              end
            end
          end
        end
        render_javascript(fid)
      end

    end

    def render_javascript(fid)
      opts = {
        :properties => @experiment.properties,
        :widget_id => @widget.widget_id,
        :url => "lw:execute/experiment?url=#{@experiment.url}",
        :script => @experiment.url
      }

      if LabWiki::Configurator[:gimi] && LabWiki::Configurator[:gimi][:ges]
        javascript %{
          var geni_projects = #{OMF::Web::SessionStore[:projects, :geni_portal].to_json};

          if (typeof(window.exp_list) === "undefined") {
            window.exp_list = new ExpListView();
          }

          window.exp_list.setElement($('select[name="propExperiment"]'));
          window.exp_list.setupExpSelect();
        }
      end

      javascript %{
        $("\##{fid}").submit(function(event) {
          event.preventDefault();

          var form_el = $(this);
          var fopts = #{opts.to_json};
          var ec = $("\##{@data_id}").data('ec');
          ec.submit(form_el, fopts);
        });
      }
    end

    def render_properties
      properties = @experiment.properties
      #puts ">>>> #{properties}"
      div :class => 'experiment-status' do
        if properties
          table :class => 'experiment-status', :style => 'width: auto'  do
            render_field_static :name => 'Name', :value => @experiment.name
            render_field_static :name => 'Script', :value => @experiment.url
            properties.each_with_index do |prop, i|
              prop[:index] = i
              render_field_static(prop)
            end
          end
        end
      end
    end


  end # class
end # module

{'fraction_non_alphanumeric': 0.14098049837486457, 'fraction_numerical': 0.003114842903575298, 'mean_word_length': 2.164095972579263, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 81, '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': '2405140', 'n_tokens_mistral': 2216, 'n_tokens_neox': 2157, 'n_words': 476}