diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-06-03 17:40:54 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-06-03 17:40:54 -0400 |
commit | 94c1be6154223d070e7f5e5bcce80e81a2098048 (patch) | |
tree | c6c058061d4cbbfb27deb15e973ac2580c2cb226 /src | |
parent | 45a2268fc8855162c39205f78b3ef286d74e5224 (diff) | |
download | SMAPI-94c1be6154223d070e7f5e5bcce80e81a2098048.tar.gz SMAPI-94c1be6154223d070e7f5e5bcce80e81a2098048.tar.bz2 SMAPI-94c1be6154223d070e7f5e5bcce80e81a2098048.zip |
fix script error on log result page
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI.Web/wwwroot/Content/js/log-parser.js | 76 |
1 files changed, 39 insertions, 37 deletions
diff --git a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js index eba6451d..44c3ad5d 100644 --- a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js +++ b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js @@ -90,48 +90,50 @@ smapi.logParser = function (data, sectionUrl) { /********** ** Upload form *********/ - // get elements - var systemOptions = $("input[name='os']"); - var systemInstructions = $("div[data-os]"); var input = $("#input"); - var submit = $("#submit"); + if (input.length) { + // get elements + var systemOptions = $("input[name='os']"); + var systemInstructions = $("div[data-os]"); + var submit = $("#submit"); - // instruction OS chooser - var chooseSystem = function() { - systemInstructions.hide(); - systemInstructions.filter("[data-os='" + $("input[name='os']:checked").val() + "']").show(); - } - systemOptions.on("click", chooseSystem); - chooseSystem(); + // instruction OS chooser + var chooseSystem = function() { + systemInstructions.hide(); + systemInstructions.filter("[data-os='" + $("input[name='os']:checked").val() + "']").show(); + } + systemOptions.on("click", chooseSystem); + chooseSystem(); - // disable submit if it's empty - var toggleSubmit = function() - { - var hasText = !!input.val().trim(); - submit.prop("disabled", !hasText); - } - input.on("input", toggleSubmit); - toggleSubmit(); + // disable submit if it's empty + var toggleSubmit = function() + { + var hasText = !!input.val().trim(); + submit.prop("disabled", !hasText); + } + input.on("input", toggleSubmit); + toggleSubmit(); - // drag & drop file - input.on({ - 'dragover dragenter': function(e) { - e.preventDefault(); - e.stopPropagation(); - }, - 'drop': function(e) { - var dataTransfer = e.originalEvent.dataTransfer; - if (dataTransfer && dataTransfer.files.length) { + // drag & drop file + input.on({ + 'dragover dragenter': function(e) { e.preventDefault(); e.stopPropagation(); - var file = dataTransfer.files[0]; - var reader = new FileReader(); - reader.onload = $.proxy(function(file, $input, event) { - $input.val(event.target.result); - toggleSubmit(); - }, this, file, $("#input")); - reader.readAsText(file); + }, + 'drop': function(e) { + var dataTransfer = e.originalEvent.dataTransfer; + if (dataTransfer && dataTransfer.files.length) { + e.preventDefault(); + e.stopPropagation(); + var file = dataTransfer.files[0]; + var reader = new FileReader(); + reader.onload = $.proxy(function(file, $input, event) { + $input.val(event.target.result); + toggleSubmit(); + }, this, file, $("#input")); + reader.readAsText(file); + } } - } - }); + }); + } }; |