Moment.js Dhivehi locale merged

The ever so useful and powerful Javascript Date library moment.js merged my Dhivehi locale pull request in the 2.11.0 release. Sure to be handy when developing Dhivehi websites!

moment.js 2.11.0 release changelog

Integrating JTK with tinyMCE 4.x

Integrating my Javascript Thaana Keyboard library to handle Thaana entry within tinyMCE for a full-featured rich-text Thaana editor is very straightforward. You just need the following config in the tinyMCE initialization.

setup: function (editor) {
      editor.on('keypress', function (e) {
          thaanaKeyboard.value = '';
          thaanaKeyboard.handleKey(e);
          editor.insertContent(thaanaKeyboard.value);
      });
}


Enjoy!


ZOHO Viewer plugin for jQuery

I discovered ZOHO Viewer, which supports a lot more file types than Google Docs Viewer, after I wrote the Google Docs Viewer jQuery plugin I posted earlier. So, I wrote another jQuery plugin that automatically embeds the ZOHO viewer for viewing the doc, docx, xls, xlsx, ppt, pptx, pps, odt, ods, odp, sxw, sxc, sxi, wpd, pdf, rtf, txt, html, csv, tsv files it supports linked to by anchor tags.

The ZOHO Viewer is an embeddable browser-based viewer that requires only a URL to a file available online. This, just like Google Docs Viewer, bypasses the need for users to have compatible software on their machines for those file types and displays the document right in the browser.

Both plugins work exactly the same and has the same configuration options. I ended up going back to Google Docs Viewer for the application I was developing because it displays the document zoomed in to fit the width of the viewer by default and has a toolbar to help navigate the document unlike ZOHO viewer. However, because ZOHO Viewer supports a much large range of file types it is still likely to become very handy.

Usage


1. Add jQuery and the zohoViewer plugin to the page.
<head>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.zohoviewer.min.js"></script>
</head>

2. Set some class name or id to the anchor tag for all URLs to files that you want to be displayed using the ZOHO Viewer. E.g. "embed"
<a href="urltofile.pdf" class="embed">Download file</a>
<a href="urltofile.pdf" id="embedURL">Download file</a>

3. Initialize zohoViewer and set it to process the URL with id or all URLs with the class name set in the previous step.
$('a.embed').zohoViewer();
$('#embedURL').zohoViewer();

Customization


The plugin offers two configuration options that set the width and height of the embedded document IFRAME. This can be set when the plugin is initialized.
$('a.embed').zohoViewer({ width: 400, height: 500 });

The plugin inserts a the IFRAME for the viewer inside an injected DIV. The DIV tags all carry the class name "zohoviewer", which allow for styling all the zohoViewer instances via CSS. If the anchor tag has the ID attribute defined, then the injected DIV tag is also set an ID attribute in the format of ID_of_Anchor + '-zohoviewer'. See the demo source code for more details.

Demo


- Check out the live demonstration

License

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

Download

- jquery.zohoviewer.v1.0.zip (v1.0, 2.2KB)

Enjoy!

Google Docs Viewer plugin for jQuery

Here's a little jQuery plugin I wrote recently that automatically embeds the Google Docs Viewer for viewing pdf, doc, docx, ppt and tiff files linked to by anchor tags.

The Google Docs Viewer is an embeddable browser-based viewer that requires only a URL to a file available online. This neatly bypasses the need for users to have compatible software on their machines for those file types and displays the document right in the browser.

Usage


1. Add jQuery and the gDocsViewer plugin to the page.
<head>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.gdocsviewer.min.js"></script>
</head>

2. Set some class name or id to the anchor tag for all URLs to files that you want to be displayed using the Google Docs Viewer. E.g. "embed"
<a href="urltofile.pdf" class="embed">Download file</a>
<a href="urltofile.pdf" id="embedURL">Download file</a>

3. Initialize gDocsViewer and set it to process the URL with id or all URLs with the class name set in the previous step.
$('a.embed').gdocsViewer();
$('#embedURL').gdocsViewer();

Customization


The plugin offers two configuration options that set the width and height of the embedded document IFRAME. This can be set when the plugin is initialized.
$('a.embed').gdocsViewer({ width: 400, height: 500 });

