10
0
mirror of https://github.com/LCPQ/QUESTDB_website.git synced 2024-12-25 13:53:48 +01:00

Add debug mode

This commit is contained in:
Mickaël Véril 2020-06-10 15:18:39 +02:00
parent 74feabe94a
commit f0673256b1
4 changed files with 101 additions and 72 deletions

View File

@ -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);

View File

@ -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
View 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()
}
}
}

View File

@ -234,7 +234,10 @@ class dataFileBase {
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) {
if (DebugMode.Enabled) {
console.assert(ex.type == 0 || (ex2.type ^ (excitationTypes.Rydberg | excitationTypes.Valence) == ex.type ^ (excitationTypes.Rydberg | excitationTypes.Valence)), "Excitation type error", [ex, ex2, data.sourceFile]) 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 ex.type = ex2.type
} }
} }
@ -329,6 +332,7 @@ class dataFileBase {
} }
} }
} }
if (DebugMode.Enabled) {
var stfy = dat.excitations.map(e => JSON.stringify([e.initial, e.final])) var stfy = dat.excitations.map(e => JSON.stringify([e.initial, e.final]))
var double = [] var double = []
stfy.forEach(function (element, i) { stfy.forEach(function (element, i) {
@ -346,6 +350,7 @@ class dataFileBase {
console.assert(Number.isNaN(ex.T1.valueOf()) | ex.T1 > 50 | ex.isUnsafe == true, "Must be unsafe", dat, ex) console.assert(Number.isNaN(ex.T1.valueOf()) | ex.T1 > 50 | ex.isUnsafe == true, "Must be unsafe", dat, ex)
} }
} }
}
return dat return dat
} }
} }