├── img ├── bg.png ├── logo.png ├── button.jpg └── buttonHover.jpg ├── README.md ├── license.txt ├── css └── unicode.css ├── js └── unicode.js └── index.html /img/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ankitpokhrel/unicode.js/master/img/bg.png -------------------------------------------------------------------------------- /img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ankitpokhrel/unicode.js/master/img/logo.png -------------------------------------------------------------------------------- /img/button.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ankitpokhrel/unicode.js/master/img/button.jpg -------------------------------------------------------------------------------- /img/buttonHover.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ankitpokhrel/unicode.js/master/img/buttonHover.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > THIS PACKAGE IS DEPRECATED AND IS NOT MAINTAINED ANYMORE. 2 | 3 | ## unicode.js 4 | 5 | A small javascript library to enable native input support in textfields. 6 | 7 | ### Usage 8 | Adding *class="unicode"* and *lang="language"* to normal input textfields and textarea will allow user to type directly in a specified language. It uses google transliteration lib for unicode purpose. So *"language"* can be the languages supported by google transliteration library. 9 | ```html 10 | 11 | 12 | ``` 13 | 14 | The above code will allow the user to type directly in **Nepali** and **Russian** language. 15 | -------------------------------------------------------------------------------- /license.txt: -------------------------------------------------------------------------------- 1 | Copyright 2012 (c) Ankit Pokhrel 2 | http://ankitpokhrel.com.np 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, ublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | The above copyright notice and this permission notice shall be included in all copies or ubstantial portions of the Software. 5 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, NCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /css/unicode.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | } 5 | 6 | body{ 7 | background: #fff url(../img/bg.png) repeat; 8 | font-family: arial; 9 | color: #eee; 10 | } 11 | 12 | h2{ 13 | font-size: 18px; 14 | margin-top: 20px; 15 | } 16 | 17 | p{ 18 | padding: 10px 0; 19 | text-align: justify; 20 | } 21 | 22 | label{ 23 | color: #FFF; 24 | font-weight: bold; 25 | margin-left: 10px; 26 | text-shadow: 0 1px 0 #000; 27 | } 28 | 29 | #container{ 30 | width: 800px; 31 | margin: 20px auto; 32 | } 33 | 34 | .outerWrapper{ 35 | margin-top: 30px; 36 | padding: 5px; 37 | background: rgba(0, 0, 0, 0.5); 38 | } 39 | 40 | .innerWrapper{ 41 | border: 2px solid #666; 42 | padding: 10px; 43 | } 44 | 45 | input[type=text], input[type=submit], select, textarea{ 46 | padding: 10px; 47 | width: 450px; 48 | border: 1px solid #ccc; 49 | margin: 10px 10px; 50 | margin-bottom: 30px; 51 | } 52 | 53 | select{ 54 | width: 150px; 55 | } 56 | 57 | input[type=submit], .linkButton{ 58 | width: 100px; 59 | border-radius: 5px; 60 | box-shadow: 1px 0px 2px 0 #222; 61 | background: url(../img/button.jpg) repeat-x; 62 | } 63 | 64 | input[type=submit]:hover, .linkButton:hover{ 65 | background: url(../img/buttonHover.jpg) repeat-x; 66 | cursor: pointer; 67 | } 68 | 69 | .linkButton{ 70 | padding: 10px; 71 | font-size: 14px; 72 | } 73 | 74 | a.linkButton{ 75 | text-decoration: none; 76 | color: #222; 77 | } 78 | 79 | .htmlCode{ 80 | background: none repeat scroll 0 0 #999999; 81 | border: 1px solid #CCCCCC; 82 | color: #222222; 83 | font-family: courier new; 84 | padding: 5px; 85 | text-align: left; 86 | font-size: 14px; 87 | font-weight: bold; 88 | margin: 10px 0; 89 | } 90 | 91 | .highlight{ 92 | font-style: italic; 93 | font-weight: bold; 94 | font-size: 12px; 95 | } 96 | 97 | #copyright{ 98 | margin: 20px 0; 99 | text-align: center; 100 | color: #222; 101 | font-size: 12px; 102 | } 103 | 104 | .heading{ 105 | position: relative; 106 | top: 30px; 107 | color: #000; 108 | } -------------------------------------------------------------------------------- /js/unicode.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * @Lib Unicode.js 4 | * @Author Ankit Pokhrel 5 | * @Version 0.0 6 | * 7 | */ 8 | 9 | //Load google transliteration package 10 | google.load("elements", "1", {packages: "transliteration"}); 11 | 12 | //Find all elements with class unicode and make it transliterable 13 | ;function init(){ 14 | var fields = document.getElementsByClassName('unicode'); // returns nodelist, cannot use foreach loop in nodelist so 15 | 16 | var forEach = Array.prototype.forEach; // extending foreach prototype, works in almost all browsers 17 | 18 | forEach.call(fields, function(elm){ 19 | var id = elm.getAttribute('id'); 20 | if(null == id){ 21 | id = GUID(); 22 | elm.setAttribute('id', id); 23 | } 24 | 25 | var lang = elm.getAttribute('lang'); 26 | if(null == lang) lang = "ne"; 27 | 28 | var options = { 29 | sourceLanguage: 30 | google.elements.transliteration.LanguageCode.ENGLISH, 31 | destinationLanguage: lang, 32 | shortcutKey: 'ctrl+l', 33 | transliterationEnabled: true 34 | }; 35 | 36 | var control = new google.elements.transliteration.TransliterationControl(options); 37 | control.makeTransliteratable([id]); 38 | }); 39 | } 40 | 41 | //Change from one language to another 42 | var mcontrol = null; 43 | ;function changeLanguage(id, lang){ 44 | if( null == mcontrol ){ 45 | var options = { 46 | sourceLanguage: 47 | google.elements.transliteration.LanguageCode.ENGLISH, 48 | destinationLanguage: lang, 49 | shortcutKey: 'ctrl+l', 50 | transliterationEnabled: true 51 | }; 52 | mcontrol = new google.elements.transliteration.TransliterationControl(options); 53 | mcontrol.makeTransliteratable([id]); 54 | } else { 55 | mcontrol.setLanguagePair( google.elements.transliteration.LanguageCode.ENGLISH, lang); 56 | } 57 | } 58 | 59 | //function GUID credit - John Millikin, http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript 60 | //Create a globally unique identifier. Used in the elements with no Id. 61 | ;function GUID (){ 62 | var S4 = function (){ 63 | return Math.floor( 64 | Math.random() * 0x10000 /* 65536 */ 65 | ).toString(16); 66 | }; 67 | 68 | return ( 69 | S4() + S4() + "-" + 70 | S4() + "-" + 71 | S4() + "-" + 72 | S4() + "-" + 73 | S4() + S4() + S4() 74 | ); 75 | } 76 | 77 | google.setOnLoadCallback(init); -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
26 |
30 | 34 | A small and easy to use javascript library to enable native input support in textfields. It uses Google Transliteration API 35 | combined with some javascript to enable unicode support in text input fields and textareas or anything where user can type in. 36 |
37 |38 | This library is currently version 0.0 and is released under MIT license. Therefore, you are free to modify and use this library under 39 | the license terms provided by MIT. By using this library you accept the license agreement. 40 |
41 |43 | Every input text field is created using <input type="text"/>. By default these text fields only accept 44 | english characters. So if the website is in language other than english, the users still have to type in english in sections like comment box, 45 | feedback box or search inputs. 46 |
47 |48 | unicode.js tries to solve this problem to some extent. The developer can create normal text fields with two new attributes class="unicode" 49 | and lang="supported language". With this minimal change the user can now type using the unicode of the specified language. Here supported 50 | language is the prefix of the language supported by this library. As it uses Google Transliteration API, the supported language is also 51 | the languages supported by this API. 52 |
53 |1. Include required libraries to your page.
122 |2. Now create normal text fields or text areas with two new attributes class="unicode" and lang="your language".
128 |
136 | 1. Support for 24 languages only.
137 | 2. Google Transliteration API is declared deprecated in 2011 and is live under its deprecation policy.
138 | 3. Google translate is powerful but paid API so will try to find some alternatives in future enhancements.
139 |