Class PramukhIME

PramukhIME is the highly customizable javascript class required for enabling PramukhIME for any HTML element like textbox, textarea, iframe or div. This class requires keyboard plugin in order to type in the language supported by that keyboard plugin. Using 4 lines of code you can enable any Webpage to have Pramukh IME on it.

<html>
<head>
<script type="text/javascript" src="js/pramukhime.js"></script>
<script type="text/javascript" src="js/pramukhindic.js"></script>

</head>
<body>
<input type="text" id="first_name">
<script language="javascript" type="text/javascript">
pramukhIME.addLanguage(PramukhIndic,"hindi");
pramukhIME.enable();

</script>
</body>
</html>
Features

Class Summary
Constructor Attributes Constructor Name and Description
 
Method Summary
Method Attributes Method Name and Description
 
addLanguage(KeyboardPlugin, DefaultLanguage, SupportedLanguages)
This function adds language plugin.
 
convert(InputString, FromLanguage, ToLanguage)
This function converts the text from one language to another.
 
disable(ElementName)
Disables Pramukh IME from single HTML element or whole Web page.
 
enable(ElementName, ElementObject, ExceptionList, DefaultEvent)
Enables PramukhIME on a specified HTML element or a page.
 
This function gets a list of all supported Unicode characters.
 
This function gets the conversion language name
 
getEventObject(ElementName, DefaultEventObject)
Depending on the browser and type of HTML element, this method returns the Event Object.
 
This function gets a list of example words of the selected language and/or keyboard layout.
 
Gets the detailed help file name of the currently selected language.
 
Gets the help image file name of the selected language and keyboard.
 
getIcon(icon)
Gets the requested icon file name of the currently selected language.
 
getLanguage(ElementName)
Gets the currently set language/keyboard name.
 
Gets the shortcut key
 
onKeydown(ElementName, Evt)
Manually assign the keydown event of HTML element.
 
onKeypress(ElementName, Evt)
Manually execute this function on the keypress event of HTML element.
 
onLanguageChange(cbName, context, remove)
Using this method, any one can subscribe to "onLanguageChange" event whenever the language is changed.
 
rectify(InputString)
This function rectifies the input string by replacing wrong combination of letters with correct one.
 
removeLanguage(LanguageName, KeyboardName)
Removes the language plugin.
 
setLanguage(LanguageName, KeyboardName)
Sets new language so now user will start typing in the provided language using provided keyboard layout.
 
setToggleKey(Key, Ctrl, Alt)
Sets the shortcut key to switch between selected language and English.
Class Detail
PramukhIME()
Method Detail
{Object} addLanguage(KeyboardPlugin, DefaultLanguage, SupportedLanguages)
This function adds language plugin. If the SupportedLanguages parameter is not provided, all the languages supported by the plugin will be added. If the SupportedLanguages is provided, only supported language from the SupportedLanguages will be activated. The developer can remove the added language, by using the function PramukhIME#removeLanguage.
Parameters:
{Object/Function/String} KeyboardPlugin
It can be an Object / Function/ Function Name which will be initialized as an object.
{String} DefaultLanguage
(Optional) Once the KeyboardPlugin is added, immediately this language will be set. If it is null, currently selected language will be unaffected.
{String Array} SupportedLanguages
(Optional) Array of language names. This list can be partial list of what KeyboardPlugin can support.
Returns:
{Object} KeyboardPlugin object

convert(InputString, FromLanguage, ToLanguage)
This function converts the text from one language to another. Keyboard developer defines which language to be converted to/from. List of supported conversion languages can be found from PramukhIME#getConversionLanguage All the characters which does not belong to the selected language will be output as it is.
Parameters:
{String} InputString
Unicode/English string
{String} FromLanguage
It is the language name from which we want to convert InputString
{String} ToLanguage
It is the language name to which we want to convert InputString
Returns:
Equivalent of the input string. Checkout keyboard developer documentation for further information.

disable(ElementName)
Disables Pramukh IME from single HTML element or whole Web page. This method cleans up memory and removes event handlers associated with element if the event handlers are automatically assigned. If you have manually assigned event handler's, you should manually remove it.
Parameters:
{String} ElementName
(Optional) Element's name for which you want to disable PramukhIME. If the element name is not specified, it will disable the PramukhIME from the whole page.

{String} enable(ElementName, ElementObject, ExceptionList, DefaultEvent)
Enables PramukhIME on a specified HTML element or a page. Using this method, you can enable PramukhIME for an element one by one by providing values in first two arguments. If you want to enable PramukhIME on all textbox and textareas, call this function without passing any argument. In the example at the very top, you may write third line as
pramukhIME.enable('first_name'); OR
pramukhIME.enable('My_custom_name',document.getElementById('first_name')); OR
pramukhIME.enable('My_custom_name',document.getElementById('first_name'),null,true);

If you want to assign events manually, you may want to code like this
pramukhIME.enable('My_custom_name',document.getElementById('first_name'),null,false);
if (Internet Explorer)
{
document.getElementById('first_name').onkeypress = function (e) { pramukhIME.onKeypress('My_custom_name',e);}
document.getElementById('first_name').onkeydown = function (e) { pramukhIME.onKeydown('My_custom_name',e);}
}
else
{
document.getElementById('first_name').addEventListener("keypress",function (e) { pramukhIME.onKeypress('My_custom_name',e);}, true);
document.getElementById('first_name').addEventListener("keydown",function (e) { pramukhIME.onKeydown('My_name',e);}, true);
}
Parameters:
{String} ElementName
(Optional) Element's name. You may pass element id/string of your choice/null(random name starting with "pramukhime_" will be generated). If ElementObject is not provided, ElementObject is assumed to be existing in DOM with id as ElementName
{Object} ElementObject
(Optional) Element's actual object. You can get this object by executing document.getElementById('ElementID')
{String} ExceptionList
(Optional) Comma separated list of ids for which you don't want to enable PramukhIME
{Boolean} DefaultEvent
(Optional) If True, library will itself attach the keypress and keydown event to element represented by ElementName or ElementObject. If False, developer has to manually handle keypress and keydown event and call PramukhIME#onKeypress and PramukhIME#onKeydown methods with necessary arguments
Throws:
General Exception if ElementObject is not specified and ElementName does not represents id of any element in DOM.
Returns:
{String} ElementName If the ElementName is not provided in the argument, it will provide the id of ElementObject or internally created element name

