partial fix for https://sourceforge.net/tracker/?func=detail&aid=2788651&group_id=176962&atid=955896
This commit is contained in:
parent
3e7330cc2b
commit
82347ac0da
|
@ -1,12 +1,12 @@
|
||||||
|
|
||||||
function Calc()
|
function Calc()
|
||||||
{
|
{
|
||||||
this.validate = validate;
|
this.validate = validate;
|
||||||
this.clear = clear;
|
this.clear = clear;
|
||||||
this.clearAll = clearAll;
|
this.clearAll = clearAll;
|
||||||
this.evaluate = evaluate;
|
this.evaluate = evaluate;
|
||||||
this.append = append;
|
this.append = append;
|
||||||
|
|
||||||
function validate(displayTextId, calcTextId, integral, separatorKey, e)
|
function validate(displayTextId, calcTextId, integral, separatorKey, e)
|
||||||
{
|
{
|
||||||
var key;
|
var key;
|
||||||
|
@ -15,14 +15,14 @@ function Calc()
|
||||||
key = e.keyCode; //IE
|
key = e.keyCode; //IE
|
||||||
else
|
else
|
||||||
key = e.which; //Firefox
|
key = e.which; //Firefox
|
||||||
|
|
||||||
if(key == 13 || key == 61) // Enter, =
|
if(key == 13 || key == 61) // Enter, =
|
||||||
{
|
{
|
||||||
evaluate(displayTextId, calcTextId);
|
evaluate(displayTextId, calcTextId);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (key == 0) // control, delete, ...
|
else if (key == 0) // control, delete, ...
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (key == 8) // backspace
|
else if (key == 8) // backspace
|
||||||
|
@ -30,10 +30,10 @@ function Calc()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (key >= 17 && key <= 20) // Control
|
else if (key >= 17 && key <= 20) // Control
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (key == 32) // space
|
else if (key == 32) // space
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ function Calc()
|
||||||
}
|
}
|
||||||
else if (key == 42 || key == 43 || key == 45 || key == 47) // *, +, -, /
|
else if (key == 42 || key == 43 || key == 45 || key == 47) // *, +, -, /
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ( key == separatorKey && !integral)
|
else if ( key == separatorKey && !integral)
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ function Calc()
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearAll(calcTextId)
|
function clearAll(calcTextId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -66,7 +66,7 @@ function Calc()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clear(calcTextId)
|
function clear(calcTextId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -82,9 +82,9 @@ function Calc()
|
||||||
catch (err)
|
catch (err)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function evaluate(displayTextId, calcTextId, separator)
|
function evaluate(displayTextId, calcTextId, separator)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -102,19 +102,20 @@ function Calc()
|
||||||
result = result.replace(/\./, separator);
|
result = result.replace(/\./, separator);
|
||||||
}
|
}
|
||||||
calcText.value = result;
|
calcText.value = result;
|
||||||
|
|
||||||
var displayText = document.getElementById(displayTextId);
|
var displayText = document.getElementById(displayTextId);
|
||||||
|
|
||||||
if (!displayText.readOnly && calcText.value != 'undefined')
|
if (!displayText.readOnly && calcText.value != 'undefined')
|
||||||
{
|
{
|
||||||
displayText.value = calcText.value;
|
displayText.value = calcText.value;
|
||||||
|
setTimeout("document.getElementById('" + displayTextId + "').focus()", 100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (err)
|
catch (err)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function append(calcTextId, val)
|
function append(calcTextId, val)
|
||||||
{
|
{
|
||||||
var calcText = document.getElementById(calcTextId);
|
var calcText = document.getElementById(calcTextId);
|
||||||
|
|
Loading…
Reference in New Issue