diff options
author | emkael <emkael@tlen.pl> | 2017-07-31 14:42:49 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2017-07-31 14:42:49 +0200 |
commit | e6c2b0521760d32ac3be5b5ca66b98f2c67046e4 (patch) | |
tree | dbf049de8438b976e9e3df140a305587e32228e0 /playoff.js | |
parent | 1a0d4323cd25b1653663013ca3183fb0b67a878e (diff) |
Customizable JS settings
Diffstat (limited to 'playoff.js')
-rw-r--r-- | playoff.js | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -16,6 +16,17 @@ var playoff = { ctx.stroke(); }, + loadSettings: function(canvas, defaults) { + for (var setting in defaults) { + var attr = 'data-' + setting.replace(/_/g, '-'); + var attr_value = canvas.getAttribute(attr); + if (attr_value) { + defaults[setting] = attr_value; + } + } + return defaults; + }, + run: function() { var boxes = document.getElementsByClassName('playoff_matchbox'); var lines = { @@ -37,6 +48,7 @@ var playoff = { } } var canvas = document.getElementById('playoff_canvas'); + this.settings = this.loadSettings(canvas, this.settings); var ctx = canvas.getContext('2d'); for (var type in lines) { ctx.strokeStyle = this.settings[type + '_colour']; |