]> Softwares of Agnibho - pdosage.git/blobdiff - src/main.js
Standardized routine.js
[pdosage.git] / src / main.js
index a2673dc393e0f05a022bd44ae08fef2b10e4cd58..53ea071752b9071505aa9d337a494e0335bcdb7b 100644 (file)
@@ -8,17 +8,17 @@
    All rights reserved
  **********************************************************************
    This file is part of PDosage.
-   
+
    PDosage is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
-   
+
    PDosage is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with PDosage. If not, see <http://www.gnu.org/licenses/>.
  **********************************************************************/
@@ -49,44 +49,45 @@ import AboutView from "./AboutView.vue";
 
 //Start app
 new Vue({
-    el: "#app",
-    components: {
-       "data-input": DataInput,
-       "quick-view": QuickView,
-       "list-view": ListView,
-       "calculator-view": CalculatorView,
-       "about-view": AboutView
-    },
-    data: {
-       patient: {age: {y:30, m:null, d:null}, wt:50},
-       dosage: "",
-       favs: "[]"
-    },
-    created:function(){
-       try{
-           this.favs=JSON.parse(localStorage.getItem("pdosage_favs"));
-       }
-       finally{
-           if(this.favs==null){
-               this.favs=["Paracetamol", "Levosalbutamol", "Domperidone", "Drotaverine", "Ranitidine"];
-           }
-       }
-       try{
-           var loc=JSON.parse(localStorage.getItem("pdosage_data"));
-           if(loc.version>data.version){
-               this.dosage=new Dosage(loc.dosage);
-           }
-           else{
-               localStorage.setItem("pdosage_data", JSON.stringify(data));
-           }
-       }
-       catch(e){
-           if(!this.dosage){
-               this.dosage=new Dosage(data.dosage);
-               localStorage.setItem("pdosage_data", JSON.stringify(data));
-           }
-       }
+  el: "#app",
+  components: {
+    "data-input": DataInput,
+    "quick-view": QuickView,
+    "list-view": ListView,
+    "calculator-view": CalculatorView,
+    "about-view": AboutView
+  },
+  data: {
+    patient: {age: {y:30, m:null, d:null}, wt:50},
+    dosage: "",
+    favs: "[]"
+  },
+  created:function(){
+    try{
+      this.favs=JSON.parse(localStorage.getItem("pdosage_favs"));
+    }
+    finally{
+      if(this.favs==null){
+        this.favs=["Paracetamol", "Levosalbutamol", "Domperidone", "Drotaverine", "Ranitidine"];
+      }
+    }
+    try{
+      var loc=JSON.parse(localStorage.getItem(STORAGE));
+      if(loc.version>data.version){
+        this.dosage=new Dosage(loc.dosage);
+      }
+      else{
+        this.dosage=new Dosage(data.dosage);
+        localStorage.setItem(STORAGE, JSON.stringify(data));
+      }
+    }
+    catch(e){
+      if(!this.dosage){
+        this.dosage=new Dosage(data.dosage);
+        localStorage.setItem(STORAGE, JSON.stringify(data));
+      }
     }
+  }
 });
 
 //Routine jobs