Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions docs/assets/js/peak-shaving-charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,15 @@
});
}

// Error text carries the scenario name and err.message - set it as text,
// never as HTML.
function showError(container, text) {
var p = document.createElement('p');
p.className = 'ps-error';
p.textContent = text;
container.replaceChildren(p);
}

function renderChart(container) {
var scenario = container.getAttribute('data-scenario');
if (!scenario) { return; }
Expand All @@ -238,8 +247,8 @@
charts.push({ chart: buildChart(canvas, rows), rows: rows,
canvas: canvas, container: container });
}).catch(function (err) {
container.innerHTML = '<p class="ps-error">Could not load scenario "' +
scenario + '": ' + err.message + '</p>';
showError(container,
'Could not load scenario "' + scenario + '": ' + err.message);
});
}

Expand All @@ -260,8 +269,7 @@
container.innerHTML = '<table>' + head + '<tbody>' + body +
'</tbody></table>';
}).catch(function (err) {
container.innerHTML = '<p class="ps-error">Could not load summary: ' +
err.message + '</p>';
showError(container, 'Could not load summary: ' + err.message);
});
}

Expand Down
Loading