From 07d07c79e00906f826cb6d3e7532f4a2ad2099ba Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 9 Apr 2022 16:01:32 -0400 Subject: load raw data from JSON per discussion This avoids loading the data synchronously as a JavaScript snippet, which improves performance when opening the page. --- src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/SMAPI.Web/wwwroot/Content/js') diff --git a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js index 72cb4a11..5a12a521 100644 --- a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js +++ b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js @@ -162,8 +162,14 @@ smapi.logParser = function (state) { } } + // load raw log data + { + const dataElement = document.querySelector(state.dataElement); + state.data = JSON.parse(dataElement.textContent.trim()); + } + // preprocess data for display - state.messages = state.data?.messages || []; + state.messages = state.data.messages || []; if (state.messages.length) { const levels = state.data.logLevels; const sections = state.data.sections; -- cgit