Disk Clock 1.11: Exposed!

Disk Clock latest 1.11. Expanded JSON to HTML to allows classes, ids, and attributes. Brought in some QUnit to test it. Used new capabilities to expose previously hidden settings in DC, including the lifetime/birthday disk set. Tweaked animation function back towards original fast-to-slow.

Settings: Exposed!

From the earliest days, Disk Clock has had a lot of hidden parameters; they are listed under Secret Hacks on the web page for those who want to mess around. Finally, with some space freed up and dynamic control creation, the appropriate settings can be put in place.

Out of Space

Or, at least some of them. A setting plus a title takes takes about 1/3 of the available space. After the settings for always and hover disks, there is only space for one other setting. This cuts you off if both disk sets have settings, or even multiple settings per disk. This pushes on the issue of having two configurable disks sets, but all the solutions I’ve thought of so far are worse than the disease.

- Button to cycle the settings
- A partial solution would be to have only one setting per disk set; but it isn’t obvious that one can change something by switching to an unrelated set.
- Remove the toggle configuration – no combinations would be allowed, so you’d have make new sets for every combination.
- Remove the always configuration – I have to work out a method to make multiple versions. Until I come up with a better idea, this is the future.
- Single disk selection; first sets primary, a second selection sets secondary. Also fails because it’s completely non-obvious.
- Only show one of the disk-set selections if they are different. Possible, but more than likely confusing. And when you have multiple sets, you are more likely to have multiple settings.
- Only show one of the disk-set selections if there are no useful settings. What if your extra set requires enough settings to hide itself?

Lying Flat

Once consequence of the control system, is that it’s a lot easier to deal with flat key-value sets than compound objects. The applies especially to persistent storage of settings. So you have to have birthday_year, month, day instead of birthday. There is also no easy way to do mixed mode bed times, so that feature is effectively disabled. Actually, the one-setting limit means that bedtime can’t show up, so it’s a moot point for the moment.

Get a Little Class (and ID, and Attributes.)

A while back I came up with a method to turn JSON into HTML, treating property names as tags. While this worked well enough for the things I was doing, the lack of of classes and ids made it unsuitable for anything with behavior attached. I borrowed a bit of syntax from HAML, in spite of this requiring quoted property names.

I’ve also been running into the limitations of the JSON syntax. Once you start adding the attributes, the character savings of the angle brackets gets sucked up by the quotes, and the closing tags start to become inconsequential in comparison to the other text. Speaking of text, it’s been failing point. The original use case was nested divs and the like, inserting some variables. The current use is basically a big literal with any dynamic values plugged in later.

No Escape

Another issue I ran into was inserting a degree character. There is an HTML entity for degree (deg). The catch is that I put in HTML-escaping when I was working on Naked Javascript and had a recursive body tag showing up ;^) The solution for now is a NoEscape class that wraps a string, and can be detected by the generator using instanceof.

Further Adventures in Testing

Since the JSON-to-HTML part was fairly isolated and functional, I used it as a case to experiment with JavaScript unit testing. I picked QUnit, which was reasonably understandable, although it lacks niceties like before/after events.

Pacha: Exposed!

One other module that got the testing treatment was pacha, the time-place that hosts astronomical calculations. I found that I needed to show the values of the default latitude and longitude as the initial values of the controls, but these were being assigned inside pacha. While I could have exposed just those fields easily enough, I set up a test harness and refactored pacha as a full fledged object amenable to Naked Javascript inspection (even though some would say this is eevil, the work of the deevil.)

Other modules may get tested as I work on them. Disk Clock itself probably needs a lot of refactoring before I can start testing problem areas like the animation system.

Change Magnet

I changed the animation system again. Ever since I switched from relative to absolute animation, I’ve been using a cosine based method that goes slower at both ends. After playing around with Grapher.app, I added some exponents that gave me a curve closer to the incremental version, but still based on the absolute time.

Posted Saturday, March 21st, 2009 under Devlog.

Comments are closed.