JSXGraph & Kompress/Dekompress

Homepage JSXGraph (Uni Bayreuth)
Interactive Geometry, plotting, visualization
JSXGraph is a cross-browser library for interactive geometry, function plotting, charting, and data visualization in a web browser. It is implemented completely in JavaScript, does not rely on any other library, and uses SVG, VML, or canvas. JSXGraph is easy to embed and has a small footprint: less than 100 KByte if embedded in a web page. No plug-ins are required! Special care has been taken to optimize the performance.
JSXGraph supports multi-touch devices running iOS, Android, firefoxOS, Windows 8 (at least).
JSXGraph is developed at the Lehrstuhl für Mathematik und ihre Didaktik, University of Bayreuth, Germany.


JSXCompressor (Ist ein Extrakt aus JSXGraph zum Komprimieren/Dekomp mit JS)
Hier wird ein gz-File geladen und mit "JXG.decompress()" dekomprimiert und in das <pre>-Tag unten geschrieben:

  Das JS-Programm "jsxcompressor.min.js" wird mit dem  Online JavaScript beautifier lesbar gemacht
Der JS-Code zum Dekomp ist:
    function load_gz(fgz) {
      var areq = new XMLHttpRequest(); 
      areq.open("POST",fgz,true); //  true = asynchron,
      areq.responseType = "arraybuffer"; // Typ setzen auf binär
      areq.onload = function(e) { 
	var arbuf = areq.response;
	var cbuf = new Uint8Array(arbuf); // ein 'View' auf arbuf
	var b64 = encode(cbuf); 
	var decomp = JXG.decompress(b64);
	document.getElementById('pre_1').innerHTML = "Das File '"+fgz+"' decompressed:\n\n"+decomp;
      }
      areq.send();
    }
  
Umständlich ist nur das vorherige b64-encoding. Das läßt sich sicher umgehen, aber leider verstehe ich den Code nicht...
Ohne zusätzliches 'encode' geht folgende Variante (Matth. Ehmann, Uni Bayreuth)
    ...
    var cbuf = new Uint8Array(response); // ein 'View' auf arraybuffer
    var decomp = (new JXG.Util.Unzip(cbuf)).unzip()[0][0];
    ...