1jQuery(document).ready(function() { 2 3 /* Calculate value for select box and radio button */ 4 function CALCULATIONCF7_custom_radio_button(){ 5 jQuery("form.wpcf7-form select option").each(function (i) { 6 if(jQuery(this).attr("type") === undefined) { 7 var cal_selectval = jQuery(this).attr("value"); 8 if(cal_selectval.indexOf("--") != -1){ 9 jQuery(this).attr("value",''); 10 jQuery(this).html('Required Pro Version for add Custom Label. <a href="https://www.plugin999.com/plugin/calculation-for-contact-form-7/" target="_blank">Click Here To Get Pro Version</a>'); 11 } 12 } 13 }) 14 jQuery("form.wpcf7-form input").each(function () { 15 if( jQuery(this).attr("type") == "radio" || jQuery(this).attr("type") == "checkbox" ) { 16 var cal_inputval = jQuery(this).attr("value"); 17 if(cal_inputval.indexOf("--") != -1){ 18 jQuery(this).val(''); 19 jQuery(this).parent().find('span.wpcf7-list-item-label').html('Required Pro Version for add Custom Label. <a href="https://www.plugin999.com/plugin/calculation-for-contact-form-7/" target="_blank">Click Here To Get Pro Version</a>'); 20 } 21 } 22 }) 23 } 24 25 /* check form length */ 26 if ( jQuery( ".wpcf7-form" ).length ) { 27 CALCULATIONCF7_custom_radio_button(); 28 CALCULATIONCF7_calculate_formulas(); 29 /* select , check box , radio button change here*/ 30 jQuery("body").on("change",".wpcf7 input,.wpcf7 select",function(e){ 31 CALCULATIONCF7_calculate_formulas(); 32 }); 33 jQuery("input[type='number']").bind('keyup', function () { 34 CALCULATIONCF7_calculate_formulas(); 35 }); 36 jQuery("input[type='text']").bind('keyup', function () { 37 CALCULATIONCF7_calculate_formulas(); 38 }); 39 } 40 41 /*calculator formula setup */ 42 function CALCULATIONCF7_calculate_formulas(){ 43 var match; 44 var reg =[]; 45 var total = 0; 46 47 jQuery("form.wpcf7-form input").each(function () { 48 if( jQuery(this).attr("type") == "checkbox" || jQuery(this).attr("type") == "radio" ) { 49 var name = jQuery(this).attr("name").replace("[]", ""); 50 reg.push(name); 51 //alert($(this).attr("name")); 52 }else{ 53 reg.push(jQuery(this).attr("name")); 54 } 55 }) 56 57 jQuery("form.wpcf7-form select").each(function () { 58 var name_select = jQuery(this).attr("name").replace("[]", ""); 59 reg.push(name_select); 60 }) 61 62 reg = calculationcf7s_duplicates_type(reg); 63 var all_tag = new RegExp( reg.join("|")); 64 jQuery( ".calculationcf7-total" ).each(function( index ) { 65 var type = ''; 66 var eq = jQuery(this).data('formulas'); 67 var prefix = jQuery(this).attr("prefix"); 68 var precision = jQuery(this).attr("precision"); 69 if(eq != '' || eq.length != 0){ 70 while ( match = all_tag.exec( eq ) ){ 71 var perfact_match = calculationcf7s_word_In_String(eq,match[0]); 72 if(perfact_match != false){ 73 var type = jQuery("input[name="+match[0]+"]").attr("type"); 74 if( type === undefined ) { 75 var type = jQuery("input[name='"+match[0]+"[]']").attr("type"); 76 } 77 //console.log(type); 78 if( type =="checkbox" ){ 79 var vl = 0; 80 jQuery("input[name='"+match[0]+"[]']:checked").each(function () { 81 var attr = jQuery(this).attr('price'); 82 //console.log(attr); 83 if (typeof attr !== typeof undefined && attr !== false) { 84 vl += new Number(attr); 85 } else { 86 vl += new Number(jQuery(this).val()); 87 } 88 }); 89 }else if( type == "radio"){ 90 var attr = jQuery("input[name='"+match[0]+"']:checked").attr('price'); 91 if (typeof attr !== typeof undefined && attr !== false) { 92 var vl = attr; 93 } else { 94 var vl = jQuery("input[name='"+match[0]+"']:checked").val(); 95 } 96 }else if( type === undefined ){ 97 var check_select = jQuery("select[name="+match[0]+"]").val(); 98 //console.log('--'+check_select+'--') 99 if(check_select === undefined){ 100 var vl = 0; 101 jQuery("select[name='"+match[0]+"[]'] option:selected").each(function () { 102 var attr = jQuery(this).attr('price'); 103 if (typeof attr !== typeof undefined && attr !== false) { 104 vl += new Number(attr); 105 } else { 106 vl += new Number(jQuery(this).val()); 107 } 108 }); 109 } else { 110 var vl = 0; 111 jQuery("select[name="+match[0]+"] option:selected").each(function () { 112 var attr = jQuery(this).attr('price'); 113 if (typeof attr !== typeof undefined && attr !== false) { 114 vl += new Number(attr); 115 } else { 116 vl += new Number(jQuery(this).val()); 117 } 118 }); 119 } 120 }else{ 121 var attr = jQuery("input[name="+match[0]+"]").attr('price'); 122 if (typeof attr !== typeof undefined && attr !== false) { 123 var vl = attr; 124 } else { 125 var vl = jQuery("input[name="+match[0]+"]").val(); 126 } 127 } 128 if(!jQuery.isNumeric(vl)){ 129 vl = 0; 130 //alert("value must be numeric"); 131 } 132 }else{ 133 var error = 1; 134 } 135 nueq = ''; 136 eq = eq.replace( match[0], vl ); 137 neq = eq; 138 var neqf = ''; 139 if(eq.indexOf("sqrt") != -1){ 140 var neweq = eq.split(" "); 141 for(var i = 0; i < neweq.length; i++){ 142 if(neweq[i].indexOf("sqrt") != -1){ 143 var sqrt = neweq[i].match("sqrt((.*))"); 144 var sqrtd = sqrt[1].replace(/[()]/g,'') 145 var sqrtroot = Math.sqrt(parseInt(sqrtd)); 146 neq = neq.replace( sqrt[1], sqrtroot ); 147 } 148 } 149 nueq = neq.split("sqrt").join(''); 150 } 151 if(nueq === ''){ 152 neqf = eq; 153 } else { 154 neqf = nueq; 155 } 156 } 157 }else{ 158 alert("Please Enter Formula in Calculator"); 159 return false;
160 } 161 if(error == 1){ 162 alert("Please Enter Valid Formula in Calculator"); 163 return false; 164 } 165 try{ 166 var fresult = ''; 167 var r = eval( neqf ); // Evaluate the final equation 168 if( precision != undefined ) { 169 fresult = r.toFixed(precision); 170 } else { 171 fresult = r; 172 } 173 174 total = fresult; 175 //console.log('--'+total); 176 177 } 178 catch(e) 179 { 180 alert( "Error:" + neqf ); 181 } 182 183 if(index === 0){ 184 if( prefix != undefined ) { 185 jQuery(this).val(prefix + total); 186 }else{ 187 jQuery(this).val(total); 188 } 189 } else { 190 jQuery(this).closest('span').html('Required Pro Version for add Custom Label. <a href="https://www.plugin999.com/plugin/calculation-for-contact-form-7/" target="_blank">Click Here To Get Pro Version</a>'); 191 } 192 }); 193 } 194 195 /*contact form 7 duplicator type */ 196 function calculationcf7s_duplicates_type(arr) { 197 var ret_arr = []; 198 var obj = {}; 199 for (var i = 0; i < arr.length; i++) { 200 obj[arr[i]] = true; 201 } 202 //console.log(obj); 203 for (var key in obj) { 204 if("_wpcf7" == key || "_wpcf7_version" == key || "_wpcf7_locale" == key || "_wpcf7_unit_tag" == key || "_wpnonce" == key || "undefined" == key || "_wpcf7_container_post" == key || "_wpcf7_nonce" == key ){ 205 206 }else { 207 ret_arr.push(key); 208 } 209 } 210 return ret_arr; 211 } 212 213 /* calculator word In String */ 214 function calculationcf7s_word_In_String(s, word){ 215 return new RegExp( '\\b' + word + '\\b', 'i').test(s); 216 } 217 218});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.