-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcalculator.html
45 lines (44 loc) · 1.6 KB
/
calculator.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
<!DOCTYPE html>
<html>
<head>
<title>Calculator!</title>
<script src="https://www.desmos.com/api/v0.9/calculator.js?apiKey=dcb31709b452b1cf9dc26972add0fda6"></script>
<style>
#calculator { width:500px; height: 400px; }
</style>
</head>
<body>
<div id="calculator"></div>
</body>
<!-- Tail-loading Scripts -->
<script>
// Get the arguments from the url string
var url_arguments = window.location.search.substring(1);
//console.log(url_arguments);
// Get the element on the page that we are going to insert the calculator into
var calculator_div = document.getElementById('calculator');
// Parse the calculator type, and based on this, load the appropriate type.
// From https://css-tricks.com/snippets/javascript/get-url-variables/
function getQueryVariable(variable, query)
{
// var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable) {
return pair[1];
}
}
return(false);
}
// Main parsing of arguments
calculator_type = getQueryVariable("type", url_arguments);
// Load applicable calculator based off of query type.
if ( calculator_type == "Basic" ) {
var calculator = Desmos.FourFunctionCalculator(calculator_div);
} else if ( calculator_type == "Scientific" ) {
var calculator = Desmos.ScientificCalculator(calculator_div);
}
//console.log(Desmos.enabledFeatures);
</script>
</html>