
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
@bva/countdown
Advanced tools
This is a JS based component for adding countdown timers using data attributes and minimal JS.
yarn add @bva/countdown
to install, and then import with import Timer from '@bva/countdown';
At the moment there is only one (very optional) parameter (passed in an object):
This is how the component does most of its configuration. There are a couple of data attributes that can be added to timers to change how they operate:
%D:%H:%M:%S
):
The component introduces a custom event as well:
countdownTimerEnded
: this is bound directly to timer elements and is dispatched when the timer's countdown ends.<!-- HTML -->
<div class="my-timer"
data-timer="3600"
data-timer-format="%M:%H"
data-complete-message="Time's up!"
data-lazy-timer
data-pause-timer>
</div>
// JavaScript
import Timer from '@bva/countdown';
document.addEventListener('DOMContentLoaded', () => {
// add event listeners to the timer elements
const timerElements = document.querySelectorAll('[data-timer]');
timerElements.forEach((timerElement) => {
timerElement.addEventListener('countdownTimerEnded', (event) => {
console.log('Timer has ended for:', event.target);
});
});
// now setup all the timers to start their countdowns
Timer.setup({});
});
There are two other methods the component exposes for more manual control over timers:
startTimer
: takes in the timer element as a parameter and will start the timer for that timer element.pauseTimer
: takes in the timer element as a parameter and will stop the timer for that timer element.Here is an example for the two methods:
import Timer from '@bva/countdown';
document.addEventListener('DOMContentLoaded', () => {
// Assuming there is only one timer on the page I care about
const myTimer = document.querySelector('[data-timer]');
Timer.startTimer(myTimer);
const stopButton = document.querySelector('[data-stop-button]');
stopButton.addEventListener('click', () => {
Timer.pauseTimer(myTimer)
});
});
FAQs
Adds a JS component for adding countdown timers
The npm package @bva/countdown receives a total of 0 weekly downloads. As such, @bva/countdown popularity was classified as not popular.
We found that @bva/countdown demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.