summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/SMAPI.Web/Views/LogParser/Index.cshtml45
-rw-r--r--src/SMAPI.Web/wwwroot/Content/js/log-parser.js8
2 files changed, 36 insertions, 17 deletions
diff --git a/src/SMAPI.Web/Views/LogParser/Index.cshtml b/src/SMAPI.Web/Views/LogParser/Index.cshtml
index 2d5dd403..11f15403 100644
--- a/src/SMAPI.Web/Views/LogParser/Index.cshtml
+++ b/src/SMAPI.Web/Views/LogParser/Index.cshtml
@@ -42,27 +42,40 @@
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1" crossorigin="anonymous"></script>
<script src="~/Content/js/file-upload.js"></script>
<script src="~/Content/js/log-parser.js"></script>
+
+ <script id="serializedData" type="application/json">
+ @if (!Model.ShowRaw)
+ {
+ <text>
+ {
+ "messages": @this.ForJson(log?.Messages),
+ "sections": @this.ForJson(logSections),
+ "logLevels": @this.ForJson(logLevels),
+ "modSlugs": @this.ForJson(log?.Mods.DistinctBy(p => p.Name).Select(p => new {p.Name, Slug = Model.GetSlug(p.Name)}).Where(p => p.Name != p.Slug).ToDictionary(p => p.Name, p => p.Slug)),
+ "screenIds": @this.ForJson(screenIds)
+ }
+ </text>
+ }
+ else
+ {
+ <text>
+ {
+ "messages": [],
+ "sections": {},
+ "logLevels": {},
+ "modSlugs": {},
+ "screenIds": []
+ }
+ </text>
+ }
+ </script>
+
<script>
$(function() {
smapi.logParser(
{
logStarted: new Date(@this.ForJson(log?.Timestamp)),
- @if (!Model.ShowRaw)
- {
- <text>
- data: {
- messages: @this.ForJson(log?.Messages),
- sections: @this.ForJson(logSections),
- logLevels: @this.ForJson(logLevels),
- modSlugs: @this.ForJson(log?.Mods.DistinctBy(p => p.Name).Select(p => new { p.Name, Slug = Model.GetSlug(p.Name) }).Where(p => p.Name != p.Slug).ToDictionary(p => p.Name, p => p.Slug)),
- screenIds: @this.ForJson(screenIds)
- },
- </text>
- }
- else
- {
- <text>data: null,</text>
- }
+ dataElement: "script#serializedData",
showPopup: @this.ForJson(log == null),
showMods: @this.ForJson(log?.Mods.Select(p => Model.GetSlug(p.Name)).Distinct().ToDictionary(slug => slug, _ => true)),
showSections: @this.ForJson(Enum.GetNames(typeof(LogSection)).ToDictionary(section => section, _ => false)),
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;