From e2b19d8a6ba5deb5a3e04c21c8e35cc04aea16b3 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 2 Dec 2017 01:05:12 -0500 Subject: rm body template so filters can be moved into the output area --- src/SMAPI.Web/Views/LogParser/Index.cshtml | 70 +++++++++++++------------- src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 42 ++++++++++------ 2 files changed, 64 insertions(+), 48 deletions(-) (limited to 'src') 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 @@
  • Click tabs to toggle message visibility
  • } -
    - +
    + @@ -102,8 +104,8 @@
    - - + +
    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('

    Parsing failed!

    Parsing of the log failed, details follow.
     

    Stage: Upload

    Error: ' + textStatus + ': ' + xhr.responseText + "
    " + $("#input").val() + "
    "); + error.html('

    Parsing failed!

    Parsing of the log failed, details follow.
     

    Stage: Upload

    Error: ' + textStatus + ': ' + xhr.responseText + "
    " + $("#input").val() + "
    "); }) .then(function(data) { $("#uploader").fadeOut(); if (!data.success) - $("#output").html('

    Parsing failed!

    Parsing of the log failed, details follow.
     

    Stage: Upload

    Error: ' + data.error + "
    " + $("#input").val() + "
    "); + error.html('

    Parsing failed!

    Parsing of the log failed, details follow.
     

    Stage: Upload

    Error: ' + data.error + "
    " + $("#input").val() + "
    "); 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('

    Parsing failed!

    Parsing of the log failed, details follow.
     

    Stage: ' + stage + "

    " + err + '
    '); + error.html('

    Parsing failed!

    Parsing of the log failed, details follow.
     

    Stage: ' + stage + "

    " + err + '
    ');
                 $("#rawlog").text($("#input").val());
             }
         }
    @@ -291,7 +305,7 @@ smapi.logParser = function(sectionUrl, pasteID) {
                     $("#input").val(data.content);
                     loadData();
                 } else {
    -                $("#output").html('

    Fetching the log failed!

    ' + data.error + '

    '); + error.html('

    Fetching the log failed!

    ' + data.error + '

    ');
                     $("#rawlog").text($("#input").val());
                 }
                 $("#uploader").fadeOut();
    -- 
    cgit