diff options
Diffstat (limited to 'src/SMAPI.Web/wwwroot/Content/js/log-parser.js')
-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); + } } - } - }); + }); + } }; |