Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Commit

Permalink
fixes for IE
Browse files Browse the repository at this point in the history
  • Loading branch information
Brucer committed Jul 20, 2011
1 parent ccef777 commit be8d91f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 15 deletions.
18 changes: 10 additions & 8 deletions chess/chess.js
Expand Up @@ -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,
Expand Down
9 changes: 7 additions & 2 deletions chess/pieces.js
Expand Up @@ -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);
}
}
}

Expand Down Expand Up @@ -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)) {
Expand Down
4 changes: 2 additions & 2 deletions engine/core/dom_render.js
Expand Up @@ -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\')';
Expand Down
8 changes: 5 additions & 3 deletions engine/core/input.js
Expand Up @@ -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];

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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)};
}
Expand Down

0 comments on commit be8d91f

Please sign in to comment.