Team:Heidelberg/Templates/Awesomesheet

From 2014.igem.org

(Difference between revisions)
m
m
Line 6: Line 6:
</style>
</style>
<script type='text/javascript'>
<script type='text/javascript'>
 +
    /**
 +
      * Converts an array buffer to a string
 +
      *
 +
      * @private
 +
      * @param {ArrayBuffer} buf The buffer to convert
 +
      * @param {Function} callback The function to call when conversion is complete
 +
      * NOTE: Quite inefficient for small data...
 +
      */
 +
    function _arrayBufferToString(buf, callback) {
 +
      var bb = new Blob([new Uint8Array(buf)]);
 +
      var f = new FileReader();
 +
      f.onload = function(e) {
 +
callback(e.target.result);
 +
      };
 +
      f.readAsText(bb);
 +
    }
 +
     var _load_unzip_format_and_insert = function(src, id) {
     var _load_unzip_format_and_insert = function(src, id) {
       // load zip file from src, unzip and format it to text
       // load zip file from src, unzip and format it to text
Line 20: Line 37:
  var gunzip = new Zlib.Gunzip(byteArray);
  var gunzip = new Zlib.Gunzip(byteArray);
  var plain = gunzip.decompress();
  var plain = gunzip.decompress();
-
  var filltext = String.fromCharCode(plain);
+
  _arrayBufferToString(plain, function(r){$(id).append(r)});
-
  $(id).append(filltext);
+
}
}
       };
       };

Revision as of 21:18, 17 October 2014