summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Views/LogParser
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-09 16:01:32 -0400
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2022-04-09 16:01:32 -0400
commit07d07c79e00906f826cb6d3e7532f4a2ad2099ba (patch)
tree1b7c657d0f2f5b99217eeab17dda97d35decd9cf /src/SMAPI.Web/Views/LogParser
parent26d29a1070e00b4edeaf3334d4c4d072d52a56ff (diff)
downloadSMAPI-07d07c79e00906f826cb6d3e7532f4a2ad2099ba.tar.gz
SMAPI-07d07c79e00906f826cb6d3e7532f4a2ad2099ba.tar.bz2
SMAPI-07d07c79e00906f826cb6d3e7532f4a2ad2099ba.zip
load raw data from JSON per discussion
This avoids loading the data synchronously as a JavaScript snippet, which improves performance when opening the page.
Diffstat (limited to 'src/SMAPI.Web/Views/LogParser')
-rw-r--r--src/SMAPI.Web/Views/LogParser/Index.cshtml45
1 files changed, 29 insertions, 16 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)),