diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-12-02 01:05:12 -0500 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-12-02 01:05:12 -0500 |
commit | e2b19d8a6ba5deb5a3e04c21c8e35cc04aea16b3 (patch) | |
tree | f56a69c092c0953cecbc28184e76fe891848ecd8 /src/SMAPI.Web/wwwroot/Content/js | |
parent | 188cd2403df315087ac646e04ba7d10449b7f709 (diff) | |
download | SMAPI-e2b19d8a6ba5deb5a3e04c21c8e35cc04aea16b3.tar.gz SMAPI-e2b19d8a6ba5deb5a3e04c21c8e35cc04aea16b3.tar.bz2 SMAPI-e2b19d8a6ba5deb5a3e04c21c8e35cc04aea16b3.zip |
rm body template so filters can be moved into the output area
Diffstat (limited to 'src/SMAPI.Web/wwwroot/Content/js')
-rw-r--r-- | src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 42 |
1 files changed, 28 insertions, 14 deletions
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(); |