diff --git a/browser-compatibility.js b/browser-compatibility.js index fb4111e5..d70be569 100644 --- a/browser-compatibility.js +++ b/browser-compatibility.js @@ -20,7 +20,7 @@ {name: "CSS selector: :not() / CSS选择器: :not()", version:{firefox:84,chrome:88,safari:9}, url: "https://caniuse.com/css-not-sel-list", test: ()=>supportsPseudoClass(":not(html)")}, //{name: "CSS selector: :has() / CSS选择器: :has()", version:{firefox:121,chrome:105,safari:15.4}, url: "https://caniuse.com/css-has", test: ()=>supportsPseudoClass(":has(html)")}, {name: "Private class fields (#name) / 类私有域(#name)", version:{firefox:90,chrome:74,safari:14.5}, url: "https://caniuse.com/mdn-javascript_classes_private_class_fields", test: ()=>Boolean(runCodeWithFunction("class test {#v = 0;}, true"))}, - {name: "Dialog element / Dialog 元素", version:{firefox:98,chrome:37,safari:15.4}, url: "https://caniuse.com/dialog", test: ()=>Boolean(eval("HTMLDialogElement"))}, + {name: "Dialog element / Dialog 元素", version:{firefox:98,chrome:37,safari:15.4}, url: "https://caniuse.com/dialog", test: ()=>Boolean(window.HTMLDialogElement)}, // {name: "Class static initialization blocks / 静态初始化块", version:{firefox:93,chrome:94,safari:16.4}, url: "https://caniuse.com/mdn-javascript_classes_static_initialization_blocks", test: ()=>supportsPseudoClass(":not(html)")}, ] return features.filter(feature=>{ diff --git a/script-universal_function.js b/script-universal_function.js index 16faa2ad..27b72f27 100644 --- a/script-universal_function.js +++ b/script-universal_function.js @@ -192,7 +192,7 @@ function BigNumberToStringLocalise(separators, splitDigits = 3 ) { const grouping = 10 ** splitDigits; separators = separators.map(s=>s.toString()); - return function(){ + return function(options = {}){ const thisValue = this.valueOf(); if (thisValue === 0 || thisValue === Infinity || @@ -213,13 +213,25 @@ function BigNumberToStringLocalise(separators, splitDigits = 3 ) { numLevels.push(numTemp); } - let outStr = thisValue < 0 ? '-' : ''; - for (let i = numLevels.length; i--; ) { - if (numLevels[i] > 0) - outStr += numLevels[i].toString(10) + separators[i]; + if (options?.sub) { + let outFragment = document.createDocumentFragment(); + if (thisValue < 0) outFragment.append('-'); + for (let i = numLevels.length; i--; ) { + if (numLevels[i] > 0) { + const separator = document.createElement("sub"); + separator.textContent = separators[i]; + outFragment.append(numLevels[i].toString(10), separator); + } + } + return outFragment; + } else { + let outStr = thisValue < 0 ? '-' : ''; + for (let i = numLevels.length; i--; ) { + if (numLevels[i] > 0) + outStr += numLevels[i].toString(10) + separators[i]; + } + return outStr; } - - return outStr; } } Number.prototype.bigNumberToString = BigNumberToStringLocalise(['', 'K ', 'M ', 'G ', 'T ', 'P ', 'E ', 'Z ', 'Y ', 'R ', 'Q '], 3); diff --git a/script.js b/script.js index a54c6bb7..e1a52fbc 100644 --- a/script.js +++ b/script.js @@ -5431,7 +5431,8 @@ function initialize() { level: level }; const needExpArr = calculateExp(tempMon); - monLvExp.textContent = needExpArr ? needExpArr.map(exp=>exp.bigNumberToString()).join(" + ") : ""; + monLvExp.innerHTML = ''; + if (needExpArr) monLvExp.append(needExpArr.map(exp=>exp.bigNumberToString({sub: true})).nodeJoin(" + ")); } editBox.reCalculateExp = reCalculateExp; //三维 @@ -5682,7 +5683,7 @@ function initialize() { if (teamTotalInfoDom) refreshTeamTotalHP(teamTotalInfoDom, teamData, editBox.memberIdx[0]); const teamTotalInfoCountDom = teamBigBox.querySelector(".team-total-info-count"); //队伍星级、属性、类型合计 - if (teamTotalInfoCountDom) refreshTeamTotalCount(teamTotalInfoCountDom, teamData, teamNum); + if (teamTotalInfoCountDom) refreshTeamTotalCount(teamTotalInfoCountDom, teamData, editBox.memberIdx[0]); const formationTotalInfoDom = formationBox.querySelector(".formation-total-info"); //所有队伍能力值合计 if (formationTotalInfoDom) refreshFormationTotalHP(formationTotalInfoDom, formation.teams); @@ -7225,11 +7226,17 @@ function refreshMemberAwoken(memberAwokenDom, assistAwokenDom, team, idx) { }); } -function setTextContentAndAttribute(dom,str) +function setTextContentAndAttribute(dom, str, number) { if (!dom) return; - dom.textContent = str; - dom.setAttribute(dataAttrName, str); + if (typeof str == "string") { + dom.textContent = str; + } + else { + dom.innerHTML = ''; + dom.append(str); + } + dom.setAttribute(dataAttrName, number ?? str); } function drawHpInfo(hpBarDom, reduceAttrRanges) @@ -7354,12 +7361,12 @@ function refreshTeamTotalHP(totalDom, team, teamIdx) { const tHpDom_noAwoken = tHpDom.querySelector(".awoken-bind"); const tHpDom_reduce = tHpDom.querySelector(".reduce"); - setTextContentAndAttribute(tHpDom_general, tHP.bigNumberToString()); - setTextContentAndAttribute(tHpDom_noAwoken, tHPNoAwoken.bigNumberToString()); + setTextContentAndAttribute(tHpDom_general, tHP.bigNumberToString({sub: true})); + setTextContentAndAttribute(tHpDom_noAwoken, tHPNoAwoken.bigNumberToString({sub: true})); tHpDom_reduce.classList.toggle("no-reduce", totalReduce == 0); setTextContentAndAttribute(tHpDom_reduce.querySelector(".reduce-scale"), (totalReduce * 100).toFixed(2)); - setTextContentAndAttribute(tHpDom_reduce.querySelector(".general"), tReduceHP.bigNumberToString()); - setTextContentAndAttribute(tHpDom_reduce.querySelector(".awoken-bind"), tReduceHPNoAwoken.bigNumberToString()); + setTextContentAndAttribute(tHpDom_reduce.querySelector(".general"), tReduceHP.bigNumberToString({sub: true})); + setTextContentAndAttribute(tHpDom_reduce.querySelector(".awoken-bind"), tReduceHPNoAwoken.bigNumberToString({sub: true})); } if (tSBDom) { diff --git a/style.css b/style.css index 25ae7de7..e98c7265 100644 --- a/style.css +++ b/style.css @@ -860,6 +860,9 @@ label.badge { font-size:0; margin-bottom:10px; } +.team-bigbox sub { + font-size: 0.75em; +} .team-bigbox:last-of-type{ margin-bottom:0; }