diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-03-13 20:25:06 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-03-13 20:25:06 -0400 |
commit | afb3c49bbaab07f3148f70d54f5140cdd83f8c20 (patch) | |
tree | dd60902c878c38617f97644b912afb38c568755e /src/SMAPI.Web | |
parent | 833d98f49136325edfc4463097710cf2391dd5b2 (diff) | |
parent | 76445dc3589265ba259070300120e96a17957e50 (diff) | |
download | SMAPI-afb3c49bbaab07f3148f70d54f5140cdd83f8c20.tar.gz SMAPI-afb3c49bbaab07f3148f70d54f5140cdd83f8c20.tar.bz2 SMAPI-afb3c49bbaab07f3148f70d54f5140cdd83f8c20.zip |
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Web')
-rw-r--r-- | src/SMAPI.Web/Controllers/ModsApiController.cs | 24 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/Clients/Chucklefish/ChucklefishClient.cs | 19 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/Clients/Nexus/NexusClient.cs | 2 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/Clients/Nexus/NexusMod.cs | 4 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs | 106 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/LogParsing/LogParser.cs | 12 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs | 4 | ||||
-rw-r--r-- | src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs | 8 | ||||
-rw-r--r-- | src/SMAPI.Web/Startup.cs | 12 | ||||
-rw-r--r-- | src/SMAPI.Web/Views/LogParser/Index.cshtml | 22 | ||||
-rw-r--r-- | src/SMAPI.Web/appsettings.json | 2 | ||||
-rw-r--r-- | src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 6 |
12 files changed, 184 insertions, 37 deletions
diff --git a/src/SMAPI.Web/Controllers/ModsApiController.cs b/src/SMAPI.Web/Controllers/ModsApiController.cs index dcb4ec52..abae7db7 100644 --- a/src/SMAPI.Web/Controllers/ModsApiController.cs +++ b/src/SMAPI.Web/Controllers/ModsApiController.cs @@ -64,14 +64,15 @@ namespace StardewModdingAPI.Web.Controllers /// <summary>Fetch version metadata for the given mods.</summary> /// <param name="modKeys">The namespaced mod keys to search as a comma-delimited array.</param> + /// <param name="allowInvalidVersions">Whether to allow non-semantic versions, instead of returning an error for those.</param> [HttpGet] - public async Task<IDictionary<string, ModInfoModel>> GetAsync(string modKeys) + public async Task<IDictionary<string, ModInfoModel>> GetAsync(string modKeys, bool allowInvalidVersions = false) { string[] modKeysArray = modKeys?.Split(',').ToArray(); if (modKeysArray == null || !modKeysArray.Any()) return new Dictionary<string, ModInfoModel>(); - return await this.PostAsync(new ModSearchModel(modKeysArray)); + return await this.PostAsync(new ModSearchModel(modKeysArray, allowInvalidVersions)); } /// <summary>Fetch version metadata for the given mods.</summary> @@ -79,7 +80,8 @@ namespace StardewModdingAPI.Web.Controllers [HttpPost] public async Task<IDictionary<string, ModInfoModel>> PostAsync([FromBody] ModSearchModel search) { - // sort & filter keys + // parse model + bool allowInvalidVersions = search?.AllowInvalidVersions ?? false; string[] modKeys = (search?.ModKeys?.ToArray() ?? new string[0]) .Distinct(StringComparer.CurrentCultureIgnoreCase) .OrderBy(p => p, StringComparer.CurrentCultureIgnoreCase) @@ -106,12 +108,20 @@ namespace StardewModdingAPI.Web.Controllers // fetch mod info result[modKey] = await this.Cache.GetOrCreateAsync($"{repository.VendorKey}:{modID}".ToLower(), async entry => { - entry.AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(this.CacheMinutes); - + // fetch info ModInfoModel info = await repository.GetModInfoAsync(modID); - if (info.Error == null && (info.Version == null || !Regex.IsMatch(info.Version, this.VersionRegex, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase))) - info = new ModInfoModel(info.Name, info.Version, info.Url, info.Version == null ? "Mod has no version number." : $"Mod has invalid semantic version '{info.Version}'."); + // validate + if (info.Error == null) + { + if (info.Version == null) + info = new ModInfoModel(info.Name, info.Version, info.Url, "Mod has no version number."); + if (!allowInvalidVersions && !Regex.IsMatch(info.Version, this.VersionRegex, RegexOptions.CultureInvariant | RegexOptions.IgnoreCase)) + info = new ModInfoModel(info.Name, info.Version, info.Url, $"Mod has invalid semantic version '{info.Version}'."); + } + + // cache & return + entry.AbsoluteExpiration = DateTimeOffset.UtcNow.AddMinutes(this.CacheMinutes); return info; }); } diff --git a/src/SMAPI.Web/Framework/Clients/Chucklefish/ChucklefishClient.cs b/src/SMAPI.Web/Framework/Clients/Chucklefish/ChucklefishClient.cs index 6772672c..029553ce 100644 --- a/src/SMAPI.Web/Framework/Clients/Chucklefish/ChucklefishClient.cs +++ b/src/SMAPI.Web/Framework/Clients/Chucklefish/ChucklefishClient.cs @@ -12,9 +12,6 @@ namespace StardewModdingAPI.Web.Framework.Clients.Chucklefish /********* ** Properties *********/ - /// <summary>The base URL for the Chucklefish mod site.</summary> - private readonly string BaseUrl; - /// <summary>The URL for a mod page excluding the base URL, where {0} is the mod ID.</summary> private readonly string ModPageUrlFormat; @@ -31,7 +28,6 @@ namespace StardewModdingAPI.Web.Framework.Clients.Chucklefish /// <param name="modPageUrlFormat">The URL for a mod page excluding the <paramref name="baseUrl"/>, where {0} is the mod ID.</param> public ChucklefishClient(string userAgent, string baseUrl, string modPageUrlFormat) { - this.BaseUrl = baseUrl; this.ModPageUrlFormat = modPageUrlFormat; this.Client = new FluentClient(baseUrl).SetUserAgent(userAgent); } @@ -59,7 +55,7 @@ namespace StardewModdingAPI.Web.Framework.Clients.Chucklefish doc.LoadHtml(html); // extract mod info - string url = new UriBuilder(new Uri(this.BaseUrl)) { Path = string.Format(this.ModPageUrlFormat, id) }.Uri.ToString(); + string url = this.GetModUrl(id); string name = doc.DocumentNode.SelectSingleNode("//meta[@name='twitter:title']").Attributes["content"].Value; if (name.StartsWith("[SMAPI] ")) name = name.Substring("[SMAPI] ".Length); @@ -79,5 +75,18 @@ namespace StardewModdingAPI.Web.Framework.Clients.Chucklefish { this.Client?.Dispose(); } + + + /********* + ** Private methods + *********/ + /// <summary>Get the full mod page URL for a given ID.</summary> + /// <param name="id">The mod ID.</param> + private string GetModUrl(uint id) + { + UriBuilder builder = new UriBuilder(this.Client.BaseClient.BaseAddress); + builder.Path += string.Format(this.ModPageUrlFormat, id); + return builder.Uri.ToString(); + } } } diff --git a/src/SMAPI.Web/Framework/Clients/Nexus/NexusClient.cs b/src/SMAPI.Web/Framework/Clients/Nexus/NexusClient.cs index 1a7011e2..adec41be 100644 --- a/src/SMAPI.Web/Framework/Clients/Nexus/NexusClient.cs +++ b/src/SMAPI.Web/Framework/Clients/Nexus/NexusClient.cs @@ -3,7 +3,7 @@ using Pathoschild.Http.Client; namespace StardewModdingAPI.Web.Framework.Clients.Nexus { - /// <summary>An HTTP client for fetching mod metadata from Nexus Mods.</summary> + /// <summary>An HTTP client for fetching mod metadata from the Nexus Mods API.</summary> internal class NexusClient : INexusClient { /********* diff --git a/src/SMAPI.Web/Framework/Clients/Nexus/NexusMod.cs b/src/SMAPI.Web/Framework/Clients/Nexus/NexusMod.cs index 2b04104f..cd52c72b 100644 --- a/src/SMAPI.Web/Framework/Clients/Nexus/NexusMod.cs +++ b/src/SMAPI.Web/Framework/Clients/Nexus/NexusMod.cs @@ -17,5 +17,9 @@ namespace StardewModdingAPI.Web.Framework.Clients.Nexus /// <summary>The mod's web URL.</summary> [JsonProperty("mod_page_uri")] public string Url { get; set; } + + /// <summary>A user-friendly error which indicates why fetching the mod info failed (if applicable).</summary> + [JsonIgnore] + public string Error { get; set; } } } diff --git a/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs b/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs new file mode 100644 index 00000000..d0597965 --- /dev/null +++ b/src/SMAPI.Web/Framework/Clients/Nexus/NexusWebScrapeClient.cs @@ -0,0 +1,106 @@ +using System; +using System.Net; +using System.Threading.Tasks; +using HtmlAgilityPack; +using Pathoschild.Http.Client; + +namespace StardewModdingAPI.Web.Framework.Clients.Nexus +{ + /// <summary>An HTTP client for fetching mod metadata from the Nexus website.</summary> + internal class NexusWebScrapeClient : INexusClient + { + /********* + ** Properties + *********/ + /// <summary>The URL for a Nexus web page excluding the base URL, where {0} is the mod ID.</summary> + private readonly string ModUrlFormat; + + /// <summary>The underlying HTTP client.</summary> + private readonly IClient Client; + + + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="userAgent">The user agent for the Nexus Mods API client.</param> + /// <param name="baseUrl">The base URL for the Nexus Mods site.</param> + /// <param name="modUrlFormat">The URL for a Nexus Mods web page excluding the <paramref name="baseUrl"/>, where {0} is the mod ID.</param> + public NexusWebScrapeClient(string userAgent, string baseUrl, string modUrlFormat) + { + this.ModUrlFormat = modUrlFormat; + this.Client = new FluentClient(baseUrl).SetUserAgent(userAgent); + } + + /// <summary>Get metadata about a mod.</summary> + /// <param name="id">The Nexus mod ID.</param> + /// <returns>Returns the mod info if found, else <c>null</c>.</returns> + public async Task<NexusMod> GetModAsync(uint id) + { + // fetch HTML + string html; + try + { + html = await this.Client + .GetAsync(string.Format(this.ModUrlFormat, id)) + .AsString(); + } + catch (ApiException ex) when (ex.Status == HttpStatusCode.NotFound) + { + return null; + } + + // parse HTML + var doc = new HtmlDocument(); + doc.LoadHtml(html); + + // handle Nexus error message + HtmlNode node = doc.DocumentNode.SelectSingleNode("//div[contains(@class, 'site-notice')][contains(@class, 'warning')]"); + if (node != null) + { + string[] errorParts = node.InnerText.Trim().Split(new[] { '\n' }, 2, System.StringSplitOptions.RemoveEmptyEntries); + string errorCode = errorParts[0]; + string errorText = errorParts.Length > 1 ? errorParts[1] : null; + switch (errorCode.Trim().ToLower()) + { + case "not found": + return null; + + default: + return new NexusMod { Error = $"Nexus error: {errorCode} ({errorText})." }; + } + } + + // extract mod info + string url = this.GetModUrl(id); + string name = doc.DocumentNode.SelectSingleNode("//h1")?.InnerText.Trim(); + string version = doc.DocumentNode.SelectSingleNode("//ul[contains(@class, 'stats')]//li[@class='stat-version']//div[@class='stat']")?.InnerText.Trim(); + + return new NexusMod + { + Name = name, + Version = version, + Url = url + }; + } + + /// <summary>Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.</summary> + public void Dispose() + { + this.Client?.Dispose(); + } + + + /********* + ** Private methods + *********/ + /// <summary>Get the full mod page URL for a given ID.</summary> + /// <param name="id">The mod ID.</param> + private string GetModUrl(uint id) + { + UriBuilder builder = new UriBuilder(this.Client.BaseClient.BaseAddress); + builder.Path += string.Format(this.ModUrlFormat, id); + return builder.Uri.ToString(); + } + } +} diff --git a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs index 23a1baa4..9e44f163 100644 --- a/src/SMAPI.Web/Framework/LogParsing/LogParser.cs +++ b/src/SMAPI.Web/Framework/LogParsing/LogParser.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text.RegularExpressions; +using StardewModdingAPI.Common; using StardewModdingAPI.Web.Framework.LogParsing.Models; namespace StardewModdingAPI.Web.Framework.LogParsing @@ -29,7 +30,8 @@ namespace StardewModdingAPI.Web.Framework.LogParsing private readonly Regex ModListStartPattern = new Regex(@"^Loaded \d+ mods:$", RegexOptions.Compiled | RegexOptions.IgnoreCase); /// <summary>A regex pattern matching an entry in SMAPI's mod list.</summary> - private readonly Regex ModListEntryPattern = new Regex(@"^ (?<name>.+) (?<version>.+) by (?<author>.+) \| (?<description>.+)$", RegexOptions.Compiled | RegexOptions.IgnoreCase); + /// <remarks>The author name and description are optional.</remarks> + private readonly Regex ModListEntryPattern = new Regex(@"^ (?<name>.+?) (?<version>" + SemanticVersionImpl.UnboundedVersionPattern + @")(?: by (?<author>[^\|]+))?(?: \| (?<description>.+))?$", RegexOptions.Compiled | RegexOptions.IgnoreCase); /// <summary>A regex pattern matching the start of SMAPI's content pack list.</summary> private readonly Regex ContentPackListStartPattern = new Regex(@"^Loaded \d+ content packs:$", RegexOptions.Compiled | RegexOptions.IgnoreCase); @@ -53,6 +55,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing return new ParsedLog { IsValid = false, + RawText = logText, Error = "The log is empty." }; } @@ -61,7 +64,8 @@ namespace StardewModdingAPI.Web.Framework.LogParsing ParsedLog log = new ParsedLog { IsValid = true, - Messages = this.CollapseRepeats(this.GetMessages(logText)).ToArray(), + RawText = logText, + Messages = this.CollapseRepeats(this.GetMessages(logText)).ToArray() }; // parse log messages @@ -152,7 +156,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing { IsValid = false, Error = ex.Message, - RawTextIfError = logText + RawText = logText }; } catch (Exception ex) @@ -161,7 +165,7 @@ namespace StardewModdingAPI.Web.Framework.LogParsing { IsValid = false, Error = $"Parsing the log file failed. Technical details:\n{ex}", - RawTextIfError = logText + RawText = logText }; } } diff --git a/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs b/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs index 31ef2fe1..a82b6a1b 100644 --- a/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs +++ b/src/SMAPI.Web/Framework/LogParsing/Models/ParsedLog.cs @@ -17,8 +17,8 @@ namespace StardewModdingAPI.Web.Framework.LogParsing.Models /// <summary>An error message indicating why the log file is invalid.</summary> public string Error { get; set; } - /// <summary>The raw text if <see cref="IsValid"/> is false.</summary> - public string RawTextIfError { get; set; } + /// <summary>The raw log text.</summary> + public string RawText { get; set; } /**** ** Log data diff --git a/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs b/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs index cfa757ab..e1dc0fcc 100644 --- a/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs +++ b/src/SMAPI.Web/Framework/ModRepositories/NexusRepository.cs @@ -39,9 +39,11 @@ namespace StardewModdingAPI.Web.Framework.ModRepositories try { NexusMod mod = await this.Client.GetModAsync(nexusID); - return mod != null - ? new ModInfoModel(mod.Name, this.NormaliseVersion(mod.Version), mod.Url) - : new ModInfoModel("Found no mod with this ID."); + if (mod == null) + return new ModInfoModel("Found no mod with this ID."); + if (mod.Error != null) + return new ModInfoModel(mod.Error); + return new ModInfoModel(mod.Name, this.NormaliseVersion(mod.Version), mod.Url); } catch (Exception ex) { diff --git a/src/SMAPI.Web/Startup.cs b/src/SMAPI.Web/Startup.cs index bc3e9f7b..d7d4d074 100644 --- a/src/SMAPI.Web/Startup.cs +++ b/src/SMAPI.Web/Startup.cs @@ -81,8 +81,13 @@ namespace StardewModdingAPI.Web password: api.GitHubPassword )); - services.AddSingleton<INexusClient>(new NexusClient( - userAgent: api.NexusUserAgent, + //services.AddSingleton<INexusClient>(new NexusClient( + // userAgent: api.NexusUserAgent, + // baseUrl: api.NexusBaseUrl, + // modUrlFormat: api.NexusModUrlFormat + //)); + services.AddSingleton<INexusClient>(new NexusWebScrapeClient( + userAgent: userAgent, baseUrl: api.NexusBaseUrl, modUrlFormat: api.NexusModUrlFormat )); @@ -147,7 +152,8 @@ namespace StardewModdingAPI.Web )); // shortcut redirects - redirects.Add(new RedirectToUrlRule("^/docs$", "https://stardewvalleywiki.com/Modding:Index")); + redirects.Add(new RedirectToUrlRule(@"^/compat\.?$", "https://stardewvalleywiki.com/Modding:SMAPI_compatibility")); + redirects.Add(new RedirectToUrlRule(@"^/docs\.?$", "https://stardewvalleywiki.com/Modding:Index")); // redirect legacy canimod.com URLs var wikiRedirects = new Dictionary<string, string[]> diff --git a/src/SMAPI.Web/Views/LogParser/Index.cshtml b/src/SMAPI.Web/Views/LogParser/Index.cshtml index be9f74a0..d2d8004e 100644 --- a/src/SMAPI.Web/Views/LogParser/Index.cshtml +++ b/src/SMAPI.Web/Views/LogParser/Index.cshtml @@ -17,16 +17,16 @@ @using StardewModdingAPI.Web.Framework.LogParsing.Models @model StardewModdingAPI.Web.ViewModels.LogParserModel @section Head { - <link rel="stylesheet" href="~/Content/css/log-parser.css?r=20180101" /> + <link rel="stylesheet" href="~/Content/css/log-parser.css?r=20180225" /> <script src="https://cdn.jsdelivr.net/npm/vue"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js" crossorigin="anonymous"></script> - <script src="~/Content/js/log-parser.js?r=20180101"></script> + <script src="~/Content/js/log-parser.js?r=20180225"></script> <script> $(function() { smapi.logParser({ logStarted: new Date(@Json.Serialize(Model.ParsedLog?.Timestamp)), showPopup: @Json.Serialize(Model.ParsedLog == null), - showMods: @Json.Serialize(Model.ParsedLog?.Mods?.ToDictionary(p => GetSlug(p.Name), p => true), new JsonSerializerSettings { Formatting = Formatting.None }), + showMods: @Json.Serialize(Model.ParsedLog?.Mods?.Select(p => GetSlug(p.Name)).Distinct().ToDictionary(slug => slug, slug => true), new JsonSerializerSettings { Formatting = Formatting.None }), showLevels: { trace: false, debug: false, @@ -78,13 +78,13 @@ <caption> Installed mods: <span class="notice txt"><i>click any mod to filter</i></span> - <span class="notice btn txt" v-on:click="showAllMods" v-if="stats.modsHidden > 0">show all</span> - <span class="notice btn txt" v-on:click="hideAllMods" v-if="stats.modsShown > 0 && stats.modsHidden > 0">hide all</span> + <span class="notice btn txt" v-on:click="showAllMods" v-show="stats.modsHidden > 0">show all</span> + <span class="notice btn txt" v-on:click="hideAllMods" v-show="stats.modsShown > 0 && stats.modsHidden > 0">hide all</span> </caption> @foreach (var mod in Model.ParsedLog.Mods.Where(p => p.ContentPackFor == null)) { <tr v-on:click="toggleMod('@GetSlug(mod.Name)')" class="mod-entry" v-bind:class="{ hidden: !showMods['@GetSlug(mod.Name)'] }"> - <td><input type="checkbox" v-bind:checked="showMods['@GetSlug(mod.Name)']" v-if="anyModsHidden" /></td> + <td><input type="checkbox" v-bind:checked="showMods['@GetSlug(mod.Name)']" v-show="anyModsHidden" /></td> <td> @mod.Name @if (contentPacks != null && contentPacks.TryGetValue(mod.Name, out LogModInfo[] contentPackList)) @@ -92,7 +92,7 @@ <div class="content-packs"> @foreach (var contentPack in contentPackList) { - <text>+@contentPack.Name @contentPack.Version</text> + <text>+ @contentPack.Name @contentPack.Version</text><br /> } </div> } @@ -127,9 +127,9 @@ <table id="log"> @foreach (var message in Model.ParsedLog.Messages) { - string levelStr = @message.Level.ToString().ToLower(); + string levelStr = message.Level.ToString().ToLower(); - <tr class="@levelStr mod" v-if="showMods['@message.Mod'] && showLevels['@levelStr']"> + <tr class="@levelStr mod" v-show="filtersAllow('@GetSlug(message.Mod)', '@levelStr')"> <td>@message.Time</td> <td>@message.Level.ToString().ToUpper()</td> <td data-title="@message.Mod">@message.Mod</td> @@ -137,7 +137,7 @@ </tr> if (message.Repeated > 0) { - <tr class="@levelStr mod mod-repeat" v-if="showMods['@message.Mod'] && showLevels['@levelStr']"> + <tr class="@levelStr mod mod-repeat" v-show="filtersAllow('@GetSlug(message.Mod)', '@levelStr')"> <td colspan="3"></td> <td><i>repeats [@message.Repeated] times.</i></td> </tr> @@ -155,7 +155,7 @@ else if (Model.ParsedLog?.IsValid == false) </div> <h3>Raw log</h3> - <pre>@Model.ParsedLog.RawTextIfError</pre> + <pre>@Model.ParsedLog.RawText</pre> } <div id="upload-area"> diff --git a/src/SMAPI.Web/appsettings.json b/src/SMAPI.Web/appsettings.json index 9758f4a7..3cf72ddb 100644 --- a/src/SMAPI.Web/appsettings.json +++ b/src/SMAPI.Web/appsettings.json @@ -18,7 +18,7 @@ "LogParserUrl": null // see top note }, "ApiClients": { - "UserAgent": "SMAPI/{0} (+https://github.com/Pathoschild/SMAPI)", + "UserAgent": "SMAPI/{0} (+https://smapi.io)", "ChucklefishBaseUrl": "https://community.playstarbound.com", "ChucklefishModPageUrlFormat": "resources/{0}", diff --git a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js index 87a70391..38a75a80 100644 --- a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js +++ b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js @@ -62,6 +62,7 @@ smapi.logParser = function (data, sectionUrl) { updateModFilters(); }, + showAllMods: function () { for (var key in this.showMods) { if (this.showMods.hasOwnProperty(key)) { @@ -70,6 +71,7 @@ smapi.logParser = function (data, sectionUrl) { } updateModFilters(); }, + hideAllMods: function () { for (var key in this.showMods) { if (this.showMods.hasOwnProperty(key)) { @@ -77,6 +79,10 @@ smapi.logParser = function (data, sectionUrl) { } } updateModFilters(); + }, + + filtersAllow: function(modId, level) { + return this.showMods[modId] !== false && this.showLevels[level] !== false; } } }); |