

/*vujava.js [optional]
* this file is part of the VIETUNI typing tool 
* by Tran Anh Tuan [tuan@physik.hu-berlin.de]
* Copyright (c) 2001, 2002 AVYS e.V.. All Rights Reserved.
*/                                             

// interface for java textarea
// vietuni act as a typing engine serving java applets to accept Viet input

var client= null;

if (typeof(initTyper) != 'undefined') {
  initTyper = jvInitTyper;
  servjava= 1;
}

function CJavaArea(txtarea, applet) {
  this.editor= applet; 
  this.txtarea= txtarea;
  this.vietarea= true;
  this.onkeypress= vietTyping;
  this.getCurrentWord= function(){ return ""+this.editor.getCurrentWord(); }
  this.replaceWord= function(newwd){ this.editor.replaceWord(newwd); }
  this.onChange= function(){ this.txtarea.doUpdate(); } 
  return this;
}

function javaAreaOnChange() { client.onChange(); }

function javaAreaKeyPress(evt) { client.onkeypress(""+evt); }

function jvInitTyper(txtarea, applet) {
  txtarea.onkeyup= null;
  if (client) return;
  client= new CJavaArea(txtarea, applet);
  txtarea.dosync= 1;
  txtarea.onchange= function(){
    if (this.dosync) client.editor.setText(this.value);
    return true;
  }
  txtarea.doUpdate= function(){
    this.dosync= 0;
    this.value= ""+client.editor.getText();
    this.dosync= 1;
    return true;
  }
  if(!theTyper) theTyper = new CVietString("");
  client.editor.activate();
}

// end vujava.js


