A simple script for binary clock, impressed by KDE's applet :)
The script is written in Vanilla JS. It provides a few methods for interaction, as explained below.
new BinaryClock( 'body' ).run( );
bower install BinClock
Info: This method starts the engine of the clock
Arguments: N/A
Info: This method stops the clock
Arguments: N/A
Info: This method makes the seconds elements visible
Arguments: N/A
Info: This method makes the seconds elements invisible
Arguments: N/A
Info: This method sets the clock orientation
Arguments:
- Orientation
- Type: String
- Value - should be one of the following:
- btt - bottom to top;
- ttb - top to bottom;
- ltr - left to right;
- rtl - right to left;
- vertical - same as btt;
- horizontal - same as rtl.
Info: This method sets the seconds block position
Arguments:
- Position
- Type: String
- Value - should be one of the following:
- center or middle - the seconds will appear between the hours and the minutes blocks;
- end or side - the seconds will appear at the end of the clock container, depending on chosen orientation.
Info: This method sets the the type of the clock - 4 or 7 bit, i.e. to be presented each digit from clock's elements or the whole block of the clock elements
Arguments:
- Type
- Type: String
- Value - should be one of the following:
- wide, long or big - for 7bit clock;
- tight, short or small - for 4bit clock.
Info: This method changes the theme of the clock (changes the css class) Arguments:
- Theme
- Type: String
- Value - CSS classname
Info: This method appends the clock to a DOM element
Arguments:
- Selector or DOM Element to append to
- Type: String
- Value - should be CSS selector or DOM id attribute of element.
Example:
new BinaryClock( )
.appendTo( 'body' )
.run( );
All of the above methods returns pointer to the created BinaryClock object; All of the above methods, except run()
and stop()
, are redrawing the clock container, regarding the new options.
new BinaryClock( 'body' )
.setSecondsPosition( 'middle' )
.setType( 'small' )
.setOrientation( 'ttb' )
.setTheme( 'thm-1' );
Example 1 | Example 2 | Example 3 | Example 4 | |
---|---|---|---|---|
Preview |