getChars()
This function gets a list of all supported Unicode characters. This function will in turn call the selected keyboard layout plugin's getChars() function.
Returns:
Array of supported Unicode characters of the selected keyboard language as a String

{Object} getConversionLanguage()
This function gets the conversion language name
Returns:
{Object} Object.language is the conversion language name as a string, Object.preferredFont is the font name to be used for showing the text and Object.reverseConversionSupported is a boolean value indicating if the exact reverse conversion of text is supported.

getEventObject(ElementName, DefaultEventObject)
Depending on the browser and type of HTML element, this method returns the Event Object. If you are passing the last parameter value as "true" in the method PramukhIME#enable, you must not use this method unless you know what you are doing.
Parameters:
{String} ElementName
Element's name
{Event} DefaultEventObject
Default event object resulting from a keyboard event
Returns:
Actual event object

getExamples()
This function gets a list of example words of the selected language and/or keyboard layout.
Returns:
Array of Unicode words of the selected keyboard layout as a String

getHelp()
Gets the detailed help file name of the currently selected language. This is an HTML page.
Returns:
detailed help html file name

getHelpImage()
Gets the help image file name of the selected language and keyboard.
Returns:
help image file name

{Object} getIcon(icon)
Gets the requested icon file name of the currently selected language.
Parameters:
{Integer} icon
1 = Language Icon, 2 = Language Conversion Icon, 3 = Language Click Icon, 4 = Language Help Icon, 5 = Script Conversion Icon, 6 = Reserved 1, 7= Reserved 2
Returns:
{Object} Object.iconFile is the icon file name, Object.x is the x position of the icon from left, Object.y is the y position of the icon from the top.

getLanguage(ElementName)
Gets the currently set language/keyboard name.
Parameters:
{String} ElementName
Element's name whose current language you want to get
Returns:
Object with Object.language is a lower cased name of the language and Object.keyboard is a lower cased name of the keyboard.

getToggleKey()
Gets the shortcut key
Returns:
Object with Object.code is the key, Object.ctrl is a boolean indicating control key press required or not and Object.alt is a boolean indicating alt key press is required or not

onKeydown(ElementName, Evt)
Manually assign the keydown event of HTML element. This is useful when element is subscribed to the event. If you are passing the last parameter value as "true" in the method PramukhIME#enable, you must not use this method unless you know what you are doing.
Parameters:
{String} ElementName
Element's name
{Event} Evt
Event object
Returns:
True/False for further bublling the event

onKeypress(ElementName, Evt)
Manually execute this function on the keypress event of HTML element. This is useful when element is subscribed to the event. If you are passing the last parameter value as "true" in the method PramukhIME#enable, you must not use this method unless you know what you are doing.
Parameters:
{String} ElementName
Element's name
{Event} Evt
Event object
Returns:
True/False for further bublling the event

onLanguageChange(cbName, context, remove)
Using this method, any one can subscribe to "onLanguageChange" event whenever the language is changed. This method is also used to remove subscription by providing third parameter as "true".
Parameters:
{Function} cbName
Callback method. This function should accept three params. 1) Language Name, 2) Keyboard Name, 3) Context
{String} context
context string. It will be passed to the callback method as it is.
{Boolean} remove
If true, subscriber will be removed from language change notification, otherwise, it will be added.
Throws:
GeneralException if callback method is not a valid method
See:
#setToggleKey

rectify(InputString)
This function rectifies the input string by replacing wrong combination of letters with correct one.
Parameters:
{String} InputString
an input string containing the letters of currently selected language
Returns:
rectified string

removeLanguage(LanguageName, KeyboardName)
Removes the language plugin. In order to successfully remove the Keyboard layout of a particular language, it must have been added by calling PramukhIME#addLanguage
Parameters:
{String} LanguageName
Language name to remove
{String} KeyboardName
Keyboard name to remove

setLanguage(LanguageName, KeyboardName)
Sets new language so now user will start typing in the provided language using provided keyboard layout. Before setting any custom language/keyboard layout, it must be added using PramukhIME#addLanguage
Parameters:
{String} LanguageName
New language name. It must be one of the supported/added language name otherwise it will set to English.
{String} KeyboardName
Name of the keyboard layout

setToggleKey(Key, Ctrl, Alt)
Sets the shortcut key to switch between selected language and English. Default value for toggle key is 120 (F9 key). If the user is typing in a text box(or any PramukhIME enabled HTML element) and presses F12 key, user can immediately start typing in English. Press F9 key to again type in previously selected language. To completely turn off switching between selected language and English, pass 0 as parameter.
Parameters:
{int} Key
Key Code in KeyDown event.
{Boolean} Ctrl
Hold down Control key for switching between English and selected language?
{Boolean} Alt
Hold down Alt key for switching between English and selected language?

Documentation generated by JsDoc Toolkit 2.4.0