<commit_before>##
## @name
## Time
##
## @description
## A directive for creating a time input field
##
## @attributes
## - mac-time-id:          ID of the text input field         (default: time-input)
## - mac-time-model:       Model to bind input to
## - mac-time-placeholder: Placeholder text of the text input (default --:--)
## - mac-time-disabled:    Enable or disable time input
## - mac-time-default:     If model is undefined, use this    (default 12:00 PM)
##                         as the starting value
##
angular.module("Mac").directive "macTime", [
  "util"
  "keys"
  "$filter"
  (util, keys, $filter) ->
    restrict: "E"
    scope:
      model:    "=macTimeModel"
      disabled: "=macTimeDisabled"
    replace:     true
    templateUrl: "template/time.html"

    compile: (element, attrs) ->

      defaults =
        id:          "time-input"
        placeholder: "--:--"
        default:     "12:00 PM"

      opts = util.extendAttributes "macTime", defaults, attrs

      inputElement = $("input", element)
      inputElement.attr
        "placeholder": opts.placeholder
        "ng-model":    "model"
        "ng-disabled": "disabled"

      ($scope, element, attrs) ->
        inputDOM        = inputElement[0]
        timeRegex       = /(\d+):(\d+) ([AP]M)?/
        highlighActions =
          hours:   -> inputDOM.setSelectionRange 0, 2
          minutes: -> inputDOM.setSelectionRange 3, 5
          markers: -> inputDOM.setSelectionRange 6, 8

        $scope.$watch "model", (value) ->
          updateScopeTime() if value?

        $scope.reset = ->
          # TODO: Have this be looser with formatting (only accepts XX:XX XX)
          $scope.time = new Date Date.parse "Jan 1, 1972, " + opts.default

        #
        # @name inputSelectAction
        # @description
        # Based on the index given, execute certain actions
        # @param {Integer} index Start index of selection
        # @param {Integer} endIndex End index of selection (default index)
        # @param {Object} actions Three functions to execute out based on selection
        #
        inputSelectAction = (index, endIndex = index, actions = {}) ->
          # Allow user to pass actions as the second parameter
          # Meaning the start and end index is the same
          if typeof endIndex is "object"<commit_msg>Using 1970 for default date (not used), using 12:00 AM for default time.<commit_after>##
## @name
## Time
##
## @description
## A directive for creating a time input field
##
## @attributes
## - mac-time-id:          ID of the text input field         (default: time-input)
## - mac-time-model:       Model to bind input to
## - mac-time-placeholder: Placeholder text of the text input (default --:--)
## - mac-time-disabled:    Enable or disable time input
## - mac-time-default:     If model is undefined, use this    (default 12:00 PM)
##                         as the starting value
##
angular.module("Mac").directive "macTime", [
  "util"
  "keys"
  "$filter"
  (util, keys, $filter) ->
    restrict: "E"
    scope:
      model:    "=macTimeModel"
      disabled: "=macTimeDisabled"
    replace:     true
    templateUrl: "template/time.html"

    compile: (element, attrs) ->

      defaults =
        id:          "time-input"
        placeholder: "--:--"
        default:     "12:00 AM"

      opts = util.extendAttributes "macTime", defaults, attrs

      inputElement = $("input", element)
      inputElement.attr
        "placeholder": opts.placeholder
        "ng-model":    "model"
        "ng-disabled": "disabled"

      ($scope, element, attrs) ->
        inputDOM        = inputElement[0]
        timeRegex       = /(\d+):(\d+) ([AP]M)?/
        highlighActions =
          hours:   -> inputDOM.setSelectionRange 0, 2
          minutes: -> inputDOM.setSelectionRange 3, 5
          markers: -> inputDOM.setSelectionRange 6, 8

        $scope.$watch "model", (value) ->
          updateScopeTime() if value?

        $scope.reset = ->
          # TODO: Have this be looser with formatting (only accepts XX:XX XX)
          $scope.time = new Date Date.parse "Jan 1, 1970, " + opts.default

        #
        # @name inputSelectAction
        # @description
        # Based on the index given, execute certain actions
        # @param {Integer} index Start index of selection
        # @param {Integer} endIndex End index of selection (default index)
        # @param {Object} actions Three functions to execute out based on selection
        #
        inputSelectAction = (index, endIndex = index, actions = {}) ->
          # Allow user to pass actions as the second parameter
          # Meaning the start and end index is the same
          if typeof endIndex is "object"
{'fraction_non_alphanumeric': 0.11925439525524253, 'fraction_numerical': 0.01016733742851091, 'mean_word_length': 2.135458167330677, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 21, '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': '4302661', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1300, 'n_words': 437}