X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=www%2Fjs%2Fremoteglot.js;h=114aaad67da76db36e420590d9c0b7c417a98d3a;hp=3aeb4dbb4fe91ad8c3cd78048c1036d87972fcec;hb=86873d4101b0bcd4e96ae79a975279c65d889619;hpb=6f688bb3ec5d9a092f107b113e4516d6b859e139 diff --git a/www/js/remoteglot.js b/www/js/remoteglot.js index 3aeb4db..114aaad 100644 --- a/www/js/remoteglot.js +++ b/www/js/remoteglot.js @@ -1,3 +1,4 @@ +var board = []; var arrows = []; var arrow_targets = []; var occupied_by_arrows = []; @@ -85,10 +86,15 @@ var create_arrow = function(from_square, to_square, fg_color, line_width, arrow_ var to_col = to_square.charCodeAt(0) - "a1".charCodeAt(0); var to_row = to_square.charCodeAt(1) - "a1".charCodeAt(1); - var from_y = (7 - from_row)*49 + 25; - var to_y = (7 - to_row)*49 + 25; - var from_x = from_col*49 + 25; - var to_x = to_col*49 + 25; + var zoom_factor = $("#board").width() / 400.0; + line_width *= zoom_factor; + arrow_size *= zoom_factor; + + var square_width = Math.floor(($("#board").width() - 1) / 8); + var from_y = (7 - from_row + 0.5)*square_width + 1; + var to_y = (7 - to_row + 0.5)*square_width + 1; + var from_x = (from_col + 0.5)*square_width + 1; + var to_x = (to_col + 0.5)*square_width + 1; var dx = to_x - from_x; var dy = to_y - from_y; @@ -140,7 +146,8 @@ var create_arrow = function(from_square, to_square, fg_color, line_width, arrow_ ["Arrow", { cssClass:"l1arrow", location:1.0, - width: arrow_size, length: arrow_size, + width: arrow_size, + length: arrow_size, paintStyle:{ lineWidth:line_width, strokeStyle:"#000", @@ -241,16 +248,8 @@ var update_board = function(board, data) { headline += '… '; } headline += data.position.last_move; - if (data.id.name) { - headline += ', '; - } } - if (data.id.name) { - headline += ' by ' + data.id.name; // + ':'; - } else { - //headline += ':'; - } $("#headline").text(headline); // The score. @@ -386,7 +385,7 @@ var update_board = function(board, data) { var init = function() { // Create board. - var board = new ChessBoard('board', 'start'); + board = new ChessBoard('board', 'start'); request_update(board, 1);