summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/wwwroot/Content
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-11-24 13:49:30 -0500
committerJesse Plamondon-Willard <Pathoschild@users.noreply.github.com>2019-11-24 13:49:30 -0500
commita3f21685049cabf2d824c8060dc0b1de47e9449e (patch)
treead9add30e9da2a50e0ea0245f1546b7378f0d282 /src/SMAPI.Web/wwwroot/Content
parent6521df7b131924835eb797251c1e956fae0d6e13 (diff)
parent277bf082675b98b95bf6184fe3c7a45b969c7ac2 (diff)
downloadSMAPI-a3f21685049cabf2d824c8060dc0b1de47e9449e.tar.gz
SMAPI-a3f21685049cabf2d824c8060dc0b1de47e9449e.tar.bz2
SMAPI-a3f21685049cabf2d824c8060dc0b1de47e9449e.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI.Web/wwwroot/Content')
-rw-r--r--src/SMAPI.Web/wwwroot/Content/css/json-validator.css111
-rw-r--r--src/SMAPI.Web/wwwroot/Content/css/main.css2
-rw-r--r--src/SMAPI.Web/wwwroot/Content/css/mods.css57
-rw-r--r--src/SMAPI.Web/wwwroot/Content/js/json-validator.js179
-rw-r--r--src/SMAPI.Web/wwwroot/Content/js/log-parser.js17
-rw-r--r--src/SMAPI.Web/wwwroot/Content/js/mods.js3
6 files changed, 335 insertions, 34 deletions
diff --git a/src/SMAPI.Web/wwwroot/Content/css/json-validator.css b/src/SMAPI.Web/wwwroot/Content/css/json-validator.css
new file mode 100644
index 00000000..cd117694
--- /dev/null
+++ b/src/SMAPI.Web/wwwroot/Content/css/json-validator.css
@@ -0,0 +1,111 @@
+/*********
+** Main layout
+*********/
+#content {
+ max-width: 100%;
+}
+
+#output {
+ padding: 10px;
+ overflow: auto;
+}
+
+#output table td {
+ font-family: monospace;
+}
+
+#output table tr th,
+#output table tr td {
+ padding: 0 0.75rem;
+ white-space: pre-wrap;
+}
+
+
+/*********
+** Result banner
+*********/
+.banner {
+ border: 2px solid gray;
+ border-radius: 5px;
+ margin-top: 1em;
+ padding: 1em;
+}
+
+.banner.success {
+ border-color: green;
+ background: #CFC;
+}
+
+.banner.error {
+ border-color: red;
+ background: #FCC;
+}
+
+/*********
+** Validation results
+*********/
+.table {
+ border-bottom: 1px dashed #888888;
+ margin-bottom: 5px;
+}
+
+#metadata th, #metadata td {
+ text-align: left;
+ padding-right: 0.7em;
+}
+
+.table {
+ border: 1px solid #000000;
+ background: #ffffff;
+ border-radius: 5px;
+ border-spacing: 1px;
+ overflow: hidden;
+ cursor: default;
+ box-shadow: 1px 1px 1px 1px #dddddd;
+}
+
+.table tr {
+ background: #eee;
+}
+
+.table tr:nth-child(even) {
+ background: #fff;
+}
+
+#output div.sunlight-line-highlight-active {
+ background-color: #eeeacc;
+}
+
+.footer-tip {
+ color: gray;
+ font-size: 0.9em;
+}
+
+.footer-tip a {
+ color: gray;
+}
+
+/*********
+** Upload form
+*********/
+#input {
+ width: 100%;
+ height: 20em;
+ max-height: 70%;
+ margin: auto;
+ box-sizing: border-box;
+ border-radius: 5px;
+ border: 1px solid #000088;
+ outline: none;
+ box-shadow: inset 0px 0px 1px 1px rgba(0, 0, 192, .2);
+}
+
+#submit {
+ font-size: 1.5em;
+ border-radius: 5px;
+ outline: none;
+ box-shadow: inset 0 0 1px 1px rgba(0, 0, 0, .2);
+ cursor: pointer;
+ border: 1px solid #008800;
+ background-color: #cfc;
+}
diff --git a/src/SMAPI.Web/wwwroot/Content/css/main.css b/src/SMAPI.Web/wwwroot/Content/css/main.css
index 57eeee88..dcc7a798 100644
--- a/src/SMAPI.Web/wwwroot/Content/css/main.css
+++ b/src/SMAPI.Web/wwwroot/Content/css/main.css
@@ -73,7 +73,7 @@ a {
}
#sidebar h4 {
- margin: 0 0 0.2em 0;
+ margin: 1.5em 0 0.2em 0;
width: 10em;
border-bottom: 1px solid #CCC;
font-size: 0.8em;
diff --git a/src/SMAPI.Web/wwwroot/Content/css/mods.css b/src/SMAPI.Web/wwwroot/Content/css/mods.css
index fc5fff47..1c2b8056 100644
--- a/src/SMAPI.Web/wwwroot/Content/css/mods.css
+++ b/src/SMAPI.Web/wwwroot/Content/css/mods.css
@@ -15,30 +15,6 @@
border: 3px solid darkgreen;
}
-table.wikitable {
- background-color:#f8f9fa;
- color:#222;
- border:1px solid #a2a9b1;
- border-collapse:collapse
-}
-
-table.wikitable > tr > th,
-table.wikitable > tr > td,
-table.wikitable > * > tr > th,
-table.wikitable > * > tr > td {
- border:1px solid #a2a9b1;
- padding:0.2em 0.4em
-}
-
-table.wikitable > tr > th,
-table.wikitable > * > tr > th {
- background-color:#eaecf0;
-}
-
-table.wikitable > caption {
- font-weight:bold
-}
-
#options {
margin-bottom: 1em;
}
@@ -73,6 +49,39 @@ table.wikitable > caption {
opacity: 0.5;
}
+div.error {
+ padding: 2em 0;
+ color: red;
+ font-weight: bold;
+}
+
+/*********
+** Mod list
+*********/
+table.wikitable {
+ background-color:#f8f9fa;
+ color:#222;
+ border:1px solid #a2a9b1;
+ border-collapse:collapse
+}
+
+table.wikitable > tr > th,
+table.wikitable > tr > td,
+table.wikitable > * > tr > th,
+table.wikitable > * > tr > td {
+ border:1px solid #a2a9b1;
+ padding:0.2em 0.4em
+}
+
+table.wikitable > tr > th,
+table.wikitable > * > tr > th {
+ background-color:#eaecf0;
+}
+
+table.wikitable > caption {
+ font-weight:bold
+}
+
#mod-list {
font-size: 0.9em;
}
diff --git a/src/SMAPI.Web/wwwroot/Content/js/json-validator.js b/src/SMAPI.Web/wwwroot/Content/js/json-validator.js
new file mode 100644
index 00000000..5499cef6
--- /dev/null
+++ b/src/SMAPI.Web/wwwroot/Content/js/json-validator.js
@@ -0,0 +1,179 @@
+/* globals $ */
+
+var smapi = smapi || {};
+
+/**
+ * Manages the logic for line range selections.
+ * @param {int} maxLines The maximum number of lines in the content.
+ */
+smapi.LineNumberRange = function (maxLines) {
+ var self = this;
+
+ /**
+ * @var {int} minLine The first line in the selection, or null if no lines selected.
+ */
+ self.minLine = null;
+
+ /**
+ * @var {int} maxLine The last line in the selection, or null if no lines selected.
+ */
+ self.maxLine = null;
+
+ /**
+ * Parse line numbers from a URL hash.
+ * @param {string} hash the URL hash to parse.
+ */
+ self.parseFromUrlHash = function (hash) {
+ self.minLine = null;
+ self.maxLine = null;
+
+ // parse hash
+ var hashParts = hash.match(/^#L(\d+)(?:-L(\d+))?$/);
+ if (!hashParts || hashParts.length <= 1)
+ return;
+
+ // extract min/max lines
+ self.minLine = parseInt(hashParts[1]);
+ self.maxLine = parseInt(hashParts[2]) || self.minLine;
+ };
+
+ /**
+ * Generate a URL hash for the current line range.
+ * @returns {string} The generated URL hash.
+ */
+ self.buildHash = function() {
+ if (!self.minLine)
+ return "";
+ else if (self.minLine === self.maxLine)
+ return "#L" + self.minLine;
+ else
+ return "#L" + self.minLine + "-L" + self.maxLine;
+ }
+
+ /**
+ * Get a list of all selected lines.
+ * @returns {Array<int>} The selected line numbers.
+ */
+ self.getLinesSelected = function() {
+ // format
+ if (!self.minLine)
+ return [];
+
+ var lines = [];
+ for (var i = self.minLine; i <= self.maxLine; i++)
+ lines.push(i);
+ return lines;
+ };
+
+ return self;
+};
+
+/**
+ * UI logic for the JSON validator page.
+ * @param {any} sectionUrl The base JSON validator page URL.
+ * @param {any} pasteID The Pastebin paste ID for the content being viewed, if any.
+ */
+smapi.jsonValidator = function (sectionUrl, pasteID) {
+ /**
+ * The original content element.
+ */
+ var originalContent = $("#raw-content").clone();
+
+ /**
+ * The currently highlighted lines.
+ */
+ var selection = new smapi.LineNumberRange();
+
+ /**
+ * Rebuild the syntax-highlighted element.
+ */
+ var formatCode = function () {
+ // reset if needed
+ $(".sunlight-container").replaceWith(originalContent.clone());
+
+ // apply default highlighting
+ Sunlight.highlightAll({
+ lineHighlight: selection.getLinesSelected()
+ });
+
+ // fix line links
+ $(".sunlight-line-number-margin a").each(function() {
+ var link = $(this);
+ var lineNumber = parseInt(link.text());
+ link
+ .attr("id", "L" + lineNumber)
+ .attr("href", "#L" + lineNumber)
+ .removeAttr("name")
+ .data("line-number", lineNumber);
+ });
+ };
+
+ /**
+ * Scroll the page so the selected range is visible.
+ */
+ var scrollToRange = function() {
+ if (!selection.minLine)
+ return;
+
+ var targetLine = Math.max(1, selection.minLine - 5);
+ $("#L" + targetLine).get(0).scrollIntoView();
+ };
+
+ /**
+ * Initialize the JSON validator page.
+ */
+ var init = function () {
+ // set initial code formatting
+ selection.parseFromUrlHash(location.hash);
+ formatCode();
+ scrollToRange();
+
+ // update code formatting on hash change
+ $(window).on("hashchange", function() {
+ selection.parseFromUrlHash(location.hash);
+ formatCode();
+ scrollToRange();
+ });
+
+ // change format
+ $("#output #format").on("change", function() {
+ var schemaName = $(this).val();
+ location.href = new URL(schemaName + "/" + pasteID, sectionUrl).toString();
+ });
+
+ // upload form
+ var input = $("#input");
+ if (input.length) {
+ // 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) {
+ 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);
+ }
+ }
+ });
+ }
+ };
+ init();
+};
diff --git a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js
index e87a1a5c..e6c7591c 100644
--- a/src/SMAPI.Web/wwwroot/Content/js/log-parser.js
+++ b/src/SMAPI.Web/wwwroot/Content/js/log-parser.js
@@ -23,7 +23,7 @@ smapi.logParser = function (data, sectionUrl) {
}
// set local time started
- if(data)
+ if (data)
data.localTimeStarted = ("0" + data.logStarted.getHours()).slice(-2) + ":" + ("0" + data.logStarted.getMinutes()).slice(-2);
// init app
@@ -100,7 +100,7 @@ smapi.logParser = function (data, sectionUrl) {
updateModFilters();
},
- filtersAllow: function(modId, level) {
+ filtersAllow: function (modId, level) {
return this.showMods[modId] !== false && this.showLevels[level] !== false;
},
@@ -121,16 +121,15 @@ smapi.logParser = function (data, sectionUrl) {
var submit = $("#submit");
// instruction OS chooser
- var chooseSystem = function() {
+ 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 toggleSubmit = function () {
var hasText = !!input.val().trim();
submit.prop("disabled", !hasText);
}
@@ -139,18 +138,18 @@ smapi.logParser = function (data, sectionUrl) {
// drag & drop file
input.on({
- 'dragover dragenter': function(e) {
+ 'dragover dragenter': function (e) {
e.preventDefault();
e.stopPropagation();
},
- 'drop': function(e) {
+ '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) {
+ reader.onload = $.proxy(function (file, $input, event) {
$input.val(event.target.result);
toggleSubmit();
}, this, file, $("#input"));
diff --git a/src/SMAPI.Web/wwwroot/Content/js/mods.js b/src/SMAPI.Web/wwwroot/Content/js/mods.js
index 130f60be..0394ac4f 100644
--- a/src/SMAPI.Web/wwwroot/Content/js/mods.js
+++ b/src/SMAPI.Web/wwwroot/Content/js/mods.js
@@ -44,6 +44,7 @@ smapi.modList = function (mods, enableBeta) {
download: {
value: {
chucklefish: { value: true, label: "Chucklefish" },
+ curseforge: { value: true, label: "CurseForge" },
moddrop: { value: true, label: "ModDrop" },
nexus: { value: true, label: "Nexus" },
custom: { value: true }
@@ -180,6 +181,8 @@ smapi.modList = function (mods, enableBeta) {
if (!filters.download.value.chucklefish.value)
ignoreSites.push("Chucklefish");
+ if (!filters.download.value.curseforge.value)
+ ignoreSites.push("CurseForge");
if (!filters.download.value.moddrop.value)
ignoreSites.push("ModDrop");
if (!filters.download.value.nexus.value)