Javascript Thaana Keyboard version 4.1

I released Javascript Thaana Keyboard v4.0 only 10 days ago but I've since been made aware of a few bugs in the script that had gone unnoticed during testing back then. I decided to cut another release to fix those bugs which, although minor, could potentially be annoying to end-users. This new release also crams in a few tweaks to improve performance.

Changelog:

+ Fixed handling of Delete key and other special keys
+ Added correct handling for Thaana brackets "()"
+ Improved performance

Usage:

Usage remains same as before, so please refer to my post on the 4.0 release.

Demo:

Check out the demonstration and testing page here.

Download:

- full source version (10.6 KB)
- packed version (2.46 KB) [recommended]

Update (19-Dec-2008): This version is now superseded by release v4.2.

Congratulations Anni! Bye bye Gayyoom

The preliminary election results seem to indicate a comfortable win for Mr. Mohamed Nasheed (Anni) in the first ever multi-party democratic elections in the Maldives. This, of course, means that we would soon have a new person taking hold of the helm of the country after 30 long years of iron-fist rule by the same person. And like almost all people I know, I too feel quite excited at the prospect of real change and improvement - in so many different aspects of Maldivian life - actually seeing daylight sometime soon. Congratulations to Anni and I wish him and his party, as well as the coalition and the rest of us Maldivians, the very best in struggle ahead.

Here is something I had made about 2 years ago to symbolize the demolition of the dictatorship of Mr. Maumoon Abdul Gayoom. It was born of boredom and was designed for use in MSN/Live Messenger as an animated emoticon so feel free to send it to your friends. To add it to Messenger, right-click on the image below, select the option to save the image to your computer and then use the emoticon add facility in Messenger to load it in.



PS: There are a few more Maumoon emoticons available here.

Vote trip

I set off to London to vote after finishing off the day at university today. Thanks to Reading being only a jump from London my trip to the polling station took a only little over an hour long, despite having to travel by foot -> bus -> train -> Underground -> foot to get there. Anyway, I decided to capture the trip...

















I am voting for change

Thanks to the recent arrangements to have a polling station here in the UK, I too now have the opportunity to have my say in the Maldivian Presidential Elections - for the very first time in my life. And for me, deciding on who to vote for in this round is a very very trivial matter - I am voting for change.

As a matter of fact, I've known I would not vote for Gayyoom ever since the two years I spent working at the President's Office (PO) six years ago. Being fresh out of school, much of the environment at PO - the cult-like demands for "loyalty" and regular "office meetings" where employees are made to sing songs praising the man (with lyrics written specifically for the occasion) - came on as a total shocker to me. By the time I left PO, having witnessed the various practices and policies enforced and encouraged, I was totally disillusioned by Gayyoom and Maldivian politics.

I am voting for change because I want to see an end to the growing national debt, care-free spending and wasteful expenditures and because I can't bear to see the growing disparity between the rich and the poor, the elite and the unprivileged and Male' and the atolls. I am voting for change because I've had it with the gangs, the drugs and the violence and because I want everyone to be able to live in peace with the rule of law upheld. I am voting for change because I believe in democratic values and because I support a free press. I am voting for change because I question the sincerity and the competence of Gayyoom to do these things and because 30 years of rule is 20 years longer than I can accept.

I am voting for change because I staunchly champion the celebration of diversity - of people and their thought - which I believe this country desperately needs and which I believe the Watah Edhey Gothah coalition represents. There, ofcourse, is no guarantee that this "change" will be any better but I'd rather give them the benefit of the doubt...

Javascript Thaana Keyboard version 4.0

Here is an update to my Javascript Thaana Keyboard (JTK). This 4.0 release packs in a bunch of new features, making JTK much more powerful and more flexible than any of the earlier releases.

Keyboard support:

Most notable on this new release is the introduction of support for the various different types of Thaana keyboard in use. JTK now supports the following keyboard layouts:

Phonetic (Segha version): This keyboard is perhaps the most popular Thaana keyboard layout. JTK identifies this keyboard as "phonetic".

Phonetic (Hassan Hameed version): This keyboard is similar to above but notably differs in its mapping of alifu, abafili, aabaafili, gaafu and the sukun. JTK identifies this keyboard as 'phonetic-hh'.

Typewriter: This is the standardized Thaana layout used on typewriters. JTK identifies this keyboard as 'typewriter'.

Browser support:

JTK 4.0 adds support for IE5.5, which has a very significant market share still. Hence JTK should now work perfectly well on Microsoft Internet Explorer 5.5+, Mozilla Firefox 1+, Opera 9+, Apple Safari 2+ and Google Chrome 0.1+.

Basic usage:

The basic usage allows for fast and easy integration of JTK on your Thaana web pages.

1. Link the file in the HEAD section of the page:

2. For any element accepting input (i.e. INPUTs, TEXTAREAs, content-editable DIVs), assign them the special class name "thaanaKeyboardInput". JTK will automatically handle text entry to any element with that class name. You can assign further classes to the elements without ill-effect, if needed.

