Update of /cvsroot/qooxdoo/qooxdoo/source/contributed/clock_olsen
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26489/source/contributed/clock_olsen
Added Files:
Tag: renderer
Clock_1.html QxBinaryClock.js QxClock.js QxDigitalClock.js
Log Message:
Added contributed section
--- NEW FILE: Clock_1.html ---
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<head>
<script type="text/javascript">window._htmlstart=(new Date).valueOf()</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
<meta http-equiv="MsThemeCompatible" content="yes" />
<meta http-equiv="ImageToolBar" content="no" />
<meta name="MSSmartTagsPreventParsing" content="yes" />
<title>qooxdoo demo dev</title>
<link type="text/css" rel="stylesheet" href="../../style/qooxdoo.css"/>
<link type="text/css" rel="stylesheet" href="../../style/demolayout.css"/>
<script type="text/javascript" src="../../../tools/script/includer.js"></script>
<script type="text/javascript" src="QxClock.js"></script>
<script type="text/javascript" src="QxBinaryClock.js"></script>
<script type="text/javascript" src="QxDigitalClock.js"></script>
</head>
<body>
<script type="text/javascript" src="../../../tools/script/demolayout.js"></script>
<div id="testDescription">
<p>Testing Clocks implementation.</p>
<p>The elements of the clock will be created on the first open of the QxClockAnalog, QxClockDigital and QxClockBinary.</p>
</div>
<script type="text/javascript">
window.application.main = function()
{
var doc = this.getClientWindow().getClientDocument();
var digitalClock = new QxDigitalClock();
digitalClock.setTop(48);
digitalClock.setLeft(20);
var binaryClock = new QxBinaryClock();
binaryClock.setTop(100);
binaryClock.setLeft(20);
binaryClock.setBackgroundColor("black");
doc.add(digitalClock, binaryClock);
};
</script>
</body>
</html>
--- NEW FILE: QxClock.js ---
/* ****************************************************************************
qooxdoo - the new era of web interface development
Version:
$Id: QxClock.js,v 1.1.2.1 2006/01/24 14:12:45 wpbasti Exp $
Copyright:
(C) 2004-2005 by Schlund + Partner AG, Germany
All rights reserved
License:
LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
Internet:
* http://qooxdoo.oss.schlund.de
Authors:
* Kent Olsson (kols)
<kent dot olsson at chello dot se>
**************************************************************************** */
/* ****************************************************************************
#package(form)
**************************************************************************** */
function QxClock()
{
QxAtom.call(this);
this.setWidth(QxConst.CORE_AUTO);
// ***********************************************************************
// TIMER
// ***********************************************************************
this._timer = new QxTimer(this.getInterval());
// ***********************************************************************
// EVENTS
// ***********************************************************************
this._timer.addEventListener(QxConst.EVENT_TYPE_INTERVAL, this._oninterval, this);
this._timer.start();
};
QxClock.extend(QxAtom, "QxClock");
/*
------------------------------------------------------------------------------------
PROPERTIES
------------------------------------------------------------------------------------
*/
/*!
The current value of the interval (this should be used internally only).
*/
QxClock.addProperty({ name : QxConst.EVENT_TYPE_INTERVAL, type : QxConst.TYPEOF_NUMBER, defaultValue : 1000 });
/*!
The current zone. Offset value is 5 for CDT and 6 for CST
*/
QxClock.addProperty({ name : "zoneOffset", type : QxConst.TYPEOF_NUMBER, defaultValue : -1 });
/*
------------------------------------------------------------------------------------
INTERVAL HANDLING
------------------------------------------------------------------------------------
*/
proto._oninterval = function(e)
{
this._timer.stop();
var date = new Date();
var hours = date.getUTCHours();
var minutes = date.getMinutes();
var seconds = date.getSeconds();
var offset = this.getZoneOffset();
if (hours < offset)
{
hours = hours + 24 - offset; // If hours < 0 add 24 for correct time
}
else
{
hours = hours - offset; // Else just subtract it.
};
this.display(hours, minutes, seconds);
QxWidget.flushGlobalQueues();
if (this.hasEventListeners(QxConst.EVENT_TYPE_INTERVAL))
{
this.dispatchEvent(new QxEvent(QxConst.EVENT_TYPE_INTERVAL));
};
this._timer.restartWith(this.getInterval());
};
/*
------------------------------------------------------------------------------------
UTILITIES
------------------------------------------------------------------------------------
*/
// placeholder method
proto.display = function(hours, minutes, seconds) {};
/*
------------------------------------------------------------------------------------
DISPOSER
------------------------------------------------------------------------------------
*/
proto.dispose = function()
{
if (this.getDisposed()) {
return true;
};
if (this._timer)
{
this._timer.stop();
this._timer.removeEventListener(QxConst.EVENT_TYPE_INTERVAL, this._oninterval, this);
this._timer.dispose();
this._timer = null;
};
return QxCanvasLayout.prototype.dispose.call(this);
};
--- NEW FILE: QxDigitalClock.js ---
/* ****************************************************************************
qooxdoo - the new era of web interface development
Version:
$Id: QxDigitalClock.js,v 1.1.2.1 2006/01/24 14:12:45 wpbasti Exp $
Copyright:
(C) 2004-2005 by Schlund + Partner AG, Germany
All rights reserved
License:
LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
Internet:
* http://qooxdoo.oss.schlund.de
Authors:
* Kent Olsson (kols)
<kent dot olsson at chello dot se>
**************************************************************************** */
/* ****************************************************************************
#package(form)
**************************************************************************** */
function QxDigitalClock()
{
QxClock.call(this);
var label = this._label = new QxLabel();
this.setLabel(label);
this.add(label);
};
QxDigitalClock.extend(QxClock, "QxDigitalClock");
/*
------------------------------------------------------------------------------------
PROPERTIES
------------------------------------------------------------------------------------
*/
QxDigitalClock.SHOW_TWELVE = "12";
QxDigitalClock.SHOW_TWENTYFOUR = "24";
/*!
Show a 12 or 24 hour clock.
*/
QxDigitalClock.addProperty({ name : "showHours", type : QxConst.TYPEOF_NUMBER, possibleValues : [QxDigitalClock.SHOW_TWELVE, QxDigitalClock.SHOW_TWENTYFOUR], defaultValue : QxDigitalClock.SHOW_TWELVE });
/*!
The current value of the interval (this should be used internally only).
*/
QxDigitalClock.addProperty({ name : "label", type : QxConst.TYPEOF_OBJECT });
/*
------------------------------------------------------------------------------------
UTILITIES
------------------------------------------------------------------------------------
*/
proto.display = function(hours, minutes, seconds)
{
var am_pm = "";
if(this.getShowHours() == "12")
{
if (hours > 11)
{
am_pm = "PM";
}
else
{
am_pm = "AM";
};
if (hours > 12)
{
hours = hours - 12;
};
if (hours == 0)
{
hours = 12;
};
};
if (minutes <= 9)
{
minutes = "0" + minutes;
};
if (seconds <= 9)
{
seconds = "0" + seconds;
};
var time = hours + ':' + minutes + ':' + seconds + " " + am_pm;
this.getLabel().setHtml(time);
};
/*
------------------------------------------------------------------------------------
DISPOSER
------------------------------------------------------------------------------------
*/
proto.dispose = function()
{
if (this.getDisposed()) {
return true;
};
if (this._label)
{
this._label.dispose();
this._label = null;
};
return QxClock.prototype.dispose.call(this);
};
--- NEW FILE: QxBinaryClock.js ---
/* ****************************************************************************
qooxdoo - the new era of web interface development
Version:
$Id: QxBinaryClock.js,v 1.1.2.1 2006/01/24 14:12:45 wpbasti Exp $
Copyright:
(C) 2004-2005 by Schlund + Partner AG, Germany
All rights reserved
License:
LGPL 2.1: http://creativecommons.org/licenses/LGPL/2.1/
Internet:
* http://qooxdoo.oss.schlund.de
Authors:
* Kent Olsson (kols)
<kent dot olsson at chello dot se>
**************************************************************************** */
/* ****************************************************************************
#package(form)
**************************************************************************** */
function QxBinaryClock()
{
QxClock.call(this);
this._hour1I = new QxImage();
this._hour2I = new QxImage();
this._divisor1I = new QxImage();
this._minute1I = new QxImage();
this._minute2I = new QxImage();
this._divisor2I = new QxImage();
this._second1I = new QxImage();
this._second2I = new QxImage();
this.add(this._hour1I, this._hour2I, this._divisor1I, this._minute1I, this._minute2I, this._divisor2I, this._second1I, this._second2I);
};
QxBinaryClock.extend(QxClock, "QxBinaryClock");
/*
------------------------------------------------------------------------------------
PROPERTIES
------------------------------------------------------------------------------------
*/
QxBinaryClock.SHOW_TWELVE = "12";
QxBinaryClock.SHOW_TWENTYFOUR = "24";
/*!
Show a 12 or 24 hour clock.
*/
QxBinaryClock.addProperty({ name : "showHours", type : QxConst.TYPEOF_NUMBER, possibleValues : [QxBinaryClock.SHOW_TWELVE, QxBinaryClock.SHOW_TWENTYFOUR], defaultValue : QxBinaryClock.SHOW_TWELVE });
/*!
The image path.
*/
QxBinaryClock.addProperty({ name : "imagePath", type : QxConst.TYPEOF_STRING, defaultValue : "./" });
/*!
The colour of the clock. It must be a subdirectory to imagePath.
*/
QxBinaryClock.addProperty({ name : "color", type : QxConst.TYPEOF_STRING, defaultValue : "green" });
/*
------------------------------------------------------------------------------------
UTILITIES
------------------------------------------------------------------------------------
*/
proto.display = function(hours, minutes, seconds)
{
if(this.getShowHours() == 12)
{
if (hours > 12)
{
hours = hours - 12;
};
if (hours == 0)
{
hours = 12;
};
};
var time = ((hours < 10) ? "0"+hours : hours) + '' + ((minutes < 10) ? "0"+minutes : minutes) + '' + ((seconds < 10) ? "0"+seconds : seconds);
var imagePath = this.getImagePath() + this.getColor() + "/";
if(this.getShowHours() == 12)
{
this._hour1I.setSource(imagePath + time.charAt(0) + ".png");
}
else
{
this._hour1I.setSource(imagePath + "blank.png");
};
this._hour2I.setSource(imagePath + time.charAt(1) + ".png");
this._divisor1I.setSource(imagePath + "divisor.png");
this._minute1I.setSource(imagePath + time.charAt(2) + ".png");
this._minute2I.setSource(imagePath + time.charAt(3) + ".png");
this._divisor2I.setSource(imagePath + "divisor.png");
this._second1I.setSource(imagePath + time.charAt(4) + ".png");
this._second2I.setSource(imagePath + time.charAt(5) + ".png");
};
/*
------------------------------------------------------------------------------------
DISPOSER
------------------------------------------------------------------------------------
*/
proto.dispose = function()
{
if (this.getDisposed()) {
return true;
};
if(this._hour1I)
{
this._hour1I.dispose();
this._hour1I = null;
};
if(this._hour2I)
{
this._hour2I.dispose();
this._hour2I = null;
};
if(this._divisor1I)
{
this._divisor1I.dispose();
this._divisor1I = null;
};
if(this._minute1I)
{
this._minute1I.dispose();
this._minute1I = null;
};
if(this._minute2I)
{
this._minute2I.dispose();
this._minute2I = null;
};
if(this._divisor2I)
{
this._divisor2I.dispose();
this._divisor2I = null;
};
if(this._second1I)
{
this._second1I.dispose();
this._second1I = null;
};
if(this._second2I)
{
this._second2I.dispose();
this._second2I = null;
};
return QxClock.prototype.dispose.call(this);
};
|