# Preview of my JavaScript Timer



## K073 (Nov 12, 2009)

Link:
http://k073.webs.com/timer.html
If the link fails to load, the server is updating and you have to wait a while before it can load again.

This timer is based on blah a.k.a. zzzonked's timer
Functions:
- tap [spacebar] to start timer and any key to stop
- the time is accurate because the timer is started when the spacebar is released and stopped whenever any button is pressed
- press '2' for 2x2 and again to enter BLD mode and again to get back to speed mode, press 3 for 3x3 and so on till 7x7. Press '9' for pyraminx
- press 'L' to view last scramble
- press 'Q' to display full details for each solve
- press 'P' to mark the current time as PLL skip and press 'O' for OLL skip
- press [escape] followed by [enter] to reset the times
- press 'D' to mark the current time as 'DNF' and press again to mark it as a +2 penalty and again to cancel the penalty
- hover on a time marked as 'DNF' to show the raw time
- press [delete] or [backspace] to delete current time
- click and drag the scramble preview to move the preview somewhere else because it might be blocking the scramble(or time)
- click on the time or press 'F' to toggle between full screen mode and normal mode(only applicable to browsers other than IE)
- click on the mean time or press 'M' to get the details including scrambles(suitable for doing small averages) and tap 'M' again to get full details without scrambles(suitable for big average attempts) so that you can copy them or whatsoever(only applicable in browsers other than IE too)
- click on the best/worst time(on the right side) or press 'Z' or 'X' to get the scramble for the relative scrambles
- click on the best/worst average of 5/12 time or press 'C', 'V', 'B', or 'N' to get the details so that you can copy them or whatsoever(only applicable in browsers other than IE too)
- click on the box displaying all the times to select and highlight all the texts, and press [CTRL]+[C] to copy them to the clipboard(after a box appears)(only applicable in non IE environment)
- If you really want it to be more "full screen" instead of seeing the navigation bars and title bars, press [F11]. If your browser supports full screen mode, the whole window will fill the screen.
Note: Google Chrome encouraged. IE disencouraged.


Previews:





Starting...




DNF function(forgot to show +2 penalty function), bracket best and worst time function, time of solve, number of solves, mean, average, standard deviation, current, best and worst average of 5 and 12.




In 3x3 Blindfolded mode. Display of memorization and execution time seperately, current time and date, full screen mode after clicking the time, position of scramble in full screen mode




Details of times after clicking on the mean time.




OLL, PLL and LL skip function, percentage of skips and DNFs, times for best average of 12 shown(click on the red 'X' to close the details box).




2x2 in blindfolded mode in non-full screen mode, scramble preview drag function.


----------



## Edward (Nov 12, 2009)

Another one? So many timers.


----------



## K073 (Nov 12, 2009)

last time I was just modifying the timer to suite my style. Now, since I made many changes, I'll just upload it and share with all the cubers.


----------



## Cride5 (Nov 12, 2009)

Nice!

If you could add in a <25 move random-state scrambler for 3x3 I'd be sold 

EDIT: There's a bit of a bug with resizing the window in Firefox/Linux. The main timer disappears!
EDIT2: What's happening is when the window is reduced in size, no scroll bar appears. Pressing spacebar causes it to scroll to the bottom which hides the timer at the top. With no scroll bars there's no way to see the timer again, unless the window can be increased in size.

@ ShadenSmith (post below), are you talking about the bug where if you stop the timer and continue to hold it, the timer starts again when you let go? This is deffo another bug :/


----------



## ShadenSmith (Nov 12, 2009)

Hold the spacebar down.


----------



## K073 (Nov 13, 2009)

random state scrambler would be too much for JavaScript.
the spacebar issue is a must because if not, when you hit the spacebar to stop the timer, and release immediately, the timer starts again.
I set the window to be opened in a pop up in full screen, why would you resize it?? just maximize the window and everything will be fine.
this timer is set to detect screen size and resize all element according to ratio given, so all the things will be crappy when you resize the window. that's the main reason I set it to pop a full screen window out.


----------



## Cride5 (Nov 13, 2009)

K073 said:


> random state scrambler would be too much for JavaScript.



