-
Notifications
You must be signed in to change notification settings - Fork 101
/
index.html
111 lines (91 loc) · 3.63 KB
/
index.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<!doctype html>
<head>
<meta charset="utf-8">
<title>Test - Online Excel Formula Beautifier</title>
<style type="text/css">/*<![CDATA[*/
#formula_input{width:90%}
/*]]>*/</style>
<!--[if gte IE 9]>
<style type="text/css">
.gradient {
filter: none;
}
</style>
<![endif]-->
</head>
<body>
<!-- Side Content -->
<div id="sideContent" class="span-6 last">
<p>
<label class="span-2" for="mode">Mode: </label>
<div class="span-4 last">
<select id="mode" class="span-4 last" onchange="window.beautifier.changeMode_update(this.value)">
<option value="beautify">Beautify</option>
<option value="js" selected="selected">Formula to JavaScript</option>
</select>
</div>
</p>
</div>
<!-- Main Content -->
<div id="container" class="span-12 colborder">
<div id="main" role="main" class="span-12 last">
<div id="inputArea">
<label for="formula_input">Enter your formula here. The leading = is optional.</label><br />
<input type="text" id="formula_input" onkeyup="window.beautifier.txtFormula_Update()" />
</div>
<div class="formula">
<!--h2>excelFormulaUtilities.formatFormulaHTML( "<span id="fomatFormula_2"></span>" );</h2-->
<pre id="fomatFormula_2_out"></pre>
</div>
</div>
</div>
<script src="src/core.js"></script>
<script src="src/ExcelFormulaUtilities.js"></script>
<script type="text/javascript">
/*<![CDATA[*/
(function(){
var MODE_BEAUTIFY = "beautify"
,MODE_JS = "js"
, txtFormula
, formulaOut
, selMode
, trim = window.excelFormulaUtilities.string.trim;
window.beautifier = {}
// Convert the input fields text to the out
function convertFormula( inputElement, outputElement, mode ) {
switch(mode){
case MODE_BEAUTIFY:
try{
outputElement.innerHTML = excelFormulaUtilities.formatFormula( trim(inputElement.value) );
outputElement.style.background = "transparent";
} catch (ex){
outputElement.style.background = "red";
}
break;
case MODE_JS:
try{
outputElement.innerHTML = excelFormulaUtilities.formula2JavaScript( trim(inputElement.value) );
outputElement.style.background = "transparent";
} catch (ex){
outputElement.style.background = "red";
}
break;
}
}
window.onload = function(){
txtFormula = document.getElementById('formula_input'),
formulaOut = document.getElementById('fomatFormula_2_out');
selMode = document.getElementById('mode');
// Handle when the formula input changes value
window.beautifier.txtFormula_Update = function(){
convertFormula(txtFormula, formulaOut, selMode.value);
}
// Handle when the mode input changes value
window.beautifier.changeMode_update = function(){
}
}
}());
/*]]>*/
</script>
</body>
</html>