The plugin inserts a the IFRAME for the viewer inside an injected DIV. The DIV tags all carry the class name "gdocsviewer", which allow for styling all the gdocsViewer instances via CSS. If the anchor tag has the ID attribute defined, then the injected DIV tag is also set an ID attribute in the format of ID_of_Anchor + '-gdocsviewer'. See the demo source code for more details.

Demo


- Check out the live demonstration

License

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

Download

- jquery.gdocsviewer.v1.0.zip (v1.0, 2.2KB)

Enjoy!

Page to Unicode Thaana 1.0

Here's a nifty little tool I made a few years ago that automatically and intelligently picks out the bits of text that use a non-Unicode Thaana font on any web page and converts it to Unicode. That probably doesn't make much sense to most of you but read on - there's a section for general web users and one for developers.

General users


Take the website of Haveeru Daily as an example. It uses a now-archaic method of displaying Thaana. Browsers cannot and will not substitute an alternative workable font if your computer does not have the exact Thaana fonts it requires and will display as non-sensical English text. But then take Miadhu Daily, which relies on something called Unicode. Browsers can and will load up the site perfectly readable as long as you have any one of the many Unicode Thaana fonts on your system. And in many situations, like at public libraries or on some phones and devices like the Kindle, Unicode-based Thaana web pages will load up just fine as there usually is some Thaana-supporting Unicode font on it while those that use the more archaic method will fail.

I came across this problem a few years ago while at the university lab one day and there was some interesting events taking place in the Maldives which I wanted to read about. Haveeru had the most news articles and was the most up-to-date but I couldn't read any of it as the Thaana fonts were not on the system and I was not allowed to install the fonts. So I wrote some quick code, specifically a bookmarklet, that converted the text on the site on-the-fly to use Unicode.

Anyway, if you find yourself in a similar situation, here is what you could do. Right click the PUT bookmarklet link below and choose to bookmark the link. When on a page, just click the PUT bookmark and the page should convert to Unicode and display Thaana.

Page to Unicode Thaana bookmarklet v1.0

Demo

Haveeru before


Haveeru after


Developers


Here's a slightly different version of the above script that can be used on web pages that do not use Unicode Thaana to offer the pages in Unicode without requiring any change to the content management system, editor etc that you have in place already. Add the script to your non-Unicode Thaana based web pages where appropriate and your visitors will get a Unicode-based web page as long they have Javascript enabled.

Usage
I would recommend that it be added towards the end of your page HTML, right before the closing BODY tag.



Download:
- put-1.0.min.js (minified, for production use)
- put-1.0.js (full source)

Enjoy :-)

Javascript Thaana Keyboard version 4.2.1

Here's an update to my Javascript Thaana Keyboard library which provides easy entry of Thaana on web pages without the involvement of OS-based keyboard switching. Hit the demo page to see it in action.

This release is solely a bugfix release addressing an issue with the display of newly entered text in multiline fields where text exceeds the size of the visible area. I originally cut this release in February but decided to hold back on a public release till I had further issues to fix or had new features added, neither of which has come since...

Thanks goes to Ahmed Ali for bringing the bug to my attention.

Changelog

+ Fixed issue with the display of newly entered text in multiline fields where text exceeds the size of the visible area.

Usage

Usage remains same as before. Please refer to my detailed post on the 4.0 release.

Demo

As usual, a demonstration and testing page is available.

Download

- full source version (5.66 KB)
- packed version (2.47 KB) [recommended]

Javascript Thaana Keyboard version 4.2

Here's a minor update to my Javascript Thaana Keyboard library. This release, version 4.2, amounts to a single bugfix addressing an error in key translation for some keys when operating under the "Phonetic-HH" keyboard mode. Everything else remains as per the earlier v4 series releases.

Thanks goes to Nattu for bringing the bug to my attention.

Changelog:

+ Fixed handling of keys when in Phonetic-HH keyboard mode

Usage:

Usage remains same as before. Please refer to my detailed post on the 4.0 release.

Demo:

Check out the demonstration and testing page here.

Download:

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

Update (13-Apr-2009): This version is now superseded by release v4.2.1.