I don't think so. Not if move-count isn't a concern. Optimal random-state is deffo a bit of an ask, but something like Thistlethwaite certainly is not. The challenge is to have something which can generate scrambles of under 25 moves. I've already tried implementing the Kociemba 2-phase algorithm in js, but the memory consumption was too high - this is mainly because js doesn't offer good enough type control to store pruning tables efficiently. This could potentially be overcome by using bitwise operations to pack more data into 32-bit integers, but is a major faff!

With regards to resizing, if you want a program to be nice for its users its good to be flexible. Its perfectly reasonable to assume that folk may wish to have multiple windows open at once, or may be even working on a 640x480 display. Even if it can't show all elements, it should at least degrade in a reasonable manner. I personally use this scrambler along-side my timer..


----------



## Johannes91 (Nov 13, 2009)

Cride5 said:


> I've already tried implementing the Kociemba 2-phase algorithm in js, but the memory consumption was too high - this is mainly because js doesn't offer good enough type control to store pruning tables efficiently.


I came to the same conclusion a while ago. Even if it could be optimized enough to run acceptably on the best JS engines, it wouldn't work for people using older/worse browsers.



Cride5 said:


> This could potentially be overcome by using bitwise operations to pack more data into 32-bit integers, but is a major faff!


Bitwise operations in JavaScript are *evil*! The language doesn't have an integer type - all numbers are double-precision (64-bit) floating point numbers. The bitwise operators convert their operands to integers, do their thing, then convert the result to floating point. They are quite unpredictable and rarely a good idea for anything.

Besides, all values are boxed (on most implementations) and an array of them takes much more space than needed. One way to store large tables could be to use a string, but I haven't tried it.

I think it would be fine to use an efficient program on the server and request new scrambles using AJAX when needed. If that annoys some people, you could print some (say, 100 or 1000) new scrambles in a JS array every time the page is loaded and only start making requests when those have been used.



Cride5 said:


> With regards to resizing, if you want a program to be nice for its users its good to be flexible.


Definitely agreed.


----------



## Cride5 (Nov 13, 2009)

Johannes91 said:


> Bitwise operations in JavaScript are *evil*! The language doesn't have an integer type - all numbers are double-precision (64-bit) floating point numbers. The bitwise operators convert their operands to integers, do their thing, then convert the result to floating point. They are quite unpredictable and rarely a good idea for anything.



Damn I didn't realise that  I assumed it did the same thing as other weakly typed languages, silently converting between types. Storing everything as 64-bit floats is just ridiculous, especially when bitwise operations insist on shrinking them to 32-bit ints. It basically means you can't do anything with bitwise operations unless you are happy to waste 32 bits! That is a serious flaw 

Storing cube state in strings sounds like a good idea. It will reduce the memory footprint 4-fold (and possibly further if used in conjunction with bitwise operations), but at the same time will increase the overhead of read/writes. It may be worth it tho..
... thx for the pointer


----------



## K073 (Nov 14, 2009)

Kociemba is written in JAVA not JavaScript! The source of the page is short because it loads Java instead of scripts to be executed by js engines. If I even put a Java applet into my timer, users will have to wait for a day to use my timer because they'll have to install latest Java.
Even if it doesn't require plugin installation, how am I going to make a Java applet interact with my scripts so that the script an fetch and save all the scrambles


----------



## Cride5 (Nov 14, 2009)

K073 said:


> Kociemba is written in JAVA not JavaScript!





Cride5 said:


> I've already *tried* implementing the Kociemba 2-phase algorithm in js, but the memory consumption was too high



Kociemba is currently implemented in C and Java. My attempt was a port of the Java implementation to Javascript. I say attempt because it failed for the reasons stated. Please don't accuse me of not knowing the difference between Java and Javascript, it's patronising.




K073 said:


> how am I going to make a Java applet interact with my scripts so that the script an fetch and save all the scrambles


this is possible...


----------



## theretardedcuber (Nov 14, 2009)

looks pretty good 
cant have enough timers =]


----------



## K073 (Nov 15, 2009)

Cride5 said:


> K073 said:
> 
> 
> > Kociemba is written in JAVA not JavaScript!
> ...


ok, my bad...



Cride5 said:


> K073 said:
> 
> 
> > how am I going to make a Java applet interact with my scripts so that the script an fetch and save all the scrambles
> ...


