Main Page » Blog-Like Typing Detected »

2010/04/21: Mad Science

Created: / Modified:

Always use secure-HTTP / Unsecure HTTP / Permanent Link

A friend of mine suggested that I develop code which allows you to navigate through the comic using the left and right arrow keys. I also decided to make it so ctrl+left sends you back to the beginning, and ctrl+right sends you to the latest comic. Now, I'm not fluent in Javascript, but I already know how to handle keypresses in it, and I'm good at stealing existing code, so I examined the site he gave me which already used it.

Hmm. Potential problem: my irrepressible lust for cross-platform compatibility requires for various reasons that I not use inline scripts, but instead point it at an external file. The problem was that the site he gave me used entirely inline Javascript, and on top of that, it uses generated-per-page code to determine what the next page is, so this problem was likely to be a tough nut to crack, short of making a single file for each individual page — wait.

Wait.

What if I were to make a PHP file, have it send a "Whoops, actually, this is a Javascript file!" message to any browser that tries to load it, and generate the Javascript based on arguments supplied by the global code about what page you're currently on?

Ahahahahaha. AHAHAHAHAHAHA. I AM A GENIUS!!

So, yeah, with much effort and the usual bugging-things-up I do whenever I code, and some testing from friends who have IE, Firefox, Chrome, and Opera between them, I got the code tested and finished, entirely for his benefit. I presume the testers were all using halfway-recent versions (I always keep Firefox and IE up-to-date), but yeah. There'll also be a little message with instructions appearing next to the format-options, which will only appear if you have Javascript enabled. So yeah.

EDIT: Okay, it was causing problems when people were using the arrow keys when typing comments. I've set it up so that if you click on any of the fields in the comment-boxes, it automatically disables it, and clicking out of it reenables it. This only works after the page has fully loaded, including images. If that doesn't work properly, ctrl+shift+T toggles it. If it still doesn't seem to work, clear your cache.

7 Comments (auto-closed) (rss feed)

Dizzy H. Slightly Voided

Oh yeah, I've also been doing some backend work that have resulted in some major changes, none of which anyone who doesn't have access to the code will ever notice |3

sRc

KM! You can't do that! It will create a time paradox!

anyway thats pretty cool. never thought of doing something like that.

Young Demon Lord

Bug report: When trying to comment on TH:Neko109, Left arrow key was still sending me back to #108, even when the text box had the focus. It took me three tries to work past my own habits so I could submit the comment.

Ubuntu 9.04, Firefox 3.6.3.

Dizzy H. Slightly Voided

/ Modified by Dizzy H. Slightly Voided:

Ah, whoops, I ought to look into that ...

EDIT: Dang, this is tough. There's a whole lot of ways it isn't working, or is working wrong. The problem is figuring out 1. how to get it to figure out that you're focused on one of the comment-buttons, and 2. figuring out that you've clicked off the comment-buttons.

EDITEDIT: Okay, see above!

Young Demon Lord

o hai, I upgraded my Ubuntu. 10.04, and the left/right bug is still here. Just sayin'. But I'm sure you knew this.

Dizzy H. Slightly Voided

Is this happening after everything fully loads?