Hosting a Clock
adding one to your own page
is nearly easy as pie
if you'd like to attach a WRLD.time clock to your web page, read on. without much effort, you can configure the color, font and position of the digits being displayed. add a background color or image to give it flair. and if you wanna go hog-wild, you can create a configuration file.
totally insane people may go so far as to download the class files so they can use the command-line version.
|Attaching a Clock||how to put a WRLD.time clock on your web page|
|Config Files||making your clock look as groovy as possible|
|On the Desktop||fun with WRLD.time clocks executed from the command line|
|UTC Sites||a list of sites which support the UTC protocol|
|Contents Previous Next||Attaching a Clock|
Basically, what you need to do is create an applet which references the WRLD.time class files.
The most direct way of doing this is referring to the class files on sleepbot.com.
Here's an example of what you'd put in your web page:
<APPLET CODEBASE="http://www.sleepbot.com/WRLDtime/lib" CODE="com.sleepbot.WRLDtime.app.WRLDtimeApplet" WIDTH=*** HEIGHT=*** > <PARAM NAME="config" VALUE="***"> <PARAM NAME="bg" VALUE="***"> <PARAM NAME="fg" VALUE="***"> <PARAM NAME="cron" VALUE="***"> </APPLET>Don't worry about the carriage returns & indentation... that's just there for visual effect. I'll explain the blue asterisks in just a moment.
First of all, the <APPLET /> tag tells the browser that an applet should be put in place. APPLET needs a closing tag, which you see on the last line of the example.
The basic stuff that an applet needs to know are the name of the applet class and where it's located. The CODE portion identifies the name of the class to display, and CODEBASE indicates where the classes are located. In this example, you're referencing the standard WRLD.time applet class (WRLDtimeApplet) from the sleepbot.com domain. That way you don't have to set them up on your own server, and you always get the latest version of the classes.
The WIDTH and HEIGHT portions are defined by you... experiment with the applet sizing until you get something that looks nice. When sizing your window, keep in mind that the standard WRLD.time applet class reserves a 25-pixel-high row at the bottom of the applet so that it can display the WRLD.time logo. For this reason, you may disregard the 'window' line described in the standard configuration. It has no purpose in an a applet context; the clock face dimensions are specified via the <APPLET /> tag.
The standard time-piece accepts parameters from the applet definition.... that's what the <PARAM /> tags are for. All of the parameters are optional... you could just as easily have no <PARAM /> tags if you wish. If you don't provide any parameters, you'll get the standard black-on-grey clock.
One clean way to configure your clock is to provide a reference to an external configuration file via the config parameter. The applet will fetch and parse the file, and configure itself accordingly. The external file may contain the bg, fg and cron lines, as well as many others. However, it's nice to provide at least the bg configuration up-front so that the Applet has that information during its initial rendering.
Unfortunately, there's one little issue with the example I've shown above. Unless the example is hosted from sleepbot.com, the configuration file won't be loadable. It's a Java security thing; the applet can't go around referencing random files on random web hosts -- it can only grab files from its own host. So unless you're also hosting the classes locally, this will be an issue. As of WRLD.time version 1.3 I've introduced a work-around so that you don't have to download and host the classes just so that you can make a complex configuration.
You may explicitly include all of your configuration in the <PARAM /> tags. You can provide everything -- bg (background), fg (foreground), cron (chronometer), digits, tablets, separators, aliases -- the whole nine yards. You could end up with a lot of tags, but it gives you that full flexibility! But depending upon how much you customize the face of the clock, you'll need to be aware of these lines:
However, in an applet, there's no way to get all of your <PARAM /> tags. You have to explicitly ask for them by name. So, these lines tell the time-piece about all the other entity lines to be parsed. Remember to keep your list up-to-date... if it doesn't contain a new (or modified) entity line name, the applet won't parse it!
See configuration files below for full details on all these parameters and the default values for the time-piece.
You'll probably have noticed that there's a pair of WRLD.time clocks on each of the pages you've been looking at here. They're identical across each page, except for the background color. All that was needed to make these clocks is the fg and bg parameters... do a View Source and see for yourself.
|Contents Previous Next||Config Files|
If all clocks looked the same, it'd be a boring, boring world.
So, in the interest of preventing such boredom, the standard time-piece determines its appearance according to a configuration file.
You may configure the time-piece via a simple text file. Each line in the file that is not blank and not a comment denotes a configuration setting. A line can be marked as a comment by making its first character a semicolon (
In an applet context, you may configure this time-piece via the <PARAM /> tags. The tag's NAME attribute is the configuration line name, and its VALUE attribute is the line to be parsed. There's really no use for comments in this context.
Configuration settings have the following general format:
NAME=KEY:VALUE, KEY:VALUE, ...NAME is the name of the setting and it is followed by an equal sign ('='); you'll see more on the individual settings below. The setting contains a series of key-value pairs, each separated by a comma (','). The KEY is separated from its VALUE by a colon (':'). If you need to include a comma (or leading or trailing whitespace) within your setting, then enclose the entire KEY:VALUE setting in full quotes ('"').
The applicable key-value combinations are defined by the setting itself. The settings are grouped below by a rough classification. Each setting can accept certain key types. Each key type is made up of one or more key-value pairs. You'll probably have to scroll around this document a while to figure out the full inter-relationships between these things.
Now, before I go into great technical detail, I'll refer you to the configuration files I've already created. They're all sitting in the same directory, and the best ones to look at are Green, jonathan and Ambience. If you want to actually see one of them in action, choose it from the many faces.
Okay, the fun starts here. First, we have what I call the Global Settings which are used to describe general display components. All Global Settings are optional... the defaults for each setting are described below.
Other than that, we have what I call the Digit Settings, which are used to define the individual rendering elements of the clock. All Digit Settings are optional... if none are provided, then the time-piece assumes the text types 0-9 for each digit and a period ('.') for the separator.
However, it's all-or-nothing; if even one Digit Setting is provided, then all digits which are not explicitly specified via a setting are not displayed.
Now, when I talk about measures and beats and digit groups and indexes here, I mean the following... A standard WRLD.time clock is expressed in the format "XX.XX". The measure is on the left and it's made up of digits 3 and 2; digit 3 is the highest digit in the clock, and it changest the slowest. The beat is on the right and it's made up of digits 1 and 0; digit 0 is the lowest digit, and it changest the fastest. Also, there's a single separator ('.') between the measure and the beat.
Here's the format for a separator setting:
If you had set up text settings for the measure's left digit, and you wanted all the digits to have the same settings, you'd could write your file with things like "d2.0=alias:d3.0" and "d1.4=alias:d3.4", etcetera.
Or you could write it another way by creating a new alias setting called "one" and referring to it like "d3.1=alias:one", "d2.1=alias:one" and "d1.1=alias:one". They're not necessary, but they make the file a little more legible and provide for re-usability.
Any point, font or color key-value pairs in the 'alias' setting override the group settings, and any key-value pairs for the digit itself override the respecitve key-values of the 'alias' settings. Just like layers on an onion.
Oh... and one more thing. 'Alias' settings don't cascade, so if you know what what means, don't do it.
Okay, now you know about the settings. Here are the individual key types and the key-value pairs that are used to define each:
The weirdest thing to get used to in configuration files is the whole 'override' thing. I'll run you through a tiny example to touch on all the aspects of overriding:
; the Global Settings bg=color:000000 fg=size:+4, x:2, color:FFFFFF ; the Digit Settings sep=text:^, bold sep1=text:_, bold, x:+3 sep3=text:*, bold, x:+6 d3=x:+10, y:+10 d3.5=image:five.gif d0.8=alias:d3.5, y:-1 d0.9=alias:eight, italic, color:00FF00 t2.0.9=text:T, x:+7 t1.89=text:T, x:+6 eight=text:8Now granted, this would look like crap, but hear me through. This clock is going to display is two separators, the 5 of the measure's left digit, and the 8 & 9 of the beat's right digit. It also has two potential tablets to display.
The background color of this clock will be black with no image. The global color will be white. The global point will be (2, 0), since we specified an absolute horizontal position and left the y alone; if you provide only one coordinate, the other one defaults to 0. The global font will be 100% default, since we didn't specify any key-value pairs that the font type recognizes.
There are three separators listed, but only two will be recognized. The first separator is named "sep" here, but "sep0" is also acceptable. It is going to be a caret, and it'll be displayed in the global font's face and size, but with a bold style. As it turns out, it doesn't make sense to do this because the global font is already bold. If you wanted to display it without the bold styling, then the setting should have the 'plain' key in it somewhere.
The second separator is named "sep1", and it's an underscore, displayed 3 pixels to the right of the caret, at (5, 0). The third separator here is named "sep3", and it is ignored because it's out of sequence. To fix this, you could add a setting named "sep2", or rename the third separator to "sep2".
All of the measure's left digits are going to be displayed at (12, 10), because its point is 10 pixels diagonal to the global point of (2, 0). Since only its 5 digit is described, you'll only know when it's between 50.00 and 59.00 through the day. The digit is an image, and the file itself is assumed to be in the same directory as the page (or the class files, if it's a desktop clock). If the file isn't there, even the 5 digit won't display!
There is no digit group setting for the beat's right digit, so each of its digits will be relative to the global settings. The 8 digit will be the same as the 5 digit from the measure's left, but it is displayed at (2, -1)... the measure's left group setting is not considered here. The 9 digit will be a text '8', and will be displayed in the face and size of the global font, with italic style (plus the default's bold style), and it will be light blue.
And then, we have the tablets... The measure's right digit (d2) always shows 'T', since the t2 tablet is 1 digit long and covers the full digit range of 0 thru 9. The t1 tablet means that 'T' is shown in leiu of d0.8 and d0.9 whenever the beat is 89.
It looks really convoluted, but it's really not all that bad. Check out my examples (linked above), experiment a little, and you should be able to implement some really cool ideas. And with the generic images and positioning, you can make it as abstract as you'd like.
Oh... and did I mention... it's all supposed to work, but I haven't done rigorous testing. If any of it needs tweaking, feel free to let me know.
|Contents Previous Next||On the Desktop|
The standard time-piece uses configuration files to define its appearance.
For this reason, the command-line application (WRLDtimeApp) takes one optional parameter:
|Contents Previous Next||UTC Sites|
Here is a list of known UTC hosts.
Each of them serves its signal from port 13.
time-a.timefreq.bldrdoc.gov time-b.timefreq.bldrdoc.gov time-a.nist.gov time-b.nist.gov time.nist.gov time-nw.nist.gov utcnist.colorado.eduFor much more detailed information, please see http://www.boulder.nist.gov/timefreq/.