even if I can do this I won't because I would rather not to make it complex by adding Java applets. Even if I really add it, how am I supposed to get the scramble preview to function properly?? I'm bad at Java language


----------



## Tim Major (Nov 15, 2009)

I'm liking it. I used qqtimer, I switched to http://zzzonked.googlepages.com/testtimer10.html
but it was missing a few functions, and did not have as many puzzles. I will use this once you finish it.


----------



## K073 (Nov 15, 2009)

quote from http://cube.crider.co.uk/scrambler.html:


> Scrambles are built by generating a statistically random cube state and using the Kociemba two-phase algorithm to find a solution to it. The inverse of the solution is then given as the scramble.


this means that the cube is scrambled, solved using 2-phase algorithm, inverse the solution to make it a scramble. the scramble is only shorten, not really necessary(except if you are not capable of doing 4/5 more moves)


----------



## Carrot (Nov 15, 2009)

I'm not sold before pyraminx is added... (optimal scrambles too xD)


----------



## Johannes91 (Nov 15, 2009)

K073 said:


> this means that the cube is scrambled, solved using 2-phase algorithm, inverse the solution to make it a scramble. the scramble is only shorten, not really necessary


The point isn't to have shorter scrambles, it's to have better scrambles. Making 25 random moves doesn't give a good distribution (some positions are significantly more probable than others), generating a random position does.

Anyway, I can't follow you. Did someone actually say you should add a Java applet to your scrambler? Cride just mentioned it as an example of another window that's nice to have open at the same time as a timer. Quote what you're replying to in the future unless it's obvious.


----------



## K073 (Nov 15, 2009)

Odder said:


> I'm not sold before pyraminx is added... (optimal scrambles too xD)


why is it so important to have pyraminx? it's a CUBE timer, not a puzzle timer. btw, that's not my point. I don't play pyraminx(or should I say "usually don't") and as I said previously, I modified a timer to suit my style, so non-cube is not necessary for me, yet.
Btw, if you really don't want any scramble previews, I can get pyraminx into it.
And, I'll consider optimal scrambler other times, now a little busy.



Johannes91 said:


> K073 said:
> 
> 
> > this means that the cube is scrambled, solved using 2-phase algorithm, inverse the solution to make it a scramble. the scramble is only shorten, not really necessary
> ...


I mean, you won't even know whether a scramble is optimal or not and the pieces are in random positions or not, unless you are doing BLD. So, you won't even know whether it's really in random position or not unless you examine every pieces during your inspection time.
No one said that I should add Java applet, but it's indirectly calling me to do so, because something like Kocembia's two-phase algorithm can only easier to do with Java but not JavaScript. If I open that thing in a new window or pop up, I wouldn't even bother the scrambles there, because there's many things blocking in between Java and JavaScript.


----------



## Carrot (Nov 15, 2009)

K073 said:


> Odder said:
> 
> 
> > I'm not sold before pyraminx is added... (optimal scrambles too xD)
> ...


Pyraminx is the puzzle I'm best at... so the timer I want to use should REALLY have pyraminx scrambles hehe 
I don't need a scramble preview... just the scramble  and as long as the move count is sub 20 I'm happy xD


----------



## Cride5 (Nov 15, 2009)

Cride5 said:


> K073 said:
> 
> 
> > how am I going to make a Java applet interact with my scripts so that the script an fetch and save all the scrambles
> ...



http://java.sun.com/products/plugin/1.3/docs/jsobject.html

Allowing the script to interface with java means you can generate random-state scramblers relatively quickly, and would allow interfacing with a stackmat. it may be a better idea to just implement the whole timer program as a java applet, but doing so means having the java plugin is a _necessity_, rather than an optional extra for providing random state scrambles + stackmat interfacing.



K073 said:


> I mean, you won't even know whether a scramble is optimal or not and the pieces are in random positions or not, unless you are doing BLD. So, you won't even know whether it's really in random position or not unless you examine every pieces during your inspection time.



Read this: http://www.speedsolving.com/forum/showthread.php?t=12969

And look up "Random Walk" and "Uniform Random Distribution"


----------



## K073 (Nov 16, 2009)

Odder said:


> Pyraminx is the puzzle I'm best at... so the timer I want to use should REALLY have pyraminx scrambles hehe
> I don't need a scramble preview... just the scramble  and as long as the move count is sub 20 I'm happy xD



alright. you wish is granted. with preview! but i don't know whether it works or not because i don't have pyraminx


----------



## blah (Nov 16, 2009)

Whoa whoa whoa. Why wasn't I informed of this? This isn't very nice. Really. Not nice.


----------



## K073 (Nov 17, 2009)

it's open source rite?


----------



## blah (Nov 17, 2009)

Just because the source is open (because I really don't know how to make it "closed" anyway) doesn't give you ANY right to tweak it and claim ownership over MY intellectual property. I really don't like how this is turning out. The only person to whom I gave full permission to alter my work to his liking was Conrad.


----------



## K073 (Nov 17, 2009)

i did give you credits and i did said that this timer is based on your previous works. it has lots of difference with your timer


----------



## Edward (Nov 17, 2009)

K073 said:


> i did give you credits and i did said that this timer is based on your previous works. it has lots of difference with your timer



I dont think your allowed to use his source without permission, even if its open. If you made an awesome, open source game, and i took your source without your permission and made a game with it, would you be happy?


----------



## K073 (Nov 17, 2009)

i wouldn't mind if you really do so, it depends on the situation


----------



## Johannes91 (Nov 17, 2009)

K073 said:


> it's open source rite?


Sounds like you have no idea what that means (see open source definition). The author has the copyright and unless he explicitly gives permission (like releasing it under GPL or BSD or some other open source license), you are not allowed to make derivative works or claim it your own etc. even if you have access to the source.


----------



## K073 (Nov 17, 2009)

even if I don't modify it(I just took how the timer save times), I can simply re-write all the scripts using the same style and claim it as mine or I could just copy and paste and edit all the strings, but now I'm not claiming the timer is fully my project but I mix many programs all together to make a better timer which suits my style which I hope suits other cubers too. And the main thing is, I gain no benefit with this timer. One more thing, major scripts in the timer's source codes is written by me, just to make things clearer.


----------



## Johannes91 (Nov 17, 2009)

K073 said:


> even if I don't modify it(I just took how the timer save times), I can simply re-write all the scripts using the same style and claim it as mine


If you genuinely rewrite it from scratch without using any of the original source, that's fine of course.



K073 said:


> or I could just copy and paste and edit all the strings


But that's obviously not ok.



K073 said:


> but now I'm not claiming the timer is fully my project but I mix many programs all together


If the people who wrote those programs don't let you use them, you're being a jackass. Giving them credit doesn't change anything.


----------



## K073 (Nov 17, 2009)

what I meant was, only 25-35% of the codes belongs to the original code of the timer. And from the original codes, I cut off almost 60% including the scramblers, puzzles, extra functions etc.


----------



## Edward (Nov 17, 2009)

K073 said:


> what I meant was, only 25-35% of the codes belongs to the original code of the timer. And from the original codes, I cut off almost 60% including the scramblers, puzzles, extra functions etc.



Then rewrite the 25-25% percent by yourself. Problem solved.


----------



## blah (Nov 17, 2009)

Doesn't solve the problem that he also stole my keyboard-controlled design philosophy and my layout and my entire coding structure and I can really go on and on about this. But I don't think there's much anyone can do about it.

Most importantly, this was my first ever JavaScript project. I learned JavaScript solely for the purpose of developing this timer. You have no idea how many hours and how much hard work I've put into this. And when everything clicked into place after a week or two and people started using it and said nice things about the BLD mode, the easy usability, the percentage calculators, etc., that was the proudest moment of my cubing career - having contributed to the community. *Now you're just gonna take all this away from me.* Thanks.



K073 said:


> i did give you credits and i did said that this timer is based on your previous works. it has lots of difference with your timer





K073 said:


> it's open source rite?





K073 said:


> i wouldn't mind if you really do so, it depends on the situation





K073 said:


> even if I don't modify it(I just took how the timer save times), I can simply re-write all the scripts using the same style and claim it as mine or I could just copy and paste and edit all the strings, but now I'm not claiming the timer is fully my project but I mix many programs all together to make a better timer which suits my style which I hope suits other cubers too. And the main thing is, I gain no benefit with this timer. One more thing, major scripts in the timer's source codes is written by me, just to make things clearer.





K073 said:


> what I meant was, only 25-35% of the codes belongs to the original code of the timer. And from the original codes, I cut off almost 60% including the scramblers, puzzles, extra functions etc.


I want to know how old you are if you can really say all this without feeling bad about anything.


----------



## eastamazonantidote (Nov 17, 2009)

@blah: I was disappointed when you gave up on your timer (or have you?). I really loved it. 2 minor fixes (scrambles saved do not correspond to the timed scramble and a better way to export times) and it would've been perfect. I can see why you're upset. At the same time, it is a great way to learn JavaScript. In fact, I copied your code and worked off it for some js practice. Your code is a great base to work off of.

@K073: give blah some credit somewhere. It's like Edison saying he invented the light bulb (which he got away with, but not everyone does. Also, this problem is a lot smaller).

That aside, I like the timer. Just, the 7x7x7 picture covers part of the scramble. May wanna fix that.


----------



## Cride5 (Nov 17, 2009)

blah said:


> Most importantly, this was my first ever JavaScript project. I learned JavaScript solely for the purpose of developing this timer. You have no idea how many hours and how much hard work I've put into this. And when everything clicked into place after a week or two and people started using it and said nice things about the BLD mode, the easy usability, the percentage calculators, etc., that was the proudest moment of my cubing career - having contributed to the community. *Now you're just gonna take all this away from me.* Thanks.



I think that's something that a lot of folks don't appreciate when they use open-source software generally. Coding is hard work, and open-source developers are doing it for the benefit of all, and for little more reward than credit from its users. I think blah made a great contribution, and I would suggest that its only right to respect his wishes.

EDIT: My recent project VisualCube was released under the terms of the LGPL open source license. It allows derived works, as long as the derived source is also LGPL and the original author is given credit. I chose LGPL because I don't mind any software using VisualCube as a _library_ not being open-source (only derived works must be).

@blah, I think for your purposes you should look at the QPL license. Its like GPL, but prevents any derived works, and only allows modifications in the form of patches to the original source. See:

 http://www.opensource.org/licenses/qtpl.php
 http://en.wikipedia.org/wiki/Q_Public_License
 http://developer.kde.org/documentation/licensing/licenses_summary.html


----------



## Edward (Nov 17, 2009)

Or, since you obviously know JavaScript or whatever code your using, create your OWN source from scratch. Don't be afraid of a little hard work.


----------



## blah (Nov 17, 2009)

I am only upset at the thread title ("my" JavaScript Timer) and at the fact that K073 did not inform me of this whatsoever. I would've gladly given him permission if he'd only asked. What pissed me off even more was his completely remorseless attitude even after Johannes and Edward pointed out what was wrong with what he was doing.

@Edward: Sure he could rewrite the whole code and make the whole thing his project. But the fact is, he stole my ideas. There are so many original features unique to my timer alone (the speed/BLD toggle, the keyboard-controlled design, the nifty shortcuts like escape/backspace/delete, the parity/PLL annotation, the memo:exec ratio calculator, etc.) Rewriting the code for these features is easy, in fact, I'm pretty sure anyone can do a better job than I did in terms of code optimization and simplicity; it's the ideas that were stolen - that's intellectual property.

@Conrad: I wish I knew more about all these different kinds of licenses. But honestly, I don't mind anyone doing anything to improve my project, *as long as they've asked me about it*. I really liked your idea of making it a collaborative project because I do realize my inadequacy as a coder, but unfortunately, none of us could devote enough time to make it happen.


----------



## K073 (Nov 18, 2009)

eastamazonantidote said:


> That aside, I like the timer. Just, the 7x7x7 picture covers part of the scramble. May wanna fix that.


do you know you can drag the scramble preview?

@blah: sorry for all the problems, and not informing you. But, at first I thought of modifying your timer because it has many functions that I don't want, then I started to add the functions that I want and make it to be compact. Soon, I upload it so that I can access it anywhere, and now I'm just sharing with others.


----------



## blah (Nov 18, 2009)

K073 said:


> @blah: sorry for all the problems, and not informing you. But, at first I thought of modifying your timer because it has many functions that I don't want, then I started to add the functions that I want and make it to be compact. Soon, I upload it so that I can access it anywhere, and now I'm just sharing with others.


You just don't get it do you?


----------



## K073 (Nov 18, 2009)

I got it. But what I meant was, I didn't intend to release to public when I was modifying it.


----------



## blah (Nov 18, 2009)

I give up.


----------



## Edward (Nov 18, 2009)

I think the point is, you have no right to modify anything about it without his permission, no matter if your releasing it or not.


----------



## K073 (Nov 18, 2009)

sorry, but isn't modifying allowed? I always see people modifying other's softwares and programs on the web


----------



## Edward (Nov 18, 2009)

After this I give up too.

Maybe this will shed some light. I could be wrong though.


----------



## K073 (Nov 18, 2009)

I read part of it and I just know it has something to do with economics and profit gaining, but I did not benefit from the act of modifying a timer(except the fact that I can now use a timer with functions that I want and need).


----------



## mazei (Nov 18, 2009)

K073, to put it in simple terms.

You stole his work. Although its open source, he'd would like it if you had asked permission to tweak the program first. And after tweaking it a little, you call it your timer even though the whole idea of the timer, the features on it, was all blah's idea. All you did was add on things like scramble picture and a few other stuff. Although you gave some credit to him, it still doesn't solve the problem that you practically stole his work.

There's more but I can't think of it since I'm hungry. Someone else finish this, and please make is clear and simple, don't use bombastic words or beautiful literature, just put out the points.


----------



## K073 (Nov 18, 2009)

ok, never mind. Blah, it's your call, I can delete the timer from the web if you want. I'm ok with that, but I'll still be using my version.

@mazei: I did not just tweak it a little, it has lots of changes and functions added and removed, like full screen, scramble preview, new hot keys, spacebar status, full statistics etc. I'd always like black backgrounds so the timers look similar is just because of what I like and prefer.


----------



## Edward (Nov 18, 2009)

K073 said:


> ok, never mind. Blah, it's your call, I can delete the timer from the web if you want. I'm ok with that, but I'll still be using my version.
> 
> @mazei: I did not just tweak it a little, it has lots of changes and functions added and removed, like full screen, scramble preview, new hot keys, spacebar status, full statistics etc. I'd always like black backgrounds so the timers look similar is just because of what I like and prefer.



With what he just said, I suggest everyone just give up.


----------



## blah (Nov 18, 2009)

I'll take your girlfriend, give her a facelift, have her get a boob job done, and then I'll use her.

But you know what? It's perfectly okay, because now it's my version of your girlfriend, so that means I'm not using your girlfriend.


----------



## joey (Nov 18, 2009)

LOLpost.

(but it's okay I think.. cos you should have cloned his gf first :/)


----------



## Johannes91 (Nov 18, 2009)

blah said:


> I'll take your girlfriend, give her a facelift, have her get a boob job done, and then I'll use her.
> 
> But you know what? It's perfectly okay, because now it's my version of your girlfriend, so that means I'm not using your girlfriend.


Just remember to give credit and mention that she was his girlfriend originally.


----------



## blah (Nov 18, 2009)

Johannes91 said:


> blah said:
> 
> 
> > I'll take your girlfriend, give her a facelift, have her get a boob job done, and then I'll use her.
> ...


Ohyeahyourerightmybad.


----------



## Me (Nov 18, 2009)

Edward said:


> Another one? So many timers.



So what? Competition is good. 



mazei said:


> K073, to put it in simple terms. You stole his work.



Theft is not, K073 please do what's right here.


----------



## K073 (Nov 19, 2009)

unfortunately, for you, I don't have a gf now.


----------



## Edward (Nov 19, 2009)

K073 said:


> unfortunately, for you, I don't have a gf now.



:fp:fp:fp:fp


----------



## Nukoca (Nov 25, 2009)

K073 said:


> ok, never mind. Blah, it's your call, I can delete the timer from the web if you want. I'm ok with that, but I'll still be using my
> version.



Why is the timer still on the web?

It's Blah timer, and he told you to take it down and delete it. INCLUDING the copy on your computer. It's HIS intellectual property, and what you have done is ILLEGAL.


----------

