events and audio in shell replay

This commit is contained in:
Alon Zakai 2012-09-12 14:31:52 -07:00
Родитель 97bee9986d
Коммит 341ea63b6f
1 изменённых файлов: 26 добавлений и 3 удалений

Просмотреть файл

@ -172,6 +172,20 @@ if (typeof nagivator == 'undefined') {
};
var setTimeout = window.setTimeout;
var document = {
eventListeners: {},
addEventListener: function(id, func) {
var listeners = document.eventListeners[id];
if (!listeners) {
listeners = document.eventListeners[id] = [];
}
listeners.push(func);
},
callEventListeners: function(id) {
var listeners = document.eventListeners[id];
if (listeners) {
listeners.forEach(function(listener) { listener() });
}
},
getElementById: function(id) {
switch(id) {
case 'canvas': {
@ -181,19 +195,25 @@ if (typeof nagivator == 'undefined') {
case 'experimental-webgl': {
return {
getExtension: function() { return 1 },
requestPointerLock: function() {
throw 'pointerLock';
},
};
}
default: throw 'canvas.getContext: ' + which;
}
},
requestPointerLock: function() {
document.callEventListeners('pointerlockchange');
},
};
}
default: throw 'getElementById: ' + id;
}
},
createElement: function(what) {
switch (what) {
case 'canvas': return document.getElementById(what);
default: throw 'createElement ' + what;
}
},
querySelector: function() {
return {
classList: {
@ -244,6 +264,9 @@ if (typeof nagivator == 'undefined') {
},
};
};
var Audio = function() {
return { play: function(){} };
};
}
var Recorder = (function() {