Bug 1017490 part 2 - rewrite clock build script in javascript