YaWK  24.1
Yet another WebKit
YAWK\WIDGETS\CLOCK\CURRENT\clock Class Reference

Embed a digital real-time clock on your website. More...

Public Member Functions

 __construct ($db)
 Load all widget settings from database and fill object. More...
 
 drawClock ()
 Draw the clock on screen. More...
 
 init ()
 Initialize: prepare JS and start the clock. More...
 
 loadJavascript ()
 Load required javascript. More...
 
 printObject ()
 Print all object data. More...
 

Public Attributes

 $clockAlign = 'text-center'
 
 $clockClass = 'h1'
 
 $clockColor = '#f5f5f5'
 
 $widget = ''
 

Detailed Description

Embed a digital real-time clock on your website.

Embed a digital clock on your website.

The clock shows the current time. (wonder, oh wonder...) You can set the clock's font color, alignment (left, center or right) as well as a custom css class to design it and put some FX on if you need to. If you need an analog clock anywhere on your website, this widget does the job.

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Version
1.0.0

Definition at line 16 of file clock.php.

Constructor & Destructor Documentation

◆ __construct()

YAWK\WIDGETS\CLOCK\CURRENT\clock::__construct (   $db)

Load all widget settings from database and fill object.

Parameters
object$dbDatabase Object

Load all widget settings on object init.

Definition at line 32 of file clock.php.

34  {
35  // load this widget settings from db
36  $this->widget = new \YAWK\widget();
37  $settings = $this->widget->getWidgetSettingsArray($db);
38  foreach ($settings as $property => $value) {
39  $this->$property = $value;
40  }
if(isset($_POST['save'])) $settings
$value

References $db, $settings, $value, and YAWK\widget\getWidgetSettingsArray().

Member Function Documentation

◆ drawClock()

YAWK\WIDGETS\CLOCK\CURRENT\clock::drawClock ( )

Draw the clock on screen.

This method draws the clock on screen

Definition at line 93 of file clock.php.

95  {
96  echo"
97  <div class=\"$this->clockAlign\">
98  <div id=\"clockDiv\" class=\"$this->clockClass\" style=\"color:#$this->clockColor\"></div>
99  </div>";

Referenced by YAWK\WIDGETS\CLOCK\CURRENT\clock\init().

◆ init()

YAWK\WIDGETS\CLOCK\CURRENT\clock::init ( )

Initialize: prepare JS and start the clock.

use this method to run the clock

Definition at line 57 of file clock.php.

59  {
60  $this->loadJavascript();
61  $this->drawClock();
drawClock()
Draw the clock on screen.
Definition: clock.php:93
loadJavascript()
Load required javascript.
Definition: clock.php:67

References YAWK\WIDGETS\CLOCK\CURRENT\clock\drawClock(), and YAWK\WIDGETS\CLOCK\CURRENT\clock\loadJavascript().

◆ loadJavascript()

YAWK\WIDGETS\CLOCK\CURRENT\clock::loadJavascript ( )

Load required javascript.

The engine behind this clock

Definition at line 67 of file clock.php.

69  {
70  echo"<body onload=\"clock();\">
71  <script type=\"text/javascript\">
72  function clock() {
73  var now = new Date();
74  var minute = now.getMinutes();
75  var second= now.getSeconds();
76  var hour = now.getHours();
77  if(minute<10) minute = \"0\" + minute;
78  if(second<10) second= \"0\" + second;
79  if(hour<10) hour=\"0\" + hour;
80  var outStr = hour+':'+minute+':'+second;
81  /* output string without leading zero int
82  * var outStr = now.getHours()+':'+now.getMinutes()+':'+now.getSeconds(); */
83  document.getElementById('clockDiv').innerHTML=outStr;
84  setTimeout('clock()',1000);
85  }
86  clock();
87  </script>";

Referenced by YAWK\WIDGETS\CLOCK\CURRENT\clock\init().

◆ printObject()

YAWK\WIDGETS\CLOCK\CURRENT\clock::printObject ( )

Print all object data.

(for development and testing purpose)

Definition at line 46 of file clock.php.

48  {
49  echo "<pre>";
50  print_r($this);
51  echo "</pre>";

Member Data Documentation

◆ $clockAlign

YAWK\WIDGETS\CLOCK\CURRENT\clock::$clockAlign = 'text-center'
Parameters
stringClock alignment

Definition at line 23 of file clock.php.

◆ $clockClass

YAWK\WIDGETS\CLOCK\CURRENT\clock::$clockClass = 'h1'
Parameters
stringClock class

Definition at line 25 of file clock.php.

◆ $clockColor

YAWK\WIDGETS\CLOCK\CURRENT\clock::$clockColor = '#f5f5f5'
Parameters
stringClock color

Definition at line 21 of file clock.php.

◆ $widget

YAWK\WIDGETS\CLOCK\CURRENT\clock::$widget = ''
Parameters
objectglobal widget object data

Definition at line 19 of file clock.php.


The documentation for this class was generated from the following file: