From 68bab37397f3719a1cd0836cc404a6a2c13eeb7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micka=C3=ABl=20V=C3=A9ril?= Date: Tue, 3 Sep 2019 15:36:32 +0200 Subject: [PATCH] Add toString and toLatex for output --- content/scripts/data.js | 47 +++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/content/scripts/data.js b/content/scripts/data.js index df595f05..f676c9f0 100644 --- a/content/scripts/data.js +++ b/content/scripts/data.js @@ -1,13 +1,27 @@ class code { constructor(name,version){ - this.name=name - this.version=version + this.name=name; + this.version=version; + }; + toString() { + var str=this.name; + if (this.version) { + str=str+' ('+this.version+')'; + } + return str; } } class basis { constructor(name,type){ - this.name=name - this.type=type + this.name=name; + this.type=type; + } + toString() { + var str=this.name; + if (this.type) { + str=str+' ('+this.type+')'; + } + return str; } } @@ -16,15 +30,27 @@ class state{ this.number=number; this.multiplicity=multiplicity; this.symetry=symetry; - } + }; + toString() { + var str=this.number+ ' ^'+this.multiplicity+this.symetry; + return str; + }; + toLaTeX() { + var tex=this.number; + tex+= String.raw` \vphantom{${this.symetry.charAt(0)}}^{${this.multiplicity}}${this.symetry}`; + return tex; + }; } class doi{ constructor(doistring){ this.string=doistring - } + }; + toString() { + return this.string; + }; get url() { - return 'https://doi.org/'+doi - } + return 'https://doi.org/'+this.string; + }; } class excitation{ constructor(start,end,Eabs){ @@ -32,11 +58,14 @@ class excitation{ this.end=end; this.Eabs=Eabs; } + toString() { + return this.start+ ', ' + this.end +', '+ this.Eabs; + } } class data { constructor(){ - this.title=""; + this.title=''; this.code=null; this.basis=null; this.doi=null;