Skip to content

Commit

Permalink
add configuration environment variable WBO_MAX_BOARD_SIZE_X to give m…
Browse files Browse the repository at this point in the history
…aximum width of board (closes lovasoa#118)
  • Loading branch information
droundy committed Sep 24, 2020
1 parent eab4370 commit 4fd733d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client-data/js/board.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,11 @@ function updateDocumentTitle() {
function resizeCanvas(m) {
//Enlarge the canvas whenever something is drawn near its border
var x = m.x | 0, y = m.y | 0
var MAX_BOARD_SIZE = 65536; // Maximum value for any x or y on the board
if (x > Tools.svg.width.baseVal.value - 2000) {
Tools.svg.width.baseVal.value = Math.min(x + 2000, MAX_BOARD_SIZE);
Tools.svg.width.baseVal.value = Math.min(x + 2000, Tools.server_config.MAX_BOARD_SIZE_X);
}
if (y > Tools.svg.height.baseVal.value - 2000) {
Tools.svg.height.baseVal.value = Math.min(y + 2000, MAX_BOARD_SIZE);
Tools.svg.height.baseVal.value = Math.min(y + 2000, Tools.server_config.MAX_BOARD_SIZE);
}
}

Expand All @@ -436,6 +435,7 @@ var scaleTimeout = null;
Tools.setScale = function setScale(scale) {
if (isNaN(scale)) scale = 1;
scale = Math.max(0.1, Math.min(10, scale));
scale = Math.min(scale, document.documentElement.clientWidth/Tools.server_config.MAX_BOARD_SIZE_X);
Tools.svg.style.willChange = 'transform';
Tools.svg.style.transform = 'scale(' + scale + ')';
clearTimeout(scaleTimeout);
Expand Down
1 change: 1 addition & 0 deletions server/client_configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const config = require("./configuration");
/** Settings that should be handed through to the clients */
module.exports = {
"MAX_BOARD_SIZE": config.MAX_BOARD_SIZE,
"MAX_BOARD_SIZE_X": config.MAX_BOARD_SIZE_X,
"MAX_EMIT_COUNT": config.MAX_EMIT_COUNT,
"MAX_EMIT_COUNT_PERIOD": config.MAX_EMIT_COUNT_PERIOD,
"BLOCKED_TOOLS": config.BLOCKED_TOOLS,
Expand Down
3 changes: 3 additions & 0 deletions server/configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ module.exports = {
/** Maximum value for any x or y on the board */
MAX_BOARD_SIZE: parseInt(process.env['WBO_MAX_BOARD_SIZE']) || 65536,

/** Maximum value for any x on the board */
MAX_BOARD_SIZE_X: parseInt(process.env['WBO_MAX_BOARD_SIZE_X']) || parseInt(process.env['WBO_MAX_BOARD_SIZE']) || 65536,

/** Maximum messages per user over the given time period before banning them */
MAX_EMIT_COUNT: parseInt(process.env['WBO_MAX_EMIT_COUNT']) || 192,

Expand Down

0 comments on commit 4fd733d

Please sign in to comment.