]>
Softwares of Agnibho - pdosage.git/blob - src/routine.js
f334d446678932fa587370a0a96792a83bb0d2bf
1 /**********************************************************************
3 * Description: Pediatric Calculator
4 * Author: Agnibho Mondal
5 * Website: http://code.agnibho.com
6 **********************************************************************
7 Copyright (c) 2016 Agnibho Mondal
9 **********************************************************************
10 This file is part of PDosage.
12 PDosage is free software: you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation, either version 3 of the License, or
15 (at your option) any later version.
17 PDosage is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with PDosage. If not, see <http://www.gnu.org/licenses/>.
24 **********************************************************************/
26 $(document
).ready(function(){
29 $(".loader").remove();
30 $(".container").fadeIn();
33 $(".version").text(VERSION
);
36 $(".copyright").each(function(){
37 if(new Date().getFullYear()>$(this).data("start")){
38 $(this).text($(this).data("start")+"-"+new Date().getFullYear());
41 $(this).text(new Date().getFullYear());
45 //Emit input on form reset
46 $("input[type='reset']").on("click", function(e
){
48 $(this.form
).find("input, select, textarea").each(function(){
49 this.dispatchEvent(new Event("input"));
54 $(window
).resize(function(){
55 $("#notify").width($(".container").width()-20);
57 $(window
).scroll(function(){
58 $("#notify").width($(".container").width()-20);
61 //Parse app info from server
62 $.get("https://code.agnibho.com/pdosage/info.json", function(data
){
63 var vCurr
=VERSION
.split(".").map(Number
);
64 var vLtst
=data
.latest
.split(".").map(Number
);
66 if(isBiggerThan(data
.latest
, VERSION
)){
67 $("#notify").slideDown();
68 $("#notify").width($(".container").width()-20);
69 $("#notify-text").text("A new version of PDosage is available.");
70 if(document
.URL
.indexOf("http://")==-1 && document
.URL
.indexOf("https://")==-1){
71 if(/(android)/i.test(navigator
.userAgent
)){
72 $("#notify-link").attr("href", data
.apk
);
73 $("#notify-link").text("Download");
76 $("#notify-link").attr("href", data
.url
);
77 $("#notify-link").text("Load");
81 $("#notify-link").attr("href", data
.url
);
82 $("#notify-link").text("Load");
87 if(data
.data
.latest
>JSON
.parse(localStorage
.getItem("pdosage_data")).version
){
88 $.get(data
.data
.src
, function(d
){
89 localStorage
.setItem("pdosage_data", JSON
.stringify(d
));
97 function isBiggerThan(v1
, v2
){
98 while(v1
.length
<v2
.length
){
101 while(v2
.length
<v1
.length
){
104 for(var i
=0; i
<v1
.length
; i
++){