mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2025-01-12 05:58:23 +01:00
Add mhchemCE utility
This commit is contained in:
parent
d77fb78cc9
commit
32b518c8f4
@ -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
16
static/js/mhchemCE.js
Normal 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\{(.*)\}$/
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user