All Projects → harunurhan → idlejs

harunurhan / idlejs

Licence: MIT license
Execute stuff when user is idle or interactive

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to idlejs

Steam-Games-Idle
❤️ Node.js based script for steam game idling / hour boosting for chosen game without using computer resources. Built by @Refloow
Stars: ✭ 46 (+31.43%)
Mutual labels:  idle
Telescope
Telescope is an engine for efficiently creating meaningful visualizations
Stars: ✭ 26 (-25.71%)
Mutual labels:  interactive
thunder
BoltDB's Interactive Shell
Stars: ✭ 80 (+128.57%)
Mutual labels:  interactive
lambda-mailer
Simple module for receiving an email from a contact form on your website.
Stars: ✭ 83 (+137.14%)
Mutual labels:  no-dependencies
inquire
A Rust library for building interactive prompts
Stars: ✭ 419 (+1097.14%)
Mutual labels:  interactive
amazon-ivs-basic-web-sample
This repository contains a collection of plain JavaScript code samples, covering several basic Amazon IVS use cases.
Stars: ✭ 29 (-17.14%)
Mutual labels:  interactive
form-saver
A simple script that lets users save and reuse form data.
Stars: ✭ 67 (+91.43%)
Mutual labels:  no-dependencies
SilentCryptoMiner
A Silent (Hidden) Free Crypto Miner Builder - Supports ETH, ETC, XMR and many more.
Stars: ✭ 547 (+1462.86%)
Mutual labels:  idle
ctxmenu
Tiny and customizable context menu generator
Stars: ✭ 20 (-42.86%)
Mutual labels:  no-dependencies
beerplop
Repository for the incremental game Beerplop
Stars: ✭ 17 (-51.43%)
Mutual labels:  idle
requestty
An easy-to-use collection of interactive cli prompts inspired by Inquirer.js.
Stars: ✭ 158 (+351.43%)
Mutual labels:  interactive
periodum
Periodum: An Interactive, Open-Source Periodic Table!
Stars: ✭ 346 (+888.57%)
Mutual labels:  interactive
psyplot
Python package for interactive data visualization
Stars: ✭ 64 (+82.86%)
Mutual labels:  interactive
ilua
Portable Lua kernel for Jupyter
Stars: ✭ 99 (+182.86%)
Mutual labels:  interactive
npm-interactive-scripts
⚡️Fast Interactive CLI for npm scripts
Stars: ✭ 17 (-51.43%)
Mutual labels:  interactive
RussianNounsJS
Склонение существительных по падежам. Обычно требуются только форма в именительном падеже, одушевлённость и род.
Stars: ✭ 29 (-17.14%)
Mutual labels:  no-dependencies
PlutoUI.jl
pluto-featured-notebooks.netlify.app/classic%20samples/plutoui.jl
Stars: ✭ 254 (+625.71%)
Mutual labels:  interactive
muxnect
Send input to just about any interactive command-line tool through a local web server
Stars: ✭ 23 (-34.29%)
Mutual labels:  interactive
augmath
Interactive Computer Algebra System. Augmenting how we *do* mathematics using computers
Stars: ✭ 41 (+17.14%)
Mutual labels:  interactive
clrprint
Print colorful output in the terminal, idle, cmd, and Windows PowerShell using the same functions.
Stars: ✭ 22 (-37.14%)
Mutual labels:  idle

idlejs

Execute a function only when certain events on certain target element have or have not occured within given timeout.

It's simple, configurable, typescript friendly and has an easy chainable API.

Install

yarn add idlejs

npm install --save idlejs

v2 to v3

Change imports from idlejs/dist to idlejs

import { ... } from 'idjejs' 

Idle

Excutes the callback function (do) when none of the specified events have occurred within given time, in other words when user is idle.

Usage

import { Idle } from 'idlejs';

// with predefined events on `document`
const idle = new Idle()
  .whenNotInteractive()
  .within(5)
  .do(() => logoutUser())
  .start();

// another example with custom events which are useful if events aren't bubbling up to the document
const idle = new Idle()
  .whenNot([{
    events: ['click', 'hover'],
    target: buttonEl,
  },
  {
    events: ['click', 'input'],
    target: inputEl,
  },
  ])
  .whenNotInteractive()
  .within(10)
  .do(logoutUser)
  .start();

For more features or examples please check the tests and source code.

NotIdle

Executes the callback function (do), if at least one of the specified events have occured within given time, in other words when user is not idle or interactive.

Usage

import { NotIdle } from 'idlejs';

// with predefined events on `document`
const idle = new Idle()
  .whenInteractive()
  .within(10)
  .do(() => log('user was active in the last 10 minutes'))
  .start();

// another example with custom events which are useful if events aren't bubbling up to the `document`
const notIdle = new NotIdle()
  .when([{
    events: ['click', 'hover'],
    target: buttonEl,
  },
  {
    events: ['click', 'input'],
    target: inputEl,
  },
  ])
  .whenInteractive()
  .within(10)
  .do(() => log('user was active in the last 10 minutes'))
  .start();

For more features or examples please check the tests and source code.

Setting time

Second parameter of within is time unit in miliseconds, by default 60000 (a minute).

// will trigger if nothing happens for 5 minutes
new Idle()
  .within(5)

// will trigger if nothing happens for 5 seconds
new Idle()
  .within(5, 1000)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].