Clock

Clock

new Clock(optionsopt)

Source:
Properties:
Name Type Attributes Default Description
options.thickness Integer <optional>
10

Thickness of the rings in percent of the maximum dimension.

options.margin Integer <optional>
0

Margin between the Circular in percent of the maximum dimension.

options.size Integer <optional>
200

Width and height of the widget.

options.show_seconds Boolean <optional>
true

Show seconds ring.

options.show_minutes Boolean <optional>
true

Show minutes ring.

options.show_hours Boolean <optional>
true

Show hours ring.

options.timeout Integer <optional>
1000

The timeout of the redraw trigger.

options.timeadd Integer <optional>
10

Set additional milliseconds to add to the timeout target system clock regulary.

options.offset Integer <optional>
0

If a timeout is set offset the system time in milliseconds.

options.fps Integer <optional>
25

Framerate for calculating SMTP frames

options.months Array.<String> <optional>
["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]

Array containing all months names.

options.days Array.<String> <optional>
["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]

Array containing all days names.

options.label function <optional>
function (date, fps, months, days) { var h = date.getHours(); var m = date.getMinutes(); var s = date.getSeconds(); return ((h < 10) ? ("0" + h) : h) + ":" + ((m < 10) ? ("0" + m) : m) + ":" + ((s < 10) ? ("0" + s) : s);

Callback to format the main label.

options.label_upper function <optional>
function (date, fps, months, days) { return days[date.getDay()]; }

Callback to format the upper label.

options.label_lower function <optional>
function (date, fps, months, days) { var d = date.getDate(); var m = date.getMonth(); var y = date.getFullYear()return ((d < 10) ? ("0" + d) : d) + ". " + months[m] + " " + y; }

Callback to format the lower label.

options.label_scale Number <optional>
0.33

The scale of label_upper and label_lower compared to the main label.

options.label_margin Number <optional>
10

Margin between the rings and the main label in percent of the overall size.

options.label_upper_pos Number <optional>
0.33

Position of the upper label as fraction of the overall height.

options.label_lower_pos Number <optional>
0.66

Position of the lower label as fraction of the overall height.

options.time Number | String | Date <optional>

Set a specific time and date. To avoid auto-udates, set timeout to 0. For more information about the value, please refer to W3Schools.

Clock shows a customized clock with circulars displaying hours, minutes and seconds. It additionally offers three freely formattable labels.

Parameters:
Name Type Attributes Default Description
options Object <optional>
{ }

An object containing initial options.

Extends

Members

_label :SVGText

Source:

The center label showing the time. Has class.aux-label

Type:
  • SVGText

_label_lower :SVGText

Source:

The lower label showing the date. Has class.aux-lowerlabel

Type:
  • SVGText

_label_upper :SVGText

Source:

The upper label showing the day. Has class.aux-upperlabel

Type:
  • SVGText

circulars :Object

Source:

An object holding all three Circular as members seconds, minutes and hours.

Type:
  • Object

circulars :Object

Source:

An object containing the Circular widgets. Members are seconds, minutes and hours.

Type:
  • Object

element :HTMLDivElement

Source:

The main DIV element. Has class .aux-clock

Type:
  • HTMLDivElement

svg :SVGImage

Source:

The main SVG image.

Type:
  • SVGImage

Methods

addChild(child)

Source:
Inherited From:
See:

Registers a widget as a child widget. This method is used to build up the widget tree. It does not modify the DOM tree.

Parameters:
Name Type Description
child Widget

The child to add.

Fires:
  • Widget#event:child_added

addChildren(a)

Source:
Inherited From:

Registers an array of widgets as children.

Parameters:
Name Type Description
a Array.<Widget>

An array of Widgets.

allChildren()

Source:
Inherited From:

Returns an array of all children.

appendChild(child)

Source:
Inherited From:

Appends child.element to the widget element and registers child as a child widget.

Parameters:
Name Type Description
child Widget

The child widget to append.

appendChildren(children)

Source:
Inherited From:

Calls Widget#appendChild for an array of widgets.

Parameters:
Name Type Description
children Array.<Widget>

The child widgets to append.

destroy()

Source:
Overrides:

Dispose of this Widget.

destroyAndRemove()

Source:
Inherited From:

Dispose of this Widget and remove it from the DOM.

disableTansitions()

Source:
Inherited From:

Disable CSS transitions.

enableDraw()

Source:
Overrides:

Schedules this widget for drawing.

Fires:

enableDrawChildren()

Source:
Inherited From:

Enables rendering for all children of this widget.

enableTransitions()

Source:
Inherited From:

Enable CSS transitions.

forceHide()

Source:
Inherited From:

Hide the widget immediately by applying the class aux-hide. Does not call disableDraw().

forceShow()

Source:
Inherited From:

Show the widget immediately by applying the class aux-show. Does not call enableDraw().

getStyle()

Source:
Inherited From:

Returns the computed style of this widget's DOM element.

hidden()

Source:
Inherited From:

Returns the current hidden status.

hide()

Source:
Inherited From:

Hide the widget. This will result in the class aux-hide being applied to this widget in the next rendering step.

invalidate(key)

Source:
Inherited From:

Invalidates an option and triggers a redraw() call.

Parameters:
Name Type Description
key string

invalidateAll()

Source:
Inherited From:

Invalidates all dependencies which will trigger all renderers to rerun.

observeResize(cb)

Source:
Inherited From:

Calls a callback whenever the widget resizes. This method will trigger one resize.

Parameters:
Name Type Description
cb function

removeChild(child)

Source:
Inherited From:

Removes a child widget. Note that this method only modifies the widget tree and does not change the DOM.

Parameters:
Name Type Description
child Widget

The child to remove.

Fires:
  • Widget#event:child_removed

removeChildren(a)

Source:
Inherited From:

Removes an array of children.

Parameters:
Name Type Description
a Array.<Widget>

An array of Widgets.

set(key, value)

Source:
Overrides:

Sets an option.

Parameters:
Name Type Description
key string

The option name.

value

The option value.

setStyle()

Source:
Inherited From:

Sets a CSS style property in this widget's DOM element.

show()

Source:
Inherited From:

Make the widget visible. This will apply the class aux-show during the next rendering step.

toggleHidden()

Source:
Inherited From:

Toggle the hidden status. This is equivalent to calling hide() or show(), depending on the current hidden status of this widget.

transitionsDisabled()

Source:
Inherited From:

Returns true if transitions are currently disabled on this widget.

visibleChildren()

Source:
Inherited From:

Returns an array of all visible children.

Events

destroy

Source:
Inherited From:

Is fired when a widget is destroyed.

doubleclick

Source:
Inherited From:

Is fired after a double click appeared. Set dblclick to 0 to disable click event handling.

Parameters:
Name Type Description
event string

The browsers MouseEvent.

GenericDOMEvents

Source:
Inherited From:

Generic DOM events. Please refer to W3Schools for further details.

hide

Source:
Inherited From:

The hide event is emitted when a widget is hidden and is not rendered anymore. This happens both with browser visibility changes and also internally when using layout widgets such as Pager.

initialized

Source:
Inherited From:

Is fired when a widget is initialized.

resize

Source:
Inherited From:

The resize event is emitted whenever a widget is being resized. This event can be used to e.g. measure its new size. Note that some widgets do internal adjustments after the resize event. If that is relevant, the Widget#resized event can be used instead.

resized

Source:
Inherited From:

The resized event is emitted after each rendering frame, which was triggered by a resize event.

set

Source:
Inherited From:

The set event is emitted when an option was set using the Widget#set method. The arguments are the option name and its new value.

Note that this happens both for user interaction and programmatical option changes.

show

Source:
Inherited From:

The show event is emitted when a widget is shown and is being rendered. This is the counterpart to Widget#hide.

timedrawn

Source:

Is fired when the time was drawn.

Parameters:
Name Type Description
time Date

The time which was drawn.

visibility

Source:
Inherited From:

Is fired when the visibility state changes. The first argument is the visibility state, which is either true or false.