New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

timer-input

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

timer-input

Monitor if the value of an input or textarea element is changed

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
1
Created
Source

timer-input

Monitor if the value of an input or textarea element is changed, like input event.

Usage

var keyword = document.getElementById('keyword');
var kwInput = new TimerInput(keyword);

kwInput.on(function(e) {
  console.log('The value of the keyword is changed!');
  console.log(e); // e: { type: 'timerinput', oldValue: '', newValue: 'foo' }
});

This module supports as a CommonJS/AMD module.

Packages

NPM:

npm install timer-input

API

The TimerInput constructor

TimerInput(element, [opts], [listener])

Create a TimerInput instance to attach/detach one or more listeners. When the value of the element is changed, the listener will be called with a TimerInputEvent object passed as the first parameter.

TimerInputEvent

  • type: "timerinput".
  • oldValue: A string represents the value before changing.
  • newValue: A string represents the value after changing.

In the listener, this refers the input or textarea element.

The opts object can be passed as the second parameter:

  • bindEvent

    Type: Boolean Default: true

    It represents if the focus and blur event of the element will be listened when an TimerInput instance is created.

The TimerInput instance methods:

start()

Set the timer. By default, when the focus event is fired, the timer will be set.

stop()

Clear the timer. By default, when the blur event is fired, the timer will be cleared.

get()

Return the value of the element.

set(value)

Use the value to update the value of the element and the listener(s) will be called, if any. If you modify the element.value directly, none of the listener(s) will be called.

on(listener)

Attach a listener.

off(listener)

Detach a listener. If no argument is passed, all exist listeners will be detached.

trigger([arg1], [arg2], ...)

Execute all exist listeners with some optional parameters passed.

destroy()

The input or textarea element is no longer monitored.

Compatibility

IE6+ and other modern browsers.

License

MIT

Keywords

input

FAQs

Package last updated on 02 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts