npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

clockish

v1.0.6

Published

A simple vanilla(pure) Javascript library for adding wall clocks to your web application

Downloads

8

Readme

clock-js

A simple vanilla(pure) Javascript library for adding wall clocks to your web application

clock-js allows you to add a wall-clock to your web application with ease.

Background

clock-js is the javascript translation of simple-desk-clock a Java application by the same author.

clock-js will make it trivial for web-devs to add clock functionality to web and Javascript apps.

Here is an image of what the clock looks like:

Clock Should Show...lol

Usage

Here are the options that can be passed to the clock constructor, though this may change over time:

             {
                canvasId: "xxxx",
                floating: true,
                outerColor: "css-color",
                middleColor: "css-color",
                innerColor: "css-color",
                tickColor: "css-color",
                secondsColor: "css-color",
                minutesColor: "css-color",
                hourColor: "css-color",
                centerSpotWidth: number,
                outerCircleAsFractionOfFrameSize: float_zero_to_1,
                showBaseText: false,
                canvas: {
                    x: 100,
                    y: 100,
                    width: 100,
                    height: 100
                }
            }
            
            Note that css-color should be an hexadecimal string e.g: #444 or #45FF22

To add clock functionality to your webpage, clock-js needs a canvas element placed in the right place in the DOM(HTML code). For instance,

<canvas id="clock-1" style="float: left; margin-left: 10px; width: 10em; height: 10em;"></canvas>

Next, create a clock-js object:

var clock = new Clock({
                canvasId: 'clock-1',
                outerColor: 'transparent',
                middleColor: '#262626',
                innerColor: '#000',
                centerSpotWidth: 2,
                outerCircleAsFractionOfFrameSize: 1.0,
                showBaseText: false
            });
            clock.run();

To stop this clock instance, do: clock.kill();

As an example, we can do:

var clock = new Clock({
                canvasId: 'clock-1',
                outerColor: 'transparent',
                middleColor: '#262626',
                innerColor: '#000',
                centerSpotWidth: 2,
                outerCircleAsFractionOfFrameSize: 1.0,
                showBaseText: false
            });
            clock.run();



     setTimeout(function() {
                clock.kill();
            }, 10000);
            
            
            

This will create a clock instance that renders on the canvas in the DOM whose id is clock-1

clock.run() starts the clock animation that runs the clock.

The clock will run for 10 seconds and then stop running, due to the setTimeout block.

This is how easy it is to deploy the clock

If you want a clock that floats on your page, specify the floating field in your clock's options, and set it to true. In this case, you need not add the canvas element to your code. The clock will dynamically create a canvas object and inject it in your HTML code.

You may customize the dynamically created object by specifying the canvas entry:

     var clock = new Clock({
                canvasId: 'clock-2',
                floating: true,
                outerColor: 'transparent',
                middleColor: '#262626',
                innerColor: '#000',
                centerSpotWidth: 2,
                outerCircleAsFractionOfFrameSize: 1.0,
                showBaseText: false,
                canvas: {
                    x: 100,
                    y: 100,
                    width: 800,
                    height:800
                }
            });
            clock2.run();

The 4 most important fields which it takes are: the x , y, width and height parameters.

Fields of the canvas:

x is the distance of the clock's left side from the left of the webpage

y is the distance of the clock's top from the top of the webpage

width is the pixel width of the canvas

height is the pixel height of the canvas

If you do not add the floating field at all or you set it to false, then you have to specify the canvas tag in your code, so that the clock will know what canvas to draw itself on.

For example:

<canvas id="clock-1" style="float: left; margin-left: 10px; width: 10em; height: 10em;"></canvas>

Stay tuned as we add more features to this library;