<commit_before>"use strict";

function convert_date_string(date_time_str) {
  // use strict ISO 8601 parsing in moment.js to avoid ambiguities
  var moment_obj =  moment(date_time_str, moment.ISO_8601, true);
  if (moment_obj.isValid) {
    return date_time_str;
  } else {
    return null;
  }
}

function make_daterange() {
   // converts the time range inputs to a format that can be
   // used by solr
   var start_val = $('input#start_time').val();
   var end_val = $('input#end_time').val();
   // TODO: add input verification on server side

   var form_button = $('form[name="datetime-selection"').find('.btn.apply');
   var btn_disabled;
   if (!start_val && !end_val) {
     var set_val = '';
     start_val_scrub = end_val_scrub = null;
       btn_disabled = true;
   } else {
     var start_val_scrub = start_val;
     var end_val_scrub = end_val;
   }

   var date_form = $('form[name="datetime-selection"]');
   var form_btn = date_form.find('.btn.apply');
   date_form.validate()
   if (date_form.valid()) {
     $('input#ext_timerange_start').val(start_val_scrub);
     $('input#ext_timerange_end').val(end_val_scrub);
     form_btn.attr('disabled', false);
   } else {
     form_btn.attr('disabled', true);
   }
}

ckan.module('ioos_theme_daterange', function($) {
    return {
        initialize: function() {
  // toggle date info popover
  $('[data-toggle="popover"]').popover({placement: 'bottom', html: true});
  var form = $(".search-form");
  $(['ext_timerange_start', 'ext_timerange_end']).each(function(index, item){
    var time_elem = $("#" + item);
    if (time_elem.length === 0) {
      $('<input type="hidden" />').attr({'id': item,
                                         'name': item}).appendTo(form);
     }
    });
    var search_params = new URLSearchParams(location.search);
    var param_start_time = search_params.get('ext_timerange_start');
    if (param_start_time !== null) {
        $('input#start_time').val(param_start_time);
    }
    var param_end_time = search_params.get('ext_timerange_end');
    if (param_end_time !== null) {
        $('input#end_time').val(param_end_time);
    }

  $('a[name="datefilter"]').daterangepicker({
    timePicker24Hour: true,
    startDate: moment().startOf('hour'),
    endDate: moment().startOf('hour').add(32, 'hour'),
    locale: {
      format: 'YYYY-MM-DDTHH:mm\\Z'
    }
  });<commit_msg>Add time selection to date/range picker<commit_after>"use strict";

function convert_date_string(date_time_str) {
  // use strict ISO 8601 parsing in moment.js to avoid ambiguities
  var moment_obj =  moment(date_time_str, moment.ISO_8601, true);
  if (moment_obj.isValid) {
    return date_time_str;
  } else {
    return null;
  }
}

function make_daterange() {
   // converts the time range inputs to a format that can be
   // used by solr
   var start_val = $('input#start_time').val();
   var end_val = $('input#end_time').val();
   // TODO: add input verification on server side

   var form_button = $('form[name="datetime-selection"').find('.btn.apply');
   var btn_disabled;
   if (!start_val && !end_val) {
     var set_val = '';
     start_val_scrub = end_val_scrub = null;
       btn_disabled = true;
   } else {
     var start_val_scrub = start_val;
     var end_val_scrub = end_val;
   }

   var date_form = $('form[name="datetime-selection"]');
   var form_btn = date_form.find('.btn.apply');
   date_form.validate()
   if (date_form.valid()) {
     $('input#ext_timerange_start').val(start_val_scrub);
     $('input#ext_timerange_end').val(end_val_scrub);
     form_btn.attr('disabled', false);
   } else {
     form_btn.attr('disabled', true);
   }
}

ckan.module('ioos_theme_daterange', function($) {
    return {
        initialize: function() {
  // toggle date info popover
  $('[data-toggle="popover"]').popover({placement: 'bottom', html: true});
  var form = $(".search-form");
  $(['ext_timerange_start', 'ext_timerange_end']).each(function(index, item){
    var time_elem = $("#" + item);
    if (time_elem.length === 0) {
      $('<input type="hidden" />').attr({'id': item,
                                         'name': item}).appendTo(form);
     }
    });
    var search_params = new URLSearchParams(location.search);
    var param_start_time = search_params.get('ext_timerange_start');
    if (param_start_time !== null) {
        $('input#start_time').val(param_start_time);
    }
    var param_end_time = search_params.get('ext_timerange_end');
    if (param_end_time !== null) {
        $('input#end_time').val(param_end_time);
    }

  $('a[name="datefilter"]').daterangepicker({
    timePicker24Hour: true,
    startDate: moment().startOf('hour'),
    endDate: moment().startOf('hour').add(32, 'hour'),
    locale: {
      format: 'YYYY-MM-DDTHH:mm\\Z'
    },
    timePicker: true
  });
{'fraction_non_alphanumeric': 0.1625728559533722, 'fraction_numerical': 0.005412156536219817, 'mean_word_length': 3.3961573650503203, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6432198', 'n_tokens_mistral': 1647, 'n_tokens_neox': 1618, 'n_words': 313}