From fe5b2f62da27ac0e2ddf60240f2b19cf2a404f69 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 28 Oct 2017 12:38:30 -0400 Subject: prettify log URL, read paste ID serverside (#358) --- src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/SMAPI.Web/wwwroot/Content/js') diff --git a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js index 3949fabe..904ca691 100644 --- a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js +++ b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js @@ -1,7 +1,7 @@ /* globals $, LZString */ var smapi = smapi || {}; -smapi.logParser = function(sectionUrl) { +smapi.logParser = function(sectionUrl, pasteID) { /********* ** Initialisation *********/ @@ -86,11 +86,10 @@ smapi.logParser = function(sectionUrl) { }) .then(function(data) { $("#uploader").fadeOut(); - console.log("Result: ", data); if (!data.success) $("#output").html('

Parsing failed!

Parsing of the log failed, details follow.
 

Stage: Upload

Error: ' + data.error + "
" + $("#input").val() + "
"); else - location.href = "?" + data.id; + location.href = (sectionUrl.replace(/\/$/, "") + "/" + data.id); }); } else { alert("Unable to parse log, the input is empty!"); @@ -106,8 +105,8 @@ smapi.logParser = function(sectionUrl) { $("#closeraw").on("click", function() { $("#popup-raw").fadeOut(400); }); - if (location.search) { - getData(); + if (pasteID) { + getData(pasteID); } else $("#popup-upload").fadeIn(); @@ -160,10 +159,6 @@ smapi.logParser = function(sectionUrl) { dataDate = regexDate.exec(data) || regexDate.exec(data) || regexDate.exec(data), dataPath = regexPath.exec(data) || regexPath.exec(data) || regexPath.exec(data), match; - console.log("dataInfo:", dataInfo); - console.log("dataMods:", dataMods); - console.log("dataDate:", dataDate); - console.log("dataPath:", dataPath); stage = "parseData.doNullCheck"; if (!dataInfo) throw new Error("Field `dataInfo` is null"); @@ -267,19 +262,19 @@ smapi.logParser = function(sectionUrl) { stage = "loadData.Post"; } catch (err) { - $("#output").html('

Parsing failed!

Parsing of the log failed, details follow.
 

Stage: ' + stage + "

" + err + '
'); + $("#output").html('

Parsing failed!

Parsing of the log failed, details follow.
 

Stage: ' + stage + "

" + err + '
'); $("#rawlog").text($("#input").val()); } } - function getData() { + function getData(pasteID) { $("#uploader").attr("data-text", "Loading..."); $("#uploader").fadeIn(); - $.get(sectionUrl + "/fetch/" + location.search.substring(1), function(data) { + $.get(sectionUrl + "/fetch/" + pasteID, function(data) { if (data.success) { $("#input").val(LZString.decompressFromUTF16(data.content) || data.content); loadData(); } else { - $("#output").html('

Fetching the log failed!

' + data.error + '

'); + $("#output").html('

Fetching the log failed!

' + data.error + '

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