function getSelectionOffset(el) { var keys = { 'selectionStart' : '__DSselectionStart' ,'selectionEnd' : '__DSselectionEnd' }; var offsetCalculator = null; var range; if ('function' == typeof el.setSelectionRange) { if (!offsetCalculator) { offsetCalculator = document.createElement('td'); document.body.appendChild(offsetCalculator); } if (offsetCalculator[keys.prevCalcNode] != el) { offsetCalculator[keys.prevCalcNode] = el; var cs = document.defaultView.getComputedStyle(el, null); for (var i in cs) { try {if (cs[i]) offsetCalculator.style[i] = cs[i];}catch(e){} } offsetCalculator.style.overflow = 'auto'; offsetCalculator.style.position = 'absolute'; offsetCalculator.style.visibility = 'hidden'; offsetCalculator.style.zIndex = '-10'; offsetCalculator.style.left="-10000px"; offsetCalculator.style.top="-10000px"; offsetCalculator.style.backgroundColor = 'yellow'; } var range = document.createRange() ,val = el.value || " "; if ('input'==el.tagName.toLowerCase()) { offsetCalculator.style.width = 'auto'; offsetCalculator.style.whiteSpace = 'nowrap'; } else { offsetCalculator.style.whiteSpace = 'off'==el.getAttribute('wrap')?"pre":""; } val = val.replace(/\x20\x20/g,"\x20\xa0"); offsetCalculator.innerHTML = ( val.substr(0,el.selectionStart)+"<span></span>" +val.substr(el.selectionStart)).replace(/\n/g,"<br />") .replace(/\t/g,"<em style=\"white-space:pre\">\t</em>"); var span = offsetCalculator.getElementsByTagName('span')[0]; span.style.borderLeft = '1px solid red'; range.offsetLeft = span.offsetLeft - el.scrollLeft; range.offsetTop = span.offsetTop - el.scrollTop; range.offsetHeight = span.offsetHeight; span = null; } else if (document.selection && document.selection.createRange) { range = document.selection.createRange(); range.offsetHeight = Math.round(range.boundingHeight/(range.text.replace(/[^\n]/g,"").length+1)); if (el.tagName && 'textarea'==el.tagName.toLowerCase()) { var xy = DOM.getOffset(el); range = { 'offsetTop' : range.offsetTop-xy.y ,'offsetLeft' : range.offsetLeft-xy.x ,'offsetHeight' : range.offsetHeight }; } } if (range) { return {'x': range.offsetLeft, 'y': range.offsetTop, 'h': range.offsetHeight}; } return {'x': 0, 'y': 0, 'h': 0}; } function editor_defaultConfig(objname,styleSheet) { this.version = "2.03"; this.width = "auto"; this.height = "auto"; this.bodyStyle = 'background-color: #FFFFFF; font-family: "Verdana"; font-size: x-medium;'; this.imgURL = _editor_url + 'images/'; this.debug = 0; this.replaceNextlines = 0; this.plaintextInput = 0; this.toolbar = [ ['fontname'], ['fontsize'], ['bold','italic','underline','separator'], ['justifyleft','justifycenter','justifyright','separator'], ['OrderedList','UnOrderedList','Outdent','Indent','separator'], ['HorizontalRule','Createlink']]; this.fontnames = { "Arial": "arial, helvetica, sans-serif", "Courier New": "courier new, courier, mono", "Georgia": "Georgia, Times New Roman, Times, Serif", "Tahoma": "Tahoma, Arial, Helvetica, sans-serif", "Times New Roman": "times new roman, times, serif", "Verdana": "Verdana, Arial, Helvetica, sans-serif", "impact": "impact", "WingDings": "WingDings"}; this.fontsizes = { "1 (8 pt)": "1", "2 (10 pt)": "2", "3 (12 pt)": "3", "4 (14 pt)": "4", "5 (18 pt)": "5", "6 (24 pt)": "6", "7 (36 pt)": "7" }; this.stylesheet = styleSheet + "/IFrame.css"; this.fontstyles = [ ]; this.btnList = { "bold": ['Bold', 'Bold', 'editor_action(this.id)', 'ed_format_bold.gif'], "italic": ['Italic', 'Italic', 'editor_action(this.id)', 'ed_format_italic.gif'], "underline": ['Underline', 'Underline', 'editor_action(this.id)', 'ed_format_underline.gif'], "strikethrough": ['StrikeThrough', 'Strikethrough', 'editor_action(this.id)', 'ed_format_strike.gif'], "subscript": ['SubScript', 'Subscript', 'editor_action(this.id)', 'ed_format_sub.gif'], "superscript": ['SuperScript', 'Superscript', 'editor_action(this.id)', 'ed_format_sup.gif'], "justifyleft": ['JustifyLeft', 'Justify Left', 'editor_action(this.id)', 'ed_align_left.gif'], "justifycenter": ['JustifyCenter', 'Justify Center', 'editor_action(this.id)', 'ed_align_center.gif'], "justifyright": ['JustifyRight', 'Justify Right', 'editor_action(this.id)', 'ed_align_right.gif'], "orderedlist": ['InsertOrderedList', 'Ordered List', 'editor_action(this.id)', 'ed_list_num.gif'], "unorderedlist": ['InsertUnorderedList', 'Bulleted List', 'editor_action(this.id)', 'ed_list_bullet.gif'], "outdent": ['Outdent', 'Decrease Indent', 'editor_action(this.id)', 'ed_indent_less.gif'], "indent": ['Indent', 'Increase Indent', 'editor_action(this.id)', 'ed_indent_more.gif'], "forecolor": ['ForeColor', 'Font Color', 'editor_action(this.id)', 'ed_color_fg.gif'], "backcolor": ['BackColor', 'Background Color', 'editor_action(this.id)', 'ed_color_bg.gif'], "horizontalrule": ['InsertHorizontalRule', 'Horizontal Rule', 'editor_action(this.id)', 'ed_hr.gif'], "createlink": ['CreateLink', 'Insert Web Link', 'editor_action(this.id)', 'ed_link.gif'], "insertimage": ['InsertImage', 'Insert Image', 'editor_action(this.id)', 'ed_image.gif'], "inserttable": ['InsertTable', 'Insert Table', 'editor_action(this.id)', 'insert_table.gif'], "htmlmode": ['HtmlMode', 'View HTML Source', 'editor_setmode(\''+objname+'\')', 'ed_html.gif'], "popupeditor": ['popupeditor', 'Enlarge Editor', 'editor_action(this.id)', 'fullscreen_maximize.gif'], "about": ['about', 'About this editor', 'editor_about(\''+objname+'\')', 'ed_about.gif'], "custom1": ['custom1', 'Purpose of button 1', 'editor_action(this.id)', 'ed_custom.gif'], "custom2": ['custom2', 'Purpose of button 2', 'editor_action(this.id)', 'ed_custom.gif'], "custom3": ['custom3', 'Purpose of button 3', 'editor_action(this.id)', 'ed_custom.gif'], "help": ['showhelp', 'Help using editor', 'editor_action(this.id)', 'ed_help.gif']}; } function editor_generate(configIndica,userConfig) { var objname = configIndica.textArea; var config = new editor_defaultConfig(objname,configIndica.styleSheet); if (userConfig) { for (var thisName in userConfig) { if (userConfig[thisName]) { config[thisName] = userConfig[thisName]; } } } document.all[objname].config = config; var obj = document.all[objname]; if (!config.width || config.width == "auto") { if (obj.style.width) { config.width = obj.style.width; } else if (obj.cols) { config.width = (obj.cols * 8) + 22; } else { config.width = '100%'; } } if (!config.height || config.height == "auto") { if (obj.style.height) { config.height = obj.style.height; } else if (obj.rows) { config.height = obj.rows * 22 } else { config.height = '200'; } } var tblOpen = '<table border=0 cellspacing=0 cellpadding=0 style="float: left;" unselectable="on"><tr><td style="border: none; padding: 1 0 0 0"><nobr>'; var tblClose = '</nobr></td></tr></table>\n'; var toolbar = ''; var btnGroup, btnItem, aboutEditor; for (var btnGroup in config.toolbar) { if (config.toolbar[btnGroup].length == 1 && config.toolbar[btnGroup][0].toLowerCase() == "linebreak") { toolbar += '<br clear="all">'; continue; } toolbar += tblOpen; for (var btnItem in config.toolbar[btnGroup]) { var btnName = config.toolbar[btnGroup][btnItem].toLowerCase(); if (btnName == "fontname") { toolbar += '<select id="_' +objname+ '_FontName" onChange="editor_action(this.id)" unselectable="on" style="margin: 1 2 0 2; font-size: 12px;">'; for (var fontname in config.fontnames) { toolbar += '<option value="' +config.fontnames[fontname]+ '">' +fontname+ '</option>'; } toolbar += '</select>'; continue; } if (btnName == "fontsize") { toolbar += '<select id="_' +objname+ '_FontSize" onChange="editor_action(this.id)" unselectable="on" style="margin: 1 2 0 0; font-size: 12px;">'; for (var fontsize in config.fontsizes) { toolbar += '<option value="' +config.fontsizes[fontsize]+ '">' +fontsize+ '</option>'; } toolbar += '</select>\n'; continue; } if (btnName == "fontstyle") { toolbar += '<select id="_' +objname+ '_FontStyle" onChange="editor_action(this.id)" unselectable="on" style="margin: 1 2 0 0; font-size: 12px;">'; + '<option value="">Font Style</option>'; for (var i in config.fontstyles) { var fontstyle = config.fontstyles[i]; toolbar += '<option value="' +fontstyle.className+ '">' +fontstyle.name+ '</option>'; } toolbar += '</select>'; continue; } if (btnName == "separator") { toolbar += '<span style="border: 1px inset; width: 1px; font-size: 16px; height: 16px; margin: 0 3 0 3"></span>'; continue; } var btnObj = config.btnList[btnName]; if (btnName == 'linebreak') { alert("htmlArea error: 'linebreak' must be in a subgroup by itself, not with other buttons.\n\nhtmlArea wysiwyg editor not created."); return; } if (!btnObj) { alert("htmlArea error: button '" +btnName+ "' not found in button list when creating the wysiwyg editor for '"+objname+"'.\nPlease make sure you entered the button name correctly.\n\nhtmlArea wysiwyg editor not created."); return; } var btnCmdID = btnObj[0]; var btnTitle = btnObj[1]; var btnOnClick = btnObj[2]; var btnImage = btnObj[3]; toolbar += '<button title="' +btnTitle+ '" id="_' +objname+ '_' +btnCmdID+ '" class="btn" onClick="' +btnOnClick+ '" onmouseover="if(this.className==\'btn\'){this.className=\'btnOver\'}" onmouseout="if(this.className==\'btnOver\'){this.className=\'btn\'}" unselectable="on"><img src="' +config.imgURL + btnImage+ '" border=0 unselectable="on"></button>'; } toolbar += tblClose; } if (configIndica.editorRequired == true) var editor = '<span id="_editor_toolbar"><table border=0 cellspacing=0 cellpadding=0 bgcolor="buttonface" style="padding: 1 0 0 2" width=' + config.width + ' unselectable="on"><tr><td>\n' + toolbar + '</td></tr></table></span>\n' + '<textarea ID="_' +objname + '_editor" style="width:' +config.width+ '; height:' +config.height+ '; margin-top: -1px; margin-bottom: -1px;" wrap=soft></textarea>'; else var editor = '<span id="_editor_toolbar"><table border=0 cellspacing=0 cellpadding=0 bgcolor="buttonface" style="padding: 1 0 0 2" width=' + config.width + ' unselectable="on"><tr><td>\n' + '</td></tr></table></span>\n' + '<textarea ID="_' +objname + '_editor" style="width:' +config.width+ '; height:' +config.height+ '; margin-top: -1px; margin-bottom: -1px;" wrap=soft></textarea>'; editor += '<div id="_' +objname + '_cMenu" style="position: absolute; visibility: hidden;"></div>'; if (!config.debug) { document.all[objname].style.display = "none"; } if (config.plaintextInput) { var contents = document.all[objname].value; contents = contents.replace(/\r\n/g, '<br>'); contents = contents.replace(/\n/g, '<br>'); contents = contents.replace(/\r/g, '<br>'); document.all[objname].value = contents; } document.all[objname].insertAdjacentHTML('afterEnd', editor); editor_setmode(objname, 'init'); document.all[objname].translit = new Translit(configIndica); for (var idx=0; idx < document.forms.length; idx++) { var r = document.forms[idx].attachEvent('onsubmit', function() { editor_filterOutput(objname); }); if (!r) { alert("Error attaching event to form!"); } } return true; } function editor_action(button_id) { var BtnParts = Array(); BtnParts = button_id.split("_"); var objname = button_id.replace(/^_(.*)_[^_]*$/, '$1'); var cmdID = BtnParts[ BtnParts.length-1 ]; var button_obj = document.all[button_id]; var editor_obj = document.all["_" +objname + "_editor"]; var config = document.all[objname].config; if (cmdID == 'showhelp') { window.open(_editor_url + "popups/editor_help.html", 'EditorHelp'); return; } if (cmdID == 'popupeditor') { window.open(_editor_url + "popups/fullscreen.html?"+objname, 'FullScreen', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=640,height=480'); return; } if (editor_obj.tagName.toLowerCase() == 'textarea') { return; } var editdoc = editor_obj.contentWindow.document; editor_focus(editor_obj); var idx = button_obj.selectedIndex; var val = (idx != null) ? button_obj[ idx ].value : null; if (0) {} else if (cmdID == 'custom1') { alert("Hello, I am custom button 1!"); } else if (cmdID == 'custom2') { var myTitle = "This is a custom title"; var myText = showModalDialog(_editor_url + "popups/custom2.html", myTitle, "resizable: yes; help: no; status: no; scroll: no; "); if (myText) { editor_insertHTML(objname, myText); } } else if (cmdID == 'custom3') { editor_insertHTML(objname, "It's easy to add buttons that insert text!"); } else if (cmdID == 'FontName' && val) { editdoc.execCommand(cmdID,0,val); } else if (cmdID == 'FontSize' && val) { editdoc.execCommand(cmdID,0,val); } else if (cmdID == 'FontStyle' && val) { editdoc.execCommand('RemoveFormat'); editdoc.execCommand('FontName',0,'636c6173734e616d6520706c616365686f6c646572'); var fontArray = editdoc.all.tags("FONT"); for (i=0; i<fontArray.length; i++) { if (fontArray[i].face == '636c6173734e616d6520706c616365686f6c646572') { fontArray[i].face = ""; fontArray[i].className = val; fontArray[i].outerHTML = fontArray[i].outerHTML.replace(/face=['"]+/, ""); } } button_obj.selectedIndex =0; } else if (cmdID == 'ForeColor' || cmdID == 'BackColor') { var oldcolor = _dec_to_rgb(editdoc.queryCommandValue(cmdID)); var newcolor = showModalDialog(_editor_url + "popups/select_color.html", oldcolor, "resizable: no; help: no; status: no; scroll: no;"); if (newcolor != null) { editdoc.execCommand(cmdID, false, "#"+newcolor); } } else { if (cmdID.toLowerCase() == 'subscript' && editdoc.queryCommandState('superscript')) { editdoc.execCommand('superscript'); } if (cmdID.toLowerCase() == 'superscript' && editdoc.queryCommandState('subscript')) { editdoc.execCommand('subscript'); } if (cmdID.toLowerCase() == 'createlink'){ editdoc.execCommand(cmdID,1); } else if (cmdID.toLowerCase() == 'insertimage'){ showModalDialog(_editor_url + "popups/insert_image.html", editdoc, "resizable: no; help: no; status: no; scroll: no; "); } else if (cmdID.toLowerCase() == 'inserttable'){ showModalDialog(_editor_url + "popups/insert_table.html?"+objname, window, "resizable: yes; help: no; status: no; scroll: no; "); } else { editdoc.execCommand(cmdID); } } editor_event(objname); } function editor_event(objname,runDelay) { var config = document.all[objname].config; var editor_obj = document.all["_" +objname+ "_editor"]; var translit = document.all[objname].translit; if (runDelay == null) { runDelay = 0; } var editdoc; var editEvent = editor_obj.contentWindow ? editor_obj.contentWindow.event : event; if (editEvent && editEvent.type == 'blur') { translit.HandleKeyDown(editEvent); editor_updateOutput(objname); return; } if (editEvent && (editEvent.type == 'mouseup' || editEvent.type == 'mousedown' || editEvent.type == 'contextmenu' || editEvent.type == 'paste')) { translit.HandleKeyPress(editEvent); return; } if (editEvent && editEvent.keyCode) { if (editEvent.type == 'keydown') { translit.HandleKeyDown(editEvent); return; } if ((editEvent.type == 'keypress')) { translit.HandleKeyPress(editEvent); return; } } if (runDelay > 0) { return setTimeout(function(){ editor_event(objname); }, runDelay); } if (this.tooSoon == 1 && runDelay >= 0) { this.queue = 1; return; } this.tooSoon = 1; setTimeout(function(){ this.tooSoon = 0; if (this.queue) { editor_event(objname,-1); }; this.queue = 0; }, 333); editor_updateOutput(objname); editor_updateToolbar(objname); } function editor_updateToolbar(objname,action) { var config = document.all[objname].config; var editor_obj = document.all["_" +objname+ "_editor"]; if (action == "enable" || action == "disable") { var tbItems = new Array('FontName','FontSize','FontStyle'); for (var btnName in config.btnList) { tbItems.push(config.btnList[btnName][0]); } for (var idxN in tbItems) { var cmdID = tbItems[idxN].toLowerCase(); var tbObj = document.all["_" +objname+ "_" +tbItems[idxN]]; if (cmdID == "htmlmode" || cmdID == "about" || cmdID == "showhelp" || cmdID == "popupeditor") { continue; } if (tbObj == null) { continue; } var isBtn = (tbObj.tagName.toLowerCase() == "button") ? true : false; if (action == "enable") { tbObj.disabled = false; if (isBtn) { tbObj.className = 'btn' }} if (action == "disable") { tbObj.disabled = true; if (isBtn) { tbObj.className = 'btnNA' }} } return; } if (editor_obj.tagName.toLowerCase() == 'textarea') { return; } var editdoc = editor_obj.contentWindow.document; var fontname_obj = document.all["_" +objname+ "_FontName"]; if (fontname_obj) { var fontname = editdoc.queryCommandValue('FontName'); if (fontname == null) { fontname_obj.value = null; } else { var found = 0; for (i=0; i<fontname_obj.length; i++) { if (fontname.toLowerCase() == fontname_obj[i].text.toLowerCase()) { fontname_obj.selectedIndex = i; found = 1; } } if (found != 1) { fontname_obj.value = null; } } } var fontsize_obj = document.all["_" +objname+ "_FontSize"]; if (fontsize_obj) { var fontsize = editdoc.queryCommandValue('FontSize'); if (fontsize == null) { fontsize_obj.value = null; } else { var found = 0; for (i=0; i<fontsize_obj.length; i++) { if (fontsize == fontsize_obj[i].value) { fontsize_obj.selectedIndex = i; found=1; } } if (found != 1) { fontsize_obj.value = null; } } } var classname_obj = document.all["_" +objname+ "_FontStyle"]; if (classname_obj) { var curRange = editdoc.selection.createRange(); var pElement; if (curRange.length) { pElement = curRange[0]; } else { pElement = curRange.parentElement(); } while (pElement && !pElement.className) { pElement = pElement.parentElement; } var thisClass = pElement ? pElement.className.toLowerCase() : ""; if (!thisClass && classname_obj.value) { classname_obj.value = null; } else { var found = 0; for (i=0; i<classname_obj.length; i++) { if (thisClass == classname_obj[i].value.toLowerCase()) { classname_obj.selectedIndex = i; found=1; } } if (found != 1) { classname_obj.value = null; } } } var IDList = Array('Bold','Italic','Underline','StrikeThrough','SubScript','SuperScript','JustifyLeft','JustifyCenter','JustifyRight','InsertOrderedList','InsertUnorderedList'); for (i=0; i<IDList.length; i++) { var btnObj = document.all["_" +objname+ "_" +IDList[i]]; if (btnObj == null) { continue; } var cmdActive = editdoc.queryCommandState( IDList[i] ); if (!cmdActive) { if (btnObj.className != 'btn') { btnObj.className = 'btn'; } if (btnObj.disabled != false) { btnObj.disabled = false; } } else if (cmdActive) { if (btnObj.className != 'btnDown') { btnObj.className = 'btnDown'; } if (btnObj.disabled != false) { btnObj.disabled = false; } } } } function editor_updateOutput(objname) { var config = document.all[objname].config; var editor_obj = document.all["_" +objname+ "_editor"]; var editEvent = editor_obj.contentWindow ? editor_obj.contentWindow.event : event; var isTextarea = (editor_obj.tagName.toLowerCase() == 'textarea'); var editdoc = isTextarea ? null : editor_obj.contentWindow.document; var contents; if (isTextarea) { contents = editor_obj.value; } else { contents = editdoc.body.innerHTML; } if (config.lastUpdateOutput && config.lastUpdateOutput == contents) { return; } else { config.lastUpdateOutput = contents; } contents = removeHTML(contents); document.all[objname].value = contents; } function removeHTML(str){ str = str.replace(/<span([^>])*>(&nbsp;)*\s*<\/span>/gi, ''); str = str.replace(/<span[^>]*>/gi, ''); str = str.replace(/<\/span[^>]*>/gi, ''); str = str.replace(/<p([^>])*>(&nbsp;)*\s*<\/p>/gi, ''); str = str.replace(/<p[^>]*>/gi, ''); str = str.replace(/<\/p[^>]*>/gi, ''); str = str.replace(/<h([^>])[0-9]>(&nbsp;)*\s*<\/h>/gi, ''); str = str.replace(/<h[^>][0-9]>/gi, ''); str = str.replace(/<\/h[^>][0-9]>/gi, ''); str = str.replace(/<B [^>]*>/ig, '<b>'); str = str.replace(/<DIV[^>]*>/ig, ''); str = str.replace(/<\/DIV>/gi, ''); str = str.replace(/<[\/\w?]+:[^>]*>/ig, ''); str = str.replace(/(&nbsp;){2,}/ig, ''); str = str.replace(/<STRONG>/ig, ''); str = str.replace(/<\/STRONG>/ig, ''); str = str.replace(/<TT>/ig, ''); str = str.replace(/<\/TT>/ig, ''); str = str.replace(/<FONT [^>]*>/ig, ''); str = str.replace(/<\/FONT>/ig, ''); str = str.replace(/STYLE=\"[^\"]*\"/ig, ''); str = str.replace(/<([\w]+) class=([^ |>]*)([^>]*)/gi, '<$1$3'); str = str.replace(/<([\w]+) style="([^"]*)"([^>]*)/gi, '<$1$3'); str = str.replace(/width=([^ |>]*)([^>]*)/gi, ''); str = str.replace(/classname=([^ |>]*)([^>]*)/gi, ''); str = str.replace(/align=([^ |>]*)([^>]*)/gi, ''); str = str.replace(/valign=([^ |>]*)([^>]*)/gi, ''); str = str.replace(/<\\?\??xml[^>]>/gi, ''); str = str.replace(/<\/?\w+:[^>]*>/gi, ''); str = str.replace(/<st1:.*?>/gi, ''); str = str.replace(/o:/gi, ''); str = str.replace(/<!--([^>])*>(&nbsp;)*\s*<\/-->/gi, ''); str = str.replace(/<!--[^>]*>/gi, ''); str = str.replace(/<\/--[^>]*>/gi, ''); str = str.replace(/<br>/ig, '\r\n'); str = str.replace(/&nbsp;/ig, ''); return str; } function editor_filterOutput(objname) { editor_updateOutput(objname); var contents = document.all[objname].value; var config = document.all[objname].config; if (contents.toLowerCase() == '<p>&nbsp;</p>') { contents = ""; } var filterTag = function(tagBody,tagName,tagAttr) { tagName = tagName.toLowerCase(); var closingTag = (tagBody.match(/^<\//)) ? true : false; if (tagName == 'img') { tagBody = tagBody.replace(/(src\s*=\s*.)[^*]*(\*\*\*)/, "$1$2"); } if (tagName == 'a') { tagBody = tagBody.replace(/(href\s*=\s*.)[^*]*(\*\*\*)/, "$1$2"); } return tagBody; }; RegExp.lastIndex = 0; var matchTag = /<\/?(\w+)((?:[^'">]*|'[^']*'|"[^"]*")*)>/g; contents = contents.replace(matchTag, filterTag); if (config.replaceNextlines) { contents = contents.replace(/\r\n/g, ' '); contents = contents.replace(/\n/g, ' '); contents = contents.replace(/\r/g, ' '); } document.all[objname].value = contents; } function editor_setmode(objname, mode) { var config = document.all[objname].config; var editor_obj = document.all["_" +objname + "_editor"]; if (document.readyState != 'complete') { setTimeout(function() { editor_setmode(objname,mode) }, 25); return; } var TextEdit = '<textarea ID="_' +objname + '_editor" style="width:' +editor_obj.style.width+ '; height:' +editor_obj.style.height+ '; margin-top: -1px; margin-bottom: -1px;"></textarea>'; var RichEdit = '<iframe ID="_' +objname+ '_editor" style="width:' +editor_obj.style.width+ '; height:' +editor_obj.style.height+ ';"></iframe>'; if (mode == "textedit" || editor_obj.tagName.toLowerCase() == 'iframe') { config.mode = "textedit"; var editdoc = editor_obj.contentWindow.document; var contents = editdoc.body.createTextRange().htmlText; editor_obj.outerHTML = TextEdit; editor_obj = document.all["_" +objname + "_editor"]; editor_obj.value = contents; editor_event(objname); editor_updateToolbar(objname, "disable"); editor_obj.onkeydown = function() { editor_event(objname); }; editor_obj.onkeypress = function() { editor_event(objname); }; editor_obj.onkeyup = function() { editor_event(objname); }; editdoc.onmousedown = function() { editor_event(objname); }; editor_obj.onmouseup = function() { editor_event(objname); }; editdoc.oncontextmenu = function() { editor_event(objname); }; editor_obj.ondrop = function() { editor_event(objname, 100); }; editor_obj.oncut = function() { editor_event(objname, 100); }; editor_obj.onpaste = function() { editor_event(objname, 100); }; editor_obj.onblur = function() { editor_event(objname, -1); }; editor_updateOutput(objname); editor_focus(editor_obj); } else { config.mode = "wysiwyg"; var contents = editor_obj.value; editor_obj.outerHTML = RichEdit; editor_obj = document.all["_" +objname + "_editor"]; var html = ""; html += '<html><head>\n'; if (config.stylesheet) { html += '<link href="' +config.stylesheet+ '" rel="stylesheet" type="text/css">\n'; } html += '<style>\n'; html += 'body {' +config.bodyStyle+ '} \n'; for (var i in config.fontstyles) { var fontstyle = config.fontstyles[i]; if (fontstyle.classStyle) { html += '.' +fontstyle.className+ ' {' +fontstyle.classStyle+ '}\n'; } } html += '</style>\n' + '</head>\n' + '<body class="hindi" contenteditable="true" topmargin=1 leftmargin=1' +'>' + contents + '</body>\n' + '</html>\n'; var editdoc = editor_obj.contentWindow.document; editdoc.open(); editdoc.write(html); editdoc.close(); editor_updateToolbar(objname, "enable"); editdoc.objname = objname; editdoc.onClick = function() { editor_event(objname); }; editdoc.onkeydown = function() { editor_event(objname); }; editdoc.onkeypress = function() { editor_event(objname); }; editdoc.onkeyup = function() { editor_event(objname); }; editdoc.onmousedown = function() { editor_event(objname); }; editdoc.onmouseup = function() { editor_event(objname); }; editdoc.oncontextmenu = function() { editor_event(objname); }; editdoc.body.ondrop = function() { editor_event(objname, 100); }; editdoc.body.oncut = function() { editor_event(objname, 100); }; editdoc.body.onpaste = function() { editor_event(objname, 100); }; editdoc.body.onblur = function() { editor_event(objname, -1); }; if (mode == 'init') { editor_focus(editor_obj); return; } } if (mode == 'init') { editor_event(objname); } } function editor_focus(editor_obj) { if (editor_obj.tagName.toLowerCase() == 'textarea') { var myfunc = function() { editor_obj.focus(); }; setTimeout(myfunc,100); } else { var editdoc = editor_obj.contentWindow.document; var editorRange = editdoc.body.createTextRange(); var curRange = editdoc.selection.createRange(); if (curRange.length == null && !editorRange.inRange(curRange)) { editorRange.collapse(); editorRange.select(); curRange = editorRange; } } } function editor_about(objname) { showModalDialog(_editor_url + "popups/about.html", window, "resizable: yes; help: no; status: no; scroll: no; "); } function _dec_to_rgb(value) { var hex_string = ""; for (var hexpair = 0; hexpair < 3; hexpair++) { var myByte = value & 0xFF; value >>= 8; var nybble2 = myByte & 0x0F; var nybble1 = (myByte >> 4) & 0x0F; hex_string += nybble1.toString(16); hex_string += nybble2.toString(16); } return hex_string.toUpperCase(); } function editor_insertHTML(objname, str1,str2, reqSel) { var config = document.all[objname].config; var editor_obj = document.all["_" +objname + "_editor"]; if (str1 == null) { str1 = ''; } if (str2 == null) { str2 = ''; } if (document.all[objname] && editor_obj == null) { document.all[objname].focus(); document.all[objname].value = document.all[objname].value + str1 + str2; return; } if (editor_obj == null) { return alert("Unable to insert HTML. Invalid object name '" +objname+ "'."); } editor_focus(editor_obj); var tagname = editor_obj.tagName.toLowerCase(); var sRange; if (tagname == 'iframe') { var editdoc = editor_obj.contentWindow.document; sRange = editdoc.selection.createRange(); var sHtml = sRange.htmlText; if (sRange.length) { return alert("Unable to insert HTML. Try highlighting content instead of selecting it."); } var oldHandler = window.onerror; window.onerror = function() { alert("Unable to insert HTML for current selection."); return true; }; if (sHtml.length) { if (str2) { sRange.pasteHTML(str1 +sHtml+ str2); } else { sRange.pasteHTML(str1); } } else { if (reqSel) { return alert("Unable to insert HTML. You must select something first."); } sRange.pasteHTML(str1 + str2); } window.onerror = oldHandler; } else if (tagname == 'textarea') { editor_obj.focus(); sRange = document.selection.createRange(); var sText = sRange.text; if (sText.length) { if (str2) { sRange.text = str1 +sText+ str2; } else { sRange.text = str1; } } else { if (reqSel) { return alert("Unable to insert HTML. You must select something first."); } sRange.text = str1 + str2; } } else { alert("Unable to insert HTML. Unknown object tag type '" +tagname+ "'."); } sRange.collapse(false); sRange.select(); } function editor_getHTML(objname) { var editor_obj = document.all["_" +objname + "_editor"]; var isTextarea = (editor_obj.tagName.toLowerCase() == 'textarea'); if (isTextarea) { return editor_obj.value; } else { return editor_obj.contentWindow.document.body.innerHTML; } } function editor_setHTML(objname, html) { var editor_obj = document.all["_" +objname + "_editor"]; var isTextarea = (editor_obj.tagName.toLowerCase() == 'textarea'); if (isTextarea) { editor_obj.value = html; } else { editor_obj.contentWindow.document.body.innerHTML = html; } } function editor_appendHTML(objname, html) { var editor_obj = document.all["_" +objname + "_editor"]; var isTextarea = (editor_obj.tagName.toLowerCase() == 'textarea'); if (isTextarea) { editor_obj.value += html; } else { editor_obj.contentWindow.document.body.innerHTML += html; } } function _isMouseOver(obj,event) { var mouseX = event.clientX; var mouseY = event.clientY; var objTop = obj.offsetTop; var objBottom = obj.offsetTop + obj.offsetHeight; var objLeft = obj.offsetLeft; var objRight = obj.offsetLeft + obj.offsetWidth; if (mouseX >= objLeft && mouseX <= objRight && mouseY >= objTop && mouseY <= objBottom) { return true; } return false; } function editor_cMenu_generate(editorWin,objname) { var parentWin = window; editorWin.event.returnValue = false; var cMenuOptions = [ ['Cut', 'Ctrl-X', function() {}], ['Copy', 'Ctrl-C', function() {}], ['Paste', 'Ctrl-C', function() {}], ['Delete', 'DEL', function() {}], ['---', null, null], ['Select All', 'Ctrl-A', function() {}], ['Clear All', '', function() {}], ['---', null, null], ['About this editor...', '', function() { alert("about this editor"); }]]; editor_cMenu.options = cMenuOptions; var cMenuHeader = '' + '<div id="_'+objname+'_cMenu" onblur="editor_cMenu(this);" oncontextmenu="return false;" onselectstart="return false"' + ' style="position: absolute; visibility: hidden; cursor: default; width: 167px; background-color: threedface;' + ' border: solid 1px; border-color: threedlightshadow threeddarkshadow threeddarkshadow threedlightshadow;">' + '<table border=0 cellspacing=0 cellpadding=0 width="100%" style="width: 167px; background-color: threedface; border: solid 1px; border-color: threedhighlight threedshadow threedshadow threedhighlight;">' + ' <tr><td colspan=2 height=1></td></tr>'; var cMenuList = ''; var cMenuFooter = '' + ' <tr><td colspan=2 height=1></td></tr>' + '</table></div>'; for (var menuIdx in editor_cMenu.options) { var menuName = editor_cMenu.options[menuIdx][0]; var menuKey = editor_cMenu.options[menuIdx][1]; var menuCode = editor_cMenu.options[menuIdx][2]; if (menuName == "---" || menuName == "separator") { cMenuList += ' <tr><td colspan=2 class="cMenuDivOuter"><div class="cMenuDivInner"></div></td></tr>'; } else { cMenuList += '<tr class="cMenu" onMouseOver="editor_cMenu(this)" onMouseOut="editor_cMenu(this)" onClick="editor_cMenu(this, \'' +menuIdx+ '\',\'' +objname+ '\')">'; if (menuKey) { cMenuList += ' <td align=left class="cMenu">' +menuName+ '</td><td align=right class="cMenu">' +menuKey+ '</td>'; } else { cMenuList += ' <td colspan=2 class="cMenu">' +menuName+ '</td>'; } cMenuList += '</tr>'; } } var cMenuHTML = cMenuHeader + cMenuList + cMenuFooter; document.all['_'+objname+'_cMenu'].outerHTML = cMenuHTML; editor_cMenu_setPosition(parentWin, editorWin, objname); parentWin['_'+objname+'_cMenu'].style.visibility = 'visible'; parentWin['_'+objname+'_cMenu'].focus(); } function editor_cMenu_setPosition(parentWin, editorWin, objname) { var event = editorWin.event; var cMenuObj = parentWin['_'+objname+'_cMenu']; var mouseX = event.clientX + parentWin.document.all['_'+objname+'_editor'].offsetLeft; var mouseY = event.clientY + parentWin.document.all['_'+objname+'_editor'].offsetTop; var cMenuH = cMenuObj.offsetHeight; var cMenuW = cMenuObj.offsetWidth; var pageH = document.body.clientHeight + document.body.scrollTop; var pageW = document.body.clientWidth + document.body.scrollLeft; if (mouseX + 5 + cMenuW > pageW) { var left = mouseX - cMenuW - 5; } else { var left = mouseX + 5; } if (mouseY + 5 + cMenuH > pageH) { var top = mouseY - cMenuH + 5; } else { var top = mouseY + 5; } cMenuObj.style.top = top; cMenuObj.style.left = left; } function editor_cMenu(obj,menuIdx,objname) { var action = event.type; if (action == "mouseover" && !obj.disabled && obj.tagName.toLowerCase() == 'tr') { obj.className = 'cMenuOver'; for (var i=0; i < obj.cells.length; i++) { obj.cells[i].className = 'cMenuOver'; } } else if (action == "mouseout" && !obj.disabled && obj.tagName.toLowerCase() == 'tr') { obj.className = 'cMenu'; for (var i=0; i < obj.cells.length; i++) { obj.cells[i].className = 'cMenu'; } } else if (action == "click" && !obj.disabled) { document.all['_'+objname+'_cMenu'].style.visibility = "hidden"; var menucode = editor_cMenu.options[menuIdx][2]; menucode(); } else if (action == "blur") { if (!_isMouseOver(obj,event)) { obj.style.visibility = 'hidden'; } else { if (obj.style.visibility != "hidden") { obj.focus(); } } } else { alert("editor_cMenu, unknown action: " + action); } } var transltObject = {}; var sessionID = ""; function configIndica() { this.textArea = ""; this.suggestionBox = ""; this.webAppAdd = ""; this.selectLanguage = ""; this.radioIntlli = ""; this.radioPhonetic = ""; this.checkBoxTypeAhead = ""; this.styleSheet = ""; this.spellBtn = ""; this.helpBtn = ""; this.alertMsg = ""; this.selectFont = ""; this.numericOption = ""; this.feedbackBtn = ""; this.summitLink = ""; this.helpMsgDiv = ""; this.convertBTN = ""; this.editorRequired = false; this.convertTextHandler = ""; this.disableHandler = ""; this.eIndicaHandler = ""; this.enableHandler = ""; this.requestHandler = ""; this.spellCheckHandler = ""; } function enableIndica(configIndica) { var expName = navigator.appName; try { if (configIndica.textArea != "" && configIndica.textArea != null) { sendRequest(configIndica); if (expName == "Microsoft Internet Explorer") { editor_generate(configIndica); setHandlerIE(configIndica); var editor_obj = document.all["_" + configIndica.textArea + "_editor"]; var langCode = document.getElementById(configIndica.selectLanguage).options[document.getElementById(configIndica.selectLanguage).selectedIndex].value; if (langCode == 1) { editor_obj.value = "यहां लिखें"; editor_obj.className = "Hindi"; } else if (langCode == 2) { editor_obj.value = "বাংলা জানি"; editor_obj.className = "Bengali"; } else if (langCode == 3) { editor_obj.value = "ટાઈપ કરવા"; editor_obj.className = "Gujarati"; } else editor_obj.value = "Write here"; } else { transltObject[configIndica.textArea + '_Translit'] = new Translit(configIndica); setEvent(configIndica); setHandlerNonIE(configIndica); } } } catch(e){} } function sendRequest(configIndica) { var enableURL = location.href; var oReq = zXmlHttp.createRequest(); var oSentAt = new Date(); oReq.onreadystatechange = function () { if (oReq.readyState == 4) { if (oReq.status == 200) { } } }; var uri = configIndica.webAppAdd + "/"+ configIndica.requestHandler +"?URL=" + enableURL; var sFullUrl = encodeURI(uri); try { if (navigator.appName != "Microsoft Internet Explorer") { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } } catch(error){} try { oReq.open("GET", sFullUrl, false); oReq.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oReq.setRequestHeader("Cache-Control", "no-cache"); oReq.send(null); } catch(error) { if (configIndica.alertMsg != "") alert(configIndica.alertMsg); var oReqHandler = zXmlHttp.createRequest(); var oSentAtHandler = new Date(); oReqHandler.onreadystatechange = function () { if (oReqHandler.readyState == 4) { if (oReqHandler.status == 200) { } } }; var currentURl = location.href; currentURl = currentURl.replace(currentURl.substring(currentURl.lastIndexOf('/') + 1),""); var handlerUri = currentURl + configIndica.requestHandler + "?URL=" + enableURL; var handlerFullUrl = encodeURI(handlerUri); oReqHandler.open("GET", handlerFullUrl, false); oReqHandler.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oReqHandler.setRequestHeader("Cache-Control", "no-cache"); oReqHandler.send(null); } } function setHandlerIE(configIndica) { try { if (configIndica.selectLanguage != "" && configIndica.selectLanguage != null) { addEventListener(configIndica.selectLanguage,'change',function () { document.all[configIndica.textArea].translit.languageChange(configIndica.selectLanguage); },false); } } catch(e){} try { if (configIndica.spellBtn != "" && configIndica.spellBtn != null) addEventListener(configIndica.spellBtn,'click',function () { document.all[configIndica.textArea].translit.spellCheck();return false; },false); } catch(e){} try { if (configIndica.helpBtn != "" && configIndica.helpBtn != null) addEventListener(configIndica.helpBtn,'click',function () { document.all[configIndica.textArea].translit.openHelpFile();return false; },false); } catch(e){} try { if (configIndica.radioIntlli != "" && configIndica.radioIntlli != null) addEventListener(configIndica.radioIntlli,'click', function () { document.all[configIndica.textArea].translit.setKBMode('false'); } ,false); } catch(e){} try { if (configIndica.radioPhonetic != "" && configIndica.radioPhonetic != null) addEventListener(configIndica.radioPhonetic,'click',function () { document.all[configIndica.textArea].translit.setKBMode('true'); },false); } catch(e){} try { if (configIndica.checkBoxTypeAhead != "" && configIndica.checkBoxTypeAhead != null) addEventListener(configIndica.checkBoxTypeAhead,'click',function () { document.all[configIndica.textArea].translit.likeWordFunction(); },false); } catch(e){} try { if (configIndica.selectFont != "" && configIndica.selectFont != null) { addEventListener(configIndica.selectFont,'change',function () { document.all[configIndica.textArea].translit.changeFontSize(configIndica.selectFont); },false); } } catch(e){} try { if (configIndica.numericOption != "" && configIndica.numericOption != null) addEventListener(configIndica.numericOption,'click',function () { document.all[configIndica.textArea].translit.numericOptionFunction(); },false); } catch(e){} try { if (configIndica.feedbackBtn != "" && configIndica.feedbackBtn != null) addEventListener(configIndica.feedbackBtn,'click',function () { document.all[configIndica.textArea].translit.feedbackFunction();return false; },false); } catch(e){} try { if (configIndica.summitLink != "" && configIndica.summitLink != null) addEventListener(configIndica.summitLink,'click',function () { return document.all[configIndica.textArea].translit.openSummitWebsite(); },false); } catch(e){} try { if (configIndica.convertBTN != "" && configIndica.convertBTN != null) addEventListener(configIndica.convertBTN,'click',function () { document.all[configIndica.textArea].translit.convertText();return false; },false); } catch(e){} } function setHandlerNonIE(configIndica) { try { if (configIndica.selectLanguage != "" && configIndica.selectLanguage != null) addEventListener(configIndica.selectLanguage,'change',function () { transltObject[configIndica.textArea + '_Translit'].languageChange(configIndica.selectLanguage); },false); } catch(e){} try { if (configIndica.spellBtn != "" && configIndica.spellBtn != null) addEventListener(configIndica.spellBtn,'click',function () { transltObject[configIndica.textArea + '_Translit'].spellCheck(); },false); } catch(e){} try { if (configIndica.helpBtn != "" && configIndica.helpBtn != null) addEventListener(configIndica.helpBtn,'click',function () { transltObject[configIndica.textArea + '_Translit'].openHelpFile(); },false); } catch(e){} try { if (configIndica.radioIntlli != "" && configIndica.radioIntlli != null) addEventListener(configIndica.radioIntlli,'click', function () { transltObject[configIndica.textArea + '_Translit'].setKBMode('false'); } ,false); } catch(e){} try { if (configIndica.radioPhonetic != "" && configIndica.radioPhonetic != null) addEventListener(configIndica.radioPhonetic,'click',function () { transltObject[configIndica.textArea + '_Translit'].setKBMode('true'); },false); } catch(e){} try { if (configIndica.checkBoxTypeAhead != "" && configIndica.checkBoxTypeAhead != null) addEventListener(configIndica.checkBoxTypeAhead,'click',function () { transltObject[configIndica.textArea + '_Translit'].likeWordFunction(); },false); } catch(e){} try { if (configIndica.selectFont != "" && configIndica.selectFont != null) addEventListener(configIndica.selectFont,'change',function () { transltObject[configIndica.textArea + '_Translit'].changeFontSize(configIndica.selectFont); },false); } catch(e){} try { if (configIndica.numericOption != "" && configIndica.numericOption != null) addEventListener(configIndica.numericOption,'click',function () { transltObject[configIndica.textArea + '_Translit'].numericOptionFunction(); },false); } catch(e){} try { if (configIndica.feedbackBtn != "" && configIndica.feedbackBtn != null) addEventListener(configIndica.feedbackBtn,'click',function () { transltObject[configIndica.textArea + '_Translit'].feedbackFunction(); },false); } catch(e){} try { if (configIndica.summitLink != "" && configIndica.summitLink != null) addEventListener(configIndica.summitLink,'click',function () { return transltObject[configIndica.textArea + '_Translit'].openSummitWebsite(); },false); } catch(e){} try { if (configIndica.convertBTN != "" && configIndica.convertBTN != null) addEventListener(configIndica.convertBTN,'click',function () { transltObject[configIndica.textArea + '_Translit'].convertText(); },false); } catch(e){} } function addEventListener(element, name, observer, capture) { if (typeof element == 'string') { element = document.getElementById(element); } if (element.addEventListener) { element.addEventListener(name, observer, capture); } else if (element.attachEvent) { element.attachEvent('on' + name, observer); } } var lastAccess; setInterval("checkSession()",10); function checkSession() { var tempLastAccess = new Date(lastAccess); var min = tempLastAccess.getMinutes(); tempLastAccess.setMinutes(min + 15); var curDate = new Date(); if (tempLastAccess < curDate) sessionID = ""; } function getSession(handlerName) { var enableURL = document.domain; var oReq = zXmlHttp.createRequest(); var oSentAt = new Date(); oReq.onreadystatechange = function () { if (oReq.readyState == 4) { if (oReq.status == 200) { sessionID = oReq.responseText; } } }; var currentURl = location.href; currentURl = currentURl.replace(currentURl.substring(currentURl.lastIndexOf('/') + 1),""); var uri = currentURl + handlerName + "?URL=" + enableURL; var sFullUrl = encodeURI(uri); try { if (navigator.appName != "Microsoft Internet Explorer") { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } } catch(error){} oReq.open("GET", sFullUrl, false); oReq.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oReq.setRequestHeader("Cache-Control", "no-cache"); oReq.send(null); if (navigator.appName != "Microsoft Internet Explorer") sessionID = oReq.responseText; lastAccess = new Date(); } function closeSession(handlerName) { var enableURL = document.domain; var oReq = zXmlHttp.createRequest(); var oSentAt = new Date(); oReq.onreadystatechange = function () { if (oReq.readyState == 4) { if (oReq.status == 200) { } } }; var currentURl = location.href; currentURl = currentURl.replace(currentURl.substring(currentURl.lastIndexOf('/') + 1),""); var uri = currentURl + handlerName + "?sessionID=" + sessionID; var sFullUrl = encodeURI(uri); try { if (navigator.appName != "Microsoft Internet Explorer") { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } } catch(error){} oReq.open("GET", sFullUrl, false); oReq.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oReq.setRequestHeader("Cache-Control", "no-cache"); oReq.send(null); } function placeCursor(to,configIndica) { var editor_obj = ""; if (navigator.appName == "Microsoft Internet Explorer") editor_obj = document.all["_" + configIndica.textArea + "_editor"]; else editor_obj = document.getElementById(this.objname); if (navigator.appName == "Microsoft Internet Explorer") { editor_obj.focus(); var objRange = editor_obj.document.selection.createRange(); objRange.moveStart('character', to); objRange.moveEnd('character', to); objRange.collapse(false); objRange.select(); } else { document.getElementById(configIndica.textArea).setSelectionRange(to,to); } } document.write('<style type="text/css">\n'); document.write('.btn { width: 22px; height: 22px; border: 1px solid buttonface; margin: 0; padding: 0; }\n'); document.write('.btnOver { width: 22px; height: 22px; border: 1px outset; }\n'); document.write('.btnDown { width: 22px; height: 22px; border: 1px inset; background-color: buttonhighlight; }\n'); document.write('.btnNA { width: 22px; height: 22px; border: 1px solid buttonface; filter: alpha(opacity=25); }\n'); document.write('.cMenu { background-color: threedface; color: menutext; cursor: Default; font-family: MS Sans Serif; font-size: 8pt; padding: 2 12 2 16; }'); document.write('.cMenuOver { background-color: highlight; color: highlighttext; cursor: Default; font-family: MS Sans Serif; font-size: 8pt; padding: 2 12 2 16; }'); document.write('.cMenuDivOuter { background-color: threedface; height: 9 }'); document.write('.cMenuDivInner { margin: 0 4 0 4; border-width: 1; border-style: solid; border-color: threedshadow threedhighlight threedhighlight threedshadow; }'); document.write('</style>\n'); _editor_url = ""; var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]); if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; } if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; } if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; } if (win_ie_ver >= 5.5) { document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"'); document.write(' language="Javascript1.2"></scr' + 'ipt>'); } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); } var translitTable = {}; function setEvent(configIndica) { document.write('<link rel="stylesheet" type="text/css" href="'+ configIndica.webAppAdd +'/Styles/IFrame.css"/>'); addEventListener(configIndica.textArea,'keydown',function(e) { textArea_event(e,configIndica); },false); addEventListener(configIndica.textArea,'keypress',function(e) { textArea_event(e,configIndica); },false); addEventListener(configIndica.textArea,'keyup',function(e) { textArea_event(e,configIndica); },false); addEventListener(configIndica.textArea,'mouseup',function(e) { textArea_event(e,configIndica); },false); addEventListener(configIndica.textArea,'click',function(e) { textArea_event(e,configIndica); },false); var langCode = document.getElementById(configIndica.selectLanguage).options[document.getElementById(configIndica.selectLanguage).selectedIndex].value; if (langCode == 1) { document.getElementById(configIndica.textArea).value = "यहां लिखें"; document.getElementById(configIndica.textArea).className = "Hindi"; document.getElementById(configIndica.textArea).rows = 15; document.getElementById(configIndica.textArea).cols = 96; } else if (langCode == 2) { document.getElementById(configIndica.textArea).value = "বাংলা জানি"; document.getElementById(configIndica.textArea).className = "Bengali"; document.getElementById(configIndica.textArea).rows = 9; document.getElementById(configIndica.textArea).cols = 70; } else if (langCode == 3) { document.getElementById(configIndica.textArea).value = "ટાઈપ કરવા"; document.getElementById(configIndica.textArea).className = "Gujarati"; document.getElementById(configIndica.textArea).rows = 14; document.getElementById(configIndica.textArea).cols = 96; } else { document.getElementById(configIndica.textArea).value = "Write here"; } document.getElementById(configIndica.textArea).focus(); } function textArea_event(e,configIndica) { var processKeyPress = true; var objName = configIndica.textArea; var translit = transltObject[objName + '_Translit']; var editEvent = e; if ((e.ctrlKey && (editEvent.which == 69 || editEvent.which == 72 || editEvent.which == 66 || editEvent.which == 71 || editEvent.which == 77)) || (((!e.ctrlKey) && (editEvent.keyCode >= 65 && editEvent.keyCode <= 91) || (editEvent.which >= 48 && editEvent.which <= 57 && translit.numericOption == true)) && (translit.lang != 0))) e.preventDefault(); if (e.ctrlKey) processKeyPress = false; if (editEvent.which == 124) e.preventDefault(); if (editEvent && editEvent.type == 'blur') { translit.HandleKeyDown(editEvent); return; } if (editEvent && (editEvent.type == 'mouseup' || editEvent.type == 'mousedown' || editEvent.type == 'contextmenu')) { translit.HandleKeyPress(editEvent); return; } if (editEvent && editEvent.which) { if (editEvent.type == 'keydown') { translit.HandleKeyDown(editEvent); return; } if ((editEvent.type == 'keypress' && processKeyPress)) { translit.HandleKeyPress(editEvent); return; } } } function translateBengali() { } translateBengali.prototype.translateIntoEnglish = function(str,isInWord) { var engStr=""; var ch = new Array(); if(str==null || str == "") return ""; for(i=0;i<str.length;i++) { ch[i] = str.charAt(i); } for(i=0;i<ch.length;i++) { var lastChr; if(ch[i]=="ক") engStr=engStr.concat("ka"); else if(ch[i]=="খ") engStr=engStr.concat("kha"); else if(ch[i]=="গ") engStr=engStr.concat("ga"); else if(ch[i]=="ঘ") engStr=engStr.concat("gha"); else if(ch[i]=="ঙ") engStr=engStr.concat("ng"); else if(ch[i]=="চ") engStr=engStr.concat("cha"); else if(ch[i]=="ছ") engStr=engStr.concat("chha"); else if(ch[i]=="জ") engStr=engStr.concat("ja"); else if(ch[i]=="ঝ") engStr=engStr.concat("jha"); else if(ch[i]=="ট") engStr=engStr.concat("ta"); else if(ch[i]=="ঠ") engStr=engStr.concat("tha"); else if(ch[i]=="ড") engStr=engStr.concat("da"); else if(ch[i]=="ঢ") engStr=engStr.concat("dha"); else if(ch[i]=="ত") engStr=engStr.concat("ta"); else if(ch[i]=="থ") engStr=engStr.concat("tha"); else if(ch[i]=="দ") engStr=engStr.concat("da"); else if(ch[i]=="ধ") engStr=engStr.concat("dha"); else if(ch[i]=="ন") engStr=engStr.concat("na"); else if(ch[i]=="প") engStr=engStr.concat("pa"); else if(ch[i]=="ফ") engStr=engStr.concat("pha"); else if(ch[i]=="ব") engStr=engStr.concat("ba"); else if(ch[i]=="ভ") engStr=engStr.concat("bha"); else if(ch[i]=="ম") engStr=engStr.concat("ma"); else if(ch[i]=="য") engStr=engStr.concat("ya"); else if(ch[i]=="র") engStr=engStr.concat("ra"); else if(ch[i]=="ল") engStr=engStr.concat("la"); else if(ch[i]=="শ") engStr=engStr.concat("sha"); else if(ch[i]=="স") engStr=engStr.concat("sa"); else if(ch[i]=="ষ") engStr=engStr.concat("ssa"); else if(ch[i]=="হ") engStr=engStr.concat("ha"); else if(ch[i]=="्") { engStr=engStr.substr(0,engStr.length-1); } else if(ch[i]=="ৃ") engStr=engStr.concat("ri"); else if(ch[i]=="অ") engStr=engStr.concat("a"); else if((ch[i]=="আ")) engStr=engStr.concat("aa"); else if((ch[i]=="ই")) engStr=engStr.concat("i"); else if((ch[i]=="ঈ")) engStr=engStr.concat("ee"); else if((ch[i]=="উ")) engStr=engStr.concat("u"); else if((ch[i]=="ঊ")) engStr=engStr.concat("oo"); else if((ch[i]=="এ")) engStr=engStr.concat("e"); else if((ch[i]=="ঐ")) engStr=engStr.concat("ai"); else if((ch[i]=="ও")) engStr=engStr.concat("o"); else if((ch[i]=="ঔ")) engStr=engStr.concat("au"); else if((ch[i]==String.fromCharCode(0x9BE))) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("aa"); } else if((ch[i]=="ি")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("i"); } else if((ch[i]=="ী")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("ee"); } else if((ch[i]=="ু")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("u"); } else if((ch[i]=="ূ")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("oo"); } else if((ch[i]=="ে")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("e"); } else if((ch[i]=="ৈ")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("ai"); } else if((ch[i]=="ো")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("o"); } else if((ch[i]=="ৌ")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("au"); } else engStr=engStr.concat(""); lastChr =ch[i]; } if(!isInWord) { if(((lastChr!="অ")&&(lastChr!="আ")&&(lastChr!="া"))&& engStr.substr(engStr.length-1,1)=='a' ) { engStr=engStr.substr(0,engStr.length-1); } } return engStr; }; function translateGujarati() { } var engStrGujaratiMap= new Array( "","n","n","","a","aa","i","ee","u","oo","","","","","e","ai", "o","","o","ou","ka","kha","ga","gha","ng","cha","chha","ja","jha","n","ta","tha", "da","dha","na","ta","tha","da","dha","na","na","pa","pha","ba","bha","ma","ya","ra", "","la","la","","va","sha","sha","sa","ha","","","aa","i","ee","u","oo", "ri","","","","e","ai","o","","o","ou","","","","","","", "","","","","","","","","","","","","","","","", "","","","","","","","","","","","","","","","", "","","","","","","","","","","","","","","","" ); translateGujarati.prototype.translateIntoEnglish = function(word,isInWord) { var engStr=""; var ch = new Array(); if(word==null || word == "") return ""; for(i=0;i<word.length;i++) ch[i] = word.charCodeAt(i); for(i=0;i<ch.length;i++) { var lastChr; if (ch[i] > 0xa80 && ch[i] < 0xb00) { ch[i] = ch[i] - 0xa81; engStr=engStr.concat(engStrGujaratiMap[ch[i]]); } else if (unicodeNumber > 0 && unicodeNumber < 0128) { engStr=engStr.concat(engStrGujaratiMap[ch[i]]); } lastChr =ch[i]; } if(!isInWord) { if (lastChr > 0 && lastChr < 0128) { if(((engStrGujaratiMap[lastChr]!="a")&&(engStrGujaratiMap[lastChr]!="aa"))&& engStr.substr(engStr.length-1,1)=='a' ) { engStr=engStr.substr(0,engStr.length-1); } } } return engStr; }; function translateHindi() { } translateHindi.prototype.translateIntoEnglish = function(word,isInWord) { var engStr=""; var ch = new Array(); if(word==null || word == "") return ""; if(word.indexOf("\u091c\u094d\u091e") >=0 ) word = word.replace("\u091c\u094d\u091e","\u0917\u094d\u092f"); for(i=0;i<word.length;i++) { ch[i] = word.charAt(i); } for(i=0;i<ch.length;i++) { var lastChr; if(ch[i]=="क") engStr=engStr.concat("ka"); else if(ch[i]=="ख") engStr=engStr.concat("kha"); else if(ch[i]=="ग") engStr=engStr.concat("ga"); else if(ch[i]=="घ") engStr=engStr.concat("gha"); else if((ch[i]=="ंग")||(ch[i]=="ङ")) engStr=engStr.concat("ng"); else if(ch[i]=="च") engStr=engStr.concat("cha"); else if(ch[i]=="छ") engStr=engStr.concat("chha"); else if(ch[i]=="ज") engStr=engStr.concat("ja"); else if(ch[i]=="झ") engStr=engStr.concat("jha"); else if(ch[i]=="ट") engStr=engStr.concat("ta"); else if(ch[i]=="ठ") engStr=engStr.concat("tha"); else if(ch[i]=="ड") engStr=engStr.concat("da"); else if(ch[i]=="ढ") engStr=engStr.concat("dha"); else if(ch[i]=="त") engStr=engStr.concat("ta"); else if(ch[i]=="थ") engStr=engStr.concat("tha"); else if(ch[i]=="द") engStr=engStr.concat("da"); else if(ch[i]=="ध") engStr=engStr.concat("dha"); else if(ch[i]=="न") engStr=engStr.concat("na"); else if(ch[i]=="ं") engStr=engStr.concat("n"); else if(ch[i]=="ऩ") engStr=engStr.concat("na"); else if(ch[i]=="प") engStr=engStr.concat("pa"); else if(ch[i]=="फ") engStr=engStr.concat("pha"); else if(ch[i]=="ब") engStr=engStr.concat("ba"); else if(ch[i]=="भ") engStr=engStr.concat("bha"); else if(ch[i]=="म") engStr=engStr.concat("ma"); else if(ch[i]=="य") engStr=engStr.concat("ya"); else if(ch[i]=="र") engStr=engStr.concat("ra"); else if(ch[i]=="ल") engStr=engStr.concat("la"); else if(ch[i]=="व") engStr=engStr.concat("va"); else if(ch[i]=="श") engStr=engStr.concat("sha"); else if(ch[i]=="स") engStr=engStr.concat("sa"); else if(ch[i]=="ष") engStr=engStr.concat("sha"); else if(ch[i]=="ण") engStr=engStr.concat("na"); else if(ch[i]=="ह") engStr=engStr.concat("ha"); else if(ch[i]=="ञ") engStr=engStr.concat("n"); else if(ch[i]=="ज्ञ") engStr=engStr.concat("gya"); else if(ch[i]=="्") { engStr=engStr.substr(0,engStr.length-1); } else if(ch[i]=="ृ") { if(engStr.substr(engStr.length-1,1)=='a') engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("ri"); } else if(ch[i]=="अ") engStr=engStr.concat("a"); else if((ch[i]=="आ")) engStr=engStr.concat("aa"); else if((ch[i]=="इ")) engStr=engStr.concat("i"); else if((ch[i]=="ई")) engStr=engStr.concat("ee"); else if((ch[i]=="उ")) engStr=engStr.concat("u"); else if((ch[i]=="ऊ")) engStr=engStr.concat("oo"); else if((ch[i]=="ए")) engStr=engStr.concat("e"); else if((ch[i]=="ऐ")) engStr=engStr.concat("ai"); else if((ch[i]=="ओ")) engStr=engStr.concat("o"); else if((ch[i]=="औ")) engStr=engStr.concat("ou"); else if(ch[i]=="ऑ") engStr=engStr.concat("o"); else if((ch[i]=="ा")) { if(engStr.substr(engStr.length-1,1)=='a'); engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("aa"); } else if((ch[i]=="ि")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("i"); } else if((ch[i]=="ी")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("ee"); } else if((ch[i]=="ु")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("u"); } else if((ch[i]=="ू")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("oo"); } else if((ch[i]=="े")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("e"); } else if((ch[i]=="ै")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("ai"); } else if((ch[i]=="ो")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("o"); } else if((ch[i]=="ॉ")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("o"); } else if((ch[i]=="ौ")) { engStr=engStr.substr(0,engStr.length-1); engStr=engStr.concat("ou"); } else engStr=engStr.concat(""); lastChr =ch[i]; } if(!isInWord) { if(((lastChr!="अ")&&(lastChr!="आ")&&(lastChr!="ा"))&& engStr.substr(engStr.length-1,1)=='a' ) { engStr=engStr.substr(0,engStr.length-1); } } return engStr; }; var lnames = { 0 : "English" ,2 : "Bengali" }; var fontNames = ["Small", "Medium", "Large"]; var hindiNumericCodeMap = ["०","१","२","३","४","५","६","७","८","९"]; var bengaliNumericCodeMap = ["০","১","২","৩","৪","৫","৬","৭","৮","৯"]; var gujaratiNumericCodeMap = ["૦","૧","૨","૩","૪","૫","૬","૭","૮","૯"]; function Translit(configIndica) { this.processKeyPress = true; this.selectedText = ""; this.sentchars = ""; this.windx = 0; this.words = null; this.convertPositionArray = null; this.punctuationArray = null; this.lang = 1; this.scriptLang = -1; this.objname = configIndica.textArea; this.mytext = null; this.leadChars = ""; this.trailChars = ""; this.timeoutId = null; this.wordList = {}; this.backgroundColor = 0; this.isphonetic = false; this.isLikeWords = false; this.numericOption = false; this.translate = new translateHindi(); this.handlerAddress = configIndica.webAppAdd; this.langDropdown = document.getElementById(configIndica.selectLanguage); if (configIndica.suggestionBox != "" && configIndica.suggestionBox != null) this.sbox = document.getElementById(configIndica.suggestionBox); else this.sbox = ""; if (configIndica.spellBtn != "" && configIndica.spellBtn != null) this.splBtn = configObj.spellBtn; else this.splBtn = ""; if (configIndica.checkBoxTypeAhead != "" && configIndica.checkBoxTypeAhead != null) this.checkBoxlikeWord = configIndica.checkBoxTypeAhead; else this.checkBoxlikeWord = ""; if (configIndica.selectFont != "" && configIndica.selectFont != null) this.selectFont = document.getElementById(configIndica.selectFont); else this.selectFont = ""; if (configIndica.numericOption != "" && configIndica.numericOption != null) this.checkBoxNumeric = configIndica.numericOption; else this.checkBoxNumeric = ""; if (configIndica.helpMsgDiv != "" && configIndica.helpMsgDiv != null) { this.helpMsgDiv = document.getElementById(configIndica.helpMsgDiv); this.helpMsgDiv.innerHTML = ""; this.helpMsgDiv.className = "tabtitleHelpEngilsh"; this.helpMsgDiv.innerHTML = "Easy Indian language writing system using English keyboard. Select the language of your choice and start typing in the text box below. If you're writing Hindi, type ‘mujhe hindi aati hai’ to get मुझे हिंदी आती है. To learn more, click <a href='help.htm' target='_blank'><span style='color: #3300ff'>Help</span></a>."; } else this.helpMsgDiv = ""; this.addLanguage(); if (configIndica.selectFont != "" && configIndica.selectFont != null) this.addFont(); this.convertTextHandler = configIndica.convertTextHandler; this.disableHandler = configIndica.disableHandler; this.eIndicaHandler = configIndica.eIndicaHandler; this.enableHandler = configIndica.enableHandler; this.requestHandler = configIndica.requestHandler; this.spellCheckHandler = configIndica.spellCheckHandler; } Translit.prototype.addLanguage = function() { for(var i in lnames) { var optn = document.createElement("OPTION"); optn.text = lnames[i]; optn.value = i; this.langDropdown.options.add(optn); } this.langDropdown.selectedIndex = 1; this.lang = this.langDropdown.options[this.langDropdown.selectedIndex].value; }; Translit.prototype.addFont = function() { for(var i=0;i<fontNames.length;i++) { var optn = document.createElement("OPTION"); optn.text = fontNames[i]; optn.value = fontNames[i]; this.selectFont.options.add(optn); } this.selectFont.selectedIndex = 0; }; Translit.prototype.HandleKeyDown = function(editEvent) { var returnValue = true; this.processKeyPress = true; var ord = editEvent.keyCode; if (ord == 16) { return; } if (ord == 17) { return; } if (ord == 18) { return; } if (this.mytext == null) { if (navigator.appName == "Microsoft Internet Explorer") this.mytext = document.all["_" + this.objname + "_editor"]; else this.mytext = document.getElementById(this.objname); } if (navigator.appName == "Microsoft Internet Explorer") try { this.selectedText = this.mytext.contentWindow.document.body.document.selection.createRange().text; } catch(error){} else this.selectedText = this.mytext.value.substr(this.mytext.selectionStart, this.mytext.selectionEnd); var keyCode; if (navigator.appName == "Microsoft Internet Explorer") keyCode = editEvent.keyCode; else keyCode = editEvent.which; var ctrlKey = editEvent.ctrlKey; var altKey = editEvent.altKey; var shiftKey = editEvent.shiftKey; if ((ctrlKey) && (keyCode == 69)) { this.lang=0; this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; if (this.sbox != "") this.sbox.style.display = "none"; this.langDropdown.selectedIndex = 0; if (this.selectFont != "") this.selectFont.selectedIndex = 0; returnValue = false; this.numericOption = false; if (this.checkBoxNumeric != "") document.getElementById(this.checkBoxNumeric).checked = false; if (this.helpMsgDiv != "") { this.helpMsgDiv.innerHTML = ""; this.helpMsgDiv.className = "tabtitleHelpEngilsh"; this.helpMsgDiv.innerHTML = "Easy Indian language writing system using English keyboard. Select the language of your choice and start typing in the text box below. If you're writing Hindi, type ‘mujhe hindi aati hai’ to get मुझे हिंदी आती है. To learn more, click <a href='help.htm' target='_blank'><span style='color: #3300ff'>Help</span></a>."; } this.processKeyPress = false; if (navigator.appName != "Microsoft Internet Explorer") editEvent.stopPropagation(); } else if ((ctrlKey) && (keyCode == 72) && lnames[1] == "Hindi") { this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; this.backgroundColor = 0; if (this.sbox != "") this.sbox.style.display = "none"; this.translate = new translateHindi(); this.selectLangOption("Hindi"); if (this.selectFont != "") this.selectFont.selectedIndex = 0; this.numericOption = false; if (this.checkBoxNumeric != "") document.getElementById(this.checkBoxNumeric).checked = false; if(this.scriptLang != 1 && !(this.scriptLang == -1 && this.lang==0)) { if (navigator.appName == "Microsoft Internet Explorer") { this.mytext.contentWindow.document.body.innerText = "यहां लिखें"; this.mytext.contentWindow.document.body.className = "Hindi"; } else { this.mytext.value = "यहां लिखें"; this.mytext.className = "Hindi"; } if (this.selectFont != "" && this.selectFont != null) this.boxSize(this.selectFont.id,lnames[1]); } this.lang=1; this.scriptLang=1; returnValue = false; if (this.helpMsgDiv != "") { this.helpMsgDiv.innerHTML = ""; this.helpMsgDiv.className = "tabtitleHelpHindi"; this.helpMsgDiv.innerHTML = "हिंदी लिखने का आसान तरीका। अपनी भाषा सिलेक्ट करें और नीचे बने टेक्स्ट बॉक्स में टाइप करना शुरू करें। 'मुझे हिंदी आती है' टाइप करने के लिये लिखें 'mujhe hindi aati hai'. ज्यादा जानकारी के लिये क्लिक करें <a href='help.htm' target='_blank'><span style='color: #3300ff'>मदद</span></a> पर।"; } this.processKeyPress = false; if (navigator.appName != "Microsoft Internet Explorer") editEvent.stopPropagation(); } else if ((ctrlKey) && (keyCode == 66) && lnames[2] == "Bengali") { this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; this.backgroundColor = 0; if (this.sbox != "") this.sbox.style.display = "none"; this.translate = new translateBengali(); this.selectLangOption("Bengali"); if (this.selectFont != "") this.selectFont.selectedIndex = 0; this.numericOption = true; if (this.checkBoxNumeric != "") document.getElementById(this.checkBoxNumeric).checked = true; if(this.scriptLang != 2 && !(this.scriptLang == -1 && this.lang==0)) { if (navigator.appName == "Microsoft Internet Explorer") { this.mytext.contentWindow.document.body.innerText = "বাংলা জানি"; this.mytext.contentWindow.document.body.className = "Bengali"; } else { this.mytext.value = "বাংলা জানি"; this.mytext.className = "Bengali"; } if (this.selectFont != "" && this.selectFont != null) this.boxSize(this.selectFont.id,lnames[2]); } this.lang=2; this.scriptLang=2; returnValue = false; if (this.helpMsgDiv != "") { this.helpMsgDiv.innerHTML = ""; this.helpMsgDiv.className = "tabtitleHelpBengali"; this.helpMsgDiv.innerHTML = "বাংলা লিখবার সহজ উপায় ৷ প্রথমে 'Language Option' এ গিয়ে নিজের ভাষা বেছে নিন, তারপর নিচের টেক্সট বক্সে টাইপ করতে আরম্ভ করুন ৷ যেমন, 'আমি বাংলা জানি' লিখবার জন্যে টাইপ করুন ami bangla jaani ৷ আরও জানতে চাইলে <a href='helpBengali.htm' target='_blank'><span style='color: #3300ff'>সাহায্য</span></a> তে ক্লিক করুন ৷"; } this.processKeyPress = false; if (navigator.appName != "Microsoft Internet Explorer") editEvent.stopPropagation(); } else if ((ctrlKey) && (keyCode == 71) && lnames[3] == "Gujarati") { this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; this.backgroundColor = 0; if (this.sbox != "") this.sbox.style.display = "none"; this.translate = new translateGujarati(); this.selectLangOption("Gujarati"); if (this.selectFont != "") this.selectFont.selectedIndex = 0; this.numericOption = false; if (this.checkBoxNumeric != "") document.getElementById(this.checkBoxNumeric).checked = false; if(this.scriptLang != 3 && !(this.scriptLang == -1 && this.lang==0)) { if (navigator.appName == "Microsoft Internet Explorer") { this.mytext.contentWindow.document.body.innerText = "ટાઈપ કરવા"; this.mytext.contentWindow.document.body.className = "Gujarati"; } else { this.mytext.value = "ટાઈપ કરવા"; this.mytext.className = "Gujarati"; } if (this.selectFont != "" && this.selectFont != null) this.boxSize(this.selectFont.id,lnames[3]); } this.lang=3; this.scriptLang=3; returnValue = false; if (this.helpMsgDiv != "") { this.helpMsgDiv.innerHTML = ""; this.helpMsgDiv.className = "tabtitleHelpGujarati"; this.helpMsgDiv.innerHTML = "ગુજરાતી લખવાનો સરળ ઉપાય. તમારી ભાષા સીલેક્ટ કરો અને નીચે આપેલ ટેક્ષ્ટબોક્ષમાં ટાઈપ કરવાનું શરૂ કરી દો ''મને ગુજરાતી આવડે છે'' ટાઈપ કરવા માટે ''mane gujaraati aavade chhe'' ટાઈપ કરો. વધારે જાણકારી મેળવવા માટે <a href='help.htm' target='_blank'><span style='color: #3300ff'>મદદ</span></a> પર કલીક કરો."; } this.processKeyPress = false; if (navigator.appName != "Microsoft Internet Explorer") editEvent.stopPropagation(); } else if ((ctrlKey) && (keyCode == 77) && lnames[4] == "Malayalam") { this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; this.backgroundColor = 0; if (this.sbox != "") this.sbox.style.display = "none"; this.KB = null; this.translate = null; this.selectLangOption("Malayalam"); if (this.selectFont != "") this.selectFont.selectedIndex = 0; this.numericOption = false; if (this.checkBoxNumeric != "") document.getElementById(this.checkBoxNumeric).checked = false; if(this.scriptLang != 4 && !(this.scriptLang == -1 && this.lang==0)) { if (navigator.appName == "Microsoft Internet Explorer") { this.mytext.contentWindow.document.body.innerText = ""; this.mytext.contentWindow.document.body.className = "Malayalam"; } else { this.mytext.value = ""; this.mytext.className = "Malayalam"; } if (this.selectFont != "" && this.selectFont != null) this.boxSize(this.selectFont.id,lnames[4]); } this.lang=4; this.scriptLang=4; returnValue = false; this.processKeyPress = false; if (navigator.appName != "Microsoft Internet Explorer") editEvent.stopPropagation(); } if (returnValue == false) { editEvent.returnValue = false; editEvent.cancelBubble = true; return; } if (ctrlKey) return true; if (keyCode==8) { if (this.sentchars.length >0) { this.sentchars = this.sentchars.substr(0, this.sentchars.length-1); if (this.sentchars == "") { this.words = null; if (this.sbox != "") this.sbox.style.display = "none"; } if (this.sentchars != "") { this.fetchWord("", this.sentchars, ""); returnValue = false; } } if (this.sentchars == "") { this.words = null; if (this.sbox != "") this.sbox.style.display = "none"; } } else if ((keyCode==38) && this.words) { if (this.windx == 0) this.windx = this.words.length; this.windx--; this.changeSuggestions(); this.insertWord(this.words[this.windx]); var s3 = this.getTrailingText(); var j = 0; while (languageChar(s3.charCodeAt(j),lnames[this.lang]) && j<s3.length) j++; if (navigator.appName == "Microsoft Internet Explorer") { var objRange = this.mytext.document.selection.createRange(); objRange.moveEnd('character', j); objRange.collapse(false); objRange.select(); } else { this.mytext.setSelectionRange(this.mytext.selectionStart + j,this.mytext.selectionStart + j); editEvent.preventDefault(); } if (this.leadChars != "") { this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; } if (this.sbox != "") { if (this.sbox.style.display != 'none') this.wordList[this.sentchars] = this.words[this.windx]; } returnValue = false; } else if ((keyCode==40) && this.words) { this.windx++; if (this.words.length == this.windx) this.windx=0; this.changeSuggestions(); this.insertWord(this.words[this.windx]); var s3 = this.getTrailingText(); var j = 0; while (languageChar(s3.charCodeAt(j),lnames[this.lang]) && j<s3.length) j++; if (navigator.appName == "Microsoft Internet Explorer") { var objRange = this.mytext.document.selection.createRange(); objRange.moveEnd('character', j); objRange.collapse(false); objRange.select(); } else { this.mytext.setSelectionRange(this.mytext.selectionStart + j,this.mytext.selectionStart + j); editEvent.preventDefault(); } if (this.leadChars != "") { this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; } if (this.sbox != "") { if (this.sbox.style.display != 'none') this.wordList[this.sentchars] = this.words[this.windx]; } returnValue = false; } else if ((keyCode==35) || (keyCode==36) || (keyCode==37) || (keyCode==39)) { this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; if (this.sbox != "") this.sbox.style.display = "none"; returnValue = true; } if (returnValue == false) { editEvent.returnValue = false; editEvent.cancelBubble = true; return; } }; Translit.prototype.selectLangOption = function(langName) { var temp = 0; var temp1 = 0; for(var i=0;i< this.langDropdown.options.length;i++) if (this.langDropdown.options[i].text == langName) this.langDropdown.selectedIndex = i; }; Translit.prototype.HandleKeyPress = function(editEvent) { if (this.processKeyPress == false) return; var returnValue = true; if (editEvent.type == 'mouseup') { this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; if (this.sbox != "") this.sbox.style.display = "none"; returnValue = true; } var ord = editEvent.keyCode; if (ord == 16) { return; } if (ord == 17) { return; } if (ord == 18) { return; } clearTimeout(this.timeoutId); if (this.mytext == null) { if (navigator.appName == "Microsoft Internet Explorer") this.mytext = document.all["_" + this.objname + "_editor"]; else this.mytext = document.getElementById(this.objname); } if (navigator.appName == "Microsoft Internet Explorer") keyCode = editEvent.keyCode; else keyCode = editEvent.which; var ctrlKey = editEvent.ctrlKey; var altKey = editEvent.altKey; var shiftKey = editEvent.shiftKey; this.currentKeyCode = keyCode; if (this.lang == 0) { if (keyCode == 13 && editEvent.type != 'blur') { if (navigator.appName == "Microsoft Internet Explorer") this.insertHTML("<br>"); this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; if (this.sbox != "") this.sbox.style.display = "none"; editEvent.returnValue = false; editEvent.cancelBubble = true; } return; } if ((keyCode >= 65) && (keyCode <= 91) || (keyCode >= 97 && keyCode <= 123)) { var oThis = this; if (this.scriptLang == -1) this.scriptLang = this.lang; this.splitWord(this.getCursorPos(), String.fromCharCode(keyCode)); returnValue = false; } else { if (this.sentchars == "") { this.words = null; if (this.sbox != "") this.sbox.style.display = "none"; returnValue = true; } if (this.sentchars != "" && editEvent.type != 'blur') { var oReq = zXmlHttp.createRequest(); var oThis = this; var oSentAt = new Date(); oReq.onreadystatechange = function () { if (oReq.readyState == 4) { if (oReq.status == 200) { oThis.insertReceivedWord(oReq.responseText, oSentAt); } } }; var s1 = this.getLeadingText(); var i = s1.length-1; while (languageChar(s1.charCodeAt(i),lnames[this.lang]) && i>=0) i--; if (sessionID == "") getSession(this.enableHandler); var uri = this.handlerAddress + "/" + this.eIndicaHandler + "?engStr=" + this.sentchars + "&langWord="+ s1.substr(i+1) +"&lang=" + lnames[this.lang] + "&GUID=" + sessionID + "&isLikeWords=" + this.isLikeWords + "&isInWords=" + (this.leadChars != "") + "&isPhonetic=" + (this.isphonetic); var sFullUrl = encodeURI(uri); try { if (navigator.appName != "Microsoft Internet Explorer") { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } } catch(error){} try { oReq.open("GET", sFullUrl, false); oReq.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oReq.setRequestHeader("Cache-Control", "no-cache"); oReq.send(null); lastAccess = new Date(); } catch(error) { var oReqHandler = zXmlHttp.createRequest(); var oSentAtHandler = new Date(); oReqHandler.onreadystatechange = function () { if (oReqHandler.readyState == 4) { if (oReqHandler.status == 200) { oThis.insertReceivedWord(oReqHandler.responseText, oSentAtHandler); } } }; var currentURl = location.href; currentURl = currentURl.replace(currentURl.substring(currentURl.lastIndexOf('/') + 1),""); if (sessionID == "") getSession(this.enableHandler); var handlerUri = currentURl + this.eIndicaHandler + "?engStr=" + this.sentchars + "&langWord="+ s1.substr(i+1) +"&lang=" + lnames[this.lang] + "&GUID=" + sessionID + "&isLikeWords=" + this.isLikeWords + "&isInWords=" + (this.leadChars != "") + "&isPhonetic=" + (this.isphonetic); var handlerFullUrl = encodeURI(handlerUri); oReqHandler.open("GET", handlerFullUrl, false); oReqHandler.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oReqHandler.setRequestHeader("Cache-Control", "no-cache"); oReqHandler.send(null); lastAccess = new Date(); } this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; if (this.sbox != "") this.sbox.style.display = "none"; returnValue = true; } if (keyCode == 13 && editEvent.type != 'blur') { if (navigator.appName == "Microsoft Internet Explorer") this.insertHTML("<br>"); this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; if (this.sbox != "") this.sbox.style.display = "none"; returnValue = false; } } if ((shiftKey) && (keyCode == 124)) { if (lnames[this.lang] == "Hindi") this.insertHTML("।"); else if (lnames[this.lang] == "Bengali") this.insertHTML("৷"); returnValue = false; } if (this.numericOption == true) { if (!shiftKey && (keyCode >= 48 && keyCode <= 57)) { if (keyCode >= 48 && keyCode <= 57) keyCode = keyCode - 48; else if (keyCode >= 96 && keyCode <= 105) keyCode = keyCode - 96; if (lnames[this.lang] == "Hindi") { this.insertHTML(hindiNumericCodeMap[keyCode]); returnValue = false; } else if (lnames[this.lang] == "Bengali") { this.insertHTML(bengaliNumericCodeMap[keyCode]); returnValue = false; } else if (lnames[this.lang] == "Gujarati") { this.insertHTML(gujaratiNumericCodeMap[keyCode]); returnValue = false; } this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; if (this.sbox != "") this.sbox.style.display = "none"; } } if (navigator.appName == "Microsoft Internet Explorer") { if (editEvent.type == 'paste'){ var pasteData = window.clipboardData.getData("Text"); pasteData = this.removeHTML(pasteData); window.clipboardData.setData("Text",pasteData); } } if (returnValue == false) { editEvent.returnValue = false; editEvent.cancelBubble = true; return; } }; Translit.prototype.removeHTML = function(str){ str = str.replace(/<span([^>])*>(&nbsp;)*\s*<\/span>/gi, ''); str = str.replace(/<span[^>]*>/gi, ''); str = str.replace(/<\/span[^>]*>/gi, ''); str = str.replace(/<p([^>])*>(&nbsp;)*\s*<\/p>/gi, ''); str = str.replace(/<p[^>]*>/gi, ''); str = str.replace(/<\/p[^>]*>/gi, ''); str = str.replace(/<h([^>])[0-9]>(&nbsp;)*\s*<\/h>/gi, ''); str = str.replace(/<h[^>][0-9]>/gi, ''); str = str.replace(/<\/h[^>][0-9]>/gi, ''); str = str.replace (/<B [^>]*>/ig, '<b>'); str = str.replace (/<DIV[^>]*>/ig, ''); str = str.replace (/<\/DIV>/gi, ''); str = str.replace (/<[\/\w?]+:[^>]*>/ig, ''); str = str.replace (/(&nbsp;){2,}/ig, '&nbsp;'); str = str.replace (/<STRONG>/ig, ''); str = str.replace (/<\/STRONG>/ig, ''); str = str.replace (/<TT>/ig, ''); str = str.replace (/<\/TT>/ig, ''); str = str.replace (/<FONT [^>]*>/ig, ''); str = str.replace (/<\/FONT>/ig, ''); str = str.replace (/STYLE=\"[^\"]*\"/ig, ''); str = str.replace(/<([\w]+) class=([^ |>]*)([^>]*)/gi, '<$1$3'); str = str.replace(/<([\w]+) style="([^"]*)"([^>]*)/gi, '<$1$3'); str = str.replace(/width=([^ |>]*)([^>]*)/gi, ''); str = str.replace(/classname=([^ |>]*)([^>]*)/gi, ''); str = str.replace(/align=([^ |>]*)([^>]*)/gi, ''); str = str.replace(/valign=([^ |>]*)([^>]*)/gi, ''); str = str.replace(/<\\?\??xml[^>]>/gi, ''); str = str.replace(/<\/?\w+:[^>]*>/gi, ''); str = str.replace(/<st1:.*?>/gi, ''); str = str.replace(/o:/gi, ''); str = str.replace(/<!--([^>])*>(&nbsp;)*\s*<\/-->/gi, ''); str = str.replace(/<!--[^>]*>/gi, ''); str = str.replace(/<\/--[^>]*>/gi, ''); return str; }; Translit.prototype.IsVowel = function(ch) { if ((ch == 'a' || ch == 'A') || (ch == 'e' || ch == 'E') || (ch == 'i' || ch == 'I') || (ch == 'o' || ch == 'O') || (ch == 'u' || ch == 'U')) return true; else return false; }; Translit.prototype.getCursorPos2 = function() { var sOldText = this.mytext.document.activeElement.innerText; var objRange = this.mytext.document.selection.createRange(); var sOldRange = objRange.text; var sWeirdString = '#%~'; objRange.text = sOldRange + sWeirdString; objRange.moveStart('character', (0 - sOldRange.length - sWeirdString.length)); var sNewText = this.mytext.document.activeElement.innerText; objRange.text = sOldRange; for (i=0; i <= sNewText.length; i++) { var sTemp = sNewText.substring(i, i + sWeirdString.length); if (sTemp == sWeirdString) { var cursorPos = (i - sOldRange.length); return cursorPos; } } }; function trimAll(sString) { while (sString.substring(0,1) == ' ') sString = sString.substring(1, sString.length); while (sString.substring(sString.length-1, sString.length) == ' ') sString = sString.substring(0,sString.length-1); return sString; } function languageChar(ch,lang) { if (lang == "Hindi") return ((((ch >= 0x900) && (ch <= 0x965)) || ((ch >= 0x970) && (ch <= 0x97f)) || ch == 0x200c) && ch != 0x0964); else if (lang == "Bengali") return ((((ch >= 0x980) && (ch <= 0x9e5)) || ((ch >= 0x9f0) && (ch <= 0x9ff)) || ch == 0x200c) && ch != 0x09f7); else if (lang == "Gujarati") return (((ch >= 0xA80) && (ch <= 0xAff)) || ch == 0x200c); else if (lang == "Malayalam") return (((ch >= 0xD00) && (ch <= 0xD7f)) || ch == 0x200c); else if (lang == "English") return (((ch >= 0x41) && (ch <= 0x5A)) || ((ch >= 0x61) && (ch <= 0x7A))); } function containsString(ary, str) { var loop = false; var i = 0; while (!loop) { if (ary[i] == str) loop = true; if (i == ary.length-1) break; i++; } return loop; } Translit.prototype.openHelpFile = function() { if (lnames[this.lang] == "Bengali") window.open('helpBengali.htm','heplWindow'); else window.open('help.htm','heplWindow'); var s1 = this.getLeadingText(); var s2 = this.getTrailingText(); var compText = s1 + s2; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } this.placeCursor(compText.length); }; Translit.prototype.setKBMode = function(setPhonetic) { var s1 = this.getLeadingText(); var s2 = this.getTrailingText(); var compText = s1 + s2; if(setPhonetic == "true") { this.isphonetic = true; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } } else if(setPhonetic == "false") { this.isphonetic = false; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } } }; Translit.prototype.likeWordFunction = function() { var s1 = this.getLeadingText(); var s2 = this.getTrailingText(); var compText = s1 + s2; if(document.getElementById(this.checkBoxlikeWord).checked == true) { this.isLikeWords = true; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } } else if(document.getElementById(this.checkBoxlikeWord).checked == false) { this.isLikeWords = false; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } } }; Translit.prototype.placeCursor = function(to) { if (navigator.appName == "Microsoft Internet Explorer") { var index = this.getCursorPos(); var objRange = this.mytext.document.selection.createRange(); objRange.moveStart('character', to-index); objRange.moveEnd('character', to-index); objRange.collapse(false); objRange.select(); } else { this.mytext.setSelectionRange(to,to); } }; Translit.prototype.languageChange = function(selectID) { var lang_obj = document.getElementById(selectID); var lang = lang_obj.options[lang_obj.selectedIndex].value; var s1 = this.getLeadingText(); var s2 = this.getTrailingText(); var compText = s1 + s2; if(lang == 0) { this.lang=0; this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; if (this.sbox != "") this.sbox.style.display = "none"; if (this.selectFont != "") this.selectFont.selectedIndex = 0; this.numericOption = false; if (this.checkBoxNumeric != "") document.getElementById(this.checkBoxNumeric).checked = false; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } this.placeCursor(compText.length); returnValue = false; if (this.helpMsgDiv != "") { this.helpMsgDiv.innerHTML = ""; this.helpMsgDiv.className = "tabtitleHelpEngilsh"; this.helpMsgDiv.innerHTML = "Easy Indian language writing system using English keyboard. Select the language of your choice and start typing in the text box below. If you're writing Hindi, type ‘mujhe hindi aati hai’ to get मुझे हिंदी आती है. To learn more, click <a href='help.htm' target='_blank'><span style='color: #3300ff'>Help</span></a>."; } } else if(lang == 1 && lnames[1] == "Hindi") { this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; this.backgroundColor = 0; if (this.selectFont != "") this.selectFont.selectedIndex = 0; this.numericOption = false; if (this.checkBoxNumeric != "") document.getElementById(this.checkBoxNumeric).checked = false; if (this.sbox != "") this.sbox.style.display = "none"; this.translate = new translateHindi(); if(this.scriptLang != 1 && !(this.scriptLang == -1 && this.lang==0)) { if (navigator.appName == "Microsoft Internet Explorer") { this.mytext.contentWindow.document.body.innerText = "यहां लिखें"; this.mytext.contentWindow.document.body.className = "Hindi"; } else { this.mytext.value = "यहां लिखें"; this.mytext.className = "Hindi"; } if (this.selectFont != "" && this.selectFont != null) this.boxSize(this.selectFont.id,lnames[1]); } this.lang=1; this.scriptLang = 1; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } this.placeCursor(compText.length); returnValue = false; if (this.helpMsgDiv != "") { this.helpMsgDiv.innerHTML = ""; this.helpMsgDiv.className = "tabtitleHelpHindi"; this.helpMsgDiv.innerHTML = "हिंदी लिखने का आसान तरीका। अपनी भाषा सिलेक्ट करें और नीचे बने टेक्स्ट बॉक्स में टाइप करना शुरू करें। 'मुझे हिंदी आती है' टाइप करने के लिये लिखें 'mujhe hindi aati hai'. ज्यादा जानकारी के लिये क्लिक करें <a href='help.htm' target='_blank'><span style='color: #3300ff'>मदद</span></a> पर।"; } } else if(lang == 2 && lnames[2] == "Bengali") { this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; this.backgroundColor = 0; if (this.selectFont != "") this.selectFont.selectedIndex = 0; this.numericOption = true; if (this.checkBoxNumeric != "") document.getElementById(this.checkBoxNumeric).checked = true; if (this.sbox != "") this.sbox.style.display = "none"; this.translate = new translateBengali(); if(this.scriptLang != 2 && !(this.scriptLang == -1 && this.lang==0)) { if (navigator.appName == "Microsoft Internet Explorer") { this.mytext.contentWindow.document.body.innerText = "বাংলা জানি"; this.mytext.contentWindow.document.body.className = "Bengali"; } else { this.mytext.value = "বাংলা জানি"; this.mytext.className = "Bengali"; } if (this.selectFont != "" && this.selectFont != null) this.boxSize(this.selectFont.id,lnames[2]); } this.lang=2; this.scriptLang = 2; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } this.placeCursor(compText.length); returnValue = false; if (this.helpMsgDiv != "") { this.helpMsgDiv.innerHTML = ""; this.helpMsgDiv.className = "tabtitleHelpBengali"; this.helpMsgDiv.innerHTML = "বাংলা লিখবার সহজ উপায় ৷ প্রথমে 'Language Option' এ গিয়ে নিজের ভাষা বেছে নিন, তারপর নিচের টেক্সট বক্সে টাইপ করতে আরম্ভ করুন ৷ যেমন, 'আমি বাংলা জানি' লিখবার জন্যে টাইপ করুন ami bangla jaani ৷ আরও জানতে চাইলে <a href='helpBengali.htm' target='_blank'><span style='color: #3300ff'>সাহায্য</span></a> তে ক্লিক করুন ৷"; } } else if(lang == 3 && lnames[3] == "Gujarati"){ this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; this.backgroundColor = 0; if (this.selectFont != "") this.selectFont.selectedIndex = 0; this.numericOption = false; if (this.checkBoxNumeric != "") document.getElementById(this.checkBoxNumeric).checked = false; if (this.sbox != "") this.sbox.style.display = "none"; this.translate = new translateGujarati(); if(this.scriptLang != 3 && !(this.scriptLang == -1 && this.lang==0)) { if (navigator.appName == "Microsoft Internet Explorer") { this.mytext.contentWindow.document.body.innerText = "ટાઈપ કરવા"; this.mytext.contentWindow.document.body.className = "Gujarati"; } else { this.mytext.value = "ટાઈપ કરવા"; this.mytext.className = "Gujarati"; } if (this.selectFont != "" && this.selectFont != null) this.boxSize(this.selectFont.id,lnames[3]); } this.lang=3; this.scriptLang = 3; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } this.placeCursor(compText.length); returnValue = false; if (this.helpMsgDiv != "") { this.helpMsgDiv.innerHTML = ""; this.helpMsgDiv.className = "tabtitleHelpGujarati"; this.helpMsgDiv.innerHTML = "ગુજરાતી લખવાનો સરળ ઉપાય. તમારી ભાષા સીલેક્ટ કરો અને નીચે આપેલ ટેક્ષ્ટબોક્ષમાં ટાઈપ કરવાનું શરૂ કરી દો ''મને ગુજરાતી આવડે છે'' ટાઈપ કરવા માટે ''mane gujaraati aavade chhe'' ટાઈપ કરો. વધારે જાણકારી મેળવવા માટે <a href='help.htm' target='_blank'><span style='color: #3300ff'>મદદ</span></a> પર કલીક કરો."; } } else if(lang == 4 && lnames[4] == "Malayalam"){ this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; this.backgroundColor = 0; if (this.selectFont != "") this.selectFont.selectedIndex = 0; this.numericOption = false; if (this.checkBoxNumeric != "") document.getElementById(this.checkBoxNumeric).checked = false; if (this.sbox != "") this.sbox.style.display = "none"; this.KB = null; this.translate = null; if(this.scriptLang != 4 && !(this.scriptLang == -1 && this.lang==0)) { if (navigator.appName == "Microsoft Internet Explorer") { this.mytext.contentWindow.document.body.innerText = ""; this.mytext.contentWindow.document.body.className = "Malayalam"; } else { this.mytext.value = ""; this.mytext.className = "Malayalam"; } if (this.selectFont != "" && this.selectFont != null) this.boxSize(this.selectFont.id,lnames[4]); } this.lang=4; this.scriptLang = 4; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } this.placeCursor(compText.length); returnValue = false; } }; Translit.prototype.markWord = function(str) { var s1 = this.getLeadingText(); var s2 = this.getTrailingText(); var compText = s1 + s2; var cursor = this.getCursorPos(); var found = false; var findIndex = -1; if (navigator.appName == "Microsoft Internet Explorer") { var objRange = this.mytext.document.selection.createRange(); objRange.moveStart('character', 0); objRange.moveEnd('character', compText.length-cursor); found = objRange.findText(str, 20000, 2); } else { if (this.mytext.value.substr(cursor, this.mytext.value.length).indexOf(str) != -1) { found = true; findIndex = this.mytext.value.substr(cursor, this.mytext.value.length).indexOf(str); } } if (found) { if (navigator.appName == "Microsoft Internet Explorer") { objRange.select(); if (this.backgroundColor == 1) { this.mytext.document.execCommand('BackColor', false, 'Gold'); document.getElementById(this.splBtn).style.backgroundColor="Gold"; } objRange.collapse(false); objRange.select(); } else { var before = this.mytext.value.substr(0, findIndex + cursor); var selected = this.mytext.value.substr(findIndex + cursor, str.length); var after = this.mytext.value.substr(findIndex + cursor + str.length, this.mytext.value.length); this.mytext.value = before + "<" + selected + ">" + after; this.placeCursor(this.mytext.value.indexOf(after)); } } }; Translit.prototype.processMisspells = function(str) { var s1 = this.getLeadingText(); var s2 = this.getTrailingText(); var compText = s1 + s2; var badWords = eval('(' + str + ')'); if (this.backgroundColor == 1) { var cursor = this.getCursorPos(); this.placeCursor(0); for(var i=0; i<badWords.length; i++) this.markWord(badWords[i]); this.placeCursor(cursor); } }; Translit.prototype.spellCheck = function() { this.backgroundColor = (this.backgroundColor == 0) ? 1 : 0 ; var oThis = this; var s1 = this.getLeadingText(); var s2 = this.getTrailingText(); var compText = s1 + s2; var cursor = this.getCursorPos(); if(this.backgroundColor == 0) { if (navigator.appName == "Microsoft Internet Explorer") { var objRange = this.mytext.document.selection.createRange(); objRange.moveStart('character', -cursor); objRange.moveEnd('character', compText.length-cursor); objRange.select(); this.mytext.document.execCommand('BackColor', true, 'White'); document.getElementById(this.splBtn).style.backgroundColor='silver'; objRange.collapse(false); objRange.select(); this.placeCursor(cursor); } else { var fullText = this.mytext.value; fullText = this.replaceAll(fullText,'<',''); fullText = this.replaceAll(fullText,'>',''); this.mytext.value = fullText; } } else { var oReq = zXmlHttp.createRequest(); var sendText = ""; if (navigator.appName == "Microsoft Internet Explorer") { var objRange = this.mytext.document.selection.createRange(); objRange.moveStart('character', -cursor); objRange.moveEnd('character', compText.length-cursor); sendText = objRange.text.replace(/&nbsp;/g," "); } else { sendText = this.mytext.value; } if (sessionID == "") getSession(this.enableHandler); var param = "text=" + sendText + "&GUID=" + sessionID + "&lang=" + lnames[oThis.lang]; var url = this.handlerAddress + "/" + this.spellCheckHandler; try { if (navigator.appName != "Microsoft Internet Explorer") { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } } catch(error){} try { oReq.open("POST", url, true); oReq.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oReq.setRequestHeader("Cache-Control", "no-cache"); oReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); oReq.setRequestHeader("Content-length", param.length); oReq.setRequestHeader("Connection", "close"); oReq.onreadystatechange = function () { if (oReq.readyState == 4) { if (oReq.status == 200) { oThis.processMisspells(oReq.responseText); } } }; oReq.send(param); lastAccess = new Date(); } catch(error) { var oReqHandler = zXmlHttp.createRequest(); oReqHandler.onreadystatechange = function () { if (oReqHandler.readyState == 4) { if (oReqHandler.status == 200) { oThis.processMisspells(oReqHandler.responseText); } } }; var currentURl = location.href; currentURl = currentURl.replace(currentURl.substring(currentURl.lastIndexOf('/') + 1),""); var handlerURL = currentURl + this.spellCheckHandler; oReqHandler.open("POST", handlerURL, true); oReqHandler.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oReqHandler.setRequestHeader("Cache-Control", "no-cache"); oReqHandler.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); oReqHandler.setRequestHeader("Content-length", param.length); oReqHandler.setRequestHeader("Connection", "close"); oReqHandler.send(param); lastAccess = new Date(); } } }; Translit.prototype.replaceAll = function(str,replace,newStr) { while (true) { str = str.replace(replace,newStr); if (str.indexOf(replace) == -1) break; } return str; }; Translit.prototype.insertHTML = function(str) { if (navigator.appName == "Microsoft Internet Explorer") { var sRange = this.mytext.document.selection.createRange(); var sHtml = sRange.htmlText; if (sRange.length) { return alert("Unable to insert HTML. Try highlighting content instead of selecting it."); } var oldHandler = window.onerror; window.onerror = function() { alert("Unable to insert HTML for current selection."); return true; }; if (str == "<br>") sRange.text += " "; sRange.pasteHTML(str); window.onerror = oldHandler; sRange.collapse(false); sRange.select(); } else { var start = this.mytext.selectionStart; var end = this.mytext.selectionEnd; this.mytext.value = this.mytext.value.substr(0, start) + str + this.mytext.value.substr(end, this.mytext.value.length); this.mytext.focus(); } }; function getLeft(fe) { var oNode = fe; var iLeft = 0; while (oNode.tagName != "BODY") { iLeft += oNode.offsetLeft; oNode = oNode.offsetParent; } return iLeft; } function getTop(fe) { var oNode = fe; var iTop = 0; while (oNode.tagName != "BODY") { iTop += oNode.offsetTop; oNode = oNode.offsetParent; } return iTop; } Translit.prototype.changeSuggestions = function() { if (this.sbox != "") { var oDivs = null; if (navigator.appName == "Microsoft Internet Explorer") oDivs = this.sbox.children; else oDivs = this.sbox.childNodes; for(var i=1; i<oDivs.length; i++) { if (i==this.windx+1) { if (this.lang == 1) oDivs[i].className = "selectedsuggestion"; else if (this.lang == 2) oDivs[i].className = "selectedsuggestionBengali"; else if (this.lang == 3) oDivs[i].className = "selectedsuggestionGujarati"; else if (this.lang == 2) oDivs[i].className = "selectedsuggestionMalyalam"; } else { if (this.lang == 1) oDivs[i].className = "nonselectedsuggestion"; else if (this.lang == 2) oDivs[i].className = "nonselectedsuggestionBengali"; else if (this.lang == 3) oDivs[i].className = "nonselectedsuggestionGujarati"; else if (this.lang == 4) oDivs[i].className = "nonselectedsuggestionMalyalam"; } } } }; Translit.prototype.showSuggestions = function (w, r) { if (this.sbox != "") { this.sbox.innerHTML = ""; if ((!w) || (w[0] == "")) { this.sbox.style.display = "none"; return; } this.sbox.style.display = "block"; if (navigator.appName != "Microsoft Internet Explorer") { if (this.lang == 1) this.sbox.style.width = "6.8em"; else if (this.lang == 2) this.sbox.style.width = "8.7em"; else if (this.lang == 3) this.sbox.style.width = "8.7em"; } var oDiv = document.createElement("div"); if (this.lang == 1) oDiv.className = "nonselectedsuggestion"; else if (this.lang == 2) oDiv.className = "nonselectedsuggestionBengali"; else if (this.lang == 3) oDiv.className = "nonselectedsuggestionGujarati"; else if (this.lang == 4) oDiv.className = "nonselectedsuggestionMalyalam"; if (this.leadChars != "") oDiv.appendChild(document.createTextNode(this.translate.translateIntoEnglish(this.leadChars,false) + this.sentchars + this.translate.translateIntoEnglish(this.trailChars,false))); else oDiv.appendChild(document.createTextNode(this.sentchars)); this.sbox.appendChild(oDiv); for(var i=0; i<w.length; i++) { if (w[i]) { var oDiv = document.createElement("div"); if (i ==this.windx) { if (this.lang == 1) oDiv.className = "selectedsuggestion"; else if (this.lang == 2) oDiv.className = "selectedsuggestionBengali"; else if (this.lang == 3) oDiv.className = "selectedsuggestionGujarati"; else if (this.lang == 4) oDiv.className = "selectedsuggestionMalyalam"; } else { if (this.lang == 1) oDiv.className = "nonselectedsuggestion"; else if (this.lang == 2) oDiv.className = "nonselectedsuggestionBengali"; else if (this.lang == 3) oDiv.className = "nonselectedsuggestionGujarati"; else if (this.lang == 4) oDiv.className = "nonselectedsuggestionMalyalam"; } oDiv.appendChild(document.createTextNode(w[i])); this.sbox.appendChild(oDiv); } } var node = this.mytext.frameElement; if (navigator.appName == "Microsoft Internet Explorer") { this.sbox.style.left = getLeft(this.mytext) + (r.left) + "px"; this.sbox.style.top = getTop(this.mytext) + (r.bottom) + 10 + "px"; } else { var of = getSelectionOffset(this.mytext); this.sbox.style.left = getLeft(this.mytext) + of.x + "px"; this.sbox.style.top = getTop(this.mytext) + of.y + of.h + "px"; } } }; Translit.prototype.getWordAtCursor = function() { var s1 = this.getLeadingText(); var s3 = this.getTrailingText(); var i = s1.length-1; while (languageChar(s1.charCodeAt(i),lnames[this.lang]) && i>=0) i--; var j = 0; while (languageChar(s3.charCodeAt(j),lnames[this.lang]) && j<s3.length) j++; return s1.substr(i+1) + s3.substr(0, j); }; Translit.prototype.getTrailingText = function() { if (navigator.appName == "Microsoft Internet Explorer") { if (this.selectedText == "") { var objRange = this.mytext.document.selection.createRange(); objRange.moveEnd('textedit', 1); var hindText = objRange.text; objRange.collapse(true); objRange.select(); return hindText; } else return ""; } else { return this.mytext.value.substr(this.mytext.selectionEnd, this.mytext.value.length); } }; Translit.prototype.getLeadingText = function() { if (navigator.appName == "Microsoft Internet Explorer") { if (this.selectedText == "") { var objRange = this.mytext.document.selection.createRange(); objRange.moveStart('textedit', -1); var foreText = objRange.text; objRange.collapse(false); objRange.select(); return foreText; } else return ""; } else { return this.mytext.value.substr(0, this.mytext.selectionStart); } }; Translit.prototype.getCursorPos = function() { if (navigator.appName == "Microsoft Internet Explorer") { if (this.selectedText == "") { var objRange = this.mytext.document.selection.createRange(); objRange.moveStart('textedit', -1); var foreText = objRange.text; objRange.collapse(false); objRange.select(); return foreText.length; } else return 0; } else { return this.mytext.selectionStart; } }; Translit.prototype.insertWord = function(s) { var s1 = this.getLeadingText(); var s3 = this.getTrailingText(); var leadCharNo = 0; while (s3.substring(s3.length-1, s3.length) == ' ') { s3 = s3.substring(0,s3.length-1); } var i = s1.length-1; while (languageChar(s1.charCodeAt(i),lnames[this.lang]) && i>=0) { i--; leadCharNo++; } var j = 0; while (languageChar(s3.charCodeAt(j),lnames[this.lang]) && j<s3.length) j++; if (navigator.appName == "Microsoft Internet Explorer") { if (this.selectedText == "") { var objRange = this.mytext.document.selection.createRange(); objRange.moveStart('character', -(s1.length-1-i)); if (this.trailChars != "") objRange.moveEnd('character', j); objRange.pasteHTML(s); if (this.trailChars != "") objRange.moveEnd('character', -j); objRange.collapse(false); objRange.select(); } else { var objRange = this.mytext.contentWindow.document.body.document.selection.createRange(); objRange.pasteHTML(s); objRange.collapse(false); objRange.select(); } } else { var start = this.mytext.selectionStart; var end = this.mytext.selectionEnd; this.mytext.value = this.mytext.value.substr(0, start-leadCharNo) + s + this.mytext.value.substr(end+j, this.mytext.value.length); this.mytext.focus(); if (this.leadChars == "") this.mytext.setSelectionRange((start-leadCharNo) + (s.length), (start-leadCharNo) + (s.length)); else this.mytext.setSelectionRange((start-leadCharNo) + (s.length - this.trailChars.length), (start-leadCharNo) + (s.length - this.trailChars.length)); } }; Translit.prototype.insertReceivedWord = function(sResp, d) { var now = new Date(); var m1 = now.getTime(); var m2 = m1 - d.getTime(); var sendRec = sResp.split(";"); if ((sendRec[0] == this.sentchars) || (sendRec[0] == this.optionChars)) { var w0 = this.wordList[this.sentchars]; var received = sendRec[1].split("\t"); if ((w0 != null) && containsString(received, w0)) { this.words = new Array(received.length); this.words[0] = w0; var j=1; for(var i=0; i<received.length; i++) { if (this.isphonetic == false && this.leadChars == "") if (received[i] != w0) this.words[j++] = this.leadChars + received[i] + this.trailChars; else if (received[i] != w0) this.words[j++] = received[i] + this.trailChars; } } else { this.words = new Array(received.length); for(var i=0; i<received.length; i++) { if (this.isphonetic == false && this.leadChars == "") { this.words[i] = this.leadChars + received[i] + this.trailChars; } else { this.words[i] = received[i] + this.trailChars; } } } var s = this.words[0]; this.windx = 0; this.insertWord(s); var charIndex = s.length-1; while (charIndex>=0) { if (!languageChar(s.charCodeAt(charIndex),lnames[this.lang])) { this.words = null; this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; if (this.sbox != "") this.sbox.style.display = "none"; break; } charIndex--; } if (this.isphonetic == true) { if (this.sbox != "") this.sbox.style.display = "none"; } else { if (navigator.appName == "Microsoft Internet Explorer") { var objRange = this.mytext.document.selection.createRange(); var rect = objRange.getBoundingClientRect(); objRange.move('character', -(s.length)); this.showSuggestions(this.words, rect); } else { this.showSuggestions(this.words); } } if(this.leadChars != "") { this.sentchars = ""; this.leadChars = ""; this.trailChars = ""; } } }; Translit.prototype.fetchWord = function(s1, s2, s3) { var oThis = this; var oSentAt = new Date(); var s1 = this.getLeadingText(); var i = s1.length-1; while (languageChar(s1.charCodeAt(i),lnames[this.lang]) && i>=0) i--; if (sessionID == "") getSession(this.enableHandler); var uri = this.handlerAddress + "/" + this.eIndicaHandler + "?engStr=" + s2 + "&langWord="+ s1.substr(i+1) +"&lang=" + lnames[this.lang] + "&GUID=" + sessionID + "&isLikeWords=" + this.isLikeWords + "&isInWords=" + (this.leadChars != "") + "&isPhonetic=" + (this.isphonetic); var sFullUrl = encodeURI(uri); var oReq = zXmlHttp.createRequest(); oReq.onreadystatechange = function () { if (oReq.readyState == 4) { if (oReq.status == 200) { oThis.insertReceivedWord(oReq.responseText, oSentAt); } } }; try { if (navigator.appName != "Microsoft Internet Explorer") { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } } catch(error){} try { oReq.open("GET", sFullUrl, true); oReq.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oReq.setRequestHeader("Cache-Control", "no-cache"); oReq.send(null); lastAccess = new Date(); } catch(error) { var oReqHandler = zXmlHttp.createRequest(); var oSentAtHandler = new Date(); oReqHandler.onreadystatechange = function () { if (oReqHandler.readyState == 4) { if (oReqHandler.status == 200) { oThis.insertReceivedWord(oReqHandler.responseText, oSentAtHandler); } } }; var currentURl = location.href; currentURl = currentURl.replace(currentURl.substring(currentURl.lastIndexOf('/') + 1),""); if (sessionID == "") getSession(this.enableHandler); var handlerURI = currentURl + this.eIndicaHandler + "?engStr=" + s2 + "&langWord="+ s1.substr(i+1) +"&lang=" + lnames[this.lang] + "&GUID=" + sessionID + "&isLikeWords=" + this.isLikeWords + "&isInWords=" + (this.leadChars != "") + "&isPhonetic=" + (this.isphonetic); var handlerFullUrl = encodeURI(handlerURI); oReqHandler.open("GET", handlerFullUrl, true); oReqHandler.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oReqHandler.setRequestHeader("Cache-Control", "no-cache"); oReqHandler.send(null); lastAccess = new Date(); } }; Translit.prototype.fetchPhonetic = function(ch) { var alphachars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; var oSentAt = new Date(); var s1 = this.getLeadingText(); var i = s1.length-1; while (languageChar(s1.charCodeAt(i),lnames[this.lang]) && i>=0) i--; this.newLangWord = this.KB.ToNative(s1.substr(i+1),ch,this.sentchars); this.insertReceivedWord(this.newLangWord, oSentAt); if (this.sbox != "") this.sbox.style.display = "none"; return false; }; Translit.prototype.splitWordPhonetic = function(index, ch) { if (this.sentchars == "") { var s1 = this.getLeadingText(); var s3 = this.getTrailingText(); var i = s1.length-1; while (languageChar(s1.charCodeAt(i),lnames[this.lang]) && i>=0) i--; var j = 0; while (languageChar(s3.charCodeAt(j),lnames[this.lang]) && j<s3.length) j++; this.leadChars = trimAll(s1.substr(i+1)); this.trailChars = trimAll(s3.substr(0, j)); } this.sentchars += ch; this.fetchPhonetic(ch); }; Translit.prototype.splitWord = function(index, ch) { if (this.sentchars == "") { var s1 = this.getLeadingText(); var s3 = this.getTrailingText(); var i = s1.length-1; while (languageChar(s1.charCodeAt(i),lnames[this.lang]) && i>=0) i--; var j = 0; while (languageChar(s3.charCodeAt(j),lnames[this.lang]) && j<s3.length) j++; this.leadChars = trimAll(s1.substr(i+1)); this.trailChars = trimAll(s3.substr(0, j)); } this.sentchars += ch; var oThis = this; if (navigator.appName == "Microsoft Internet Explorer") { this.timeoutId = setTimeout( function() { oThis.fetchWord("", oThis.sentchars, ""); }, 250); } else oThis.fetchWord("", oThis.sentchars, ""); }; Translit.prototype.changeFontSize = function(selectFont) { var font_obj = document.getElementById(selectFont); var fontSize = font_obj.options[font_obj.selectedIndex].value; if (navigator.appName == "Microsoft Internet Explorer") this.mytext.contentWindow.document.body.className = lnames[this.lang] + fontSize; else { if (lnames[this.lang] != "English") { this.mytext.className = lnames[this.lang] + fontSize; this.boxSize(selectFont,lnames[this.lang]); } document.getElementById(this.objname).focus(); } var s1 = this.getLeadingText(); var s2 = this.getTrailingText(); var compText = s1 + s2; this.placeCursor(compText.length); }; Translit.prototype.boxSize = function(selectFont,language) { var font_obj = document.getElementById(selectFont); var fontSize = font_obj.options[font_obj.selectedIndex].value; if (language == "Hindi") { if (fontSize == "Small") { this.mytext.rows = 15; this.mytext.cols = 96; } else if (fontSize == "Medium") { this.mytext.rows = 12; this.mytext.cols = 76; } else if (fontSize == "Large") { this.mytext.rows = 11; this.mytext.cols = 69; } } else if (language == "Bengali") { if (fontSize == "Small") { this.mytext.rows = 9; this.mytext.cols = 70; } else if (fontSize == "Medium") { this.mytext.rows = 8; this.mytext.cols = 64; } else if (fontSize == "Large") { this.mytext.rows = 7; this.mytext.cols = 59; } } else if (language == "Gujarati") { if (fontSize == "Small") { this.mytext.rows = 14; this.mytext.cols = 96; } else if (fontSize == "Medium") { this.mytext.rows = 13; this.mytext.cols = 85; } else if (fontSize == "Large") { this.mytext.rows = 12; this.mytext.cols = 76; } } }; Translit.prototype.numericOptionFunction = function() { var s1 = this.getLeadingText(); var s2 = this.getTrailingText(); var compText = s1 + s2; if(document.getElementById(this.checkBoxNumeric).checked == true) { this.numericOption = true; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } } else if(document.getElementById(this.checkBoxNumeric).checked == false) { this.numericOption = false; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } } }; Translit.prototype.feedbackFunction = function() { var s1 = this.getLeadingText(); var s2 = this.getTrailingText(); var compText = s1 + s2; var uri = "feedBack.aspx?text=" + compText; var sFullUrl = encodeURI(uri); window.open(sFullUrl,'feedbackWindow'); if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } this.placeCursor(compText.length); }; Translit.prototype.openSummitWebsite = function() { window.open('http://www.summitindia.com','SummitWebsite'); var s1 = this.getLeadingText(); var s2 = this.getTrailingText(); var compText = s1 + s2; if (navigator.appName != "Microsoft Internet Explorer") { document.getElementById(this.objname).focus(); } this.placeCursor(compText.length); return false; }; Translit.prototype.convertText = function() { var oReq = zXmlHttp.createRequest(); var oThis = this; var sendText = ""; if (navigator.appName == "Microsoft Internet Explorer") sendText = this.mytext.contentWindow.document.body.document.selection.createRange().text; else sendText = this.mytext.value.substr(this.mytext.selectionStart, this.mytext.selectionEnd); if (sessionID == "") getSession(this.enableHandler); sendText = this.parseText(sendText); var param = "text=" + sendText + "&GUID=" + sessionID + "&lang=" + lnames[oThis.lang] + "&isPhonetic=false"; var url = this.handlerAddress + "/" + this.convertTextHandler; try { if (navigator.appName != "Microsoft Internet Explorer") { netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead"); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } } catch(error){} try { oReq.open("POST", url, true); oReq.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oReq.setRequestHeader("Cache-Control", "no-cache"); oReq.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); oReq.setRequestHeader("Content-length", param.length); oReq.setRequestHeader("Connection", "close"); oReq.onreadystatechange = function () { if (oReq.readyState == 4) { if (oReq.status == 200) { oThis.processConvertText(oReq.responseText); } } }; oReq.send(param); lastAccess = new Date(); } catch(error) { var oReqHandler = zXmlHttp.createRequest(); oReqHandler.onreadystatechange = function () { if (oReqHandler.readyState == 4) { if (oReqHandler.status == 200) { oThis.processConvertText(oReqHandler.responseText); } } }; var currentURl = location.href; currentURl = currentURl.replace(currentURl.substring(currentURl.lastIndexOf('/') + 1),""); var handlerURL = currentURl + this.convertTextHandler; oReqHandler.open("POST", handlerURL, true); oReqHandler.setRequestHeader("If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"); oReqHandler.setRequestHeader("Cache-Control", "no-cache"); oReqHandler.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); oReqHandler.setRequestHeader("Content-length", param.length); oReqHandler.setRequestHeader("Connection", "close"); oReqHandler.send(param); lastAccess = new Date(); } }; Translit.prototype.processConvertText = function(str) { if (str != "" && str != null) { str = this.reverseParse(str); if (navigator.appName == "Microsoft Internet Explorer") { var objRange = this.mytext.contentWindow.document.body.document.selection.createRange(); objRange.text = str; objRange.collapse(false); objRange.select(); } else { var start = this.mytext.selectionStart; var end = this.mytext.selectionEnd; this.mytext.value = this.mytext.value.substr(0, start) + str + this.mytext.value.substr(end, this.mytext.value.length); this.mytext.focus(); } } }; Translit.prototype.reverseParse = function(str) { var recviedWord = ""; var returnStr = ""; var punIndex = 0; var wordIndex = 0; if (str == "" && str == null) return returnStr; recviedWord = str.split(" "); for(var i=0;i<this.convertPositionArray.length;i++) { if (this.convertPositionArray[i] == "W") returnStr = returnStr + recviedWord[wordIndex++]; else if(this.convertPositionArray[i] == "P") returnStr = returnStr + this.punctuationArray[punIndex++]; } this.convertPositionArray = null; this.punctuationArray = null; return returnStr; }; Translit.prototype.parseText = function(str) { var returnWord = ""; this.punctuationArray = new Array(); this.convertPositionArray = new Array(); var posIndex = 0; var punIndex = 0; var i=0; if (str == null || str == "") return returnWord; var curLang = this.getLangOfChar(str.charCodeAt(0)); while (i < str.length) { var sb = ""; while (curLang == this.getLangOfChar(str.charCodeAt(i))) { sb = sb + str.charAt(i); i++; if (i == str.length) break; } if (curLang == "English") { if (returnWord == "") returnWord = sb; else returnWord = returnWord + " " + sb; this.convertPositionArray[posIndex++] = "W"; } else { this.punctuationArray[punIndex++] = sb; this.convertPositionArray[posIndex++] = "P"; } if (i == str.length) break; curLang = this.getLangOfChar(str.charCodeAt(i)); } return returnWord; }; Translit.prototype.getLangOfChar = function(ch) { if (((ch >= 0x41) && (ch <= 0x5A)) || ((ch >= 0x61) && (ch <= 0x7A))) return "English"; else if ((ch >= 0x900) && (ch <= 0x97f)) return "Hindi"; else if ((ch > 0x980) && (ch < 0xa00)) return "Bengali"; else if ((ch > 0xa80) && (ch < 0xaff)) return "Gujarati"; else return "Punctuation"; }; function XParser(sFileName,bIsXml) { var oThis = this; this.title=this.link=this.description=this.copyright=this.generator=this.modified=this.author=new XParserElement(); this.onload = null; if (bIsXml) this.load(sFileName); else { var oReq = zXmlHttp.createRequest(); oReq.onreadystatechange = function () { if (oReq.readyState == 4) { if (oReq.status == 200) { oThis.load(oReq.responseText); } } }; oReq.open("GET", sFileName, true); oReq.send(null); } } function XParserElement(oNode,sValue) { this.node = oNode || false; this.value = sValue || (this.node && this.node.text) || false; if (this.node) { this.attributes = []; var oAtts = this.node.attributes; for (var i = 0; i < oAtts.length; i++) { this.attributes[i] = new XParserAttribute(oAtts[i]); this.attributes[oAtts[i].nodeName] = new XParserAttribute(oAtts[i]); } } else this.attributes = 0; this.isNull = (!this.node && !this.value && !this.attributes); } function XParserAttribute(oNode) { this.value = oNode.nodeValue; } function XParserItem(itemNode) { this.title=this.link=this.author=this.description=this.date=new XParserElement(); for (var i = 0; i < itemNode.childNodes.length; i++) { var oNode = itemNode.childNodes[i]; if (oNode.nodeType == 1) { switch (oNode.tagName.toLowerCase()) { case "title": this.title = new XParserElement(oNode); break; case "link": if (oNode.getAttribute("href")) this.link = new XParserElement(oNode,oNode.getAttribute("href")); else this.link = new XParserElement(oNode); break; case "author": this.author = new XParserElement(oNode); break; case "description": this.description = new XParserElement(oNode); break; case "pubdate": this.date = new XParserElement(oNode); break; case "content": this.description = new XParserElement(oNode); break; case "issued": this.date = new XParserElement(oNode); break; case "dc:date": this.date = new XParserElement(oNode); break; default: break; } } } } if (navigator.product == "Gecko") { Text.prototype.__defineGetter__( "text", function () { return this.nodeValue; } ); Node.prototype.__defineGetter__( "text", function () { var oChildren = this.childNodes; var aText = []; for ( var i = 0; i < oChildren.length; i++ ) aText[i] = oChildren[i].nodeValue; return aText.join(""); } ); } XParser.prototype.load = function (sXml) { var oXmlDom = zXmlDom.createDocument(); oXmlDom.loadXML(sXml); this.root = oXmlDom.documentElement; this.isRss = (this.root.tagName.toLowerCase() == "rss"); if (this.isRss && parseInt(this.root.getAttribute("version")) < 2) throw new Error("RSS Version is less than 2");; this.isAtom = (this.root.tagName.toLowerCase() == "feed"); this.type = (this.isRss)?"RSS":"Atom";; var oChannel = (this.isRss)?this.root.getElementsByTagName("channel")[0]:this.root; for (var i = 0; i < oChannel.childNodes.length; i++) { var oNode = oChannel.childNodes[i]; if (oNode.nodeType == 1) { switch (oNode.tagName.toLowerCase()) { case "title": this.title = new XParserElement(oNode); break; case "link": if (this.isAtom) { if (oNode.getAttribute("rel").toLowerCase() == "alternate") { this.link = new XParserElement(oNode,oNode.getAttribute("href")); } } else { this.link = new XParserElement(oNode); } break; case "copyright": this.copyright = new XParserElement(oNode); break; case "generator": this.generator = new XParserElement(oNode); break; case "description": this.description = new XParserElement(oNode); break; case "lastbuilddate": this.modified = new XParserElement(oNode); break; case "managingeditor": this.author = new XParserElement(oNode); break; case "tagline": this.description = new XParserElement(oNode); break; case "modified": this.modified = new XParserElement(oNode); break; case "author": this.author = new XParserElement(oNode); break; default: break; } } } this.items = []; var oItems = null; if (this.isRss) { oItems = oChannel.getElementsByTagName("item"); } else { try { oXmlDom.setProperty("SelectionNamespaces","xmlns:atom='http://purl.org/atom/ns#'"); oItems = oXmlDom.selectNodes("/atom:feed/atom:entry"); } catch (oError) { oItems = oChannel.getElementsByTagName("entry"); } } for (var i = 0; i < oItems.length; i++) { this.items[i] = new XParserItem(oItems[i]); } if (typeof(this.onload) == "function") this.onload(); }; var zXml={useActiveX:(typeof ActiveXObject!="undefined"),useDom:document.implementation&&document.implementation.createDocument,useXmlHttp:(typeof XMLHttpRequest!="undefined")};zXml.ARR_XMLHTTP_VERS=["MSXML2.XmlHttp.5.0","MSXML2.XmlHttp.4.0","MSXML2.XmlHttp.3.0","MSXML2.XmlHttp","Microsoft.XmlHttp"];zXml.ARR_DOM_VERS=["MSXML2.DOMDocument.5.0","MSXML2.DOMDocument.4.0","MSXML2.DOMDocument.3.0","MSXML2.DOMDocument","Microsoft.XmlDom"];;function zXmlHttp(){}zXmlHttp.createRequest=function(){if(zXml.useXmlHttp){return new XMLHttpRequest();}else if(zXml.useActiveX){if(!zXml.XMLHTTP_VER){for(var i=0;i<zXml.ARR_XMLHTTP_VERS.length;i++){try{new ActiveXObject(zXml.ARR_XMLHTTP_VERS[i]);zXml.XMLHTTP_VER=zXml.ARR_XMLHTTP_VERS[i];break;}catch(oError){;}}}if(zXml.XMLHTTP_VER){return new ActiveXObject(zXml.XMLHTTP_VER);}else{throw new Error("Could not create XML HTTP Request.");}}else{throw new Error("Your browser doesn't support an XML HTTP Request.");}};zXmlHttp.isSupported=function(){return zXml.useXmlHttp||zXml.useActiveX;};function zXmlDom(){}zXmlDom.createDocument=function(){if(zXml.useDom){var oXmlDom=document.implementation.createDocument("","",null);oXmlDom.parseError={valueOf:function(){return this.errorCode;},toString:function(){return this.errorCode.toString()}};oXmlDom.__initError__();oXmlDom.addEventListener("load",function(){this.__checkForErrors__();this.__changeReadyState__(4);},false);return oXmlDom;;}else if(zXml.useActiveX){if(!zXml.DOM_VER){for(var i=0;i<zXml.ARR_DOM_VERS.length;i++){try{new ActiveXObject(zXml.ARR_DOM_VERS[i]);zXml.DOM_VER=zXml.ARR_DOM_VERS[i];break;}catch(oError){;}}}if(zXml.DOM_VER){return new ActiveXObject(zXml.DOM_VER);}else{throw new Error("Could not create XML DOM document.");}}else{throw new Error("Your browser doesn't support an XML DOM document.");}};zXmlDom.isSupported=function(){return zXml.useDom||zXml.useActiveX;};var oMozDocument=null;if(typeof XMLDocument!="undefined"){oMozDocument=XMLDocument;}else if(typeof Document!="undefined"){oMozDocument=Document;}if(oMozDocument&&!window.opera){oMozDocument.prototype.readyState=0;oMozDocument.prototype.onreadystatechange=null;oMozDocument.prototype.__changeReadyState__=function(iReadyState){this.readyState=iReadyState;if(typeof this.onreadystatechange=="function"){this.onreadystatechange();}};oMozDocument.prototype.__initError__=function(){this.parseError.errorCode=0;this.parseError.filepos=-1;this.parseError.line=-1;this.parseError.linepos=-1;this.parseError.reason=null;this.parseError.srcText=null;this.parseError.url=null;};oMozDocument.prototype.__checkForErrors__=function(){if(this.documentElement.tagName=="parsererror"){var reError=/>([\s\S]*?)Location:([\s\S]*?)Line Number(\d+),Column(\d+):<sourcetext>([\s\S]*?)(?:\-*\^)/;reError.test(this.xml);this.parseError.errorCode=-999999;this.parseError.reason=RegExp.$1;this.parseError.url=RegExp.$2;this.parseError.line=parseInt(RegExp.$3);this.parseError.linepos=parseInt(RegExp.$4);this.parseError.srcText=RegExp.$5;}};oMozDocument.prototype.loadXML=function(sXml){this.__initError__();this.__changeReadyState__(1);var oParser=new DOMParser();var oXmlDom=oParser.parseFromString(sXml,"text/xml");while(this.firstChild){this.removeChild(this.firstChild);}for(var i=0;i<oXmlDom.childNodes.length;i++){var oNewNode=this.importNode(oXmlDom.childNodes[i],true);this.appendChild(oNewNode);}this.__checkForErrors__();this.__changeReadyState__(4);};oMozDocument.prototype.__load__=oMozDocument.prototype.load;oMozDocument.prototype.load=function(sURL){this.__initError__();this.__changeReadyState__(1);this.__load__(sURL);};Node.prototype.__defineGetter__("xml",function(){var oSerializer=new XMLSerializer();return oSerializer.serializeToString(this,"text/xml");});Node.prototype.__defineGetter__("text",function(){var sText="";for(var i=0;i<this.childNodes.length;i++){if(this.childNodes[i].hasChildNodes()){sText+=this.childNodes[i].text;}else{sText+=this.childNodes[i].nodeValue;}}return sText;});}function zXslt(){}zXslt.transformToText=function(oXml,oXslt){if(typeof XSLTProcessor!="undefined"){var oProcessor=new XSLTProcessor();oProcessor.importStylesheet(oXslt);var oResultDom=oProcessor.transformToDocument(oXml);var sResult=oResultDom.xml;if(sResult.indexOf("<transformiix:result")>-1){sResult=sResult.substring(sResult.indexOf(">")+1,sResult.lastIndexOf("<"));}return sResult;;}else if(zXml.useActiveX){return oXml.transformNode(oXslt);}else{throw new Error("No XSLT engine found.");}};function zXPath(){}zXPath.selectNodes=function(oRefNode,sXPath,sXmlNs){if(typeof XPathEvaluator!="undefined"){oXmlNs=oXmlNs||{};var nsResolver=function(sPrefix){return oXmlNs[sPrefix];};var oEvaluator=new XPathEvaluator();var oResult=oEvaluator.evaluate(sXPath,oRefNode,nsResolver,XPathResult.ORDERED_NODE_ITERATOR_TYPE,null);var aNodes=new Array;if(oResult!=null){var oElement=oResult.iterateNext();while(oElement){aNodes.push(oElement);oElement=oResult.iterateNext();}}return aNodes;}else if(zXml.useActiveX){if(oXmlNs){var sXmlNs="";for(var sProp in oXmlNs){sXmlNs+="xmlns:"+sProp+"="+oXmlNs[sProp]+" ";}oRefNode.ownerDocument.setProperty("SelectionNamespaces",sXmlNs);};return oRefNode.selectNodes(sXPath);}else{throw new Error("No XPath engine found.");}};zXPath.selectSingleNode=function(oRefNode,sXPath,oXmlNs){if(typeof XPathEvaluator!="undefined"){;oXmlNs=oXmlNs||{};var nsResolver=function(sPrefix){return oXmlNs[sPrefix];};var oEvaluator=new XPathEvaluator();var oResult=oEvaluator.evaluate(sXPath,oRefNode,nsResolver,XPathResult.FIRST_ORDERED_NODE_TYPE,null);if(oResult!=null){return oResult.singleNodeValue;}else{return null;};}else if(zXML.useActiveX){if(oXmlNs){var sXmlNs="";for(var sProp in oXmlNs){sXmlNs+="xmlns:"+sProp+"="+oXmlNs[sProp]+" ";}oRefNode.ownerDocument.setProperty("SelectionNamespaces",sXmlNs);};return oRefNode.selectSingleNode(sXPath);}else{throw new Error("No XPath engine found.");}};function zXMLSerializer(){}zXMLSerializer.prototype.serializeToString=function(oNode){var sXml="";switch(oNode.nodeType){case 1:sXml="<"+oNode.tagName;for(var i=0;i<oNode.attributes.length;i++){sXml+=" "+oNode.attributes[i].name+"=\""+oNode.attributes[i].value+"\"";}sXml+=">";for(var i=0;i<oNode.childNodes.length;i++){sXml+=this.serializeToString(oNode.childNodes[i]);}sXml+="</"+oNode.tagName+">";break;case 3:sXml=oNode.nodeValue;break;case 4:sXml="<![CDATA["+oNode.nodeValue+"]]>";break;case 7:sXml="<?"+oNode.nodevalue+"?>";break;case 8:sXml="<!--"+oNode.nodevalue+"-->";break;case 9:for(var i=0;i<oNode.childNodes.length;i++){sXml+=this.serializeToString(oNode.childNodes[i]);}break;};return sXml;}; 