3. There are two ways to set the keyboard used for an element.
defaultKeyboard method: This method allows setting a default keyboard to be used on all elements handled by JTK. To do this, add the following to the HEAD section of your web page but make sure it is added after the code inserted from step 1 above.

thaanaKeyboardState method: This method allows per element control on the type of keyboard used by an element handled by JTK. To do this, add a form element (can be a radio, checkbox, select, hidden or text field) with its name set to the text entry element id suffixed with the string "_thaanaKeyboardState". The value of these fields should specify either 'off', 'phonetic', 'phonetic-hh' or 'typewriter', indicating the status and the keyboard in use.

So, if you had a text entry field with the id "fullname" then the keyboard could be specified using a hidden field as follows:



4. Make sure that the text direction for the Thaana fields is set to "rtl". This can be easily achieved using CSS, by adding a class definition for the "thaanaKeyboardInput" class or by any other method of your choice. Adding the following to your CSS definition should suffice for most uses:
.thaanaKeyboardInput {
    font-family: faruma, 'mv iyyu nala', 'mv elaaf normal';
    direction: rtl;
}

If the above instructions are followed correctly, the JTK Thaana functionality would be in effect soon as the page has loaded!

Advanced Usage: The JTK object, methods and properties

To facilitate advanced integration functionality for developers looking to have (finer) control over its behavior, JTK now makes itself available as a public object named "thaanaKeyboard".

The following properties and methods exposed by the "thaanaKeyboard" object:

defaultKeyboard: [property] The Thaana keyboard layout type to default to when JTK enabled elements do not have a keyboard specified.
Valid values are: 'off' to keep Thaana disabled, 'phonetic' to use the standard phonetic layout, 'phonetic-hh' to use the phonetic layout by Dr. Hassan Hameed and 'typewriter' to use the typewriter layout.

setHandlerById ( id, action ): [method] Sets the state of the JTK handler for a page element.
The id argument should be a string containing the id of any content-editable element. The action argument should specify either "enable" or "disable" depending on whether input handling for Thaana should be enabled or disabled, respectively.

setHandlerByClass ( class, action ): [method] Sets the state of the JTK handler for a set of page elements.
The class argument should be a string containing the class name of any content-editable element (i.e input, textarea etc). The action argument should specify either "enable" or "disable" depending on whether input handling for Thaana should be enabled or disabled, respectively.

License:

JTK 4.0 is released under the MIT License, allowing its use in both personal and commercial applications as long as the copyright and license permission notice remains intact.

Demo:

Check out the demonstration and testing page here.

Download:

- original full source version (10.0 KB)
- packed version (2.33 KB) [recommended]

As always, drop a line here if you use it and/or have problems or suggestions. Enjoy. :-)

Update (31-Oct-2008): This version is now superseded by release v4.1.

MySQL and Unicode Thaana

Anyone developing custom code for a Thaana application or website will undoubtedly run into many interesting challenges and issues. Judging by how often I get emails asking for help with getting MySQL to play nice when using Unicode Thaana, I'd say it's one of the very first issues many (newbie?) web developers face.

Here are some of the basics that one should keep in mind when attempting to use Unicode Thaana and MySQL.

Charset
It is very important that the correct character set be used when using Unicode Thaana for MySQL to correctly recognize the text. If you are going nuts over your code returning "???" or junk characters after trying to store Thaana text into a MySQL database, then it most certainly is because of an incorrect charset being used.

I recommend issuing the following SQL commands upon successfully establishing a connection with the MySQL server.
SET NAMES utf8;
SET CHARACTER SET utf8;

Read up the MySQL reference page on connection charsets and collations for more details.

Collation
MySQL does not have special language specific collation rules for Thaana - and there is no need for such far as I am aware. I recommend using the "utf8_unicode_ci" collation when creating tables and fields in MySQL.

Refer to the MySQL reference page Unicode character sets for more details.

Happy databasing :-)

Dhiraagu e-Directory data for download (2008-10-06)

Here is the data from Dhiraagu e-Directory that I had mentioned in my previous post "Phone usage (Maumoon, Political Parties, Government and Businesses)". The data was acquired yesterday and contains all of 338,371 entries (made up of 305,198 mobile numbers, 24423 landline numbers and 8750 island/resort numbers) that was listed on the e-Directory service. It is interesting to note that the total entries now is 114,018 more than the March 2007 data I published earlier. This increase comes from an almost doubling of mobile numbers registered (the March 2007 showed 194,025 mobile numbers)!

Anyway, here's the data. As before, it's presented as a Tab-Separated Values (a.k.a CSV) format file racking up 16.8MB uncompressed. I've Zipped down the file to 5.1MB for easier downloading. The file can be opened in Excel, OpenOffice or imported into Access or any other database.

- Download edirectory-2008-10-06.zip

Enjoy!