/** * JS for Translations Component * @copyright Copyright (C) 2007 Ifan Evans. All rights reserved. * @license GNU/GPL */ /** * ffAutoCorrect * Dynamically change user input in a form field by checking the last characters of the field * against a list of keys held in 'ffacList' and replacing them with the corresponding value * eg: ffacList[a^]=â * there's a one second delay on the replacement * set ffacList outside the function * call the function using onkeyup="ffAutoCorrect(this)" */ var ffacElement; var ffacList = new Array(); var ffacOldName = ''; var ffacOldValue = ''; function ffAutoCorrect(element) { // initialise variables on first call, then timeout for one second if (typeof(element) == 'object') { ffacElement = element; element = null; ffacOldName = ffacElement.name; ffacOldValue = ffacElement.value; setTimeout("ffAutoCorrect()",1000); } // process on second call, only if name and value are unchanged else if ( (ffacElement.name == ffacOldName) && (ffacElement.value == ffacOldValue) ) { // get element length el = ffacElement.value.length; // process the AutoCorrect List for (s in ffacList) { // skip non-strings if ( typeof(ffacList[s]) != "string" ) continue; // get search string length sl = s.length; // check element is at least as long as search string if (el>=sl) { // check for matching string at end of element if ( ffacElement.value.slice(el-sl) == s ) { // replace matching string ffacElement.value = ffacElement.value.slice(0,el-sl) + ffacList[s]; // return after making the replacement return; } } } } } /** * ffAppendRow * Append a row (src) to the end of a table (table) */ function ffAppendRow(table,src) { if ( document.getElementById(table) && document.getElementById(src) ) { // add new row at end of table var newTR = document.getElementById(table).insertRow(-1); // IE won't let us set the innerHTML of a row object, we need to copy the cells and their properties from the source var cells = document.getElementById(src).cells; var props = new Array('width','align','valign','colSpan','innerHTML','className'); for(var td=0;td