<commit_before>{Layer} = require "./Layer"
{Events} = require "./Events"

Events.EnterKey  = "EnterKey"
Events.BackSpaceKey  = "BackSpaceKey"

class exports.InputLayer extends Layer
	constructor: (options={}) ->

		options.backgroundColor ?= "#fff"
		options.width ?= 480
		options.height ?= 100

		super options

		@input = document.createElement("input")
		@_element.appendChild(@input)

		@input.style.font = "400 40px/1.25 -apple-system, SF UI Text, Helvetica Neue"
		@input.style.outline = "none"
		@input.style.backgroundColor = "transparent"
		@input.style.width = "#{@width}px"
		@input.style.height = "#{@height}px"
		@input.style.paddingLeft = "32px"
		@input.style.color = "#aaa"
		@input.style.cursor = "auto"
		@input.value = "Placeholder"

		@input.onfocus = ->
			@style.color = "#000"
			@value = ""

		# Supported characters
		# characters =
		# 	"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@{}#$%^&*()_+1234567890".split("")

		isInArray = (value, array) ->
			return array.indexOf(value) > -1

		@input.onkeyup = (e) =>

			# Check last character
			lastCharacter = @input.value.substr(@input.value.length - 1)

			# Exclude enter, space and caps lock
			unless e.which is 20 or e.which is 13 or e.which is 8
				@emit("change:value", @input.value)

			# If enter key is pressed<commit_msg>Include backspace but stop firing event when values are empty<commit_after>{Layer} = require "./Layer"
{Events} = require "./Events"

Events.EnterKey  = "EnterKey"
Events.BackSpaceKey  = "BackSpaceKey"

class exports.InputLayer extends Layer
	constructor: (options={}) ->

		options.backgroundColor ?= "#fff"
		options.width ?= 480
		options.height ?= 100

		super options

		@input = document.createElement("input")
		@_element.appendChild(@input)

		@input.style.font = "400 40px/1.25 -apple-system, SF UI Text, Helvetica Neue"
		@input.style.outline = "none"
		@input.style.backgroundColor = "transparent"
		@input.style.width = "#{@width}px"
		@input.style.height = "#{@height}px"
		@input.style.paddingLeft = "32px"
		@input.style.color = "#aaa"
		@input.style.cursor = "auto"
		@input.value = "Placeholder"

		@input.onfocus = ->
			@style.color = "#000"
			@value = ""

		# Supported characters
		# characters =
		# 	"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!@{}#$%^&*()_+1234567890".split("")

		isInArray = (value, array) ->
			return array.indexOf(value) > -1

		@input.onkeyup = (e) =>

			# Check last character
			lastCharacter = @input.value.substr(@input.value.length - 1)

			# Exclude enter, space and caps lock
			unless e.which is 20 or e.which is 13 or @value is ""
				@emit("change:value", @input.value)

			# If enter key is pressed
{'fraction_non_alphanumeric': 0.1563663440059568, 'fraction_numerical': 0.02643335815338794, 'mean_word_length': 3.8414414414414413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '4376088', 'n_tokens_mistral': 1099, 'n_tokens_neox': 931, 'n_words': 205}