-
Notifications
You must be signed in to change notification settings - Fork 0
/
parabola.html
122 lines (104 loc) · 3.53 KB
/
parabola.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
<!--
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://www.desmos.com/api/v1.1/calculator.js?apiKey=dcb31709b452b1cf9dc26972add0fda6">
</script>
<script language="javascript" type="text/javascript" src="fns.js">
</script>
</head>
<body>
<div id="calculator" style="width: 700px; height: 400px;"></div>
<script >
var elt = document.getElementById('calculator');
var calculator = Desmos.GraphingCalculator(elt);
calculator.setExpression({id:'graph1', latex:'(0,0)'});
</script>
</body>
</html>
-->
<html>
<head>
<meta charset="UTF-8">
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/p5.js"></script>
<script language="javascript" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.6.1/addons/p5.dom.js"></script>
<!-- <script language="javascript" type="text/javascript" src="fns.js"></script> -->
<script src="https://www.desmos.com/api/v1.1/calculator.js?apiKey=dcb31709b452b1cf9dc26972add0fda6">
</script>
</head>
<body>
<div id="calculator" style="width: 1200px; height: 600px;"></div>
<script >
var txt;
var cnt = 1;
function CSVToArray(strData, strDelimiter ){
strDelimiter = (strDelimiter || ",");
var objPattern = new RegExp(
(
// Delimiters.
"(\\" + strDelimiter + "|\\r?\\n|\\r|^)" +
// Quoted fields.
"(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" +
// Standard fields.
"([^\"\\" + strDelimiter + "\\r\\n]*))"
),
"gi"
);
var arrData = [[]];
var arrMatches = null;
while (arrMatches = objPattern.exec( strData )){
var strMatchedDelimiter = arrMatches[ 1 ];
if (
strMatchedDelimiter.length &&
strMatchedDelimiter !== strDelimiter
){
arrData.push( [] );
}
var strMatchedValue;
if (arrMatches[ 2 ]){
strMatchedValue = arrMatches[ 2 ].replace(
new RegExp( "\"\"", "g" ),
"\""
);
} else {
strMatchedValue = arrMatches[ 3 ];
}
arrData[ arrData.length - 1 ].push( strMatchedValue );
}
return(arrData);
}
function parse_and_display(data) {
arr = CSVToArray(data);
var i;
var fin = "";
for (i = 0; i < arr[0].length; i++) {
temp = '(' + (i+1) + ',' + arr[0][i] + ')';
fin += temp;
if (i!=arr[0].length-1)
fin += ','
}
// createP(fin);
cnt += 1
calculator.setExpression({id:'graph'+cnt, latex:fin});
}
function fileSelected(file) {
// window.alert(file.name + " " + file.size + " " + file.type);
if (file.type == "text") {
parse_and_display(file.data);
} else {
window.alert("I need a text file.");
}
// console.log(file);
}
function setup() {
noCanvas();
createFileInput(fileSelected);
}
var elt = document.getElementById('calculator');
var calculator = Desmos.GraphingCalculator(elt);
calculator.setExpression({id:'graph1', latex:txt});
</script>
</body>
</html>