]> Softwares of Agnibho - pdosage.git/blob - src/routine.js
26f2aef51d8867596903270625dc1210e7465b80
[pdosage.git] / src / routine.js
1 /**********************************************************************
2 * Title: PDosage
3 * Description: Pediatric Calculator
4 * Author: Agnibho Mondal
5 * Website: http://code.agnibho.com
6 **********************************************************************
7 Copyright (c) 2016 Agnibho Mondal
8 All rights reserved
9 **********************************************************************
10 This file is part of PDosage.
11
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.
16
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.
21
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 **********************************************************************/
25
26 $(document).ready(function(){
27
28 //Remove loader
29 $(".loader").remove();
30 $(".container").fadeIn();
31
32 //Update copyright
33 $(".copyright").each(function(){
34 if(new Date().getFullYear()>$(this).data("start")){
35 $(this).text($(this).data("start")+"-"+new Date().getFullYear());
36 }
37 else{
38 $(this).text(new Date().getFullYear());
39 }
40 });
41
42 //Emit input on form reset
43 $("input[type='reset']").on("click", function(e){
44 this.form.reset();
45 $(this.form).find("input, select, textarea").each(function(){
46 this.dispatchEvent(new Event("input"));
47 });
48 });
49
50 //Change focus after number input
51 $(".jump-focus").on("input", function(){
52 if($(this).val().length == $(this).prop("maxlength")){
53 var all=$("input").toArray();
54 var i=all.indexOf(this)+1;
55 $(all[i]).focus().select();
56 }
57 });
58
59 //Defocus after input finished
60 $(".stop-focus").on("input", function(){
61 if($(this).val().length == $(this).prop("maxlength")){
62 $(this).blur();
63 var target=$($(this).data("ref"));
64 $("html, body").animate({
65 scrollTop: $(target).offset().top
66 }, 1000);
67 }
68 });
69 });