10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-24 13:23:40 +01:00

Add description class and simplify lables

This commit is contained in:
Mickaël Véril 2020-03-08 16:17:04 +01:00
parent 35d0d2aefc
commit 828fa5cf6c
2 changed files with 30 additions and 45 deletions

View File

@ -75,35 +75,14 @@ draft: false
$("<li/>").text(name).appendTo(vertkindtl)
}
for (const [name, value] of excitationTypes.All) {
var description = null
switch (Number(value)) {
case Number(excitationTypes.VALENCE):
description = name.toLowerCase()
break;
case Number(excitationTypes.RYDBERG):
const word = name
description = word.charAt(0).toUpperCase() + word.substring(1).toLowerCase()
break;
case Number(excitationTypes.Single):
description = name.toLowerCase()
break;
case Number(excitationTypes.Double):
description = name.toLowerCase()
break;
case Number(excitationTypes.Singlet):
description = name.toLowerCase()
break;
case Number(excitationTypes.Triplet):
description = name.toLowerCase()
break;
default:
description = null;
break;
var txt=value.description.string
if (value.description.isLaTeX) {
txt=LatexInline[0]+txt+LatexInline[1]
}
$("<li/>").text(LatexInline[0] + value.LaTeX + LatexInline[1] + (description == null ? '' : ": " + description)).appendTo(extl)
$("<li/>").text(txt).appendTo(extl)
var cbli = $("<li/>")
$("<input/>", { type: "checkbox", id: "cb_" + name, name: name, value: Number(value) }).change(nestedCheckbox_change).appendTo(cbli);
$('<label />', { 'for': 'cb_' + name, text: LatexInline[0] + value.LaTeX + LatexInline[1] + (description == null ? '' : ": " + description) }).appendTo(cbli);
$('<label />', { 'for': 'cb_' + name, text: txt }).appendTo(cbli);
cbextl.append(cbli);
}
await MathJax.typesetPromise();
@ -431,9 +410,9 @@ draft: false
}
var Vertkindtext = ""
if (ex[3].Value == VertExcitationKinds.Fluorescence.Value) {
Vertkindtext = String.raw`[${VertExcitationKinds.Fluorescence.LaTeX}]`
Vertkindtext = String.raw`[\mathrm{F}]`
}
$("<th/>", { scope: "rowgroup" }).text(String.raw`${LatexInline[0]}${ex[0].toLaTeX()} \rightarrow ${ex[1].toLaTeX()} ${Vertkindtext}(${ex[2].LaTeX}) ${LatexInline[1]}`).appendTo(tr)
$("<th/>", { scope: "rowgroup" }).text(String.raw`${LatexInline[0]}${ex[0].toLaTeX()} \rightarrow ${ex[1].toLaTeX()} ${Vertkindtext}(${ex[2].description.string}) ${LatexInline[1]}`).appendTo(tr)
var entries = Array.from(exdat.entries())
for (const method of sortedMethods) {
td = $("<td/>").addClass("NumberCell")

View File

@ -1,14 +1,14 @@
class excitationTypes {
static get VALENCE() { return new excitationType(1<< 1, String.raw`\mathrm{V}`) }
static get RYDBERG() { return new excitationType(1 << 2, String.raw`\mathrm{R}`) }
static get PiPis() { return new excitationType(1 << 3, String.raw`\pi \rightarrow \pi^\star`) }
static get nPis() { return new excitationType(1 << 4, String.raw`n \rightarrow \pi^\star`) }
static get Single() { return new excitationType(1 << 5, "S") }
static get Double() { return new excitationType(1 << 6, "D") }
static get Singlet() { return new excitationType(1 << 7, "1") }
static get Triplet() { return new excitationType(1 << 8, "3") }
static get VALENCE() { return new excitationType(1<< 1, new description("VALENCE")) }
static get RYDBERG() { return new excitationType(1 << 2, new description("RYDBERG")) }
static get PiPis() { return new excitationType(1 << 3, new description(String.raw`\pi \rightarrow \pi^\star`,true)) }
static get nPis() { return new excitationType(1 << 4, new description(String.raw`n \rightarrow \pi^\star`,true)) }
static get Single() { return new excitationType(1 << 5, new description("Single")) }
static get Double() { return new excitationType(1 << 6, new description("Double")) }
static get Singlet() { return new excitationType(1 << 7, new description("Singlet")) }
static get Triplet() { return new excitationType(1 << 8, new description("Triplet")) }
// Max bit shifts is 31 because int are int32 So 1 << 31 are -2147483648
static get Others() { return new excitationType(1 << 31, String.raw`\mathrm{Others}`) }
static get Others() { return new excitationType(1 << 31, new description("Others"))}
static get All() { return EnumUltils.getAll(this,excitationType)}
static GetFlags(value){return EnumUltils.GetFlags(value,this,excitationType)}
}
@ -31,19 +31,25 @@ class EnumUltils{
}
}
class LaTeXDescribedValueBase {
constructor(value, laTeX) {
class description {
constructor(string,isLaTeX=false) {
this.string = string
this.isLaTeX=isLaTeX
}
}
class DescribedValueBase {
constructor(value, description) {
this.Value = value;
this.LaTeX = laTeX
this.description = description
}
valueOf() {
return this.Value;
}
}
class excitationType extends LaTeXDescribedValueBase{
class excitationType extends DescribedValueBase{
}
class VertExcitationKind extends LaTeXDescribedValueBase{
class VertExcitationKind extends DescribedValueBase{
}
class code {
@ -141,7 +147,7 @@ class excitationBase {
constructor(initial, final, type = '', T1 = null) {
this.initial = initial;
this.final = final
this.type = new excitationType(0, type)
this.type = new excitationType(0, new description(type,true))
if (type !== "") {
const tys = type.split(";")
const arrow = String.raw`\rightarrow`
@ -324,8 +330,8 @@ class dataFileBase {
}
}
class VertExcitationKinds{
static get Absorbtion() {return new VertExcitationKind(1, String.raw`\mathrm{A}`)}
static get Fluorescence() {return new VertExcitationKind(1<<1, String.raw`\mathrm{F}`)}
static get Absorbtion() {return new VertExcitationKind(1, new description("Absorption"))}
static get Fluorescence() {return new VertExcitationKind(1<<1, new description("Fluorescence"))}
static get All() { return EnumUltils.getAll(this,VertExcitationKind)}
static GetFlags(value){return EnumUltils.GetFlags(value,this,VertExcitationKind)}
}