10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-08-25 13:41:50 +02:00

Add mhchemCE utility

This commit is contained in:
Mickaël Véril 2020-09-28 09:31:11 +02:00
parent d77fb78cc9
commit 32b518c8f4
2 changed files with 18 additions and 8 deletions

View File

@ -24,6 +24,7 @@ draft: false
<script src="/js/numberUtils.js"></script>
<script src="/js/indexDB.js"></script>
<script src="/js/ArrayExtensions.js"></script>
<script src="/js/mhchemCE.js"></script>
<script>
function adjustSticky() {
const height = $("nav").height()
@ -253,13 +254,7 @@ draft: false
return "Unnamed set"
}
case "molecule":
const mhchemCE = /^\\ce\{(.*)\}$/
const m = value.match(mhchemCE)
if (m) {
return m[1]
} else {
return value
}
return mhchemCE.extract(value)
break;
default:
return value.toString()
@ -545,7 +540,6 @@ draft: false
}
for (const [molecule, moldat] of datadic.entries()) {
var printmol = true;
const mhchemCE = /^\\ce\{.*\}$/
for (const [jsonex, exdat] of moldat.entries()) {
const ex = JSON.parse(jsonex)
Reflect.setPrototypeOf(ex[0], state.prototype)

16
static/js/mhchemCE.js Normal file
View File

@ -0,0 +1,16 @@
class mhchemCE{
static extract(string) {
const m = string.match(mhchemCE.regEx)
if (m) {
return m[1]
} else {
return string
}
}
static test(string){
return mhchemCE.regEx.test(string)
}
static get regEx(){
return /^\\ce\{(.*)\}$/
}
}