mirror of
https://github.com/LCPQ/QUESTDB_website.git
synced 2024-12-25 05:43:46 +01:00
Add debug mode
This commit is contained in:
parent
74feabe94a
commit
f0673256b1
@ -26,6 +26,7 @@ draft: false
|
|||||||
<script src="https://unpkg.com/simple-statistics@7.0.2/dist/simple-statistics.min.js"></script>
|
<script src="https://unpkg.com/simple-statistics@7.0.2/dist/simple-statistics.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/npm/bowser@2.5.3/es5.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/bowser@2.5.3/es5.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.13.1/js-yaml.min.js"></script>
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.13.1/js-yaml.min.js"></script>
|
||||||
|
<script src="/js/DebugMode.js"></script>
|
||||||
<script src="/js/numberUtils.js"></script>
|
<script src="/js/numberUtils.js"></script>
|
||||||
<script>
|
<script>
|
||||||
function adjustSticky() {
|
function adjustSticky() {
|
||||||
@ -83,6 +84,9 @@ draft: false
|
|||||||
}
|
}
|
||||||
$("<li/>").text(txt).appendTo(extl)
|
$("<li/>").text(txt).appendTo(extl)
|
||||||
var cbli = $("<li/>")
|
var cbli = $("<li/>")
|
||||||
|
if(!DebugMode.Enabled && value==(1 << 31)){
|
||||||
|
cbli.hide()
|
||||||
|
}
|
||||||
$("<input/>", { type: "checkbox", id: "cb_" + name, name: name, value: Number(value) }).change(nestedCheckbox_change).appendTo(cbli);
|
$("<input/>", { type: "checkbox", id: "cb_" + name, name: name, value: Number(value) }).change(nestedCheckbox_change).appendTo(cbli);
|
||||||
$('<label />', { 'for': 'cb_' + name, text: txt }).appendTo(cbli);
|
$('<label />', { 'for': 'cb_' + name, text: txt }).appendTo(cbli);
|
||||||
cbextl.append(cbli);
|
cbextl.append(cbli);
|
||||||
|
@ -14,6 +14,7 @@ draft: false
|
|||||||
<script src="/js/getPublis.js"></script>
|
<script src="/js/getPublis.js"></script>
|
||||||
<script src="/js/websiteFile.js"></script>
|
<script src="/js/websiteFile.js"></script>
|
||||||
<script src="/js/numberUtils.js"></script>
|
<script src="/js/numberUtils.js"></script>
|
||||||
|
<script src="/js/DebugMode.js"></script>
|
||||||
<script src="/js/createPubliUI.js"></script>
|
<script src="/js/createPubliUI.js"></script>
|
||||||
{{< getDataFilesName >}}
|
{{< getDataFilesName >}}
|
||||||
<script>
|
<script>
|
||||||
|
19
static/js/DebugMode.js
Normal file
19
static/js/DebugMode.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
class DebugMode {
|
||||||
|
static get Enabled() {
|
||||||
|
var debug = window.sessionStorage.getItem("debug")
|
||||||
|
if (debug == null) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return Boolean(JSON.parse(debug))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static set Enabled(value) {
|
||||||
|
const newval = Boolean(value)
|
||||||
|
if (this.Enabled !== newval) {
|
||||||
|
window.sessionStorage.setItem("debug", newval)
|
||||||
|
window.location.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +1,21 @@
|
|||||||
class excitationTypes {
|
class excitationTypes {
|
||||||
static get Valence() { return new excitationType(1<< 1, new description("Valence")) }
|
static get Valence() { return new excitationType(1 << 1, new description("Valence")) }
|
||||||
static get Rydberg() { return new excitationType(1 << 2, new description("Rydberg")) }
|
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 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 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 Single() { return new excitationType(1 << 5, new description("Single")) }
|
||||||
static get Double() { return new excitationType(1 << 6, new description("Double")) }
|
static get Double() { return new excitationType(1 << 6, new description("Double")) }
|
||||||
static get SingletSinglet() { return new excitationType(1 << 7, new description(String.raw`\mathrm{Singlet} \rightarrow \mathrm{Singlet}`,true)) }
|
static get SingletSinglet() { return new excitationType(1 << 7, new description(String.raw`\mathrm{Singlet} \rightarrow \mathrm{Singlet}`, true)) }
|
||||||
static get SingletTriplet() { return new excitationType(1 << 8, new description(String.raw`\mathrm{Singlet} \rightarrow \mathrm{Triplet}`,true)) }
|
static get SingletTriplet() { return new excitationType(1 << 8, new description(String.raw`\mathrm{Singlet} \rightarrow \mathrm{Triplet}`, true)) }
|
||||||
static get DoubletDoublet() { return new excitationType(1 << 9, new description(String.raw`\mathrm{Doublet} \rightarrow \mathrm{Doublet}`,true)) }
|
static get DoubletDoublet() { return new excitationType(1 << 9, new description(String.raw`\mathrm{Doublet} \rightarrow \mathrm{Doublet}`, true)) }
|
||||||
// Max bit shifts is 31 because int are int32 So 1 << 31 are -2147483648
|
// Max bit shifts is 31 because int are int32 So 1 << 31 are -2147483648
|
||||||
static get Others() { return new excitationType(1 << 31, new description("Others"))}
|
static get Others() { return new excitationType(1 << 31, new description("Others")) }
|
||||||
static get All() { return EnumUltils.getAll(this,excitationType)}
|
static get All() { return EnumUltils.getAll(this, excitationType) }
|
||||||
static GetFlags(value){return EnumUltils.GetFlags(value,this,excitationType)}
|
static GetFlags(value) { return EnumUltils.GetFlags(value, this, excitationType) }
|
||||||
}
|
}
|
||||||
|
|
||||||
class EnumUltils{
|
class EnumUltils {
|
||||||
static getAll(enumClass,valueType) {
|
static getAll(enumClass, valueType) {
|
||||||
var lst = []
|
var lst = []
|
||||||
for (const prop of Object.getOwnPropertyNames(enumClass)) {
|
for (const prop of Object.getOwnPropertyNames(enumClass)) {
|
||||||
if (prop != "All") {
|
if (prop != "All") {
|
||||||
@ -27,15 +27,15 @@ class EnumUltils{
|
|||||||
}
|
}
|
||||||
return lst
|
return lst
|
||||||
}
|
}
|
||||||
static GetFlags(value,enumClass,valueType) {
|
static GetFlags(value, enumClass, valueType) {
|
||||||
return this.getAll(enumClass,valueType).filter((x) => { value & x[1] })
|
return this.getAll(enumClass, valueType).filter((x) => { value & x[1] })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class description {
|
class description {
|
||||||
constructor(string,isLaTeX=false) {
|
constructor(string, isLaTeX = false) {
|
||||||
this.string = string
|
this.string = string
|
||||||
this.isLaTeX=isLaTeX
|
this.isLaTeX = isLaTeX
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class DescribedValueBase {
|
class DescribedValueBase {
|
||||||
@ -48,9 +48,9 @@ class DescribedValueBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class excitationType extends DescribedValueBase{
|
class excitationType extends DescribedValueBase {
|
||||||
}
|
}
|
||||||
class VertExcitationKind extends DescribedValueBase{
|
class VertExcitationKind extends DescribedValueBase {
|
||||||
|
|
||||||
}
|
}
|
||||||
class code {
|
class code {
|
||||||
@ -88,7 +88,7 @@ class method {
|
|||||||
return new method(vals[0], null)
|
return new method(vals[0], null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toString(separator="/") {
|
toString(separator = "/") {
|
||||||
var str = this.name;
|
var str = this.name;
|
||||||
if (this.basis) {
|
if (this.basis) {
|
||||||
str = str + separator + this.basis;
|
str = str + separator + this.basis;
|
||||||
@ -116,23 +116,23 @@ class state {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
class DOI {
|
class DOI {
|
||||||
constructor(doistring,IsSupporting=false) {
|
constructor(doistring, IsSupporting = false) {
|
||||||
this.string = doistring
|
this.string = doistring
|
||||||
this.IsSupporting = IsSupporting
|
this.IsSupporting = IsSupporting
|
||||||
};
|
};
|
||||||
static fromString(str){
|
static fromString(str) {
|
||||||
const vals=str.split(",")
|
const vals = str.split(",")
|
||||||
if (vals.length==1) {
|
if (vals.length == 1) {
|
||||||
return new DOI(vals[0].toString())
|
return new DOI(vals[0].toString())
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
return new DOI(vals[0].toString(),(true ? vals[1]=== true.toString() : false))
|
return new DOI(vals[0].toString(), (true ? vals[1] === true.toString() : false))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toString() {
|
toString() {
|
||||||
var str=this.string;
|
var str = this.string;
|
||||||
if (this.IsSupporting) {
|
if (this.IsSupporting) {
|
||||||
str+=" "+"(SI)"
|
str += " " + "(SI)"
|
||||||
}
|
}
|
||||||
return str
|
return str
|
||||||
};
|
};
|
||||||
@ -145,7 +145,7 @@ class excitationBase {
|
|||||||
constructor(initial, final, type = '', T1 = null) {
|
constructor(initial, final, type = '', T1 = null) {
|
||||||
this.initial = initial;
|
this.initial = initial;
|
||||||
this.final = final
|
this.final = final
|
||||||
this.type = new excitationType(0, new description(type,true))
|
this.type = new excitationType(0, new description(type, true))
|
||||||
if (type) {
|
if (type) {
|
||||||
const tys = type.split(";")
|
const tys = type.split(";")
|
||||||
const arrow = String.raw`\rightarrow`
|
const arrow = String.raw`\rightarrow`
|
||||||
@ -173,16 +173,16 @@ class excitationBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var m = new Map([
|
var m = new Map([
|
||||||
[JSON.stringify([1,1]), excitationTypes.SingletSinglet],
|
[JSON.stringify([1, 1]), excitationTypes.SingletSinglet],
|
||||||
[JSON.stringify([2,2]), excitationTypes.DoubletDoublet],
|
[JSON.stringify([2, 2]), excitationTypes.DoubletDoublet],
|
||||||
[JSON.stringify([1,3]), excitationTypes.SingletTriplet],
|
[JSON.stringify([1, 3]), excitationTypes.SingletTriplet],
|
||||||
])
|
])
|
||||||
const marray=JSON.stringify([initial.multiplicity, final.multiplicity])
|
const marray = JSON.stringify([initial.multiplicity, final.multiplicity])
|
||||||
if (m.has(marray)) {
|
if (m.has(marray)) {
|
||||||
this.type.Value=this.type.Value|m.get(marray)
|
this.type.Value = this.type.Value | m.get(marray)
|
||||||
}
|
}
|
||||||
if (this.type.Value==0) {
|
if (this.type.Value == 0) {
|
||||||
this.type.Value=excitationTypes.Others.Value;
|
this.type.Value = excitationTypes.Others.Value;
|
||||||
}
|
}
|
||||||
this.T1 = T1
|
this.T1 = T1
|
||||||
}
|
}
|
||||||
@ -230,16 +230,19 @@ class dataFileBase {
|
|||||||
}
|
}
|
||||||
CopyExcitationsTypeFrom(data) {
|
CopyExcitationsTypeFrom(data) {
|
||||||
for (const ex of this.excitations) {
|
for (const ex of this.excitations) {
|
||||||
const ex2=data.excitations.find((e)=>{
|
const ex2 = data.excitations.find((e) => {
|
||||||
return (JSON.stringify(e.initial)===JSON.stringify(ex.initial)) && (JSON.stringify(e.final)===JSON.stringify(ex.final))
|
return (JSON.stringify(e.initial) === JSON.stringify(ex.initial)) && (JSON.stringify(e.final) === JSON.stringify(ex.final))
|
||||||
})
|
})
|
||||||
if(ex2!==undefined){
|
if (ex2 !== undefined) {
|
||||||
console.assert(ex.type==0 || (ex2.type^(excitationTypes.Rydberg | excitationTypes.Valence)==ex.type^(excitationTypes.Rydberg | excitationTypes.Valence)),"Excitation type error",[ex,ex2,data.sourceFile])
|
if (DebugMode.Enabled) {
|
||||||
ex.type=ex2.type
|
console.assert(ex.type == 0 || (ex2.type ^ (excitationTypes.Rydberg | excitationTypes.Valence) == ex.type ^ (excitationTypes.Rydberg | excitationTypes.Valence)), "Excitation type error", [ex, ex2, data.sourceFile])
|
||||||
|
}
|
||||||
|
|
||||||
|
ex.type = ex2.type
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static async loadAsync(file,kind=undefined) {
|
static async loadAsync(file, kind = undefined) {
|
||||||
switch (trueTypeOf(file)) {
|
switch (trueTypeOf(file)) {
|
||||||
case String.name:
|
case String.name:
|
||||||
file = getFullDataPath(file)
|
file = getFullDataPath(file)
|
||||||
@ -249,7 +252,7 @@ class dataFileBase {
|
|||||||
var str = await getTextFromUploadedFileAsync(file)
|
var str = await getTextFromUploadedFileAsync(file)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
var dat = this.loadString(str,kind);
|
var dat = this.loadString(str, kind);
|
||||||
dat.sourceFile = new websiteFile(file)
|
dat.sourceFile = new websiteFile(file)
|
||||||
return dat
|
return dat
|
||||||
}
|
}
|
||||||
@ -276,11 +279,11 @@ class dataFileBase {
|
|||||||
_OnReadRow(line) {
|
_OnReadRow(line) {
|
||||||
var vals = line.match(/\([^\)]+\)|\S+/g)
|
var vals = line.match(/\([^\)]+\)|\S+/g)
|
||||||
var start = new state(parseInt(vals[0], 10), parseInt(vals[1], 10), vals[2]);
|
var start = new state(parseInt(vals[0], 10), parseInt(vals[1], 10), vals[2]);
|
||||||
var end = new state(parseInt(vals[3], 10), parseInt(vals[4],10), vals[5]);
|
var end = new state(parseInt(vals[3], 10), parseInt(vals[4], 10), vals[5]);
|
||||||
var hasType = vals.length >= 7 && isNaN(vals[6])
|
var hasType = vals.length >= 7 && isNaN(vals[6])
|
||||||
var type = ((vals.length >= 7 && hasType) ? vals[6] : null)
|
var type = ((vals.length >= 7 && hasType) ? vals[6] : null)
|
||||||
if (type==="_") {
|
if (type === "_") {
|
||||||
type=null
|
type = null
|
||||||
}
|
}
|
||||||
if (type) {
|
if (type) {
|
||||||
const m = type.match(/^\(([^\)]*)\)$/)
|
const m = type.match(/^\(([^\)]*)\)$/)
|
||||||
@ -294,7 +297,7 @@ class dataFileBase {
|
|||||||
var isUnsafe = ((vals.length >= 10 + hasType) ? vals[9 + hasType] === true.toString() : false)
|
var isUnsafe = ((vals.length >= 10 + hasType) ? vals[9 + hasType] === true.toString() : false)
|
||||||
var ex = new excitationValue(start, end, type, val, oscilatorForces, T1, isUnsafe);
|
var ex = new excitationValue(start, end, type, val, oscilatorForces, T1, isUnsafe);
|
||||||
if (this.VertExcitationKind) {
|
if (this.VertExcitationKind) {
|
||||||
ex.VertExcitationKind=this.VertExcitationKind
|
ex.VertExcitationKind = this.VertExcitationKind
|
||||||
}
|
}
|
||||||
return ex;
|
return ex;
|
||||||
};
|
};
|
||||||
@ -306,10 +309,10 @@ class dataFileBase {
|
|||||||
//if data has value
|
//if data has value
|
||||||
if (match.length == 3 && match[2]) {
|
if (match.length == 3 && match[2]) {
|
||||||
var val = match[2]
|
var val = match[2]
|
||||||
this._OnReadMetaPair(key,val)
|
this._OnReadMetaPair(key, val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static loadString(text,kind=null) {
|
static loadString(text, kind = null) {
|
||||||
// for each line with metadata
|
// for each line with metadata
|
||||||
var ismetaArea = true;
|
var ismetaArea = true;
|
||||||
var dat = new VertDataFile()
|
var dat = new VertDataFile()
|
||||||
@ -325,43 +328,45 @@ class dataFileBase {
|
|||||||
}
|
}
|
||||||
} else { //else its row
|
} else { //else its row
|
||||||
ismetaArea = false;
|
ismetaArea = false;
|
||||||
dat.excitations.push(dat._OnReadRow(line,kind));
|
dat.excitations.push(dat._OnReadRow(line, kind));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var stfy=dat.excitations.map(e=>JSON.stringify([e.initial,e.final]))
|
if (DebugMode.Enabled) {
|
||||||
var double=[]
|
var stfy = dat.excitations.map(e => JSON.stringify([e.initial, e.final]))
|
||||||
stfy.forEach(function(element, i) {
|
var double = []
|
||||||
// Find if there is a duplicate or not
|
stfy.forEach(function (element, i) {
|
||||||
if (stfy.indexOf(element, i + 1) >= 0) {
|
// Find if there is a duplicate or not
|
||||||
// Find if the element is already in the result array or not
|
if (stfy.indexOf(element, i + 1) >= 0) {
|
||||||
if (double.indexOf(element) === -1) {
|
// Find if the element is already in the result array or not
|
||||||
double.push(dat.excitations[i])
|
if (double.indexOf(element) === -1) {
|
||||||
|
double.push(dat.excitations[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
console.assert(double.length === 0, "Double found", double, dat.molecule, dat.method.toString())
|
||||||
|
if (dat.DOI.string !== "10.1021/acs.jctc.8b01205") {
|
||||||
|
for (const ex of dat.excitations) {
|
||||||
|
console.assert(Number.isNaN(ex.T1.valueOf()) | ex.T1 > 50 | ex.isUnsafe == true, "Must be unsafe", dat, ex)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
});
|
|
||||||
console.assert(double.length===0,"Double found",double,dat.molecule,dat.method.toString())
|
|
||||||
if (dat.DOI.string!=="10.1021/acs.jctc.8b01205") {
|
|
||||||
for (const ex of dat.excitations) {
|
|
||||||
console.assert(Number.isNaN(ex.T1.valueOf()) | ex.T1>50 | ex.isUnsafe==true,"Must be unsafe",dat,ex)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return dat
|
return dat
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class VertExcitationKinds{
|
class VertExcitationKinds {
|
||||||
static get Absorbtion() {return new VertExcitationKind(1, new description("Absorption"))}
|
static get Absorbtion() { return new VertExcitationKind(1, new description("Absorption")) }
|
||||||
static get Fluorescence() {return new VertExcitationKind(1<<1, new description("Fluorescence"))}
|
static get Fluorescence() { return new VertExcitationKind(1 << 1, new description("Fluorescence")) }
|
||||||
static get All() { return EnumUltils.getAll(this,VertExcitationKind)}
|
static get All() { return EnumUltils.getAll(this, VertExcitationKind) }
|
||||||
static GetFlags(value){return EnumUltils.GetFlags(value,this,VertExcitationKind)}
|
static GetFlags(value) { return EnumUltils.GetFlags(value, this, VertExcitationKind) }
|
||||||
}
|
}
|
||||||
class VertDataFile extends dataFileBase {
|
class VertDataFile extends dataFileBase {
|
||||||
constructor(VertExcitationKind) {
|
constructor(VertExcitationKind) {
|
||||||
super()
|
super()
|
||||||
this.VertExcitationKind=VertExcitationKind
|
this.VertExcitationKind = VertExcitationKind
|
||||||
this.geometry = null
|
this.geometry = null
|
||||||
}
|
}
|
||||||
_OnReadMetaPair(key, value) {
|
_OnReadMetaPair(key, value) {
|
||||||
if (key == "geom") {
|
if (key == "geom") {
|
||||||
this.geometry = method.fromString(value)
|
this.geometry = method.fromString(value)
|
||||||
}
|
}
|
||||||
@ -369,9 +374,9 @@ class VertDataFile extends dataFileBase {
|
|||||||
super._OnReadMetaPair(key, value)
|
super._OnReadMetaPair(key, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_OnReadRow(line,kind) {
|
_OnReadRow(line, kind) {
|
||||||
var ex=super._OnReadRow(line)
|
var ex = super._OnReadRow(line)
|
||||||
ex.VertExcitationKind=kind
|
ex.VertExcitationKind = kind
|
||||||
return ex
|
return ex
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user