www/js/global.js

changeset 462
c91175610f8a
parent 446
ee7bcfb8e270
child 463
0efdafd23753
equal deleted inserted replaced
461:f147a3962775 462:c91175610f8a
710 var mashlist = new $.jqx.dataAdapter(mashProfileSource); 710 var mashlist = new $.jqx.dataAdapter(mashProfileSource);
711 711
712 712
713 713
714 714
715 $(document).ready(function () { 715 $(document).ready(function(){
716 716 $("#jqxMenu").jqxMenu({width:1280,height:'30px',autoOpen:false,clickToOpen:true,theme:theme});
717 $("#jqxMenu").jqxMenu({ 717 $("#jqxWidget").css('visibility','visible');
718 width: 1280,
719 height: '30px',
720 autoOpen: false,
721 clickToOpen: true,
722 theme: theme
723 });
724 $("#jqxWidget").css('visibility', 'visible');
725 }); 718 });
726 719
727 720
728 721
729 function Round(n,d) { 722 function Round(n,d){for(var i=0,m=1;i<d;i++,m*=10);return Math.round(n*m)/m;}
730 var m, i;
731 for (i = 0, m = 1; i < d; i++, m *= 10);
732 return Math.round(n * m) / m;
733 }
734 723
735 724
736 /* 725 /*
737 * From "Rekenen aan bier" by Hans Halberstadt. 726 * From "Rekenen aan bier" by Hans Halberstadt.
738 */ 727 */
767 console.log("B("+sugar+"."+volume+","+alc+","+eiwit+","+glycerol+"):"+B); 756 console.log("B("+sugar+"."+volume+","+alc+","+eiwit+","+glycerol+"):"+B);
768 return B; 757 return B;
769 } 758 }
770 759
771 760
772 function ebc_to_srm(ebc) { 761 function ebc_to_srm(ebc){
773 var srm = -1.32303E-12 * Math.pow(ebc, 4) - 0.00000000291515 * Math.pow(ebc, 3) + 0.00000818515 * Math.pow(ebc, 2) + 0.372038 * ebc + 0.596351; 762 var srm = -1.32303E-12*Math.pow(ebc,4)-0.00000000291515*Math.pow(ebc,3)+0.00000818515*Math.pow(ebc,2)+0.372038*ebc+0.596351;
774 if ((ebc < 0) || (srm < 0)) 763 if(srm<0)srm=0;return srm;
775 console.log("ebc_to_srm("+ebc+") = "+srm); 764 }
776 return srm 765 function srm_to_ebc(srm){
777 } 766 var ebc=Math.round(0.000000000176506*Math.pow(srm,4)+0.000000154529*Math.pow(srm,3)-0.000159428*Math.pow(srm,2)+2.68837*srm-1.6004);
778 767 if(ebc<0)ebc=0;return ebc;
779 768 }
780 769
781 function srm_to_ebc(srm) 770
782 { 771
783 var ebc = Math.round(0.000000000176506 * Math.pow(srm, 4) + 0.000000154529 * Math.pow(srm, 3) - 0.000159428 * Math.pow(srm, 2) + 2.68837 * srm - 1.6004); 772 /* Return incremented color by the boil and yeast.
784 if ((ebc < 0) || (srm < 0)) 773 * https://www.hobbybrouwen.nl/forum/index.php/topic,19020.msg281132.html#msg281132 */
785 console.log("srm_to_ebc("+srm+") = "+ebc); 774 function get_kt(ebc){
786 return ebc; 775 var kt=1;
787 } 776 if(ebc<3)kt=3.5;else if(ebc<6)kt=3;else if(ebc<8)kt=2.75;else if(ebc<10)kt=2.5;else if(ebc<20)kt=1.8;
788 777 else if(ebc<30)kt=1.6;else if(ebc<60)kt=1.3;else if(ebc<100)kt=1.2;else if(ebc<300)kt=1.1;return kt;
789 778 }
790
791 /*
792 * Return incremented color by the boil and yeast.
793 * https://www.hobbybrouwen.nl/forum/index.php/topic,19020.msg281132.html#msg281132
794 */
795 function get_kt(ebc) {
796
797 var kt = 1;
798 if (ebc < 3)
799 kt = 3.5;
800 else if (ebc < 6)
801 kt = 3;
802 else if (ebc < 8)
803 kt = 2.75;
804 else if (ebc < 10)
805 kt = 2.5;
806 else if (ebc < 20)
807 kt = 1.8;
808 else if (ebc < 30)
809 kt = 1.6;
810 else if (ebc < 60)
811 kt = 1.3;
812 else if (ebc < 100)
813 kt = 1.2;
814 else if (ebc < 300)
815 kt = 1.1;
816 return kt;
817 }
818
819
820
821 function abvol(og,fg){ 779 function abvol(og,fg){
822 if(((og-fg)<0)||(fg<0.9))return 0; 780 if(((og-fg)<0)||(fg<0.9))return 0;
823 var factor=og*3157*Math.pow(10,-5)+9.716*Math.pow(10,-2); 781 var factor=og*3157*Math.pow(10,-5)+9.716*Math.pow(10,-2);
824 return (og*1000-fg*1000)*factor; 782 return (og*1000-fg*1000)*factor;
825 } 783 }
826 784
827 785
828 786
829 /* 787 /* Kleurwerking naar SRM. Niet voor Halberstadt, Naudts */
830 * Kleurwerking naar SRM. Niet voor Halberstadt, Naudts 788 function kw_to_srm(colormethod,c){
831 */
832 function kw_to_srm(colormethod, c) {
833 if(colormethod==0)return 1.4922*Math.pow(c,0.6859);//Morey 789 if(colormethod==0)return 1.4922*Math.pow(c,0.6859);//Morey
834 if(colormethod==1)return 0.3*c+4.7;//Mosher 790 if(colormethod==1)return 0.3*c+4.7;//Mosher
835 if(colormethod==2)return 0.2*c+8.4;//Daniels 791 if(colormethod==2)return 0.2*c+8.4;//Daniels
836 return 0;//Halberstadt,Naudts 792 return 0;//Halberstadt,Naudts
837 } 793 }
840 796
841 797
842 /* 798 /*
843 * Berekeningen uit https://www.hobbybrouwen.nl/forum/index.php/topic,6079.msg69464.html#msg69464 799 * Berekeningen uit https://www.hobbybrouwen.nl/forum/index.php/topic,6079.msg69464.html#msg69464
844 */ 800 */
845 function toIBU(Use, Form, SG, Volume, Amount, Boiltime, Alpha, Method) 801 function toIBU(Use,Form,SG,Volume,Amount,Boiltime,Alpha,Method){
846 {
847 var gravity=parseFloat(SG); 802 var gravity=parseFloat(SG);
848 var liters=parseFloat(Volume); 803 var liters=parseFloat(Volume);
849 var alpha=parseFloat(Alpha)/100; 804 var alpha=parseFloat(Alpha)/100;
850 var mass=parseFloat(Amount)*1000; 805 var mass=parseFloat(Amount)*1000;
851 var time=parseFloat(Boiltime); 806 var time=parseFloat(Boiltime);
872 } 827 }
873 if(Form==4){// Cryo hop 828 if(Form==4){// Cryo hop
874 pfactor+=my_factor_cryohop/100; 829 pfactor+=my_factor_cryohop/100;
875 } 830 }
876 831
877 if(Method==0){// Tinseth 832 if(Method==0){// Tinseth
878 /* http://realbeer.com/hops/research.html */ 833 /* http://realbeer.com/hops/research.html */
879 var AddedAlphaAcids = (alpha * mass * 1000) / liters; 834 var AddedAlphaAcids=(alpha*mass*1000)/liters;
880 var Bigness_factor = 1.65 * Math.pow( 0.000125, gravity - 1); 835 var Bigness_factor=1.65*Math.pow(0.000125,gravity-1);
881 var BoilTime_factor = ((1 - Math.exp(-0.04 * time)) / 4.15); 836 var BoilTime_factor=((1-Math.exp(-0.04*time))/4.15);
882 var utiisation = Bigness_factor * BoilTime_factor; 837 var utiisation=Bigness_factor*BoilTime_factor;
883 ibu = Round(utiisation * AddedAlphaAcids * fmoment * pfactor,1); 838 ibu=Round(utiisation*AddedAlphaAcids*fmoment*pfactor,1);
884 } 839 }
885 if(Method==2){// Daniels 840 if(Method==2){// Daniels
886 var boilfactor; 841 var boilfactor;
887 var sgfactor; 842 var sgfactor;
888 if (Form==2)// Leaf 843 if(Form==2)// Leaf
889 boilfactor = -(0.0041*time*time)+(0.6162*time)+1.5779; 844 boilfactor=-(0.0041*time*time)+(0.6162*time)+1.5779;
890 else 845 else
891 boilfactor = -(0.0051*time*time)+(0.7835*time)+1.9348; 846 boilfactor=-(0.0051*time*time)+(0.7835*time)+1.9348;
892 if (gravity<1050) 847 if(gravity<1050)
893 sgfactor=0; 848 sgfactor=0;
894 else 849 else
895 sgfactor=(gravity-1050)/200; 850 sgfactor=(gravity-1050)/200;
896 ibu = Round(fmoment*((mass*(alpha*100)*boilfactor* 0.1)/(liters*(1+sgfactor))),1); 851 ibu = Round(fmoment*((mass*(alpha*100)*boilfactor* 0.1)/(liters*(1+sgfactor))),1);
897 } 852 }
898 if(Method==1){// Rager 853 if(Method==1){// Rager
899 var boilfactor; 854 var sgfactor;
900 var sgfactor; 855 var boilfactor=fmoment*18.11+13.86*Math.tanh((time*31.32)/18.27);
901 boilfactor = fmoment*18.11+13.86*Math.tanh((time*31.32)/18.27); 856 if(gravity<1050)
902 if (gravity<1050) 857 sgfactor=0;
903 sgfactor=0; 858 else
904 else 859 sgfactor=(gravity-1050)/200;
905 sgfactor=(gravity-1050)/200; 860 ibu = Round((mass*(alpha*100)*boilfactor*0.1)/(liters*(1+sgfactor)),1);
906 ibu = Round((mass*(alpha*100)*boilfactor*0.1)/(liters*(1+sgfactor)),1); 861 }
907 } 862
908 863 //console.log("toIBU("+Use+","+Form+","+SG+","+Volume+","+Amount+","+Boiltime+","+Alpha+","+Method+"):"+ibu+" fm:"+fmoment+" pf:"+pfactor);
909 //console.log("toIBU("+Use+","+Form+","+SG+","+Volume+","+Amount+","+Boiltime+","+Alpha+","+Method+"):"+ibu+" fm:"+fmoment+" pf:"+pfactor); 864 return ibu;
910 return ibu;
911 } 865 }
912 866
913 867
914 868
915 function ebc_to_color(ebc){return srm_to_color(ebc_to_srm(ebc));} 869 function ebc_to_color(ebc){return srm_to_color(ebc_to_srm(ebc));}
916 function srm_to_color(srm){ 870 function srm_to_color(srm){
917 var i = Math.round(srm * 10); 871 var i = Math.round(srm * 10);
918 if(i<0){ 872 if(i<0)i=0;
919 i=0; 873 if(i>299)i=299;
920 } 874
921 if(i>299){ 875 /* Table copied from Brouwhulp/BrewBuddy */
922 i=299; 876 var R=[
923 } 877 250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,//0
924 878 250,250,250,250,250,249,248,247,246,245,244,243,242,241,240,239,238,237,236,235,//2
925 /* Table copied from Brouwhulp/BrewBuddy */ 879 234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,219,218,217,216,215,//4
926 var R = [ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, // 0 880 214,213,212,211,210,209,208,207,206,205,204,203,202,201,200,200,199,199,198,198,//6
927 250, 250, 250, 250, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, 236, 235, // 2 881 197,197,196,196,195,195,194,194,193,193,192,192,192,192,192,192,192,192,192,192,//8
928 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, 219, 218, 217, 216, 215, // 4 882 192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,192,//10
929 214, 213, 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, 202, 201, 200, 200, 199, 199, 198, 198, // 6 883 192,192,192,192,192,192,192,192,191,190,189,188,187,186,185,184,183,182,181,180,//12
930 197, 197, 196, 196, 195, 195, 194, 194, 193, 193, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 8 884 179,178,177,175,174,172,171,169,168,167,195,164,162,161,159,158,157,155,154,152,//14
931 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, 192, // 10 885 151,149,148,147,145,144,142,141,139,138,137,135,134,132,131,129,128,127,125,124,//16
932 192, 192, 192, 192, 192, 192, 192, 192, 191, 190, 189, 188, 187, 186, 185, 184, 183, 182, 181, 180, // 12 886 122,121,119,118,117,115,114,112,111,109,108,107,105,104,102,101, 99, 98, 97, 95,//18
933 179, 178, 177, 175, 174, 172, 171, 169, 168, 167, 195, 164, 162, 161, 159, 158, 157, 155, 154, 152, // 14 887 94, 92, 91, 89, 88, 87, 85, 84, 82, 81, 79, 78, 77, 75, 74, 72, 71, 69, 68, 67,//20
934 151, 149, 148, 147, 145, 144, 142, 141, 139, 138, 137, 135, 134, 132, 131, 129, 128, 127, 125, 124, // 16 888 65, 64, 62, 61, 59, 58, 57, 55, 54, 52, 51, 49, 48, 47, 45, 44, 43, 41, 39, 38,//22
935 122, 121, 119, 118, 117, 115, 114, 112, 111, 109, 108, 107, 105, 104, 102, 101, 99, 98, 97, 95, // 18 889 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28,//24
936 94, 92, 91, 89, 88, 87, 85, 84, 82, 81, 79, 78, 77, 75, 74, 72, 71, 69, 68, 67, // 20 890 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18,//26
937 65, 64, 62, 61, 59, 58, 57, 55, 54, 52, 51, 49, 48, 47, 45, 44, 43, 41, 39, 38, // 22 891 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8];
938 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 32, 31, 31, 30, 30, 29, 29, 28, 28, // 24 892
939 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, // 26 893 var G=[
940 17, 17, 16, 16, 15, 15, 14, 14, 13, 13, 12, 12, 11, 11, 10, 10, 9, 9, 8, 8 ]; 894 250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,250,
941 895 250,250,250,250,250,250,249,248,247,246,245,244,242,240,238,236,234,232,230,228,
942 var G = [ 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 896 226,224,222,220,218,216,214,212,210,208,206,204,202,200,198,196,194,192,190,188,
943 250, 250, 250, 250, 250, 250, 249, 248, 247, 246, 245, 244, 242, 240, 238, 236, 234, 232, 230, 228, 897 186,184,182,180,178,176,174,172,170,168,166,164,162,160,158,156,154,152,150,148,
944 226, 224, 222, 220, 218, 216, 214, 212, 210, 208, 206, 204, 202, 200, 198, 196, 194, 192, 190, 188, 898 146,144,142,141,140,139,139,138,137,136,136,135,134,133,133,132,131,130,130,129,
945 186, 184, 182, 180, 178, 176, 174, 172, 170, 168, 166, 164, 162, 160, 158, 156, 154, 152, 150, 148, 899 128,127,127,126,125,124,124,123,122,121,121,120,119,118,118,117,116,115,115,114,
946 146, 144, 142, 141, 140, 139, 139, 138, 137, 136, 136, 135, 134, 133, 133, 132, 131, 130, 130, 129, 900 113,112,112,111,110,109,109,108,107,106,106,105,104,103,103,102,101,100,100, 99,
947 128, 127, 127, 126, 125, 124, 124, 123, 122, 121, 121, 120, 119, 118, 118, 117, 116, 115, 115, 114, 901 98, 97, 97, 96, 95, 94, 94, 93, 92, 91, 91, 90, 89, 88, 88, 87, 86, 85, 85, 84,
948 113, 112, 112, 111, 110, 109, 109, 108, 107, 106, 106, 105, 104, 103, 103, 102, 101, 100, 100, 99, 902 83, 82, 82, 81, 80, 79, 78, 77, 76, 75, 75, 74, 73, 72, 72, 71, 70, 69, 69, 68,
949 98, 97, 97, 96, 95, 94, 94, 93, 92, 91, 91, 90, 89, 88, 88, 87, 86, 85, 85, 84, 903 67, 66, 66, 65, 64, 63, 63, 62, 61, 60, 60, 59, 58, 57, 57, 56, 55, 54, 54, 53,
950 83, 82, 82, 81, 80, 79, 78, 77, 76, 75, 75, 74, 73, 72, 72, 71, 70, 69, 69, 68, 904 52, 51, 51, 50, 49, 48, 48, 47, 46, 45, 45, 44, 43, 42, 42, 41, 40, 39, 39, 38,
951 67, 66, 66, 65, 64, 63, 63, 62, 61, 60, 60, 59, 58, 57, 57, 56, 55, 54, 54, 53, 905 37, 36, 36, 35, 34, 33, 33, 32, 31, 30, 30, 29, 28, 27, 27, 26, 25, 24, 24, 23,
952 52, 51, 51, 50, 49, 48, 48, 47, 46, 45, 45, 44, 43, 42, 42, 41, 40, 39, 39, 38, 906 22, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16,
953 37, 36, 36, 35, 34, 33, 33, 32, 31, 30, 30, 29, 28, 27, 27, 26, 25, 24, 24, 23, 907 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9,
954 22, 22, 22, 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 16, 16, 908 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3];
955 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 909
956 9, 9, 8, 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3 ]; 910 var B=[
957 911 210,204,199,193,188,182,177,171,166,160,155,149,144,138,133,127,122,116,111,105,
958 var B = [ 210, 204, 199, 193, 188, 182, 177, 171, 166, 160, 155, 149, 144, 138, 133, 127, 122, 116, 111, 105, 912 100, 94, 89, 83, 78, 72, 67, 61, 56, 50, 45, 45, 45, 46, 46, 46, 46, 47, 47, 47,
959 100, 94, 89, 83, 78, 72, 67, 61, 56, 50, 45, 45, 45, 46, 46, 46, 46, 47, 47, 47, 913 47, 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52,
960 47, 48, 48, 48, 48, 49, 49, 49, 49, 50, 50, 50, 50, 51, 51, 51, 51, 52, 52, 52, 914 52, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56,
961 52, 53, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 55, 56, 56, 56, 56, 56, 56, 56, 915 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
962 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 916 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
963 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 917 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56,
964 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 918 56, 56, 56, 55, 55, 55, 55, 54, 54, 54, 54, 53, 53, 53, 53, 52, 52, 52, 52, 51,
965 56, 56, 56, 55, 55, 55, 55, 54, 54, 54, 54, 53, 53, 53, 53, 52, 52, 52, 52, 51, 919 51, 51, 51, 50, 50, 50, 50, 49, 49, 48, 47, 47, 46, 45, 45, 44, 43, 43, 42, 41,
966 51, 51, 51, 50, 50, 50, 50, 49, 49, 48, 47, 47, 46, 45, 45, 44, 43, 43, 42, 41, 920 41, 40, 39, 39, 38, 37, 37, 36, 35, 34, 33, 32, 31, 29, 28, 27, 26, 25, 24, 23,
967 41, 40, 39, 39, 38, 37, 37, 36, 35, 34, 33, 32, 31, 29, 28, 27, 26, 25, 24, 23, 921 21, 20, 19, 18, 17, 16, 15, 13, 12, 11, 10, 9, 8, 9, 9, 10, 10, 11, 11, 12,
968 21, 20, 19, 18, 17, 16, 15, 13, 12, 11, 10, 9, 8, 9, 9, 10, 10, 11, 11, 12, 922 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22,
969 12, 13, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 923 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 15, 15,
970 21, 21, 21, 20, 20, 20, 19, 19, 19, 18, 18, 18, 17, 17, 17, 17, 16, 16, 15, 15, 924 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8,
971 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 8, 925 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2];
972 8, 8, 7, 7, 7, 6, 6, 6, 5, 5, 5, 4, 4, 4, 3, 3, 3, 2, 2, 2 ];
973 926
974 var color=R[i]*65536+G[i]*256+B[i]; 927 var color=R[i]*65536+G[i]*256+B[i];
975 var result=color.toString(16).toUpperCase(); 928 var result=color.toString(16).toUpperCase();
976 if(result.length<6) { 929 if(result.length<6) {
977 result='0'+result; 930 result='0'+result;

mercurial