-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBCScript.js
More file actions
74 lines (51 loc) · 1.55 KB
/
BCScript.js
File metadata and controls
74 lines (51 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
function addChar(C){
document.form.textview.value = document.form.textview.value+C
}
function compute(){
var exp = document.form.textview.value;
if(exp){
document.form.textview.value = stringMath(exp)
}
}
function removeAllChar(){
document.form.textview.value = "";
}
function removeOneChar(){
var exp = document.form.textview.value;
if(exp){
document.form.textview.value = exp.substring(0, exp.length-1);
}
}
function dispChar(e){
if(e.keyCode==13){
compute();
return false;
}
}
function convert(){
var liste, from_unit, to_unit, subject;
liste = document.getElementById("from");
from_unit = liste.options[liste.selectedIndex].text;
liste = document.getElementById("to");
to_unit = liste.options[liste.selectedIndex].text;
liste = document.getElementById("subject");
subject = liste.options[liste.selectedIndex].text;
document.form.textview.value = conversionObject.functions.converter(subject, from_unit, to_unit, document.form.textview.value);
}
function setSubject(){
var liste, subject;
liste = document.getElementById("subject");
subject = liste.options[liste.selectedIndex].text;
setSelectChoices(subject)
}
function setSelectChoices(subject){
var liste_from, liste_to
liste_from = document.getElementById("from");
liste_to = document.getElementById("to");
liste_from.options.length = 0;
liste_to.options.length = 0;
for (var key in conversionObject.master[subject]){
liste_from.options[liste_from.length] = new Option(key,key);
liste_to.options[liste_to.length] = new Option(key,key);
}
}