Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Start putting in the framework for developing the javascript kernel
  • Loading branch information
sorear committed Aug 16, 2012
1 parent c86e8e5 commit 7832503
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
9 changes: 9 additions & 0 deletions 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>
39 changes: 39 additions & 0 deletions 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;

})();

0 comments on commit 7832503

Please sign in to comment.