Skip navigation.

miscoded

the web is a hack

extending the web is hard

, , ,

The Prototype library defines a .replace() method on any element that replaces the contents of that element. The WebForms 2 spec defines a .replace attribute on INPUT type=submit that can be set to replace="values" to make a form submit not replace the entire document but simply update the form contents. You can't give two different things the same name. So if you use Prototype and call someInput.replace() your script will stop with an error in Opera because we support WebForms2 and "replace" is a property and not a method.

The wonderful flexibility of ECMAScript / JavaScript lets script authors define nearly anything and everything just about anywhere in the environment. That's why extending JavaScript is getting so complicated - anything we add to specifications and in browsers risks conflicting with something that an author already added somewhere. ES4 plans to come to the rescue with namespaces but until we get there we'll keep stumbling into problems when we try to improve the web. HTML5, you're overdue and welcome - but proceed with caution..

Employees anonymous are recruitment stars

There is a new recruitment video posted both on the desktopteam blog and on YouTube. I notice the comments and feedback are rather mixed. Some commenters think the video is trying too hard to be cool.

I think the main point of the video is easy to miss. The main point is that those people on the screen are genuine employees, not some PR agency cast. They probably came up with those words to describe Opera all by themselves too (knowing some of them I don't think it was scripted.)

Why is that point easy to miss? Because all of them except Håkon are anonymous. The video does not actually tell a casual watcher that these people work for Opera Software!

So the problem with the video is not that it fails to communicate "cool". The problem is that it fails to communicate "genuine". Simply due to the omission of people's names and titles. Someone please tell HR that "employees anonymous" isn't a group the target audience wants to join...

BTW, funny that one of YouTube's "related links" was Royal Opera House recruitment video - which does pretty much the same thing but pulls it off.. :smile:

You should consider joining Opera of course :smile:

nice stack, Firebug

, ,

One of the nice UI features of Firebug is that it goes to great lengths to give functions a recognisable description.

Sometimes it even goes too far... :

Firebug stack

:smile: p: :smile:

Script formatter user JS

, ,

The web is full of scripts that are "compressed" with all whitespace removed to make them download faster. Such scripts are hard to debug..

Here is a small user JavaScript which re-formats script source code to make those "compressed" files simpler to debug with Opera Dragonfly

Download User Javascript..

Note: this script is converted from PHP in a quick and messy way - apologies for any PHPisms, and for the variables that are still prefixed with a dollar sign. I've been using it for a while but I still find bugs and scripts that the formatter can not handle, so be prepared that there may still be some work to do.. Let's call it an alpha release :smile:

Dragonfly arriving

,

Dragonfly blog has details and download links. dev.opera.com has technical details and tutorials.

Now, this is an alpha release. Some issues you may have to overlook gracefully include:

  • If you enable breaking on every script, the debugger will also break when Opera runs browser.js or user scripts - but no code will appear in the code pane! You will have to click "run" one or more times to get past your user scripts.
  • It only responds every second time you press [F10].. :frown:
  • Live CSS editing is missing..
  • ..and so is HTTP logging and some other nice features that will arrive later.


That said, Dragonfly is already making itself useful in its present form. Have fun with it!

new spec for old key events

, ,

I've just tried to help the Web-API WG specify the "DOM0" key events. We badly need a spec here, one that documents the current implementations and finds a reasonable and web-compatible compromise where they differ.

Below is the whole text I sent to the public-webapi list. Comments are welcome both here and on public-webapi.

The text below refers to a table of virtual key codes. This table can be viewed here:
http://spreadsheets.google.com/pub?key=p32PJW4aXyuBDbcEUj4dmaw

INTRODUCTION
The specification of key events describes processing of input from keyboard devices. Key events rely on hardware support and DOM applications should not assume that any specific keys will be available, meaning they should be designed so that no information or command can be accessed only through generating a key event.

On many operating system, the system will handle character mappings but on devices where such mappings are not available an implementation may include its own conversion tables and for example decide to send ENTER key events with key code 13 if a joystick-type control in a mobile phone UI is pressed down.

Key input normally has a default action, e.g. inserting text. The default action of a key depends on what sort of element has focus, for example if focus is in a TEXTAREA the default action of the ENTER key is to insert a line break. If focus is on a link, the default action for ENTER usually is to follow the link. What the default action for a certain key is can not be determined from an event listener. The default action can be prevented by calling the event.preventDefault() method or returning false from an event handler, but implementations MAY make this configurable and let the user specify either globally or on a per-key basis that event listeners are not allowed to override the defaults.

INPUT METHOD EDITORS
Input method editors or IMEs are frequently used to type for example Chinese, Japanese and Korean characters. An active IME captures all keypresses and processes them to determine what character the user wants to insert.

Depending on the IME and its settings, most keys will either initiate, contribute to or finish the conversion process. For example, with the standard Microsoft Japanese IME active in Hiragana mode, pressing the "K" key will start a conversion process. Pressing "U" will contribute to it and the IME will show the Hiragana "ku" character. Pressing Enter will complete the conversion and insert the character into the document.

In this specification, the expression "input used for IME character creation" means input the IME is processing to transform into the actual output character(s). The expression "IME character insertion" means the insertion that occurs when the IME is done and the user confirms the generated characters to insert them into the text.

Note that IMEs can also insert text without any key events occurring at all, e.g. with handwriting recognition or on-screen keyboards.

KEY TYPES
Some key types defined by ranges of Microsoft Windows virtual key codes:
  • Alphanumerical keys: all keys with key codes in the ranges 48-57 and 65-90.
  • Function keys: keys with key code in range 112 - 135
  • Dead keys: keys that are used to add accents to the next key that is typed. One example is an U+00A8 DIARESIS key. On many keyboard layouts, dead keys are in the OEM range and their placement and key codes vary by keyboard layout. It is not possible to specify virtual key codes for them and the implementation must query the system whether the key that was pressed was a dead key or not.
  • Navigation keys: keys with key code in range 33 - 40 (arrows, Home/End, page navigation)


RELATIONSHIP BETWEEN EVENT TYPES

There are two types of key events:
  • Hardware reference events. The keydown and keyup events report that a key was pressed down and released. These events include keyboard reference information but do not confirm what character(s) if any will be inserted. Keyboard reference codes are hardware-, software-, locale- and system-dependent, but implementations should map as many keys as possible to virtual key codes as defined below.
  • Text insertion events. The keypress and textInput events include complete information about the character the input is generating, if any, taking into account shift states, previous dead keys and other contextual information required to decide what character will be inserted by a key press. The textInput event also shows what character(s) were generated by an active input method editor. The keypress event MUST NOT fire when an IME is processing the input for conversion.


All keys except dead keys fire the hardware reference events. What other events are fired depends on the type of key that is pressed and response from the event listeners. Typically, alphanumerical keys and punctuation keys fire text insertion events while control keys and navigation keys do not. Dead keys may fire text insertion events if pressed twice or followed by a space. The first time a dead key is pressed fires no events at all.

KEY CODE CALCULCATION FOR HARDWARE REFERENCE EVENTS
The key code for keydown / keyup events is calculated as follows:
  1. If input is a numerical character (0-9), return the ASCII code of the character.
  2. If input is a lower case character (not limited to English a-z), return the ASCII code of the upper case equivalent. [TODO#1]
  3. Look up key code in table of Microsoft Windows virtual key codes, return it if found. [NOTE#2]
  4. Read virtual key code from system if possible. [TODO#2]
  5. If no key code was found, return 0.


PROCESSING OF KEYPRESS EVENTS

When a key is pressed, and the keydown event has been processed an implementation must behave as if it implemented this algorithm when firing keypress events:

  1. If the keypress follows a keydown event on the same key and the earlier keydown event had its default action cancelled, terminate this algorithm. [NOTE#1]
  2. If the input is key input used for IME character creation, terminate this algorithm. [TODO#3]
  3. If the key does not cause text input and is not the Escape key (i.e. if the key is not is an alphanumerical key, a punctuation key, a repeated press of a dead key or the Escape key), terminate this algorithm.
  4. Set event meta key properties (shiftKey, ctrlKey, altKey, metaKey) depending on what meta keys are pressed, if any
  5. For backwards compatibility reasons the character code property has two different names. Define charCode and keyCode, set both to the decimal value of the unicode reference number of the corresponding character.
  6. Fire the event. If it was not cancelled with event.preventDefault() proceed to fire a textInput event.
  7. If the same keystroke inserts several characters, fire one keypress event for each
  8. If the key is held down, repeatedly fire one keydown event and one or more keypress events at a rate determined by the system's repeat key interval setting



NOTE#1: follow Firefox or IE on what to do if keydown's preventDefault() was called? Test results:
  • IE, Safari: fire keydown, keyup. No text insertion. (Above text standardises this)
  • Firefox: fires keydown, keypress (does not insert text), keyup (and apparently web content relies on this)
  • Opera: ignores preventDefault() on keydown, does not insert text if preventDefault() is called on keypress


NOTE#2: Microsoft virtual key codes attached as spreadsheet (Open Office format). Since step 1 and 2 of this algorithm handle alphanumerical keys, this step will mainly deal with punctuation characters. Their placements and virtual key codes vary greatly between keyboard layouts on Windows. The reason key codes for punctuation characters are so weird in a typical MSIE implementation are that they are usually placed on the keys Microsoft defines as "OEM keys". These are numbered OEM 1 - OEM 7 (with another OEM_102 on some layouts) plus OEM_COMMA, OEM_PERIOD, OEM_PLUS and OEM_MINUS.

However, different keyboard layouts change what OEM reference a certain key has! So the letter "ø" on a Norwegian keyboard is considered an OEM_3 key (code 192) but on EN-US layout the very same key is called OEM_1 and has code 186. Thus, even striking the *very same* key gives different virtual key codes on different keyboard layouts. Neither are those virtual key codes mapped to actual input: typing the *very same* character on different keyboard layouts can produce different key codes because these keys are associated with different "OEM" keys under the hood.

OEM_COMMA, OEM_PERIOD, OEM_PLUS, OEM_MINUS are obviously meant to map to the corresponding punctuation on most keyboards, but even this is not consistently applied. For example, on a Norwegian keyboard layout the + character is on the OEM_PLUS key and returns the virtual key code 187 but on the Icelandic layout + is on the OEM_2 key and returns its virtual key code 191.

There is no really consistent way to figure out how this should work for any OS and device. The assignment of keys to virtual key codes in Microsoft's OEM range is too chaotic to emulate, and not useful to authors. The way forward would be to specify explicit keyCode/charCode values for the following keys that never change with keyboard layouts:
  • Backspace
  • Tab
  • Caps Lock
  • Shift
  • Control
  • Alt
  • Enter

And those punctuation characters that are *meant* to not change virtual codes between keyboard layouts:
  • Period (.)
  • Comma (,)
  • Plus (+)
  • Minus (-)
  • Decimal key (on numpad)
  • Space

Then leave other punctuation characters implementation dependent and inform script authors that they should listen to keypress or textInput events to reliably detect those.

TODO#1: note that IE does NOT take the upper-case value of certain non-English character (for example ø/Ø on Norwegian keyboards). I believe doing so makes the model cleaner and is unlikely to cause compatibility problems - this needs investigation though. Here we also probably need to specify some specific algorithm for upper/lower-casing characters?

TODO#2: Step 4 of this algorithm is incomplete, probably needs to specify how to get a virtual key from system? The issue step 4 is trying to solve is: If a given key, say the I key is mapped to something else, say "Hiragana I" keydown/keyup will still have the key code of an upper-case I in reference implementations but not according to this algorithm without some magic in step 4. Hence we need to fall back to reading virtual key codes from the system in step 4, but how to do this exactly is underspecified and will probably vary between operating systems.

TODO#3: If the IME is NOT in the middle of a conversion, keys that do not initiate a conversion in that IME (such as ESC and Enter) *do* fire keypress events. Is the text clear enough?

TODO: dead keys pressed twice fire two keypress events. Dead keys followed by space fire keydown space, keypress for the dead key's accent, keyup space (!). Dead keys are currently a bit underspecified in the above text.


USEFUL LINKS ON WINDOWS KEY HANDLING
http://www.microsoft.com/globaldev/handson/dev/inputinwin.mspx
http://www.woodmann.com/fravia/sources/WINUSER.H
http://tonesnotes.com/blog/2003/03/keycodes_defined_in_winuserh.html
http://www.microsoft.com/globaldev/tools/msklc.mspx

hot and lively

, , ,

Once upon a time, there was only one important free mail service. When I left Oslo University to go to London and knew I was going to loose my student address, this was where I went to get a new mailbox. And even a couple of years later, when I started working for Opera, bugs affecting Hotmail were top-top-top priority. (Opera 7.51's bug 143675, "Opera deletes random messages from my Hotmail inbox" remains one of the scariest bugs I've analysed. Few bugs match that one in obvious and devastating violation of the user's trust.)

Well, how times have changed... A quick search of bugs filed for the respective services since GMail launched shows that there are roughly 3 times more GMail-bugs than Hotmail bugs in the bug tracker since 2004. Apparently, GMail's popularity has skyrocketed while Hotmail's has dropped, right?

Not so fast. Sometimes I see lists of E-mail addresses wherever random people register for newsletters or sign up for something in a reception. Technical people who tend to use Opera more frequently may lean heavily towards GMail, but among the general population Hotmail / Windows Live Mail is still a giant.

This is why I'm very glad to say that it should now be possible to use Hotmail's AJAXy interface with Opera 9.2x and 9.5. It's thanks to a sophisticated browser.js patch from David Bloom and an extra "spoof as Firefox" setting. If you're a Hotmail user, let me know how it works for you!

it's so nice to say ... goodbye!

Let's keep this short and to the point: I have to leave Opera QA because of increasing allergy to IFRAMEs. My doctor says it's a new condition that is under-diagnosed in the web developer community, but a growing problem.

We all know that IFRAMEs have infected the web, at ever increasing speed since a certain announcement four years ago, and today I can hardly find a single bug to work on that won't give me allergic reactions.

So, goodbye. I plan to become a natural scientist to study spiders, just because I'm still sort of attached to that "Web" thing. Au revoir.