<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>保存和还原GGB文件</title>
</head>
<body>
<button id="save">保存</button>
<button id="restore">还原</button>
<div id="applet"></div>
<textarea readonly placeholder="保存后将显示内容"></textarea>
<script src="http://cdn.bootcss.com/zepto/1.2.0/zepto.min.js"></script>
<script src="../GeoGebra/deployggb.js"></script>
<script>
  var base64;
  var applet = new GGBApplet({ showToolbar: true, width: 500, height: 400 });
  applet.setHTML5Codebase('../GeoGebra/HTML5/5.0/web/', true);
  window.onload = function() {
    applet.inject('applet', 'html5');
  };
  $('#save').click(function() {
    ggbApplet.getBase64(function(content) {
      base64 = content;
      $('textarea').text(content);
    });
  });
  $('#restore').click(function() {
    if (base64) {
      ggbApplet.setBase64(base64);
    }
  });
</script>
</body>
</html>