-
Notifications
You must be signed in to change notification settings - Fork 10
/
example-api-save-state.html
60 lines (51 loc) · 2.64 KB
/
example-api-save-state.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
<!DOCTYPE html>
<html>
<head>
<title>Saving and Loading</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="navigation.js"></script>
</head>
<body>
<div class="contentBox" id="contentBox">
<h1>Saving and Loading using API</h1>
<p class="text"><br>GeoGebra resources can be saved into and loaded from
<a class="inlineLink" href="https://en.wikipedia.org/wiki/Base64">Base64</a> format.</p>
<script type="text/javascript" src="https://www.geogebra.org/apps/deployggb.js"></script>
<script type="text/javascript">
var parameters = {
"width":550,
"height":245,
"showToolBar":false,
"borderColor":null,
"showMenuBar":false,
"showAlgebraInput":false,
"customToolbar":"0 || 1",
"showResetIcon":true,
"enableLabelDrags":false,
"enableShiftDragZoom":true,
"enableRightClick":false,
"capturingThreshold":null,
"showToolBarHelp":true,
"errorDialogsActive":true,
"useBrowserForJS":false,
"material_id":"ztq4xfyj"};
var applet = new GGBApplet(parameters,true);
// when used with Math Apps Bundle, uncomment this:
// applet.setHTML5Codebase('GeoGebra/HTML5/5.0/web/');
window.onload = function() { applet.inject('applet_container'); }
function saveGgbFile(){ ggbApplet.getBase64(function(b){document.getElementById("Base64").value = b}); }
function loadGgbFile(){ ggbApplet.setBase64(document.getElementById("Base64").value); }
</script>
<div id="applet_container"></div>
<p class="text"><br>
Move points A, B, C and press <b>Save</b>. Then move the points again. <br>Press <b>Load</b> to load the previously saved construction.
</p>
<p>
<a class="appBtn noimage blue" href="javascript:saveGgbFile()">Save</a>
<a class="appBtn noimage blue" href="javascript:loadGgbFile()">Load</a>
</p>
<p class="text">To make this example self-contained, saving to a server was replaced by a textfield below. <br>In a real setting, the content of the following textfield will be stored in a database or file on the server:</p>
<textarea name="Base64" id="Base64" class="inputfield" cols=75 rows=8></textarea>
</div>
</body>
</html>