Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Start putting in the framework for developing the javascript kernel

  • Loading branch information...
commit 7832503579f87128865f26581513deb12d24892a 1 parent c86e8e5
@sorear authored
Showing with 48 additions and 0 deletions.
  1. +9 −0 js/index.html
  2. +39 −0 js/niecza.js
View
9 js/index.html
@@ -0,0 +1,9 @@
+<html>
+ <head>
+ <title>Niecza/JS test harness</title>
+ <script src="niecza.js"></script>
+ <script>Niecza.Serialization.loadSerFile('CORE.ser', function(){});</script>
+ </head>
+ <body>
+ </body>
+</html>
View
39 js/niecza.js
@@ -0,0 +1,39 @@
+// This will be moved to m4 later
+
+(function() {
+
+var Niecza = {};
+
+var NSer = Niecza.Serialization = {};
+
+var NSThaw = Niecza.Serialization.Thaw = function (buffer, callback) {
+ this.buffer = buffer;
+ this.view = new DataView(buffer);
+ this.offset = 0;
+};
+
+NSThaw.prototype.$className = 'Niecza.Serialization.Thaw';
+
+
+NSer.loadSerFileEnd = function(ev) {
+ var xhr = ev.target,
+ cb = xhr.nieczaCallback;
+ if (xhr.status >= 200 && xhr.status < 300) {
+ new NSThaw(xhr.response, cb);
+ } else {
+ cb(false, xhr.statusText, xhr);
+ }
+};
+
+NSer.loadSerFile = function (url, callback) {
+ var xhr = new XMLHttpRequest();
+ xhr.responseType = 'arraybuffer';
+ xhr.onloadend = NSer.loadSerFileEnd;
+ xhr.nieczaCallback = callback;
+ xhr.open('GET', url);
+ xhr.send(null);
+};
+
+window.Niecza = Niecza;
+
+})();
Please sign in to comment.
Something went wrong with that request. Please try again.