[REF] tools: rename extras into tools

This commit is contained in:
Géry Debongnie
2019-06-09 16:56:27 +02:00
parent 2a19aeb6a3
commit e1bcea77b5
70 changed files with 32 additions and 31 deletions
+42
View File
@@ -0,0 +1,42 @@
.main {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: grid;
grid-template-columns: 220px 1fr;
}
.left-thing {
background-color: gray;
padding: 20px;
color: white;
}
.left-thing button {
width: 100%;
}
.right-thing {
padding: 20px;
overflow: auto;
}
/* Message widget */
.message .author {
font-weight: bold;
}
.message {
width: 400px;
background-color: lightblue;
margin: 10px 5px;
border-radius: 5px;
padding: 5px;
}
.remove {
float: right;
}
+49
View File
@@ -0,0 +1,49 @@
//------------------------------------------------------------------------------
// Generating demo data
//------------------------------------------------------------------------------
const AUTHORS = ["Aaron", "David", "Vincent"];
const CONTENT = [
"Lorem ipsum dolor sit amet",
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem",
"Excepteur sint occaecat cupidatat non proident"
];
function chooseRandomly(array) {
const index = Math.floor(Math.random() * array.length);
return array[index];
}
let nextId = 1;
export function buildData(n = 1000) {
const data = [];
for (let i = 0; i < n; i++) {
let id = nextId++;
data.push({
id: id,
author: chooseRandomly(AUTHORS),
msg: `${id}: ${chooseRandomly(CONTENT)}`,
likes: 0
});
}
return data;
}
//------------------------------------------------------------------------------
// Measuring helpers
//------------------------------------------------------------------------------
let startTime;
let lastMeasure;
export function startMeasure(descr) {
startTime = performance.now();
lastMeasure = descr;
}
export function stopMeasure() {
let last = lastMeasure;
if (lastMeasure) {
window.setTimeout(function() {
lastMeasure = null;
const stop = performance.now();
console.log(`[${last}] took ${Number(stop - startTime).toFixed()}ms`);
}, 0);
}
}