-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
executable file
·274 lines (201 loc) · 5.38 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="div.css">
<title>Diggs Graph</title>
<script type="text/javascript" language="javascript" src="jquery-3.2.1.js"></script>
<script type="text/javascript" language="javascript" src="jquery.flot.js"></script>
</head>
<body>
<input type="text" id="fileUpload">
<button id="removebtn" type="button" onclick="loadXMLDoc()">Get Data</button>
<script >
function loadXMLDoc()
{
var filePath = document.getElementById("fileUpload").value;
// allen added to see what the file name is that is being accessed?
alert(document.getElementById("fileUpload").value)
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
alert(this.readyState + " " + this.status)
if (this.readyState == 4 && this.status == 200) {
myFunction(this);
}
};
// filePath.toString;
xmlhttp.open("GET", filePath, true);
xmlhttp.send();
//alert(err);
// document.getElementById("removebtn").remove();
}
function myFunction(xml) { //processes the file to get "percentPassing" and "particleSize"
try{ //trys to process the file
alert("hi");
var i;
var xmlDoc = xml.responseXML;
var x = xmlDoc.getElementsByTagName("procedure");
var data =new Array (x.length);
for (i = 0; i <x.length; i++) {
var testdata = [];
var j;
//document.getElementById("demo").innerHTML = x[i].getElementsByTagName("percentPassing").length;
for (j=0;j<x[i].getElementsByTagName("percentPassing").length;j++){
var passing=x[i].getElementsByTagName("percentPassing")[j].childNodes[0].nodeValue;
var size=x[i].getElementsByTagName("particleSize")[j].childNodes[0].nodeValue;
testdata.push(size,passing);
}
var temp=new Array(testdata.length/2);
var j;
var k=0;
for (j=0;k<temp.length;j++){
temp[k]=[testdata[j],testdata[j+1]];
k++;
j++
//alert (k);
}
data[i]=new Array();
for (j=0;j<temp.length;j++){
data[i][j]=temp[j];
//alert(data[i][j]);
}
}
//alert(data[11][0]);
$(function() {
//var options1 = {
//lines: { show: true },
//xaxis: { ticks: [0.001,0.01,0.1,1,10,100],
//transform: Function("v","return v == 0 ? Math.log("+Math.pow(10,0)+") : Math.log(v);"), tickDecimals: 3 },
// grid: { hoverable: true, clickable: true , color: "#999"}
// };
var datasets;
datasets = {
0: {
label: "0" ,
data: data[0]
},
1: {
label: 1 ,
data: data[1]
} ,
2: {
label: 2 ,
data: data[2]
} ,
3: {
label: 3 ,
data: data[3]
} ,
4: {
label: 4 ,
data: data[4]
} ,
5: {
label: 5 ,
data: data[5]
},
6: {
label: 6 ,
data: data[6]
},
7: {
label: 7 ,
data: data[7]
},
8: {
label: 8 ,
data: data[8]
},
9: {
label: 9 ,
data: data[9]
},
10: {
label: 10 ,
data: data[10]
},
11: {
label: 11 ,
data: data[11]
}
};
// hard-code color indices to prevent them from shifting as
// countries are turned on/off
var q = 0;
$.each(datasets, function(key, val) {
val.color = q;
++q;
});
// insert checkboxes
var choiceContainer = $("#choices");
$.each(datasets, function(key, val) {
choiceContainer.append("<br/><input type='checkbox' name='" + key +
"' checked='checked' id='id" + key + "'></input>" +
"<label for='id" + key + "'>"
+ val.label + "</label>");
});
choiceContainer.find("input").click(plotAccordingToChoices);
function plotAccordingToChoices() {
var table="<th>Size(mm),Passing(%)</th>";
var data2 = [];
choiceContainer.find("input:checked").each(function () {
var key = $(this).attr("name");
if (key && datasets[key])
{
data2.push(datasets[key]);
table += "<tr><td>" + "Data Set " + key + "</td>";
for (i = 0; i<data[key].length; i++)
{
table += "<td>" +
data[key][i] +
"</td>";
document.getElementById("myTable").innerHTML = table;
}
table += "</tr>";
}
});
if (data2.length > 0) {
$.plot("#placeholder", data2, {
yaxis: {
max:100
},
xaxis:
{
// min: 0,
ticks: [0.0001,0.001,0.01,0.1,1,10,100,1000],
transform: function(v) {return Math.log(v+0.0001); /*move away from zero*/} ,
tickDecimals: 4 ,
tickFormatter: function (v, axis) {return "10" + (Math.round( Math.log(v)/Math.LN10)).toString().sup();}
}
//grid: { hoverable: true, clickable: true , color: "#999"}
});
}
}
plotAccordingToChoices();
// Add the Flot version string to the footer
$("#footer").prepend("Flot " + $.plot.version + " – ");
});
}
catch (err){ //returns any cases of error
alert(err.message);
}
}
</script>
<!--<p id="demo"></p>-->
<div id="" style="overflow-x: auto; width:1027px; margin-left: auto ; margin-right: auto ;">
<table id="myTable"></table>
</div>
<br>
<table id="content">
<td>
<div>
<div id="placeholder"></div>
</div>
</td>
<td id="choices"></td>
</table>
<br><br>
<div id="footer">
Copyright © 2007 - 2014 IOLA and Ole Laursen, page by Tom Cadden
</div>
</body>
</html>