Skip to content

Commit

Permalink
minor formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
paawak committed May 8, 2016
1 parent 80d2c95 commit 9186719
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions js/bhasha.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,18 @@ bhasha.indic.IndicEditor.prototype.replaceWithindicStrings = function(keyEvent)
var indicTextEditor = keyEvent.target;
var selectionStart = indicTextEditor.selectionStart;
var selectionEnd = indicTextEditor.selectionEnd;
var charTyped = keyEvent.charCode;
var indicString = indicStringMap[String.fromCharCode(charTyped)];
var charTyped = String.fromCharCode(keyEvent.charCode);
var indicString = indicStringMap[charTyped];
console.log("***selectionStart: " + selectionStart + ", selectionEnd: " + selectionEnd + ", charTyped: " + charTyped + ", indicString: " + indicString);
if (indicString) {

if (keyTypedHistory.length == 3) {
keyTypedHistory = "";
}

if (indicString) {
keyTypedHistory += charTyped;
console.log("replacing roman chars with indic chars");
console.log("keyTypedHistory: " + keyTypedHistory);
keyEvent.preventDefault();
var existingText = indicTextEditor.value;

Expand All @@ -51,16 +58,18 @@ bhasha.indic.IndicEditor.prototype.replaceWithindicStrings = function(keyEvent)
} else {
var textBeforeCaret = existingText.slice(0, selectionStart);
var textAfterCaret = existingText.slice(selectionEnd);
console.log("textBeforeCaret=" + textBeforeCaret);
console.log("textAfterCaret=" + textAfterCaret);
//console.log("textBeforeCaret=" + textBeforeCaret);
//console.log("textAfterCaret=" + textAfterCaret);
indicTextEditor.value = textBeforeCaret + indicString + textAfterCaret;
indicTextEditor.setSelectionRange(selectionStart + 1, selectionStart + 1);
}

}
} else {
keyTypedHistory = "";
}
};


var keyTypedHistory = "";


var indicStringMap = {
Expand Down

0 comments on commit 9186719

Please sign in to comment.