diff options
Diffstat (limited to 'src/SMAPI.Web')
-rw-r--r-- | src/SMAPI.Web/Views/LogParser/Index.cshtml | 70 | ||||
-rw-r--r-- | src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 42 |
2 files changed, 64 insertions, 48 deletions
diff --git a/src/SMAPI.Web/Views/LogParser/Index.cshtml b/src/SMAPI.Web/Views/LogParser/Index.cshtml index 705ed961..a18586a9 100644 --- a/src/SMAPI.Web/Views/LogParser/Index.cshtml +++ b/src/SMAPI.Web/Views/LogParser/Index.cshtml @@ -33,39 +33,41 @@ <li class="notice">Click tabs to toggle message visibility</li> </ul> } -<div id="output" class="trace debug"></div> -<script class="template" id="template-body" type="text/html"> - <div class="always"> - <table id="gameinfo"> - <caption>Game info:</caption> - <tr> - <td>SMAPI Version</td> - <td>{0}</td> - </tr> - <tr> - <td>Game Version</td> - <td>{1}</td> - </tr> - <tr> - <td>Platform</td> - <td>{2}</td> - </tr> - <tr> - <td>Mods path</td> - <td>{4}</td> - </tr> - <tr> - <td>Log started</td> - <td>{3}</td> - </tr> - </table> - <br /> - <table id="modslist"> - <caption>Installed Mods: <span id="modlink-r" class="notice btn">Remove all mod filters</span><span class="notice txt"><i>Click any mod to filter</i></span> <span id="modlink-a" class="notice btn txt">Select all</span></caption> - </table> +<div id="output" class="trace debug"> + <div id="log-data" style="display: none;"> + <div class="always"> + <table id="gameinfo"> + <caption>Game info:</caption> + <tr> + <td>SMAPI Version</td> + <td id="api-version"></td> + </tr> + <tr> + <td>Game Version</td> + <td id="game-version"></td> + </tr> + <tr> + <td>Platform</td> + <td id="platform"></td> + </tr> + <tr> + <td>Mods path</td> + <td id="mods-path"></td> + </tr> + <tr> + <td>Log started</td> + <td id="log-started"></td> + </tr> + </table> + <br /> + <table id="modslist"> + <caption>Installed Mods: <span id="modlink-r" class="notice btn">Remove all mod filters</span><span class="notice txt"><i>Click any mod to filter</i></span> <span id="modlink-a" class="notice btn txt">Select all</span></caption> + </table> + </div> + <table id="log"></table> </div> - <table id="log"></table> -</script> + <div id="error" class="color-red"></div> +</div> <script class="template" id="template-css" type="text/html"> #output.modfilter:not(.mod-{0}) .mod-{0} { display:none; } #output.modfilter.mod-{0} #modslist tr { background:#ffeeee; } #output.modfilter.mod-{0} #modslist tr#modlink-{0} { background:#eeffee; } </script> @@ -102,8 +104,8 @@ </ol> <textarea id="input" placeholder="Paste or drag the log here"></textarea> <div class="buttons"> - <input type="button" id="submit" value="Parse"/> - <input type="button" id="cancel" value="Cancel"/> + <input type="button" id="submit" value="Parse" /> + <input type="button" id="cancel" value="Cancel" /> </div> </div> </div> diff --git a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js index b2bea673..95949a8b 100644 --- a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js +++ b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js @@ -8,6 +8,7 @@ smapi.logParser = function(sectionUrl, pasteID) { var stage, flags = $("#modflags"), output = $("#output"), + error = $("#error"), filters = 0, memory = "", versionInfo, @@ -15,7 +16,6 @@ smapi.logParser = function(sectionUrl, pasteID) { modMap, modErrors, logInfo, - templateBody = $("#template-body").text(), templateModentry = $("#template-modentry").text(), templateCss = $("#template-css").text(), templateLogentry = $("#template-logentry").text(), @@ -30,7 +30,7 @@ smapi.logParser = function(sectionUrl, pasteID) { $("#filters li").on("click", function(evt) { var t = $(evt.currentTarget); t.toggleClass("active"); - $("#output").toggleClass(t.text().toLowerCase()); + output.toggleClass(t.text().toLowerCase()); }); $("#upload-button").on("click", function() { memory = $("#input").val() || ""; @@ -38,13 +38,13 @@ smapi.logParser = function(sectionUrl, pasteID) { $("#popup-upload").fadeIn(); }); - var closeUploadPopUp = function () { - $("#popup-upload").fadeOut(400, function () { + var closeUploadPopUp = function() { + $("#popup-upload").fadeOut(400, function() { $("#input").val(memory); memory = ""; }); }; - + $("#popup-upload").on({ 'dragover dragenter': function(e) { e.preventDefault(); @@ -67,7 +67,7 @@ smapi.logParser = function(sectionUrl, pasteID) { reader.readAsText(file); } }, - 'click': function (e) { + 'click': function(e) { if (e.target.id === "popup-upload") closeUploadPopUp(); } @@ -89,12 +89,12 @@ smapi.logParser = function(sectionUrl, pasteID) { }) .fail(function(xhr, textStatus) { $("#uploader").fadeOut(); - $("#output").html('<div id="log" class="color-red"><h1>Parsing failed!</h1>Parsing of the log failed, details follow.<br /> <p>Stage: Upload</p>Error: ' + textStatus + ': ' + xhr.responseText + "<hr /><pre>" + $("#input").val() + "</pre></div>"); + error.html('<h1>Parsing failed!</h1>Parsing of the log failed, details follow.<br /> <p>Stage: Upload</p>Error: ' + textStatus + ': ' + xhr.responseText + "<hr /><pre>" + $("#input").val() + "</pre>"); }) .then(function(data) { $("#uploader").fadeOut(); if (!data.success) - $("#output").html('<div id="log" class="color-red"><h1>Parsing failed!</h1>Parsing of the log failed, details follow.<br /> <p>Stage: Upload</p>Error: ' + data.error + "<hr />" + $("#input").val() + "</div>"); + error.html('<h1>Parsing failed!</h1>Parsing of the log failed, details follow.<br /> <p>Stage: Upload</p>Error: ' + data.error + "<hr /><pre>" + $("#input").val() + "</pre>"); else location.href = (sectionUrl.replace(/\/$/, "") + "/" + data.id); }); @@ -104,7 +104,7 @@ smapi.logParser = function(sectionUrl, pasteID) { } }); - $(document).on("keydown", function (e) { + $(document).on("keydown", function(e) { if (e.which == 27) { if ($("#popup-upload").css("display") !== "none" && $("#popup-upload").css("opacity") == 1) { closeUploadPopUp(); @@ -119,7 +119,7 @@ smapi.logParser = function(sectionUrl, pasteID) { $("#popup-raw").fadeOut(400); }); - $("#popup-raw").on("click", function (e) { + $("#popup-raw").on("click", function(e) { if (e.target.id === "popup-raw") { $("#popup-raw").fadeOut(400); } @@ -201,7 +201,13 @@ smapi.logParser = function(sectionUrl, pasteID) { ]; stage = "parseData.parseInfo"; var date = dataDate ? new Date(dataDate[1] + "Z") : null; - versionInfo = [dataInfo[1], dataInfo[2], dataInfo[3], date ? date.getFullYear() + "-" + ("0" + date.getMonth().toString()).substr(-2) + "-" + ("0" + date.getDay().toString()).substr(-2) + " at " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + " " + date.toLocaleTimeString("en-us", { timeZoneName: "short" }).split(" ")[2] : "No timestamp found", dataPath[1]]; + versionInfo = { + apiVersion: dataInfo[1], + gameVersion: dataInfo[2], + platform: dataInfo[3], + logDate: date ? date.getFullYear() + "-" + ("0" + date.getMonth().toString()).substr(-2) + "-" + ("0" + date.getDay().toString()).substr(-2) + " at " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds() + " " + date.toLocaleTimeString("en-us", { timeZoneName: "short" }).split(" ")[2] : "No timestamp found", + modsPath: dataPath[1] + }; stage = "parseData.parseMods"; while ((match = regexMod.exec(dataMods))) { modErrors[match[1]] = 0; @@ -221,7 +227,13 @@ smapi.logParser = function(sectionUrl, pasteID) { function renderData() { stage = "renderData.pre"; - output.html(prepare(templateBody, versionInfo)); + + output.find("#api-version").text(versionInfo.apiVersion); + output.find("#game-version").text(versionInfo.gameVersion); + output.find("#platform").text(versionInfo.platform); + output.find("#log-started").text(versionInfo.logDate); + output.find("#mods-path").text(versionInfo.modsPath); + var modslist = $("#modslist"), log = $("#log"), modCache = [], y = 0; for (; y < modInfo.length; y++) { var errors = modErrors[modInfo[y][0]], @@ -258,6 +270,8 @@ smapi.logParser = function(sectionUrl, pasteID) { log.append(logCache.join("")); $("#modlink-r").on("click", removeFilter); $("#modlink-a").on("click", selectAll); + + $("#log-data").show(); } function prepare(str, arr) { @@ -279,7 +293,7 @@ smapi.logParser = function(sectionUrl, pasteID) { stage = "loadData.Post"; } catch (err) { - $("#output").html('<div id="log" class="color-red"><h1>Parsing failed!</h1>Parsing of the log failed, details follow.<br /> <p>Stage: ' + stage + "</p>" + err + '<hr /><pre id="rawlog"></pre></div>'); + error.html('<h1>Parsing failed!</h1>Parsing of the log failed, details follow.<br /> <p>Stage: ' + stage + "</p>" + err + '<hr /><pre id="rawlog"></pre>'); $("#rawlog").text($("#input").val()); } } @@ -291,7 +305,7 @@ smapi.logParser = function(sectionUrl, pasteID) { $("#input").val(data.content); loadData(); } else { - $("#output").html('<div id="log" class="color-red"><h1>Fetching the log failed!</h1><p>' + data.error + '</p><pre id="rawlog"></pre></div>'); + error.html('<h1>Fetching the log failed!</h1><p>' + data.error + '</p><pre id="rawlog"></pre>'); $("#rawlog").text($("#input").val()); } $("#uploader").fadeOut(); |