@first-lego-league/display
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -108,14 +108,3 @@ displaySystem.config({ | ||
}] | ||
}, | ||
'table': { | ||
visible: true, | ||
header: ['rank', 'NO.', 'name', 'best', '1', '2', '3'], | ||
data: [ | ||
['--', '--', ' ', '--', '--', '--', '--'], | ||
], | ||
timer: 10000, | ||
lines: 8 | ||
}, | ||
'css': { | ||
},'css': { | ||
href: [ | ||
@@ -133,2 +122,14 @@ 'themes/fll/flltable.css', | ||
}, | ||
'table': { | ||
visible: true, | ||
header: ['rank', 'NO.', 'name', 'best', '1', '2', '3'], | ||
data: [ | ||
['--', '--', ' ', '--', '--', '--', '--'], | ||
], | ||
timer: 5000, | ||
margins:{top:25,bottom:75}, | ||
lines: 12 | ||
}, | ||
'geometry': { | ||
@@ -135,0 +136,0 @@ zoom: 1, |
@@ -39,14 +39,2 @@ displaySystem.registerModule({ | ||
function handleButton(module, f, inputs) { | ||
return function() { | ||
var data = inputs.map(getValue); | ||
if (system.ws) { | ||
//handle via websocket | ||
sendMessage(name,fn,args,data); | ||
} else { | ||
//handle directly | ||
f.apply(module,data); | ||
} | ||
} | ||
} | ||
@@ -62,3 +50,12 @@ function renderModule(module, name, container) { | ||
btn.innerHTML = fn; | ||
btn.addEventListener('click', handleButton(module, f, inps)); | ||
btn.addEventListener('click', function () { | ||
var data = inps.map(getValue); | ||
if (system.ws) { | ||
//handle via websocket | ||
sendMessage(name,fn,args,data); | ||
} else { | ||
//handle directly | ||
f.apply(module, data); | ||
} | ||
}); | ||
inps.forEach(appendTo(s)); | ||
@@ -65,0 +62,0 @@ s.appendChild(btn); |
@@ -32,3 +32,3 @@ displaySystem.registerModule({ | ||
var numberOfLines = 8; | ||
var numberOfLines; | ||
var pageTimeout = 5000; | ||
@@ -89,3 +89,5 @@ var pageTimer; | ||
}).join(''); | ||
getElement().innerHTML = head + html; | ||
} | ||
@@ -107,2 +109,3 @@ | ||
} | ||
setDynamicLines(config.margins); | ||
} | ||
@@ -134,2 +137,34 @@ | ||
function setDynamicLines(margins) { | ||
//margins is an object with "top" and "bottom" properties, which are percentages. these percentages are the % from the total height of the window | ||
// i.e. if margins={top: 25, bottom: 75}, the table will take up 50% of the total height of the window, starting at 25% of the window and ending at 75% (rounding the number of lines). | ||
if (!margins.top || !margins.bottom) { | ||
setLines(config.lines); | ||
} else { | ||
var style = window.getComputedStyle(getElement(), null); | ||
var styleLineHeight = parseInt(style.lineHeight); | ||
var lineHeight; //this value simply defines it as a number, and ensures it's not undefined or null. | ||
if (!isNaN(styleLineHeight)) { | ||
lineHeight = styleLineHeight; | ||
} else { | ||
var tbody = Array.from(getElement().children).find((child) => { | ||
return child.tagName === "TBODY"; | ||
}); | ||
if (tbody.children) { | ||
lineHeight = tbody.children[0].clientHeight; | ||
} | ||
} | ||
var height = getElement().parentElement.clientHeight; | ||
var top = margins.top / 100 * height; | ||
var bottom = margins.bottom / 100 * height; | ||
if(lineHeight){ | ||
var linesToSee = Math.floor(Math.abs(bottom - top) / lineHeight); | ||
setLines(linesToSee); | ||
}else{ | ||
setLines(config.lines); | ||
} | ||
} | ||
} | ||
if (config.timer) { | ||
@@ -151,2 +186,6 @@ setTimer(config.timer / 1000); | ||
} | ||
if(config.margins){ | ||
setDynamicLines(config.margins); | ||
} | ||
@@ -153,0 +192,0 @@ onMessage('setData', function (msg) { |
{ | ||
"name": "@first-lego-league/display", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Display Systems", | ||
@@ -5,0 +5,0 @@ "main": "config.js", |
2804062
3985