Skip to content

Commit

Permalink
Select version in web app
Browse files Browse the repository at this point in the history
  • Loading branch information
dhoepelman committed Sep 11, 2015
1 parent 7e17bcb commit 07d656b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 8 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*.config eol=crlf
*.md eol=lf

*.html eol=lf
*.css eol=lf

###############################################################################
# Set default behavior for command prompt diff.
#
Expand Down
4 changes: 2 additions & 2 deletions app/XLParser.Web/Default.aspx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
<td><textarea cols="25" rows="1" id="formulainput"></textarea></td>
<td>
<select id="parserversionselected">
<option selected value="120">1.2.0</option>
<option selected value="120a">1.2.0a</option>
<option value="114">1.1.4</option>
<option value="113">1.1.3</option>
<option value="112">1.1.2</option>
<option value="100">1.0.0</option>
</select>
</td>
<td>
<button id="parsebutton" onclick="newTree(document.getElementById('formulainput').value)">Parse</button>
<button id="parsebutton" onclick="newTree(document.getElementById('formulainput').value, document.getElementById('parserversionselected').value)">Parse</button>
</td>
</tr>
</table>
Expand Down
2 changes: 1 addition & 1 deletion app/XLParser.Web/Parse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void ProcessRequest(HttpContext context)
context.Response.Cache.SetMaxAge(new TimeSpan(0, 0, 5));
}

// Dynamically load an library version
// Dynamically load a library version
var xlparserVersion = context.Request.Params["version"] ?? latestVersion;
if (!Regex.IsMatch(xlparserVersion, @"^[0-9]{3}[\-a-z0-9]*$"))
{
Expand Down
3 changes: 3 additions & 0 deletions app/XLParser.Web/XLParser Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
<Content Include="xlparser\114.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="xlparser\120a.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Compile Include="Default.aspx.cs">
Expand Down
11 changes: 6 additions & 5 deletions app/XLParser.Web/d3vizsvg.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var default_formula = "SUM(B5,2)";
var latestVersion = "120a";

var margin = { top: 20, right: 20, bottom: 20, left: 20 },
width = 500 - margin.right - margin.left,
Expand All @@ -14,9 +15,11 @@ var diagonal = d3.svg.diagonal()
var vis;

// Replace the existing parse tree image with a new one
function newTree(formula) {
function newTree(formula, version) {
var encodedFormula = encodeURIComponent(formula);
var url = "Parse.json?formula=" + encodedFormula;
var url = "Parse.json?version=" + version + "&formula=" + encodedFormula;

d3.select("#d3viz").html("");

// Request the JSON parse tree
d3.json(url, function (request, json) {
Expand All @@ -37,8 +40,6 @@ function newTree(formula) {
tree = d3.layout.tree().size([w, h]);
i = 0;

d3.select("#d3viz").html("");

var svg = d3.select("#d3viz")
.append("svg")
.attr("id", "dynamicSVGParsetree")
Expand Down Expand Up @@ -91,7 +92,7 @@ function newTree(formula) {
}

// Set the parse tree image to the default formula and enter it in the formula input field
newTree(default_formula);
newTree(default_formula, latestVersion);
d3.select('#formulainput').text(default_formula);

// Create nodes in the parse tree
Expand Down

0 comments on commit 07d656b

Please sign in to comment.