From 670096343fc72d396e2f7bae6ae719f7ee38ba87 Mon Sep 17 00:00:00 2001 From: ForwardFeed <76596109+ForwardFeed@users.noreply.github.com> Date: Thu, 2 Nov 2023 21:41:47 +0100 Subject: [PATCH 1/6] seems to be working overall, need to test thought --- src/index.template.html | 4 + src/js/moveset_import.js | 4 +- src/js/sharecalc.js | 391 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 397 insertions(+), 2 deletions(-) create mode 100644 src/js/sharecalc.js diff --git a/src/index.template.html b/src/index.template.html index e799c7db0..08c8699cd 100644 --- a/src/index.template.html +++ b/src/index.template.html @@ -1028,6 +1028,9 @@ +
+ +
@@ -1610,6 +1613,7 @@ +
Created by Honko, maintained by Austin and Kris diff --git a/src/js/moveset_import.js b/src/js/moveset_import.js index 825c58aaa..3b4c5154f 100644 --- a/src/js/moveset_import.js +++ b/src/js/moveset_import.js @@ -299,10 +299,10 @@ function addSets(pokes, name) { } } if (addedpokes > 0) { - alert("Successfully imported " + addedpokes + " set(s)"); + //alert("Successfully imported " + addedpokes + " set(s)"); $(allPokemon("#importedSetsOptions")).css("display", "inline"); } else { - alert("No sets imported, please check your syntax and try again"); + //alert("No sets imported, please check your syntax and try again"); } } diff --git a/src/js/sharecalc.js b/src/js/sharecalc.js new file mode 100644 index 000000000..a8824709e --- /dev/null +++ b/src/js/sharecalc.js @@ -0,0 +1,391 @@ +var SHARE_FIELD_TABLE = [ + ["input:radio[name='defaultLevel']", "find"], + ["input:checkbox[name='terrain']", "find"], + ["input:radio[name='format']", "find"], + ["#beads","checked"], + ["#tablets","checked"], + ["#sword","checked"], + ["#vessel","checked"], + ["#magicroom","checked"], + ["#wonderroom","checked"], + ["#gravity","checked"], + ["#srL","checked"], ["#srR","checked"], + ["#steelsurgeL","checked"], ["#steelsurgeR","checked"], + ["#vinelashL","checked"], ["#vinelashR","checked"], + ["#wildfireL","checked"], ["#wildfireR","checked"], + ["#cannonadeL","checked"], ["#cannonadeR","checked"], + ["#volcalithL","checked"], ["#volcalithR","checked"], + ["#reflectL","checked"], ["#reflectR","checked"], + ["#lightScreenL","checked"], ["#lightScreenR","checked"], + ["#protectL","checked"], ["#protectR","checked"], + ["#leechSeedL","checked"], ["#leechSeedR","checked"], + ["#foresightL","checked"], ["#foresightR","checked"], + ["#helpingHandL","checked"], ["#helpingHandR","checked"], + ["#tailwindL","checked"], ["#tailwindR","checked"], + ["#flowerGiftL","checked"], ["#flowerGiftR","checked"], + ["#friendGuardL","checked"], ["#friendGuardR","checked"], + ["#auroraVeilL","checked"], ["#auroraVeilR","checked"], + ["#batteryL","checked"], ["#batteryR","checked"], + ["#powerSpotL","checked"], ["#powerSpotR","checked"], + ["#switchingL","checked"], ["#switchingR","checked"], + ["#critL1", "checked"], ["#critR1", "checked"], + ["#critL2", "checked"], ["#critR2", "checked"], + ["#critL3", "checked"], ["#critR3", "checked"], + ["#critL4", "checked"], ["#critR4", "checked"], + ["#zL1", "checked"], ["#zR1", "checked"], + ["#zL2", "checked"], ["#zR2", "checked"], + ["#zL3", "checked"], ["#zR3", "checked"], + ["#zL4", "checked"], ["#zR4", "checked"], +] +// GS => Generation Specific +var SHARE_GS_FIELD_TABLE = [ + +] +var SHARE_PANNEL_TABLE = [ + [".forme","indexid", "pokedex"], + [".gender","keyid", "genders"], + [".current-hp","val"], + [".percent-hp","val", "100"], + [".status","indexid", "CALC_STATUS"], + [".at .boost","val", "0"], + [".df .boost","val", "0"], + [".sp .boost","val", "0"], + [".saltcure","checked"], + [".max","checked"], +] +var SHARE_GS_PANNEL_TABLE = [ + +] +var SHARE_SET_TABLE = [ + [".level","val", "100"], + [".teraType","indexid", "typeChart"], + [".nature","keyidTI", "NATURES_BY_ID"], + [".item","index", "items"], + [".ability","index", "abilities"], + [".move1 .select2-offscreen.move-selector","indexid", "moves"], + [".move2 .select2-offscreen.move-selector","indexid", "moves"], + [".move3 .select2-offscreen.move-selector","indexid", "moves"], + [".move4 .select2-offscreen.move-selector","indexid", "moves"], + //evs // in function of generation + //ivs // -- + //dvs // -- +] +var SHARE_GS_SET_TABLE = [ + +] + +var genders = ["Male", "Female", ""] +// this was made in an effort to reduce the length of URL +// However questionnable if the complexity it adds is worth. +function adaptFieldsToGen(){ + if (gen == 1) { + SHARE_GS_SET_TABLE = [ + [".sl .dvs","val","15"], + ]; + SHARE_GS_FIELD_TABLE = [ + [".sl .boost","val","0"], + ]; + } else { + SHARE_GS_FIELD_TABLE = [ + [".sa .boost","val","0"], + [".sd .boost","val","0"], + ]; + } + if (gen == 2) { + SHARE_GS_SET_TABLE = [ + [".sa .dvs","val","15"], + [".sd .dvs","val","15"], + ]; + SHARE_GS_FIELD_TABLE = [ + ["#gscSpikesL", "checked"], + ["#gscSpikesR", "checked"], + ["input:radio[name='gscWeather']", "find"], + ]; + } + if (gen < 3){ + SHARE_GS_SET_TABLE = [ + [".hp .dvs","val","15"], + [".at .dvs","val","15"], + [".df .dvs","val","15"], + [".sp .dvs","val","15"], + ]; + + } else { + SHARE_GS_FIELD_TABLE = [ + ["input:radio[name='spikesL']:checked", "val", "0"], + ["input:radio[name='spikesR']:checked", "val", "0"], + ["input:radio[name='weather']", "find"], + ]; + SHARE_GS_SET_TABLE = [ + [".hp .ivs","val","31"], + [".hp .evs","val","0"], + [".at .ivs","val","31"], + [".at .evs","val","0"], + [".df .ivs","val","31"], + [".df .evs","val","0"], + [".sa .ivs","val","31"], + [".sa .evs","val","0"], + [".sd .ivs","val","31"], + [".sd .evs","val","0"], + [".sp .ivs","val","31"], + [".sp .evs","val","0"], + ]; + } +} + +function exportCalculation(){ + adaptFieldsToGen() + var findChecked = function(query){ + var fullQuery = $(query).toArray() + for (var i = 0, iLen = fullQuery.length; i < iLen; i++){ + if (fullQuery[i].checked){ + return i + } + } + return "" + } + // the second layer of compaction + // addLoc => additionnal locator, to adapt to pannels + var tableCompaction = function(table, addLoc){ + addLoc = addLoc || "" + var fieldComposition = "" + for (var i = 0, iLen = table.length; i < iLen; i++){ + var field = table[i]; + var locator = $(addLoc + field[0]); + var extractor = field[1]; + var data = "" + if (extractor === "checked") { + data = +locator.prop("checked") + if (data == 0){ + data = "" + } + } else if (extractor === "val"){ + data = locator.val(); + var defaultVal = field[2] + if (data == defaultVal){ + data = "" + } + } else if (extractor === "find"){ + data = findChecked(locator) + } else if (extractor === "index"){ + var obj = window[field[2]] + data = obj.indexOf(locator.val()) + } else if (extractor === "keyidTI"){ + var obj = window[field[2]] + var value = toID(locator.val()) + data = Object.keys(obj).indexOf(value) + } else if (extractor === "keyid"){ + var obj = window[field[2]] + data = obj.indexOf(locator.val()) + } else if (extractor === "indexid"){ + var obj = window[field[2]] + data = Object.keys(obj).indexOf(locator.val()) + } else if (extractor === "text"){ + data = locator.text() + } + if (!data) { + data = "" + } + fieldComposition += data + ":"; + } + return fieldComposition + } + fieldComposition = ""; + fieldComposition += Object.keys(pokedex).indexOf( + $('#p1 .set-selector.select2-offscreen').val().replace(/ \(.*/, "")) + + ":"; + fieldComposition += Object.keys(pokedex).indexOf( + $('#p2 .set-selector.select2-offscreen').val().replace(/ \(.*/, "")) + + ":"; + fieldComposition += tableCompaction( + SHARE_SET_TABLE.concat(SHARE_GS_SET_TABLE), "#p1 "); + fieldComposition += tableCompaction( + SHARE_SET_TABLE.concat(SHARE_GS_SET_TABLE), "#p2 "); + fieldComposition += tableCompaction( + SHARE_PANNEL_TABLE.concat(SHARE_GS_PANNEL_TABLE), "#p1 "); + fieldComposition += tableCompaction( + SHARE_PANNEL_TABLE.concat(SHARE_GS_PANNEL_TABLE), "#p2 "); + fieldComposition += tableCompaction( + SHARE_FIELD_TABLE.concat(SHARE_GS_FIELD_TABLE)); + // trim the last separator + fieldComposition = fieldComposition.replace(/\:$/,""); + //1:1::11:8:22:-1:28:243:94:30:::11:13:12:::11:8:22:-1:28:243:94:30:::11:13:12::-1:1:::::::355::-1::::::::355:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: + + //return fieldComposition + /* further compaction alg + if there is 3 or more default values in a row + (care to make the tables in a way that all default value sensitive + row are aligned, so its optimise evenmore) + if the field encounters ;, it will interprets the integer following + as the number of default value in a row. + so the uncompacter will expand it intuitively. + */ + var data = fieldComposition.split(":"); + var compactedFieldComposition = ""; + var skip = 0 + // effectively the first layer of compaction + // which trims 50% of the data + var writeSkipped = function(data, skip){ + if (skip == 1){ + // means "::" + data = data.slice(0,-1) + "!"; + } else if (skip == 2) { + // means ":::" + data = data.slice(0,-1) + "~"; + } else if (skip == 3){ + // means ":::" + data = data.slice(0,-1) + "_"; + } + else if (skip >3) { + data = data.slice(0,-1); + data += ";" + skip + ":"; + } + return data; + } + for (var i = 0, iLen = data.length; i < iLen; i++){ + var row = data[i] + if (row === ""){ + skip++; + continue; + } + compactedFieldComposition = writeSkipped(compactedFieldComposition, skip); + + skip = 0 + compactedFieldComposition += row + ":"; + } + if (skip > 0){ + compactedFieldComposition = writeSkipped(compactedFieldComposition, skip); + } + // trim the last separator + compactedFieldComposition = compactedFieldComposition.replace(/\:$/,""); + //file:///media/notalinux/_dev_sdb3/Programation/web/damage-calc/dist/index.html?gen=2&share=1:1::11:::8:::22:::-1:::28:::243:::94:::30:;3:11:;3:13:;3:12:;5:11:;5:8:;5:22:;5:-1:;5:28:;5:243:;5:94:;5:30:;7:11:;7:13:;7:12:;8:-1:;8:1:;14:355:;15:-1:;22:355:;23:_:;23:_:;23:_:;88:_: + //file:///media/notalinux/_dev_sdb3/Programation/web/damage-calc/dist/index.html?gen=2&share=1:1::11:8:22:-1:28:243:94:30:::11:13:12:::11:8:22:-1:28:243:94:30:::11:13:12::-1:1:::::::355::-1::::::::355::_:_:_::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::_ + return "&share=" + compactedFieldComposition; +} + +function importCalculation(compactedData){ + /* + uncompact the first layer of compactions + */ + compactedData = compactedData.replaceAll("!", "::") + compactedData = compactedData.replaceAll("~", ":::") + compactedData = compactedData.replaceAll("_", "::::") + compactedData = compactedData.split(";"); + var data = compactedData[0] + for (var i = 1; i < compactedData.length; i++){ + var row = compactedData[i]; + var skip = row.match(/^[^:]+/)[0]; + row = row.slice(skip.length) + row = ":".repeat(+skip) + row + data += row + } + data = data.split(":") + adaptFieldsToGen() + // function to uncompact the second layer + var tableUncompaction = function(table, addLoc){ + for (var i = 0, iLen = table.length; i < iLen; i++){ + addLoc = addLoc || ""; + var field = table[i]; + var locator = $(addLoc + field[0]); + var extractor = field[1]; + var field_data = data.splice(0,1)[0] + if (extractor === "checked") { + if (+field_data){ + locator.prop("checked", true); + } else { + locator.prop("checked", false); + } + } else if (extractor === "val"){ + var defaultVal = field[2]; + if (field_data){ + locator.val(field_data); + } else { + locator.val(defaultVal); + } + } else if (extractor === "find"){ + if (field_data !== ""){ + locator.eq(field_data).prop("checked", true) + } + } else if (extractor === "index"){ + if (field_data){ + var obj = window[field[2]] + locator.val(obj[field_data]) + } + } else if (extractor === "keyidTI"){ + if (field_data){ + var obj = window[field[2]] + field_data = obj[Object.keys(obj)[field_data]].name + locator.val(field_data) + } + } else if (extractor === "keyid"){ + var obj = window[field[2]] + field_data = obj[Object.keys(obj)[field_data]] + locator.val(field_data) + } else if (extractor === "indexid"){ + var obj = window[field[2]] + field_data = Object.keys(obj)[field_data] + locator.val(field_data) + } else if (extractor === "text"){ + locator.text(field_data) + } + } + } + var pokeL = Object.keys(pokedex)[data.splice(0,1)[0]]; + var pokeR = Object.keys(pokedex)[data.splice(0,1)[0]]; + pokeL = pokeL + " (Shared Set L)"; + pokeR = pokeR + " (Shared Set R)"; + $('#p1 input.set-selector').val(pokeL); + $('#p2 input.set-selector').val(pokeR); + tableUncompaction( + SHARE_SET_TABLE.concat(SHARE_GS_SET_TABLE), "#p1 "); + tableUncompaction( + SHARE_SET_TABLE.concat(SHARE_GS_SET_TABLE), "#p2 "); + + // by doing all of this, i don't overwrite any existing set + // with a newly created set it's overall easier to interact with + ExportPokemon($('#p1')) + document.getElementsByClassName("import-name-text")[0].value = "Shared Set L" + $("#import.bs-btn").click(); + ExportPokemon($('#p2')) + document.getElementsByClassName("import-name-text")[0].value = "Shared Set R" + $("#import.bs-btn").click(); + $('#p1 input.set-selector').val(pokeL); + $('#p2 input.set-selector').val(pokeR); + // then actualizing it set all default value to initial + $('input.set-selector').change() + $('#p1 .set-selector .select2-chosen').text(pokeL); + $('#p2 .set-selector .select2-chosen').text(pokeR); + // just replace all the field by the once shared. + tableUncompaction( + SHARE_PANNEL_TABLE.concat(SHARE_GS_PANNEL_TABLE), "#p1 "); + tableUncompaction( + SHARE_PANNEL_TABLE.concat(SHARE_GS_PANNEL_TABLE), "#p2 "); + tableUncompaction( + SHARE_FIELD_TABLE.concat(SHARE_GS_FIELD_TABLE)); + + //for some reason i had to clean this + document.getElementsByClassName("import-team-text")[0].value = ""; + document.getElementsByClassName("import-name-text")[0].value = "Custom Set"; +} + +$(document).ready(function(){ + $('#share-calc').click(function(){ + var baseLink = (window.location+"").replace(/(?<=html).*/, ""); + var gen = "?gen=" + $("input:radio[name='gen']:checked").val(); + var data = exportCalculation(); + navigator.clipboard.writeText(baseLink+gen+data).then(function () { + $('#share-calc').text("Copied to clipboard") + setTimeout(function(){ + $('#share-calc').text("Share Calculation") + }, 2500) + }); + }) + var params = new URLSearchParams(window.location.search); + var data = params.get('share') + if (data){ + importCalculation(data) + params.delete('share'); + } + +}) + From 984653fd045045b394d5c0ad6414df934a363b02 Mon Sep 17 00:00:00 2001 From: ForwardFeed <76596109+ForwardFeed@users.noreply.github.com> Date: Fri, 3 Nov 2023 09:57:20 +0100 Subject: [PATCH 2/6] some more testing and it should be done --- package-lock.json | 399 +++++++++++------------- package.json | 2 +- src/js/sharecalc.js | 736 ++++++++++++++++++++++---------------------- 3 files changed, 554 insertions(+), 583 deletions(-) diff --git a/package-lock.json b/package-lock.json index 499c7918d..f2755d866 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,7 +7,7 @@ "hasInstallScript": true, "license": "MIT", "devDependencies": { - "eslint": "^8.35.0", + "eslint": "^8.52.0", "express": "^4.18.2", "subpkg": "^4.1.0" }, @@ -56,6 +56,15 @@ "typescript": "^4.9.3" } }, + "node_modules/@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/@ampproject/remapping": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", @@ -1690,15 +1699,39 @@ "node": ">=6.9.0" } }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "dependencies": { + "eslint-visitor-keys": "^3.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", + "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "dev": true, + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, "node_modules/@eslint/eslintrc": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.0.tgz", - "integrity": "sha512-fluIaaV+GyV24CCu/ggiHdV+j4RNh85yQnAYS/G2mZODZgGmmlrgCydjUcV3YvxCm9x8nMAfThsqTni4KiXT4A==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", + "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", "dev": true, "dependencies": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.4.0", + "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -1714,9 +1747,9 @@ } }, "node_modules/@eslint/eslintrc/node_modules/globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "version": "13.23.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", + "integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==", "dev": true, "dependencies": { "type-fest": "^0.20.2" @@ -1729,21 +1762,21 @@ } }, "node_modules/@eslint/js": { - "version": "8.35.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.35.0.tgz", - "integrity": "sha512-JXdzbRiWclLVoD8sNUjR443VVlYqiYmDVT6rGUEIEHU5YJW0gaVZwV2xgM7D4arkvASqD0IlLUVjHiFuxaftRw==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.52.0.tgz", + "integrity": "sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, "node_modules/@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.11.13", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", + "integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", "dev": true, "dependencies": { - "@humanwhocodes/object-schema": "^1.2.1", + "@humanwhocodes/object-schema": "^2.0.1", "debug": "^4.1.1", "minimatch": "^3.0.5" }, @@ -1765,9 +1798,9 @@ } }, "node_modules/@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", + "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", "dev": true }, "node_modules/@jridgewell/gen-mapping": { @@ -1876,6 +1909,12 @@ "node": ">= 8" } }, + "node_modules/@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, "node_modules/accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -1890,9 +1929,9 @@ } }, "node_modules/acorn": { - "version": "8.8.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", - "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", + "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", "devOptional": true, "bin": { "acorn": "bin/acorn" @@ -2344,26 +2383,28 @@ } }, "node_modules/eslint": { - "version": "8.35.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.35.0.tgz", - "integrity": "sha512-BxAf1fVL7w+JLRQhWl2pzGeSiGqbWumV4WNvc9Rhp6tiCtm4oHnyPBSEtMGZwrQgudFQ+otqzWoPB7x+hxoWsw==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.52.0.tgz", + "integrity": "sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg==", "dev": true, "dependencies": { - "@eslint/eslintrc": "^2.0.0", - "@eslint/js": "8.35.0", - "@humanwhocodes/config-array": "^0.11.8", + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.2", + "@eslint/js": "8.52.0", + "@humanwhocodes/config-array": "^0.11.13", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -2371,23 +2412,19 @@ "find-up": "^5.0.0", "glob-parent": "^6.0.2", "globals": "^13.19.0", - "grapheme-splitter": "^1.0.4", + "graphemer": "^1.4.0", "ignore": "^5.2.0", - "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" }, "bin": { @@ -2401,9 +2438,9 @@ } }, "node_modules/eslint-scope": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", - "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, "dependencies": { "esrecurse": "^4.3.0", @@ -2411,42 +2448,21 @@ }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" - } - }, - "node_modules/eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "dependencies": { - "eslint-visitor-keys": "^2.0.0" - }, - "engines": { - "node": "^10.0.0 || ^12.0.0 || >= 14.0.0" }, "funding": { - "url": "https://github.com/sponsors/mysticatea" - }, - "peerDependencies": { - "eslint": ">=5" - } - }, - "node_modules/eslint-utils/node_modules/eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true, - "engines": { - "node": ">=10" + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" } }, "node_modules/eslint/node_modules/ansi-styles": { @@ -2547,14 +2563,14 @@ } }, "node_modules/espree": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", - "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, "dependencies": { - "acorn": "^8.8.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.1" }, "engines": { "node": "^12.22.0 || ^14.17.0 || >=16.0.0" @@ -2872,10 +2888,10 @@ "node": ">=4" } }, - "node_modules/grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "node_modules/graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true }, "node_modules/has": { @@ -3046,16 +3062,6 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, - "node_modules/js-sdsl": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz", - "integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==", - "dev": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/js-sdsl" - } - }, "node_modules/js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -3286,17 +3292,17 @@ } }, "node_modules/optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", "dev": true, "dependencies": { + "@aashutoshrathi/word-wrap": "^1.2.3", "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "type-check": "^0.4.0" }, "engines": { "node": ">= 0.8.0" @@ -3421,9 +3427,9 @@ } }, "node_modules/punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true, "engines": { "node": ">=6" @@ -3521,18 +3527,6 @@ "@babel/runtime": "^7.8.4" } }, - "node_modules/regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true, - "engines": { - "node": ">=8" - }, - "funding": { - "url": "https://github.com/sponsors/mysticatea" - } - }, "node_modules/regexpu-core": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.2.2.tgz", @@ -4068,15 +4062,6 @@ "node": ">= 8" } }, - "node_modules/word-wrap": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", - "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", - "dev": true, - "engines": { - "node": ">=0.10.0" - } - }, "node_modules/wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -4103,6 +4088,12 @@ } }, "dependencies": { + "@aashutoshrathi/word-wrap": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", + "integrity": "sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==", + "dev": true + }, "@ampproject/remapping": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", @@ -5237,15 +5228,30 @@ "to-fast-properties": "^2.0.0" } }, + "@eslint-community/eslint-utils": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.0.tgz", + "integrity": "sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^3.3.0" + } + }, + "@eslint-community/regexpp": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.10.0.tgz", + "integrity": "sha512-Cu96Sd2By9mCNTx2iyKOmq10v22jUVQv0lQnlGNy16oE9589yE+QADPbrMGCkA51cKZSg3Pu/aTJVTGfL/qjUA==", + "dev": true + }, "@eslint/eslintrc": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.0.0.tgz", - "integrity": "sha512-fluIaaV+GyV24CCu/ggiHdV+j4RNh85yQnAYS/G2mZODZgGmmlrgCydjUcV3YvxCm9x8nMAfThsqTni4KiXT4A==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-2.1.2.tgz", + "integrity": "sha512-+wvgpDsrB1YqAMdEUCcnTlpfVBH7Vqn6A/NT3D8WVXFIaKMlErPIZT3oCIAVCOtarRpMtelZLqJeU3t7WY6X6g==", "dev": true, "requires": { "ajv": "^6.12.4", "debug": "^4.3.2", - "espree": "^9.4.0", + "espree": "^9.6.0", "globals": "^13.19.0", "ignore": "^5.2.0", "import-fresh": "^3.2.1", @@ -5255,9 +5261,9 @@ }, "dependencies": { "globals": { - "version": "13.20.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-13.20.0.tgz", - "integrity": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", + "version": "13.23.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-13.23.0.tgz", + "integrity": "sha512-XAmF0RjlrjY23MA51q3HltdlGxUpXPvg0GioKiD9X6HD28iMjo2dKC8Vqwm7lne4GNr78+RHTfliktR6ZH09wA==", "dev": true, "requires": { "type-fest": "^0.20.2" @@ -5266,18 +5272,18 @@ } }, "@eslint/js": { - "version": "8.35.0", - "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.35.0.tgz", - "integrity": "sha512-JXdzbRiWclLVoD8sNUjR443VVlYqiYmDVT6rGUEIEHU5YJW0gaVZwV2xgM7D4arkvASqD0IlLUVjHiFuxaftRw==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-8.52.0.tgz", + "integrity": "sha512-mjZVbpaeMZludF2fsWLD0Z9gCref1Tk4i9+wddjRvpUNqqcndPkBD09N/Mapey0b3jaXbLm2kICwFv2E64QinA==", "dev": true }, "@humanwhocodes/config-array": { - "version": "0.11.8", - "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.8.tgz", - "integrity": "sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==", + "version": "0.11.13", + "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.13.tgz", + "integrity": "sha512-JSBDMiDKSzQVngfRjOdFXgFfklaXI4K9nLF49Auh21lmBWRLIK3+xTErTWD4KU54pb6coM6ESE7Awz/FNU3zgQ==", "dev": true, "requires": { - "@humanwhocodes/object-schema": "^1.2.1", + "@humanwhocodes/object-schema": "^2.0.1", "debug": "^4.1.1", "minimatch": "^3.0.5" } @@ -5289,9 +5295,9 @@ "dev": true }, "@humanwhocodes/object-schema": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz", - "integrity": "sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/object-schema/-/object-schema-2.0.1.tgz", + "integrity": "sha512-dvuCeX5fC9dXgJn9t+X5atfmgQAzUOWqS1254Gh0m6i8wKd10ebXkfNKiRK+1GWi/yTvvLDHpoxLr0xxxeslWw==", "dev": true }, "@jridgewell/gen-mapping": { @@ -5381,6 +5387,12 @@ "fastq": "^1.6.0" } }, + "@ungap/structured-clone": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@ungap/structured-clone/-/structured-clone-1.2.0.tgz", + "integrity": "sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==", + "dev": true + }, "accepts": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", @@ -5392,9 +5404,9 @@ } }, "acorn": { - "version": "8.8.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", - "integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", + "version": "8.11.2", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz", + "integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==", "devOptional": true }, "acorn-jsx": { @@ -5736,26 +5748,28 @@ "optional": true }, "eslint": { - "version": "8.35.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.35.0.tgz", - "integrity": "sha512-BxAf1fVL7w+JLRQhWl2pzGeSiGqbWumV4WNvc9Rhp6tiCtm4oHnyPBSEtMGZwrQgudFQ+otqzWoPB7x+hxoWsw==", + "version": "8.52.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.52.0.tgz", + "integrity": "sha512-zh/JHnaixqHZsolRB/w9/02akBk9EPrOs9JwcTP2ek7yL5bVvXuRariiaAjjoJ5DvuwQ1WAE/HsMz+w17YgBCg==", "dev": true, "requires": { - "@eslint/eslintrc": "^2.0.0", - "@eslint/js": "8.35.0", - "@humanwhocodes/config-array": "^0.11.8", + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.6.1", + "@eslint/eslintrc": "^2.1.2", + "@eslint/js": "8.52.0", + "@humanwhocodes/config-array": "^0.11.13", "@humanwhocodes/module-importer": "^1.0.1", "@nodelib/fs.walk": "^1.2.8", - "ajv": "^6.10.0", + "@ungap/structured-clone": "^1.2.0", + "ajv": "^6.12.4", "chalk": "^4.0.0", "cross-spawn": "^7.0.2", "debug": "^4.3.2", "doctrine": "^3.0.0", "escape-string-regexp": "^4.0.0", - "eslint-scope": "^7.1.1", - "eslint-utils": "^3.0.0", - "eslint-visitor-keys": "^3.3.0", - "espree": "^9.4.0", + "eslint-scope": "^7.2.2", + "eslint-visitor-keys": "^3.4.3", + "espree": "^9.6.1", "esquery": "^1.4.2", "esutils": "^2.0.2", "fast-deep-equal": "^3.1.3", @@ -5763,23 +5777,19 @@ "find-up": "^5.0.0", "glob-parent": "^6.0.2", "globals": "^13.19.0", - "grapheme-splitter": "^1.0.4", + "graphemer": "^1.4.0", "ignore": "^5.2.0", - "import-fresh": "^3.0.0", "imurmurhash": "^0.1.4", "is-glob": "^4.0.0", "is-path-inside": "^3.0.3", - "js-sdsl": "^4.1.4", "js-yaml": "^4.1.0", "json-stable-stringify-without-jsonify": "^1.0.1", "levn": "^0.4.1", "lodash.merge": "^4.6.2", "minimatch": "^3.1.2", "natural-compare": "^1.4.0", - "optionator": "^0.9.1", - "regexpp": "^3.2.0", + "optionator": "^0.9.3", "strip-ansi": "^6.0.1", - "strip-json-comments": "^3.1.0", "text-table": "^0.2.0" }, "dependencies": { @@ -5850,47 +5860,30 @@ } }, "eslint-scope": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.1.1.tgz", - "integrity": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", + "version": "7.2.2", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-7.2.2.tgz", + "integrity": "sha512-dOt21O7lTMhDM+X9mB4GX+DZrZtCUJPL/wlcTqxyrx5IvO0IYtILdtrQGQp+8n5S0gwSVmOf9NQrjMOgfQZlIg==", "dev": true, "requires": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" } }, - "eslint-utils": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-3.0.0.tgz", - "integrity": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", - "dev": true, - "requires": { - "eslint-visitor-keys": "^2.0.0" - }, - "dependencies": { - "eslint-visitor-keys": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-2.1.0.tgz", - "integrity": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", - "dev": true - } - } - }, "eslint-visitor-keys": { - "version": "3.3.0", - "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.3.0.tgz", - "integrity": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", "dev": true }, "espree": { - "version": "9.4.1", - "resolved": "https://registry.npmjs.org/espree/-/espree-9.4.1.tgz", - "integrity": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", + "version": "9.6.1", + "resolved": "https://registry.npmjs.org/espree/-/espree-9.6.1.tgz", + "integrity": "sha512-oruZaFkjorTpF32kDSI5/75ViwGeZginGGy2NoOSg3Q9bnwlnmDm4HLnkl0RE3n+njDXR037aY1+x58Z/zFdwQ==", "dev": true, "requires": { - "acorn": "^8.8.0", + "acorn": "^8.9.0", "acorn-jsx": "^5.3.2", - "eslint-visitor-keys": "^3.3.0" + "eslint-visitor-keys": "^3.4.1" } }, "esquery": { @@ -6149,10 +6142,10 @@ "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", "optional": true }, - "grapheme-splitter": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/grapheme-splitter/-/grapheme-splitter-1.0.4.tgz", - "integrity": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", + "graphemer": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", + "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "dev": true }, "has": { @@ -6278,12 +6271,6 @@ "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, - "js-sdsl": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/js-sdsl/-/js-sdsl-4.2.0.tgz", - "integrity": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==", - "dev": true - }, "js-tokens": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", @@ -6460,17 +6447,17 @@ } }, "optionator": { - "version": "0.9.1", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.1.tgz", - "integrity": "sha512-74RlY5FCnhq4jRxVUPKDaRwrVNXMqsGsiW6AJw4XK8hmtm10wC0ypZBLw5IIp85NZMr91+qd1RvvENwg7jjRFw==", + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.3.tgz", + "integrity": "sha512-JjCoypp+jKn1ttEFExxhetCKeJt9zhAgAve5FXHixTvFDW/5aEktX9bufBKLRRMdU7bNtpLfcGu94B3cdEJgjg==", "dev": true, "requires": { + "@aashutoshrathi/word-wrap": "^1.2.3", "deep-is": "^0.1.3", "fast-levenshtein": "^2.0.6", "levn": "^0.4.1", "prelude-ls": "^1.2.1", - "type-check": "^0.4.0", - "word-wrap": "^1.2.3" + "type-check": "^0.4.0" } }, "p-limit": { @@ -6559,9 +6546,9 @@ } }, "punycode": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", - "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", "dev": true }, "qs": { @@ -6627,12 +6614,6 @@ "@babel/runtime": "^7.8.4" } }, - "regexpp": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/regexpp/-/regexpp-3.2.0.tgz", - "integrity": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", - "dev": true - }, "regexpu-core": { "version": "5.2.2", "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-5.2.2.tgz", @@ -7006,12 +6987,6 @@ "isexe": "^2.0.0" } }, - "word-wrap": { - "version": "1.2.4", - "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.4.tgz", - "integrity": "sha512-2V81OA4ugVo5pRo46hAoD2ivUJx8jXmWXfUkY4KFNw0hEptvN0QfH3K4nHiwzGeKl5rFKedV48QVoqYavy4YpA==", - "dev": true - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/package.json b/package.json index c92e29775..415882404 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "repository": "github:smogon/damage-calc", "license": "MIT", "devDependencies": { - "eslint": "^8.35.0", + "eslint": "^8.52.0", "express": "^4.18.2", "subpkg": "^4.1.0" }, diff --git a/src/js/sharecalc.js b/src/js/sharecalc.js index a8824709e..053310a44 100644 --- a/src/js/sharecalc.js +++ b/src/js/sharecalc.js @@ -1,391 +1,387 @@ var SHARE_FIELD_TABLE = [ - ["input:radio[name='defaultLevel']", "find"], - ["input:checkbox[name='terrain']", "find"], - ["input:radio[name='format']", "find"], - ["#beads","checked"], - ["#tablets","checked"], - ["#sword","checked"], - ["#vessel","checked"], - ["#magicroom","checked"], - ["#wonderroom","checked"], - ["#gravity","checked"], - ["#srL","checked"], ["#srR","checked"], - ["#steelsurgeL","checked"], ["#steelsurgeR","checked"], - ["#vinelashL","checked"], ["#vinelashR","checked"], - ["#wildfireL","checked"], ["#wildfireR","checked"], - ["#cannonadeL","checked"], ["#cannonadeR","checked"], - ["#volcalithL","checked"], ["#volcalithR","checked"], - ["#reflectL","checked"], ["#reflectR","checked"], - ["#lightScreenL","checked"], ["#lightScreenR","checked"], - ["#protectL","checked"], ["#protectR","checked"], - ["#leechSeedL","checked"], ["#leechSeedR","checked"], - ["#foresightL","checked"], ["#foresightR","checked"], - ["#helpingHandL","checked"], ["#helpingHandR","checked"], - ["#tailwindL","checked"], ["#tailwindR","checked"], - ["#flowerGiftL","checked"], ["#flowerGiftR","checked"], - ["#friendGuardL","checked"], ["#friendGuardR","checked"], - ["#auroraVeilL","checked"], ["#auroraVeilR","checked"], - ["#batteryL","checked"], ["#batteryR","checked"], - ["#powerSpotL","checked"], ["#powerSpotR","checked"], - ["#switchingL","checked"], ["#switchingR","checked"], - ["#critL1", "checked"], ["#critR1", "checked"], - ["#critL2", "checked"], ["#critR2", "checked"], - ["#critL3", "checked"], ["#critR3", "checked"], - ["#critL4", "checked"], ["#critR4", "checked"], - ["#zL1", "checked"], ["#zR1", "checked"], - ["#zL2", "checked"], ["#zR2", "checked"], - ["#zL3", "checked"], ["#zR3", "checked"], - ["#zL4", "checked"], ["#zR4", "checked"], -] -// GS => Generation Specific -var SHARE_GS_FIELD_TABLE = [ + ["input:radio[name='defaultLevel']", "find"], + ["input:checkbox[name='terrain']", "find"], + ["input:radio[name='format']", "find"], //not working + ["#beads", "checked"], + ["#tablets", "checked"], + ["#sword", "checked"], + ["#vessel", "checked"], + ["#magicroom", "checked"], + ["#wonderroom", "checked"], + ["#gravity", "checked"], + ["#srL", "checked"], ["#srR", "checked"], + ["#steelsurgeL", "checked"], ["#steelsurgeR", "checked"], + ["#vinelashL", "checked"], ["#vinelashR", "checked"], + ["#wildfireL", "checked"], ["#wildfireR", "checked"], + ["#cannonadeL", "checked"], ["#cannonadeR", "checked"], + ["#volcalithL", "checked"], ["#volcalithR", "checked"], + ["#reflectL", "checked"], ["#reflectR", "checked"], + ["#lightScreenL", "checked"], ["#lightScreenR", "checked"], + ["#protectL", "checked"], ["#protectR", "checked"], + ["#leechSeedL", "checked"], ["#leechSeedR", "checked"], + ["#foresightL", "checked"], ["#foresightR", "checked"], + ["#helpingHandL", "checked"], ["#helpingHandR", "checked"], + ["#tailwindL", "checked"], ["#tailwindR", "checked"], + ["#flowerGiftL", "checked"], ["#flowerGiftR", "checked"], + ["#friendGuardL", "checked"], ["#friendGuardR", "checked"], + ["#auroraVeilL", "checked"], ["#auroraVeilR", "checked"], + ["#batteryL", "checked"], ["#batteryR", "checked"], + ["#powerSpotL", "checked"], ["#powerSpotR", "checked"], + ["#switchingL", "checked"], ["#switchingR", "checked"], + ["#critL1", "checked"], ["#critR1", "checked"], + ["#critL2", "checked"], ["#critR2", "checked"], + ["#critL3", "checked"], ["#critR3", "checked"], + ["#critL4", "checked"], ["#critR4", "checked"], + ["#zL1", "checked"], ["#zR1", "checked"], + ["#zL2", "checked"], ["#zR2", "checked"], + ["#zL3", "checked"], ["#zR3", "checked"], + ["#zL4", "checked"], ["#zR4", "checked"], +]; -] var SHARE_PANNEL_TABLE = [ - [".forme","indexid", "pokedex"], - [".gender","keyid", "genders"], - [".current-hp","val"], - [".percent-hp","val", "100"], - [".status","indexid", "CALC_STATUS"], - [".at .boost","val", "0"], - [".df .boost","val", "0"], - [".sp .boost","val", "0"], - [".saltcure","checked"], - [".max","checked"], -] -var SHARE_GS_PANNEL_TABLE = [ + [".gender", "keyid", "genders"], + //[".current-hp", "val"], conflict with dynamax + [".percent-hp", "val", "100"], + [".status", "indexid", "CALC_STATUS"], + [".at .boost", "val", "0"], + [".df .boost", "val", "0"], + [".sp .boost", "val", "0"], + [".saltcure", "checked"], + [".max", "checked"], +]; -] var SHARE_SET_TABLE = [ - [".level","val", "100"], - [".teraType","indexid", "typeChart"], - [".nature","keyidTI", "NATURES_BY_ID"], - [".item","index", "items"], - [".ability","index", "abilities"], - [".move1 .select2-offscreen.move-selector","indexid", "moves"], - [".move2 .select2-offscreen.move-selector","indexid", "moves"], - [".move3 .select2-offscreen.move-selector","indexid", "moves"], - [".move4 .select2-offscreen.move-selector","indexid", "moves"], - //evs // in function of generation - //ivs // -- - //dvs // -- -] -var SHARE_GS_SET_TABLE = [ + [".level", "val", "100"], + [".teraType", "indexid", "typeChart"], + [".nature", "keyidTI", "NATURES_BY_ID"], + [".item", "index", "items"], + [".ability", "index", "abilities"], + [".move1 .select2-offscreen.move-selector", "indexid", "moves"], + [".move2 .select2-offscreen.move-selector", "indexid", "moves"], + [".move3 .select2-offscreen.move-selector", "indexid", "moves"], + [".move4 .select2-offscreen.move-selector", "indexid", "moves"], + //evs // in function of generation + //ivs // -- + //dvs // -- +]; +// GS => Generation Specific +var SHARE_GS_SET_TABLE, SHARE_GS_PANNEL_TABLE, SHARE_GS_FIELD_TABLE; -] +var genders = ["Male", "Female", ""]; -var genders = ["Male", "Female", ""] // this was made in an effort to reduce the length of URL -// However questionnable if the complexity it adds is worth. -function adaptFieldsToGen(){ - if (gen == 1) { - SHARE_GS_SET_TABLE = [ - [".sl .dvs","val","15"], - ]; - SHARE_GS_FIELD_TABLE = [ - [".sl .boost","val","0"], - ]; +// However questionnable if the complexity it adds is worth. +function adaptFieldsToGen() { + SHARE_GS_SET_TABLE = []; + SHARE_GS_FIELD_TABLE = []; + SHARE_GS_PANNEL_TABLE = []; + if (gen == 1) { + SHARE_GS_SET_TABLE = SHARE_GS_SET_TABLE.concat([ + [".sl .dvs", "val", "15"], + ]); + SHARE_GS_PANNEL_TABLE = SHARE_GS_PANNEL_TABLE.concat([ + [".sl .boost", "val", "0"], + ]); + } else { + SHARE_GS_PANNEL_TABLE = SHARE_GS_PANNEL_TABLE.concat([ + [".sa .boost", "val", "0"], + [".sd .boost", "val", "0"], + ]); + } + if (gen == 2) { + SHARE_GS_SET_TABLE = SHARE_GS_SET_TABLE.concat([ + [".sa .dvs", "val", "15"], + [".sd .dvs", "val", "15"], + ]); + SHARE_GS_FIELD_TABLE = SHARE_GS_FIELD_TABLE.concat([ + ["#gscSpikesL", "checked"], + ["#gscSpikesR", "checked"], + ["input:radio[name='gscWeather']", "find"], + ]); + } + if (gen < 3) { + SHARE_GS_SET_TABLE = SHARE_GS_SET_TABLE.concat([ + [".hp .dvs", "val", "15"], + [".at .dvs", "val", "15"], + [".df .dvs", "val", "15"], + [".sp .dvs", "val", "15"], + ]); } else { - SHARE_GS_FIELD_TABLE = [ - [".sa .boost","val","0"], - [".sd .boost","val","0"], - ]; - } - if (gen == 2) { - SHARE_GS_SET_TABLE = [ - [".sa .dvs","val","15"], - [".sd .dvs","val","15"], - ]; - SHARE_GS_FIELD_TABLE = [ - ["#gscSpikesL", "checked"], - ["#gscSpikesR", "checked"], - ["input:radio[name='gscWeather']", "find"], - ]; + SHARE_GS_FIELD_TABLE = SHARE_GS_FIELD_TABLE.concat([ + ["input:radio[name='spikesL']:checked", "val", "0"], + ["input:radio[name='spikesR']:checked", "val", "0"], + ["input:radio[name='weather']", "find"], + ]); + SHARE_GS_SET_TABLE = SHARE_GS_SET_TABLE.concat([ + [".hp .ivs", "val", "31"], + [".hp .evs", "val", "0"], + [".at .ivs", "val", "31"], + [".at .evs", "val", "0"], + [".df .ivs", "val", "31"], + [".df .evs", "val", "0"], + [".sa .ivs", "val", "31"], + [".sa .evs", "val", "0"], + [".sd .ivs", "val", "31"], + [".sd .evs", "val", "0"], + [".sp .ivs", "val", "31"], + [".sp .evs", "val", "0"], + ]); } - if (gen < 3){ - SHARE_GS_SET_TABLE = [ - [".hp .dvs","val","15"], - [".at .dvs","val","15"], - [".df .dvs","val","15"], - [".sp .dvs","val","15"], - ]; - - } else { - SHARE_GS_FIELD_TABLE = [ - ["input:radio[name='spikesL']:checked", "val", "0"], - ["input:radio[name='spikesR']:checked", "val", "0"], - ["input:radio[name='weather']", "find"], - ]; - SHARE_GS_SET_TABLE = [ - [".hp .ivs","val","31"], - [".hp .evs","val","0"], - [".at .ivs","val","31"], - [".at .evs","val","0"], - [".df .ivs","val","31"], - [".df .evs","val","0"], - [".sa .ivs","val","31"], - [".sa .evs","val","0"], - [".sd .ivs","val","31"], - [".sd .evs","val","0"], - [".sp .ivs","val","31"], - [".sp .evs","val","0"], - ]; - } } -function exportCalculation(){ - adaptFieldsToGen() - var findChecked = function(query){ - var fullQuery = $(query).toArray() - for (var i = 0, iLen = fullQuery.length; i < iLen; i++){ - if (fullQuery[i].checked){ - return i - } - } - return "" - } - // the second layer of compaction - // addLoc => additionnal locator, to adapt to pannels - var tableCompaction = function(table, addLoc){ - addLoc = addLoc || "" - var fieldComposition = "" - for (var i = 0, iLen = table.length; i < iLen; i++){ - var field = table[i]; - var locator = $(addLoc + field[0]); - var extractor = field[1]; - var data = "" - if (extractor === "checked") { - data = +locator.prop("checked") - if (data == 0){ - data = "" - } - } else if (extractor === "val"){ - data = locator.val(); - var defaultVal = field[2] - if (data == defaultVal){ - data = "" - } - } else if (extractor === "find"){ - data = findChecked(locator) - } else if (extractor === "index"){ - var obj = window[field[2]] - data = obj.indexOf(locator.val()) - } else if (extractor === "keyidTI"){ - var obj = window[field[2]] - var value = toID(locator.val()) - data = Object.keys(obj).indexOf(value) - } else if (extractor === "keyid"){ - var obj = window[field[2]] - data = obj.indexOf(locator.val()) - } else if (extractor === "indexid"){ - var obj = window[field[2]] - data = Object.keys(obj).indexOf(locator.val()) - } else if (extractor === "text"){ - data = locator.text() - } - if (!data) { - data = "" - } - fieldComposition += data + ":"; - } - return fieldComposition - } - fieldComposition = ""; - fieldComposition += Object.keys(pokedex).indexOf( - $('#p1 .set-selector.select2-offscreen').val().replace(/ \(.*/, "")) - + ":"; - fieldComposition += Object.keys(pokedex).indexOf( - $('#p2 .set-selector.select2-offscreen').val().replace(/ \(.*/, "")) - + ":"; - fieldComposition += tableCompaction( - SHARE_SET_TABLE.concat(SHARE_GS_SET_TABLE), "#p1 "); - fieldComposition += tableCompaction( - SHARE_SET_TABLE.concat(SHARE_GS_SET_TABLE), "#p2 "); - fieldComposition += tableCompaction( - SHARE_PANNEL_TABLE.concat(SHARE_GS_PANNEL_TABLE), "#p1 "); - fieldComposition += tableCompaction( - SHARE_PANNEL_TABLE.concat(SHARE_GS_PANNEL_TABLE), "#p2 "); - fieldComposition += tableCompaction( - SHARE_FIELD_TABLE.concat(SHARE_GS_FIELD_TABLE)); - // trim the last separator - fieldComposition = fieldComposition.replace(/\:$/,""); - //1:1::11:8:22:-1:28:243:94:30:::11:13:12:::11:8:22:-1:28:243:94:30:::11:13:12::-1:1:::::::355::-1::::::::355:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: - - //return fieldComposition - /* further compaction alg - if there is 3 or more default values in a row - (care to make the tables in a way that all default value sensitive - row are aligned, so its optimise evenmore) - if the field encounters ;, it will interprets the integer following - as the number of default value in a row. - so the uncompacter will expand it intuitively. - */ - var data = fieldComposition.split(":"); - var compactedFieldComposition = ""; - var skip = 0 - // effectively the first layer of compaction - // which trims 50% of the data - var writeSkipped = function(data, skip){ - if (skip == 1){ - // means "::" - data = data.slice(0,-1) + "!"; - } else if (skip == 2) { - // means ":::" - data = data.slice(0,-1) + "~"; - } else if (skip == 3){ - // means ":::" - data = data.slice(0,-1) + "_"; - } - else if (skip >3) { - data = data.slice(0,-1); - data += ";" + skip + ":"; - } - return data; - } - for (var i = 0, iLen = data.length; i < iLen; i++){ - var row = data[i] - if (row === ""){ - skip++; - continue; - } - compactedFieldComposition = writeSkipped(compactedFieldComposition, skip); - - skip = 0 - compactedFieldComposition += row + ":"; - } - if (skip > 0){ - compactedFieldComposition = writeSkipped(compactedFieldComposition, skip); - } - // trim the last separator - compactedFieldComposition = compactedFieldComposition.replace(/\:$/,""); - //file:///media/notalinux/_dev_sdb3/Programation/web/damage-calc/dist/index.html?gen=2&share=1:1::11:::8:::22:::-1:::28:::243:::94:::30:;3:11:;3:13:;3:12:;5:11:;5:8:;5:22:;5:-1:;5:28:;5:243:;5:94:;5:30:;7:11:;7:13:;7:12:;8:-1:;8:1:;14:355:;15:-1:;22:355:;23:_:;23:_:;23:_:;88:_: - //file:///media/notalinux/_dev_sdb3/Programation/web/damage-calc/dist/index.html?gen=2&share=1:1::11:8:22:-1:28:243:94:30:::11:13:12:::11:8:22:-1:28:243:94:30:::11:13:12::-1:1:::::::355::-1::::::::355::_:_:_::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::_ - return "&share=" + compactedFieldComposition; +function exportCalculation() { + adaptFieldsToGen(); + var findChecked = function (query) { + var fullQuery = $(query).toArray(); + for (var i = 0, iLen = fullQuery.length; i < iLen; i++) { + if (fullQuery[i].checked) { + return i; + } + } + return ""; + }; + // the second layer of compaction + // addLoc => additionnal locator, to adapt to pannels + var tableCompaction = function (table, addLoc) { + addLoc = addLoc || ""; + var fieldComposition = ""; + for (var i = 0, iLen = table.length; i < iLen; i++) { + var field = table[i]; + var locator = $(addLoc + field[0]); + var extractor = field[1]; + var data = ""; + if (extractor === "checked") { + data = +locator.prop("checked"); + if (data == 0) { + data = ""; + } + } else if (extractor === "val") { + data = locator.val(); + var defaultVal = field[2]; + if (data == defaultVal) { + data = ""; + } + } else if (extractor === "find") { + data = findChecked(locator); + } else if (extractor === "index") { + var obj = window[field[2]]; + data = obj.indexOf(locator.val()); + } else if (extractor === "keyidTI") { + var obj = window[field[2]]; + var value = window.toID(locator.val()); + data = Object.keys(obj).indexOf(value); + } else if (extractor === "keyid") { + var obj = window[field[2]]; + data = obj.indexOf(locator.val()); + } else if (extractor === "indexid") { + var obj = window[field[2]]; + data = Object.keys(obj).indexOf(locator.val()); + } else if (extractor === "text") { + data = locator.text(); + } + if (!data) { + data = ""; + } + fieldComposition += data + ":"; + } + return fieldComposition; + }; + // directly share the form as the pokemon + var pokeL = $('#p1 .set-selector.select2-offscreen').val().replace(/ \(.*/, ""); + var forme = $('#p1 .forme').val(); + if (pokedex[pokeL].otherFormes.includes(forme)) pokeL = forme; + var pokeR = $('#p2 .set-selector.select2-offscreen').val().replace(/ \(.*/, ""); + forme = $('#p2 .forme').val(); + if (pokedex[pokeR].otherFormes.includes(forme)) pokeR = forme; + var fieldComposition = ""; + fieldComposition += Object.keys(pokedex).indexOf( + pokeL) + ":"; + fieldComposition += Object.keys(pokedex).indexOf( + pokeR) + ":"; + fieldComposition += tableCompaction( + SHARE_SET_TABLE.concat(SHARE_GS_SET_TABLE), "#p1 "); + fieldComposition += tableCompaction( + SHARE_SET_TABLE.concat(SHARE_GS_SET_TABLE), "#p2 "); + fieldComposition += tableCompaction( + SHARE_PANNEL_TABLE.concat(SHARE_GS_PANNEL_TABLE), "#p1 "); + fieldComposition += tableCompaction( + SHARE_PANNEL_TABLE.concat(SHARE_GS_PANNEL_TABLE), "#p2 "); + fieldComposition += tableCompaction( + SHARE_FIELD_TABLE.concat(SHARE_GS_FIELD_TABLE)); + // trim the last separator + fieldComposition = fieldComposition.replace(RegExp(":$"), ""); + + /* further compaction alg + if there is 3 or more default values in a row + (care to make the tables in a way that all default value sensitive + row are aligned, so its optimise evenmore) + if the field encounters ;, it will interprets the integer following + as the number of default value in a row. + so the uncompacter will expand it intuitively. + */ + var data = fieldComposition.split(":"); + var compactedFieldComposition = ""; + var skip = 0; + // effectively the first layer of compaction + // which trims 50% of the data + var writeSkipped = function (data, skip) { + if (skip == 1) { + // means "::" + data = data.slice(0, -1) + "!"; + } else if (skip == 2) { + // means ":::" + data = data.slice(0, -1) + "~"; + } else if (skip == 3) { + // means ":::" + data = data.slice(0, -1) + "_"; + } else if (skip > 3) { + data = data.slice(0, -1); + data += ";" + skip + ":"; + } + return data; + }; + for (var i = 0, iLen = data.length; i < iLen; i++) { + var row = data[i]; + if (row === "") { + skip++; + continue; + } + compactedFieldComposition = writeSkipped(compactedFieldComposition, skip); + skip = 0; + compactedFieldComposition += row + ":"; + } + if (skip > 0) { + compactedFieldComposition = writeSkipped(compactedFieldComposition, skip); + } + // trim the last separator + compactedFieldComposition = compactedFieldComposition.replace(RegExp(":$"), ""); + return "&share=" + compactedFieldComposition; } -function importCalculation(compactedData){ - /* - uncompact the first layer of compactions - */ - compactedData = compactedData.replaceAll("!", "::") - compactedData = compactedData.replaceAll("~", ":::") - compactedData = compactedData.replaceAll("_", "::::") - compactedData = compactedData.split(";"); - var data = compactedData[0] - for (var i = 1; i < compactedData.length; i++){ - var row = compactedData[i]; - var skip = row.match(/^[^:]+/)[0]; - row = row.slice(skip.length) - row = ":".repeat(+skip) + row - data += row - } - data = data.split(":") - adaptFieldsToGen() - // function to uncompact the second layer - var tableUncompaction = function(table, addLoc){ - for (var i = 0, iLen = table.length; i < iLen; i++){ - addLoc = addLoc || ""; - var field = table[i]; - var locator = $(addLoc + field[0]); - var extractor = field[1]; - var field_data = data.splice(0,1)[0] - if (extractor === "checked") { - if (+field_data){ - locator.prop("checked", true); - } else { - locator.prop("checked", false); - } - } else if (extractor === "val"){ - var defaultVal = field[2]; - if (field_data){ - locator.val(field_data); - } else { - locator.val(defaultVal); - } - } else if (extractor === "find"){ - if (field_data !== ""){ - locator.eq(field_data).prop("checked", true) - } - } else if (extractor === "index"){ - if (field_data){ - var obj = window[field[2]] - locator.val(obj[field_data]) - } - } else if (extractor === "keyidTI"){ - if (field_data){ - var obj = window[field[2]] - field_data = obj[Object.keys(obj)[field_data]].name - locator.val(field_data) - } - } else if (extractor === "keyid"){ - var obj = window[field[2]] - field_data = obj[Object.keys(obj)[field_data]] - locator.val(field_data) - } else if (extractor === "indexid"){ - var obj = window[field[2]] - field_data = Object.keys(obj)[field_data] - locator.val(field_data) - } else if (extractor === "text"){ - locator.text(field_data) - } - } - } - var pokeL = Object.keys(pokedex)[data.splice(0,1)[0]]; - var pokeR = Object.keys(pokedex)[data.splice(0,1)[0]]; - pokeL = pokeL + " (Shared Set L)"; - pokeR = pokeR + " (Shared Set R)"; - $('#p1 input.set-selector').val(pokeL); - $('#p2 input.set-selector').val(pokeR); - tableUncompaction( - SHARE_SET_TABLE.concat(SHARE_GS_SET_TABLE), "#p1 "); - tableUncompaction( - SHARE_SET_TABLE.concat(SHARE_GS_SET_TABLE), "#p2 "); +function importCalculation(compactedData) { + /* + uncompact the first layer of compactions + */ + compactedData = compactedData.replaceAll("!", "::"); + compactedData = compactedData.replaceAll("~", ":::"); + compactedData = compactedData.replaceAll("_", "::::"); + compactedData = compactedData.split(";"); + var data = compactedData[0]; + for (var i = 1; i < compactedData.length; i++) { + var row = compactedData[i]; + var skip = row.match(/^[^:]+/)[0]; + row = row.slice(skip.length); + row = ":".repeat(+skip) + row; + data += row; + } + data = data.split(":"); + adaptFieldsToGen(); + // function to uncompact the second layer + var tableUncompaction = function (table, addLoc) { + for (var i = 0, iLen = table.length; i < iLen; i++) { + addLoc = addLoc || ""; + var field = table[i]; + var locator = $(addLoc + field[0]); + var extractor = field[1]; + var field_data = data.splice(0, 1)[0]; + if (extractor === "checked") { + if (+field_data) { + locator.prop("checked", true); + } else { + locator.prop("checked", false); + } + } else if (extractor === "val") { + console.log(field_data,field); + var defaultVal = field[2]; + if (field_data) { + locator.val(field_data); + } else { + locator.val(defaultVal); + } + } else if (extractor === "find") { + if (field_data !== "") { + locator.eq(field_data).prop("checked", true); + } + } else if (extractor === "index") { + if (field_data) { + var obj = window[field[2]]; + locator.val(obj[field_data]); + } + } else if (extractor === "keyidTI") { + if (field_data) { + var obj = window[field[2]]; + field_data = obj[Object.keys(obj)[field_data]].name; + locator.val(field_data); + } + } else if (extractor === "keyid") { + var obj = window[field[2]]; + field_data = obj[Object.keys(obj)[field_data]]; + locator.val(field_data); + } else if (extractor === "indexid") { + var obj = window[field[2]]; + field_data = Object.keys(obj)[field_data]; + locator.val(field_data); + } else if (extractor === "text") { + locator.text(field_data); + } + } + }; + var pokeL = Object.keys(pokedex)[data.splice(0, 1)[0]]; + var pokeR = Object.keys(pokedex)[data.splice(0, 1)[0]]; + pokeL = pokeL + " (Shared Set L)"; + pokeR = pokeR + " (Shared Set R)"; + $('#p1 input.set-selector').val(pokeL); + $('#p2 input.set-selector').val(pokeR); + tableUncompaction( + SHARE_SET_TABLE.concat(SHARE_GS_SET_TABLE), "#p1 "); + tableUncompaction( + SHARE_SET_TABLE.concat(SHARE_GS_SET_TABLE), "#p2 "); - // by doing all of this, i don't overwrite any existing set - // with a newly created set it's overall easier to interact with - ExportPokemon($('#p1')) - document.getElementsByClassName("import-name-text")[0].value = "Shared Set L" - $("#import.bs-btn").click(); - ExportPokemon($('#p2')) - document.getElementsByClassName("import-name-text")[0].value = "Shared Set R" - $("#import.bs-btn").click(); - $('#p1 input.set-selector').val(pokeL); - $('#p2 input.set-selector').val(pokeR); - // then actualizing it set all default value to initial - $('input.set-selector').change() - $('#p1 .set-selector .select2-chosen').text(pokeL); - $('#p2 .set-selector .select2-chosen').text(pokeR); - // just replace all the field by the once shared. - tableUncompaction( - SHARE_PANNEL_TABLE.concat(SHARE_GS_PANNEL_TABLE), "#p1 "); - tableUncompaction( - SHARE_PANNEL_TABLE.concat(SHARE_GS_PANNEL_TABLE), "#p2 "); - tableUncompaction( - SHARE_FIELD_TABLE.concat(SHARE_GS_FIELD_TABLE)); + // by doing all of this, i don't overwrite any existing set + // with a newly created set it's overall easier to interact with + window.ExportPokemon($('#p1')); + document.getElementsByClassName("import-name-text")[0].value = "Shared Set L"; + $("#import.bs-btn").click(); + window.ExportPokemon($('#p2')); + document.getElementsByClassName("import-name-text")[0].value = "Shared Set R"; + $("#import.bs-btn").click(); + $('#p1 input.set-selector').val(pokeL); + $('#p2 input.set-selector').val(pokeR); + // then actualizing it set all default value to initial + $('input.set-selector').change(); + $('#p1 .set-selector .select2-chosen').text(pokeL); + $('#p2 .set-selector .select2-chosen').text(pokeR); + // just replace all the field by the once shared. + tableUncompaction( + SHARE_PANNEL_TABLE.concat(SHARE_GS_PANNEL_TABLE), "#p1 "); + tableUncompaction( + SHARE_PANNEL_TABLE.concat(SHARE_GS_PANNEL_TABLE), "#p2 "); + tableUncompaction( + SHARE_FIELD_TABLE.concat(SHARE_GS_FIELD_TABLE)); - //for some reason i had to clean this - document.getElementsByClassName("import-team-text")[0].value = ""; + //for some reason i had to clean this + document.getElementsByClassName("import-team-text")[0].value = ""; document.getElementsByClassName("import-name-text")[0].value = "Custom Set"; } -$(document).ready(function(){ - $('#share-calc').click(function(){ - var baseLink = (window.location+"").replace(/(?<=html).*/, ""); - var gen = "?gen=" + $("input:radio[name='gen']:checked").val(); - var data = exportCalculation(); - navigator.clipboard.writeText(baseLink+gen+data).then(function () { - $('#share-calc').text("Copied to clipboard") - setTimeout(function(){ - $('#share-calc').text("Share Calculation") - }, 2500) - }); - }) - var params = new URLSearchParams(window.location.search); - var data = params.get('share') - if (data){ - importCalculation(data) - params.delete('share'); - } +$(document).ready(function () { + $('#share-calc').click(function () { + var baseLink = (window.location + "").replace(RegExp("(?<=html).*"), ""); + var gen = "?gen=" + $("input:radio[name='gen']:checked").val(); + var data = exportCalculation(); + navigator.clipboard.writeText(baseLink + gen + data).then(function () { + $('#share-calc').text("Copied to clipboard"); + setTimeout(function () { + $('#share-calc').text("Share Calculation"); + }, 2500); + }); + }); + var params = new URLSearchParams(window.location.search); + var data = params.get('share'); + if (data) { + importCalculation(data); + params.delete('share'); + } -}) +}); From e3c7aedb2ec1b62c9c906b5298e844b3426a5291 Mon Sep 17 00:00:00 2001 From: ForwardFeed <76596109+ForwardFeed@users.noreply.github.com> Date: Sat, 4 Nov 2023 13:30:07 +0100 Subject: [PATCH 3/6] small fix and commenting --- src/js/moveset_import.js | 4 ++-- src/js/sharecalc.js | 44 ++++++++++++++++++++++++++++++++-------- 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/js/moveset_import.js b/src/js/moveset_import.js index 3b4c5154f..825c58aaa 100644 --- a/src/js/moveset_import.js +++ b/src/js/moveset_import.js @@ -299,10 +299,10 @@ function addSets(pokes, name) { } } if (addedpokes > 0) { - //alert("Successfully imported " + addedpokes + " set(s)"); + alert("Successfully imported " + addedpokes + " set(s)"); $(allPokemon("#importedSetsOptions")).css("display", "inline"); } else { - //alert("No sets imported, please check your syntax and try again"); + alert("No sets imported, please check your syntax and try again"); } } diff --git a/src/js/sharecalc.js b/src/js/sharecalc.js index 053310a44..697407da9 100644 --- a/src/js/sharecalc.js +++ b/src/js/sharecalc.js @@ -1,7 +1,39 @@ +/* + Quick Explanation. + This is to share with someone your calculation at a given time. + By clicking Share Calculation at the Import/Export section, + the user gets a link copied to its clipboard. + The user then share this link to another user by external means, + which when opened recreate the calculation. + + I'll call field HTML nodes that contains a data important + needed to recreate the calculation. + Some field might be missing. To add another field to be shared + there are table, or rather maps, that are used to ravel and unravel the data. + Each element of the table have this structure. + [0] => Jquery selector to the HTML node + [1] => The function name to call to extract the data from the HTML node + [2] => Specific to the function name, + for example for the func "val", it's the default value, so when not written it can be + implicitely recovered without writing any data. + + Table wise: + use SHARE_FIELD_TABLE if it's not specific to a pannel, + or if you directly target the field by its ID. + use SHARE_PANNEL_TABLE if it's specific a pannel, + and you have a class or any non-id Jquery selector. + use SHARE_SET_TABLE if it's data that is used by the export/import + because when shared it first insert the calculation protagonists + as a custom set. + + adaptFieldsToGen() function modify just before ravelling the data to + , in idea, to share only what's needed. but to be fair it might be overkill. + +*/ var SHARE_FIELD_TABLE = [ ["input:radio[name='defaultLevel']", "find"], ["input:checkbox[name='terrain']", "find"], - ["input:radio[name='format']", "find"], //not working + ["input:radio[name='format']", "find"], ["#beads", "checked"], ["#tablets", "checked"], ["#sword", "checked"], @@ -40,8 +72,7 @@ var SHARE_FIELD_TABLE = [ var SHARE_PANNEL_TABLE = [ [".gender", "keyid", "genders"], - //[".current-hp", "val"], conflict with dynamax - [".percent-hp", "val", "100"], + [".current-hp", "val"], [".status", "indexid", "CALC_STATUS"], [".at .boost", "val", "0"], [".df .boost", "val", "0"], @@ -69,8 +100,6 @@ var SHARE_GS_SET_TABLE, SHARE_GS_PANNEL_TABLE, SHARE_GS_FIELD_TABLE; var genders = ["Male", "Female", ""]; -// this was made in an effort to reduce the length of URL -// However questionnable if the complexity it adds is worth. function adaptFieldsToGen() { SHARE_GS_SET_TABLE = []; SHARE_GS_FIELD_TABLE = []; @@ -189,10 +218,10 @@ function exportCalculation() { // directly share the form as the pokemon var pokeL = $('#p1 .set-selector.select2-offscreen').val().replace(/ \(.*/, ""); var forme = $('#p1 .forme').val(); - if (pokedex[pokeL].otherFormes.includes(forme)) pokeL = forme; + if (pokedex[pokeL].otherFormes && pokedex[pokeL].otherFormes.includes(forme)) pokeL = forme; var pokeR = $('#p2 .set-selector.select2-offscreen').val().replace(/ \(.*/, ""); forme = $('#p2 .forme').val(); - if (pokedex[pokeR].otherFormes.includes(forme)) pokeR = forme; + if (pokedex[pokeR].otherFormes && pokedex[pokeR].otherFormes.includes(forme)) pokeR = forme; var fieldComposition = ""; fieldComposition += Object.keys(pokedex).indexOf( pokeL) + ":"; @@ -291,7 +320,6 @@ function importCalculation(compactedData) { locator.prop("checked", false); } } else if (extractor === "val") { - console.log(field_data,field); var defaultVal = field[2]; if (field_data) { locator.val(field_data); From 41c0a01dcc5668b54420f51543e49c44be1b3ca0 Mon Sep 17 00:00:00 2001 From: ForwardFeed <76596109+ForwardFeed@users.noreply.github.com> Date: Sat, 4 Nov 2023 19:56:08 +0100 Subject: [PATCH 4/6] notified bug with dynamax --- src/js/sharecalc.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/js/sharecalc.js b/src/js/sharecalc.js index 697407da9..34ef0b37c 100644 --- a/src/js/sharecalc.js +++ b/src/js/sharecalc.js @@ -72,13 +72,15 @@ var SHARE_FIELD_TABLE = [ var SHARE_PANNEL_TABLE = [ [".gender", "keyid", "genders"], + [".max", "checked"], + // bug: gigamax conflicts with current HP because it generates the giga max hp update after the current hp + // effectively doubling the HP it should have [".current-hp", "val"], [".status", "indexid", "CALC_STATUS"], [".at .boost", "val", "0"], [".df .boost", "val", "0"], [".sp .boost", "val", "0"], [".saltcure", "checked"], - [".max", "checked"], ]; var SHARE_SET_TABLE = [ From 181242b7d282710d37245d75c1c63b745b982a3b Mon Sep 17 00:00:00 2001 From: ForwardFeed <76596109+ForwardFeed@users.noreply.github.com> Date: Thu, 9 Nov 2023 13:53:40 +0100 Subject: [PATCH 5/6] small bug fix --- src/js/sharecalc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/sharecalc.js b/src/js/sharecalc.js index 34ef0b37c..b28b2b2be 100644 --- a/src/js/sharecalc.js +++ b/src/js/sharecalc.js @@ -273,7 +273,7 @@ function exportCalculation() { }; for (var i = 0, iLen = data.length; i < iLen; i++) { var row = data[i]; - if (row === "") { + if (row === "" && i != 0) { skip++; continue; } From 2b8c8608477afcf55c233850120b7a07d3191a6f Mon Sep 17 00:00:00 2001 From: Austin Couturier Date: Mon, 1 Jul 2024 14:07:49 -0600 Subject: [PATCH 6/6] remove unneeded lines --- calc/package-lock.json | 2 +- calc/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/calc/package-lock.json b/calc/package-lock.json index 70705e585..d02867d6b 100644 --- a/calc/package-lock.json +++ b/calc/package-lock.json @@ -8454,4 +8454,4 @@ "dev": true } } -} +} \ No newline at end of file diff --git a/calc/package.json b/calc/package.json index 4120d562c..2f26a63cd 100644 --- a/calc/package.json +++ b/calc/package.json @@ -37,4 +37,4 @@ "pretest": "npm run build", "posttest": "npm run lint" } -} +} \ No newline at end of file