summaryrefslogtreecommitdiff
path: root/playoff.js
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-07-31 14:42:49 +0200
committeremkael <emkael@tlen.pl>2017-07-31 14:42:49 +0200
commite6c2b0521760d32ac3be5b5ca66b98f2c67046e4 (patch)
treedbf049de8438b976e9e3df140a305587e32228e0 /playoff.js
parent1a0d4323cd25b1653663013ca3183fb0b67a878e (diff)
Customizable JS settings
Diffstat (limited to 'playoff.js')
-rw-r--r--playoff.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/playoff.js b/playoff.js
index 3e01e97..1763d59 100644
--- a/playoff.js
+++ b/playoff.js
@@ -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'];