spending and revenue tables
This commit is contained in:
+200
@@ -0,0 +1,200 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=1920, initial-scale=1">
|
||||
<title>Top 20 — Spending</title>
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css">
|
||||
<style>
|
||||
@font-face { font-family: 'ONY One'; src: local('ONY One Regular'), url('file:///home/itten/.local/share/fonts/ONYOne-Regular.otf') format('opentype'); font-weight: 400; }
|
||||
@font-face { font-family: 'ONY One'; src: local('ONY One Medium'), url('file:///home/itten/.local/share/fonts/ONYOne-Medium.otf') format('opentype'); font-weight: 500; }
|
||||
@font-face { font-family: 'ONY One'; src: local('ONY One Bold'), url('file:///home/itten/.local/share/fonts/ONYOne-Bold.otf') format('opentype'); font-weight: 700; }
|
||||
|
||||
:root {
|
||||
--bg: #222524;
|
||||
--white: #FFFFFF;
|
||||
--neutral: #919292;
|
||||
--accent: #91FF55;
|
||||
--negative: #F8F700;
|
||||
--row-alt: #2A2D2C;
|
||||
}
|
||||
|
||||
* { margin: 0; padding: 0; box-sizing: border-box; }
|
||||
|
||||
html, body {
|
||||
width: 1920px;
|
||||
height: 1080px;
|
||||
background: var(--bg);
|
||||
overflow: hidden;
|
||||
font-family: 'ONY One', 'Arial Narrow', sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
.frame {
|
||||
position: relative;
|
||||
width: 1920px;
|
||||
height: 1080px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.table-wrapper {
|
||||
width: fit-content;
|
||||
max-width: 1730px;
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.table-title {
|
||||
font-size: 40px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
color: var(--white);
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
letter-spacing: 3px;
|
||||
}
|
||||
|
||||
.table-header {
|
||||
display: grid;
|
||||
grid-template-columns: 70px auto 80px 150px 150px 150px;
|
||||
align-items: center;
|
||||
border-bottom: 3px solid var(--white);
|
||||
padding-bottom: 12px;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
|
||||
.header-cell {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
text-transform: uppercase;
|
||||
text-align: center;
|
||||
color: var(--neutral);
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.header-cell.left { text-align: left; }
|
||||
.header-cell.right { text-align: right; }
|
||||
|
||||
.table-row {
|
||||
display: grid;
|
||||
grid-template-columns: 70px auto 80px 150px 150px 150px;
|
||||
align-items: center;
|
||||
height: 40px;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.table-row:nth-child(even) {
|
||||
background: var(--row-alt);
|
||||
}
|
||||
|
||||
.col-rank {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
color: var(--neutral);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.col-team {
|
||||
font-size: 26px;
|
||||
font-weight: 500;
|
||||
color: var(--white);
|
||||
padding-left: 24px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.col-val {
|
||||
font-size: 24px;
|
||||
font-weight: 500;
|
||||
color: var(--white);
|
||||
text-align: right;
|
||||
padding-right: 24px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.col-diff {
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
text-align: right;
|
||||
padding-right: 24px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.diff-positive { color: var(--accent); }
|
||||
.diff-negative { color: var(--negative); }
|
||||
.diff-zero { color: var(--neutral); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="frame">
|
||||
<div class="table-wrapper">
|
||||
<div class="table-title">Топ-20 команд по затратам</div>
|
||||
<div class="table-header">
|
||||
<div class="header-cell">№</div>
|
||||
<div class="header-cell left">Команда</div>
|
||||
<div></div>
|
||||
<div class="header-cell right">Затраты</div>
|
||||
<div class="header-cell right">Доходы</div>
|
||||
<div class="header-cell right">Разница</div>
|
||||
</div>
|
||||
<div id="rows"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var CSV_URL = "top-20-teams-by-spending.csv";
|
||||
|
||||
function parseCSV(text) {
|
||||
var lines = text.trim().split(/\r?\n/);
|
||||
var result = [];
|
||||
for (var i = 1; i < lines.length; i++) {
|
||||
var line = lines[i].trim();
|
||||
if (!line) continue;
|
||||
var fields = [];
|
||||
var cur = "", inQ = false;
|
||||
for (var j = 0; j < line.length; j++) {
|
||||
var ch = line[j];
|
||||
if (ch === '"') inQ = !inQ;
|
||||
else if (ch === ',' && !inQ) { fields.push(cur.trim()); cur = ""; }
|
||||
else cur += ch;
|
||||
}
|
||||
fields.push(cur.trim());
|
||||
if (fields.length >= 4) result.push({
|
||||
team: fields[0], spend: fields[1], income: fields[2], diff: fields[3]
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function diffClass(val) {
|
||||
var n = parseFloat(val.replace(",", ".").replace("«", "").replace("»", "").replace("-", ""));
|
||||
if (isNaN(n) || n === 0) return "diff-zero";
|
||||
return val.indexOf("-") !== -1 ? "diff-negative" : "diff-positive";
|
||||
}
|
||||
|
||||
function buildRow(idx, row) {
|
||||
return '<div class="table-row">' +
|
||||
'<div class="col-rank">' + (idx + 1) + '</div>' +
|
||||
'<div class="col-team">' + row.team + '</div>' +
|
||||
'<div></div>' +
|
||||
'<div class="col-val">' + row.spend + '</div>' +
|
||||
'<div class="col-val">' + row.income + '</div>' +
|
||||
'<div class="col-diff ' + diffClass(row.diff) + '">' + row.diff + '</div>' +
|
||||
'</div>';
|
||||
}
|
||||
|
||||
fetch(CSV_URL)
|
||||
.then(function (r) { return r.text(); })
|
||||
.then(function (text) {
|
||||
var data = parseCSV(text);
|
||||
document.getElementById("rows").innerHTML =
|
||||
data.map(function (row, i) { return buildRow(i, row); }).join("");
|
||||
console.log("Loaded " + data.length + " rows");
|
||||
})
|
||||
.catch(function (e) { console.error("Failed to load CSV", e); });
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user