Permalink
Browse files

fixes for IE

  • Loading branch information...
1 parent ccef777 commit be8d91fd41964689f10eeaeff3a15df2780f16af @Brucer Brucer committed Jul 20, 2011
Showing with 24 additions and 15 deletions.
  1. +10 −8 chess/chess.js
  2. +7 −2 chess/pieces.js
  3. +2 −2 engine/core/dom_render.js
  4. +5 −3 engine/core/input.js
View
@@ -208,14 +208,16 @@ var Chess = (function() {
function init() {
cache = window.applicationCache;
- cache.addEventListener('checking', checking, false);
- cache.addEventListener('error', cacheError, false);
- cache.addEventListener('update', function(e) { sup(e,3); }, false);
- cache.addEventListener('noupdate', noUpdate, false);
- cache.addEventListener('downloading', function(e) { sup(e,4); }, false);
- cache.addEventListener('progress', loading, false);
- cache.addEventListener('updateready', updateReady, false);
- cache.addEventListener('cached', cached, false);
+ if (cache) {
+ cache.addEventListener('checking', checking, false);
+ cache.addEventListener('error', cacheError, false);
+ cache.addEventListener('update', function(e) { sup(e,3); }, false);
+ cache.addEventListener('noupdate', noUpdate, false);
+ cache.addEventListener('downloading', function(e) { sup(e,4); }, false);
+ cache.addEventListener('progress', loading, false);
+ cache.addEventListener('updateready', updateReady, false);
+ cache.addEventListener('cached', cached, false);
+ }
GameFrame.updateSettings({
render_mode: GameFrame.HTML_ONLY,
View
@@ -80,8 +80,10 @@ var Pieces = (function() {
var square, sprite;
for (var i=0,len=positions.length;i<len;i++) {
var piece = positions[i];
- square = Board.getSquare(piece[2],piece[3]);
- addPieceGob(square, piece[0], piece[1], 0);
+ if (piece) {
+ square = Board.getSquare(piece[2],piece[3]);
+ addPieceGob(square, piece[0], piece[1], 0);
+ }
}
}
@@ -443,6 +445,9 @@ var Pieces = (function() {
function select(x,y) {
var pos = Board.nearestSquare(x,y);
var square = Board.getSquare(pos[0],pos[1]);
+ if (!square) {
+ return;
+ }
if (!selected) {
if (square.piece && square.piece.color == Board.toMove()) {
if (possibleMoves(square.i,square.j,square.piece)) {
@@ -186,8 +186,8 @@ var DomRender = (function() {
switch (Browser.browser) {
case Browser.IE:
- dstyle.left = pos[0] + 'px';
- dstyle.top = pos[1] + 'px';
+ dstyle.left = (pos[0]+domel.clientWidth*0.5 - scale*domel.clientWidth*0.5) + 'px';
+ dstyle.top = (pos[1]+domel.clientHeight*0.5 - scale*domel.clientHeight*0.5) + 'px';
dstyle.filter = 'progid:DXImageTransform.Microsoft.Matrix(M11=\'' +
ct*scale + '\',M12=\'' + nst*scale + '\',M21=\'' + st*scale + '\',M22=\'' + ct*scale +
'\',sizingMethod=\'auto expand\')';
View
@@ -46,7 +46,7 @@ var Input = (function() {
button = 1;
}
- var pos = GameFrame.page2view([event.pageX, event.pageY]);
+ var pos = GameFrame.page2view([event.pageX||event.clientX, event.pageY||event.clientY]);
var px = pos[0];
var py = pos[1];
@@ -91,7 +91,9 @@ var Input = (function() {
}
function keyPress(event, down) {
- var code = event.which;
+ event = event || window.event;
+ var code = event.which || event.keyCode;
+
var return_value = true;
Input.key_state[code] = down;
if (code == 27) {
@@ -228,7 +230,7 @@ var Input = (function() {
el['onkeydown'] = function(event) {return keyPress(event, 1)};
- if (Browser.FIREFOX) {
+ if (0 && Browser.FIREFOX) {
document.onkeyup = function(event) {return keyPress(event, 0)};
document.onkeydown = function(event) {return keyPress(event, 1)};
}

0 comments on commit be8d91f

Please sign in to comment.