function validateFloatKeyPress(el, evt) { var charCode = (evt.which) ? evt.which : event.keyCode; var number = el.value.split('.'); if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) { return false; } //just one dot if(number.length>1 && charCode == 46){ return false; } //get the carat position var caratPos = getSelectionStart(el); var dotPos = el.value.indexOf("."); if( caratPos > dotPos && dotPos>-1 && (number[1].length > 1)){ return false; } return true; } function getSelectionStart(o) { if (o.createTextRange) { var r = document.selection.createRange().duplicate() r.moveEnd('character', o.value.length) if (r.text == '') return o.value.length return o.value.lastIndexOf(r.text) } else return o.selectionStart } $(document).ready(function() { var aleatorioimg = Math.floor(Math.random() * 3)*1+1*1; if(aleatorioimg==3){aleatorioimg=2;} $(".banner").css({ 'background-image': 'linear-gradient(to bottom, rgba(0, 0, 0, 0.2) 80%, rgba(0, 0, 0, 0.2) 100%), url(../images/entrada' + aleatorioimg + '.jpg)' }); // Header Scroll $(window).on('scroll', function() { var scroll = $(window).scrollTop(); if (scroll >= 50) { $('#header').addClass('fixed'); } else { //$('#header').removeClass('fixed'); $('#header').addClass('fixed'); } }); // Fancybox $('.work-box').fancybox(); // Flexslider $('.flexslider').flexslider({ animation: "fade", directionNav: false, }); // Page Scroll var sections = $('section') nav = $('nav[role="navigation"]'); $(window).on('scroll', function () { var cur_pos = $(this).scrollTop(); sections.each(function() { var top = $(this).offset().top - 76 bottom = top + $(this).outerHeight(); if (cur_pos >= top && cur_pos <= bottom) { nav.find('a').removeClass('active'); nav.find('a[href="#'+$(this).attr('id')+'"]').addClass('active'); } }); }); nav.find('a').on('click', function () { var $el = $(this) id = $el.attr('href'); $('html, body').animate({ scrollTop: $(id).offset().top - 75 }, 500); return false; }); // Mobile Navigation $('.nav-toggle').on('click', function() { $(this).toggleClass('close-nav'); nav.toggleClass('open'); return false; }); nav.find('a').on('click', function() { $('.nav-toggle').toggleClass('close-nav'); nav.toggleClass('open'); }); /* $(".draggable").draggable({ containment: "#montra2", scroll: false, revert: true }); $( ".droppable" ).droppable({ drop: function( event, ui ) { console.log(ui.draggable.attr("id")); $( "#lista_alimentos" ).text($( "#lista_alimentos" ).text()+'--'+ui.draggable.attr("id")); // $("#menu").append('
  • New list item
  • '); $( this ) .addClass( "ui-state-highlight" ) .find( "p" ) .html( "Dropped!" ); } }); function Drop(event, ui) { var draggableId = ui.draggable.attr("id"); var droppableId = $(this).attr("id"); }*/ $('#carouselExampleSlidesOnly').carousel({ interval: 4500, cycle: true }); $('#primary-nav').css("font-weight","Bold"); document.addEventListener("scroll", function() { scrollHeight = window.pageYOffset; document.getElementsByClassName("imglogo")[0].style.height = scrollHeight >= 200 ? "40px" : "40px"; if(document.getElementsByClassName("imglogo")[0].style.height = scrollHeight >= 200){$('#primary-nav').css("font-weight","Bold");}else{$('#primary-nav').css("font-weight","initial");} }, false); $( ".decimais" ).change(function() { var max = Math.round(parseInt($(this).attr('max')* 100)); var min = Math.round(parseInt($(this).attr('min')* 100)); var valori = Math.round(parseInt($(this).val()* 100)); if (valori > max){ $(this).val(''); alert('Altura máxima de '+$(this).attr('max')); }else if (valori < min){ $(this).val(''); alert('Altura mínima de '+$(this).attr('min')); } }); $( ".numeros" ).change(function() { var max = parseInt($(this).attr('max')); var min = parseInt($(this).attr('min')); var id1 = $(this).attr('id').substring(0,7); if ($(this).val() > max) { if(id1=='idadecr'){ alert('Este questionário só se aplica a crianças entre os 3 e os 10 anos!'); $(this).val(''); }else{ $(this).val(''); } $(this).val(''); } else if ($(this).val() < min) { if($(this).attr('id')=='idade'){ alert('Para preencher este questionário tem que ter 18 anos ou mais!');$(this).val(''); }else if(id1=='idadecr'){ alert('Este questionário só se aplica a crianças entre os 3 e os 10 anos!');$(this).val(''); }else{ $(this).val(''); } $(this).val(''); } }); /* alert('Uncaught SyntaxError: Unexpected identifier'); alert('SyntaxError: "use strict" not allowed in function with non-simple parameters'); var erros= ['RangeError: radix must be an integer', 'RangeError: repeat count must be less than infinity', 'RangeError: repeat count must be non-negative', 'ReferenceError: "x" is not defined', 'ReferenceError: assignment to undeclared variable "x"', 'ReferenceError: cant access lexical declaration`X before initialization', 'ReferenceError: deprecated caller or arguments usage', 'ReferenceError: invalid assignment left-hand side', 'ReferenceError: reference to undefined property "x"', 'SyntaxError: "0"-prefixed octal literals and octal escape seq. are deprecated', 'SyntaxError: "use strict" not allowed in function with non-simple parameters', 'SyntaxError: "x" is a reserved identifier', 'SyntaxError: JSON.parse: bad parsing', 'SyntaxError: Malformed formal parameter', 'SyntaxError: Unexpected token', 'SyntaxError: Using //@ to indicate s'] var aleatorio = Math.floor(Math.random() * 3); for (i = 0; i < aleatorio; i++) { var aleatorio2 = Math.floor(Math.random() * 15); alert(erros[aleatorio2]); } */ $(document).on('click', '#acabar', function() { var dados = { "tab":'users', "nice":69 }; $('.pgtconhecimento').each(function () { console[this.id] = this.value; var nome = $(this).attr('name'); if ($(this).is(':checked')) {dados[this.name] = this.value;} }); //console.log(dados); $.post("save.php", {dados}, function(resp){ console.log(resp); $('#step6').hide(); $('#pai_da_barra').hide(); $('#obrigadinho').modal('show'); }); }); $(document).on('click', '.next', function() { console.log('aqui'); /////////////////////ERROR AQUI ALGURES////////////// var tabelas = { "step1":"users", "step2":"crianca" , "step3":"lanche" , "step4":"crianca" , "step5":"crianca" }; var aidi = $(this).attr('id'); var thisId = $(this).parents('.tab-pane').attr("id"); var nextId = $(this).parents('.tab-pane').next().attr("id"); var nextId = $(this).parents('.tab-pane').next().attr("id"); var dados = { "tab":tabelas[thisId], "nice":69, "criancaID":$('#idcriancaactual').val() }; var okchilda = okchild(); if( (aidi == 'continuar1' && okchilda) || aidi != 'continuar1' ){ $('.waitpage').show(); console.log(thisId); console.log(nextId); if(thisId=='step1' || thisId=='step2' || thisId=='step3' || thisId=='step4' || thisId=='step5'){ //if(thisId=='step3'){dados['criancaID']=$('#idcriancaactual').val(); } dados['criancaID']=$('#idcriancaactual').val(); $('#'+thisId+' input[type=text]').each(function () {dados[this.id] = this.value;}); $('#'+thisId+' input[type=hidden]').each(function () {dados[this.id] = this.value;}); $('#'+thisId+' input[type=number]').each(function () {dados[this.id] = this.value;}); $('#'+thisId+' input[type=date]').each(function () {dados[this.id] = this.value;}); $('#'+thisId+' input[type=checkbox]').each(function () { if ($(this).is(':checked')) {dados[this.name] = this.value;} }); $('#'+thisId+' input[type=radio]').each(function () { if ($(this).is(':checked')) { dados[this.name] = this.value;} }); $( '#'+thisId+' select').each(function () {dados[this.id] = this.value;}); console.log(dados); console.log('error_loagagag'); $.post("save.php", {dados}, function(resp){ console.log(resp); if(resp['nrcriancas'] > 0){ var tdsidades = []; for(var xis=1;xis<=resp['nrcriancas'];xis++){ $('#crid'+xis).val(resp['idcri'+xis]); //tdsidades[resp['idcri'+xis]]=$('#idadecr'+xis).val(); tdsidades[xis]=$('#idadecr'+xis).val(); } const findDuplicates = (arr) => { let sorted_arr = arr.slice().sort(); let results = []; let novosnomes = []; let nrduplicado = 1; var idsduplicados = []; var numberoficial = 1; for (let i = 0; i < sorted_arr.length - 1; i++) { if (sorted_arr[i + 1] == sorted_arr[i]) { results.push(sorted_arr[i]); $('#txtcri'+numberoficial).val( 'sobre a '+nrduplicado+'ª criança de '+sorted_arr[i]+' anos' ); nrduplicado++; }else{ if (sorted_arr[i - 1] == sorted_arr[i]) { results.push(sorted_arr[i]); $('#txtcri'+numberoficial).val( 'sobre a '+nrduplicado+'ª criança de '+sorted_arr[i]+' anos' ); }else{ $('#txtcri'+numberoficial).val( 'sobre a criança de '+sorted_arr[i]+' anos' ); novosnomes.push(sorted_arr[i]); } nrduplicado = 1; } numberoficial++; } return results; } var counts = findDuplicates(tdsidades); console.log(tdsidades); if ( tdsidades.includes("Mango") ){ }else{ } $('.agecriact').html( $('#txtcri'+1).val() ); $('#idcriancaactual').val(resp['idcri1']); $('#criancaID').val(resp['idcri1']); } if(resp['ok']){ var ultimolanche = 0; $(".freelunch").each(function() { //console.log( $(this).val()+' : '+$(this).attr('id') ); if($(this).val() == 1){ultimolanche++;} }); if( thisId=='step3' ){ console.log('nega'); if($('#tipolanche').val()=='peq'){ $("#famhabitual").hide(); $('#famquantoslanches').show(); $('.waitpage').hide(); }else if( ultimolanche == 0){ $('.waitpage').hide(); $('[href=#'+nextId+']').tab('show'); }else{ $( "#step3" ).remove(); $.ajax({ type: 'POST', url: 'lanches.php', success: function(resp) { var h = document.getElementById("step2"); h.insertAdjacentHTML("afterend", resp); $('#step3').addClass( "active in" ); if($('#lanmn1').val() == 1){ $('#lanmn1').val(''); $("#tipolanche").val('lanmn1'); $(".nomerefeicao").text('1º lanche da manhã'); }else if($('#lanmn2').val() == 1){ $('#lanmn2').val(''); $("#tipolanche").val('lanmn2'); $(".nomerefeicao").text('2º lanche da manhã'); }else if($('#lantd1').val() == 1){ $('#lantd1').val(''); $("#tipolanche").val('lantd1'); $(".nomerefeicao").text('1º lanche da tarde'); }else if($('#lantd2').val() == 1){ $('#lantd2').val(''); $("#tipolanche").val('lantd2'); $(".nomerefeicao").text('2º lanche da tarde'); }else if($('#lantd3').val() == 1){ $('#lantd3').val(''); $("#tipolanche").val('lantd3'); $(".nomerefeicao").text('3º lanche da tarde'); }else if($('#lannt1').val() == 1){ $('#lannt1').val(''); $("#tipolanche").val('lannt'); $(".nomerefeicao").text('lanche da noite'); } $("#criancaID").val($("#idcriancaactual").val()); } }); $('.waitpage').hide(); } }else if(thisId=='step5' ){ var anterior = $('#idcriancaactual').val(); var idscriancas = { }; var another = 0; $('.progress-bar').css({width: '80%'}); console.log(anterior); $('.idcriancas').each(function () { if( $(this).val() > 0 && $(this).val() != anterior){idscriancas[this.id] = this.value;another++;} if( $(this).val() == anterior ){ $(this).val(''); } }); if(another > 0){ var proximaidchild = idscriancas[Object.keys(idscriancas)[0]] ; var proximaidchildnome = Object.keys(idscriancas)[0].substring(4); console.log(idscriancas); console.log(proximaidchildnome); $('.agecriact').html($('#txtcri'+proximaidchildnome).val()); $('[href=#step2]').tab('show'); $('#step2').addClass( "active in" ); $( "#step3" ).remove(); $.ajax({type: 'POST',url: 'lanches.php', success: function(resp) {var h = document.getElementById("step2"); h.insertAdjacentHTML("afterend", resp); $('#idcriancaactual').val( proximaidchild ); $('#criancaID').val( proximaidchild ); $('#kid1').slideDown(); $('#kid5').slideUp(); $('#env1').slideDown(); $('#env2').slideUp(); $('#pre3').slideUp(); $('#pre1').slideDown(); $('.btnrosinha ').removeClass( "active" ) clear_form_elements('step2'); clear_form_elements('step4'); clear_form_elements('step5'); $('.waitpage').hide(); $('#newkidmodal').modal('show'); var elmnt = document.getElementById("crititulo2"); elmnt.scrollIntoView(); setTimeout(function(){ $('#newkidmodal').modal('hide')}, 2500); }}); }else{ $('.waitpage').hide(); $('[href=#'+nextId+']').tab('show'); } }else{ $('.waitpage').hide(); $('[href=#'+nextId+']').tab('show'); } } }, "json"); }else{ $('.waitpage').hide(); $('[href=#'+nextId+']').tab('show'); } }else{alert('Por favor preencha a idade de todas as crianças!')} return false; }) $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) { var step = $(e.target).data('step'); var percent = (parseInt(step) / 7) * 100; $('.progress-bar').css({width: percent + '%'}); $('.progress-bar').text("Secção " + step + " de 7"); }) $(document).on('click', '.first', function() { $('#myWizard a:first').tab('show') }) $(document).on('click', '#seguintefam', function() { var partes = $('#quais').val().split('£'); partes.sort(function(partes,b){return partes - b}) var tamanho = partes.length; var cleanpartes = partes.filter(function () { return true }); cleanpartes.shift(); tamanho = cleanpartes.length; //console.log(partes); if(tamanho > 0){ $('#myfams').hide(); var btnnexthide=cleanpartes[0]*1+1*1; $('#fam'+cleanpartes[0]).show('fast'); if(tamanho==1){ if(cleanpartes[0] != 5 && cleanpartes[0] != 9){ $('#confirmar').show('fast');$('#pro'+btnnexthide).hide('fast'); }else{ $('#confirmar').hide('fast');$('#pro'+btnnexthide).hide('fast'); } } $([document.documentElement, document.body]).animate({scrollTop: $('#fam'+cleanpartes[0]).offset().top - 150}, 500); }else{alert('Escolha pelo menos uma família de alimentos.');} }) $(document).on('click', '.proximo', function() { var partes = $('#quais').val().split('£'); partes.sort(function(partes,b){return partes - b}) var tamanho = partes.length; var cleanpartes = partes.filter(function () { return true }); cleanpartes.shift(); tamanho = cleanpartes.length; var aidipai = $(this).parent().attr('id').substring(3); var aidi = $(this).attr('id').substring(3); var onde = cleanpartes.indexOf(aidipai); var paraonde = onde*1+1; var nomedosfilhos=''; var inacabados = []; $('#'+$(this).parent().attr('id')+' input:checkbox.alimentovalue').each(function () { if ($(this).is(':checked')) {nomedosfilhos = 'quant_'+this.name.substring(3);nomedopai = this.name.substring(3); var limento = ["papa", "cereais1", "cereais2", "cereais3", "cereais4", "cereais5", "cereais6", "cereais7", "cereais8", "cereais9", "cereais10", "cereais11", "cereais12"]; var yeasfood = limento.includes(nomedopai) ; console.log(nomedopai); if ( !$("input[name='"+nomedosfilhos+"']:checked").val() && !yeasfood) {inacabados.push(this.name.substring(3));}}}); if(inacabados.length > 0){alert('Por favor selecione as quantidades para os alimentos que escolheu.'); }else{ $(this).parent().hide(); /*console.log(tamanho); console.log(cleanpartes); console.log(onde*1+1);*/ $('#fam'+cleanpartes[paraonde]).show('fast'); if(cleanpartes[tamanho-1] == cleanpartes[paraonde]){ var ondeactuar= cleanpartes[paraonde]*1+1; $('#confirmar').show('fast'); $('#pro'+ondeactuar).hide('fast'); } //console.log(cleanpartes[onde]); var btnnexthide=cleanpartes[onde]*1+1*1; if(cleanpartes[paraonde] != 5 && cleanpartes[paraonde] != 9){ //$('#confirmar').show('fast');$('#pro'+btnnexthide).hide('fast'); }else{ $('#confirmar').hide('fast');$('#pro'+btnnexthide).hide('fast'); } $([document.documentElement, document.body]).animate({scrollTop: $('#myWizard').offset().top - 50}, 500); } }); $( "#nrcriancas" ).change(function() { for(var yess=9;yess>0;yess--){ if(yess > $(this).val()){ $( "#cortinacrianca"+yess ).hide(); $( "#idadecr"+yess ).val(''); }else{ $( "#cortinacrianca"+yess ).slideDown(); } } }); $(document).on('click', '.patherfood', function() { var partes = $('#quais').val().split('£'); var a = partes.indexOf($(this).attr('onde')); if(a > -1){ //console.log(partes); $('#quais').val(''); $(this).css('backgroundColor','#ffffff'); partes.splice(a, 1); //console.log(partes); for (var index = 0; index < partes.length; ++index) { //console.log(partes[index]); if(partes[index].length){$('#quais').val($('#quais').val()+partes[index]+'£');} } }else{ if(partes.length < 4 || true){ $('#quais').val($('#quais').val()+$(this).attr('onde')+'£'); $(this).css('backgroundColor','rgba(38, 187, 227, 0.5)'); }else{ //alert('Limite de pesquisa por 3 temas em simultâneo.'); } } }); $(document).on('click', '#confirmar', function() { var classfood = ''; var nome = ''; var imagesrc = ''; var inacabados = []; $('#'+$(this).parent().attr('id')+' input:checkbox.alimentovalue').each(function () { if ($(this).is(':checked')) {nomedosfilhos = 'quant_'+this.name.substring(3);nomedopai = this.name.substring(3); var limento = ["papa", "cereais1", "cereais2", "cereais3", "cereais4", "cereais5", "cereais6", "cereais7", "cereais8", "cereais9", "cereais10", "cereais11", "cereais12"]; var yeasfood = limento.includes(nomedopai) ; console.log(nomedopai); if ( !$("input[name='"+nomedosfilhos+"']:checked").val() && !yeasfood) {inacabados.push(this.name.substring(3));}}}); if(inacabados.length > 0){alert('Por favor selecione as quantidades para os alimentos que escolheu.'); }else{ $("#confirmar").hide(); $('#step3 .wella').hide(); $('#step3 input[type=checkbox]').each(function () { classfood = $(this).attr('class'); if ($(this).is(':checked') && classfood == 'alimentovalue') { nome = $(this).attr('id').substring(3); imagesrc = $('#'+nome).attr('src'); $('#listafinal').append($('',{id:'listfinal'+nome,class:'escolhidas',src:imagesrc}));} }); $('#comfirmarfam').slideDown('fast', function() { $([document.documentElement, document.body]).animate({scrollTop: $('#myWizard').offset().top}, 500); }); } }); $(document).on('click', '#outrosfinal', function() { $("#comfirmarfam").hide(); $("#fam16").show(); }); $(document).on('click', '#confirmarnrlanches', function() { $.post("save.php", {dados}, function(resp){ }, "json"); var lanmn = $("#lanchesmanha").val(); var lantd = $("#lanchestarde").val(); var lannt = $("#lanchesnoite").val(); var dados = { "tab":'crianca', "nice":69 , "lanmn":lanmn , "lantd":lantd , "lannt":lannt }; if(lanmn == 0 && lantd == 0 && lannt == 0 ){ $('#step4').addClass( "active in" ); $('[href=#step4]').tab('show'); $([document.documentElement, document.body]).animate({scrollTop: $('#myWizard').offset().top}, 500); }else{ for (var i = 1; i <= lanmn; i++) { $('#lanmn'+i).val('1');} for (var i = 1; i <= lantd; i++) { $('#lantd'+i).val('1');} for (var i = 1; i <= lannt; i++) { $('#lannt'+i).val('1');} $( "#step3" ).remove(); $.ajax({ type: 'POST', url: 'lanches.php', success: function(resp) { var h = document.getElementById("step2"); h.insertAdjacentHTML("afterend", resp); $('#step3').addClass( "active in" ); if($('#lanmn1').val() == 1){ $('#lanmn1').val(''); $("#tipolanche").val('lanmn1'); $(".nomerefeicao").text('1º lanche da manhã'); }else if($('#lanmn2').val() == 1){ $('#lanmn2').val(''); $("#tipolanche").val('lanmn2'); $(".nomerefeicao").text('2º lanche da manhã'); }else if($('#lantd1').val() == 1){ $('#lantd1').val(''); $("#tipolanche").val('lantd1'); $(".nomerefeicao").text('1º lanche da tarde'); }else if($('#lantd2').val() == 1){ $('#lantd2').val(''); $("#tipolanche").val('lantd2'); $(".nomerefeicao").text('2º lanche da tarde'); }else if($('#lantd3').val() == 1){ $('#lantd3').val(''); $("#tipolanche").val('lantd3'); $(".nomerefeicao").text('3º lanche da tarde'); }else if($('#lannt1').val() == 1){ $('#lannt1').val(''); $("#tipolanche").val('lannt'); $(".nomerefeicao").text('lanche da noite'); } $("#criancaID").val($("#idcriancaactual").val()); } }); //console.log('MANIGA'); $("#famquantoslanches").hide(); $("#myfams").show(); $([document.documentElement, document.body]).animate({scrollTop: $('#myWizard').offset().top}, 500); } }); $(document).on('click', '#passarafrenteoutros', function() { if( document.getElementById("fotocomida").files.length == 0 ){ console.log("sem foto"); }else{ //var file = document.getElementById('fotocomida').files[0]; //Files[0] = 1st file var fd = new FormData(); var files = $('#fotocomida')[0].files[0]; fd.append('file',files); fd.append('tipolanche',$('#tipolanche').val() ); fd.append('user_id',$('#user_id').val() ); fd.append('criancaID',$('#criancaID').val() ); $.ajax({ url: 'uploadfood.php', type: 'post', data: fd, contentType: false, processData: false, success: function(response){ console.log(response); if(response != 0){ //$("#img").attr("src",response); //$(".preview img").show(); // Display image element }else{ alert('file not uploaded'); } }, }); } $("#fam16").hide(); $('#famhabitual').slideDown('fast', function() { $([document.documentElement, document.body]).animate({scrollTop: $('#myWizard').offset().top}, 500); }); }); $(document).on('click', '#proximohabitaul', function() { $("#comfirmarfam").hide(); $('#famhabitual').slideDown('fast', function() { $([document.documentElement, document.body]).animate({scrollTop: $('#myWizard').offset().top}, 500); }); }); $(document).on('click', '.tool2, .tool3', function() { var id = $(this).find('.alimentos').attr('id'); $('#val'+id).click(); if($('#val'+id).is(":checked")){ $('#qut'+id).show(); $(this).css('backgroundColor','rgba(38, 187, 227, 0.5)'); //$('#chk'+id).show(); if(id == 'leite' || id == 'leite_chocolate' || id == 'leite_morango' ){ $('#acucarmodal').modal('show'); $('#valqual').val(id); }else if(id == 'iogurte'){ $('#iogurtemodal').modal('show'); $('#valqualiogu').val(id); }else if(id == 'iogurte_liquido'){ $('#iogurteliquidomodal').modal('show'); $('#valqualioguliq').val(id); } if(id=='tacacereais1'){$('#valtacacereais2').parent().css('backgroundColor','#ffffff');$('#valtacacereais2').prop( "checked", false );} if(id=='tacacereais2'){$('#valtacacereais1').parent().css('backgroundColor','#ffffff');$('#valtacacereais1').prop( "checked", false );} }else{ $('#qut'+id).hide(); $('#chk'+id).hide(); $('input[name="quant_'+id+'"]').prop('checked', false); $(this).css('backgroundColor','#ffffff'); $('#acucar'+id).val(''); $('#val'+id).prop( "checked", false ); if(id == 'iogurte'){ $('#tipiogurte').val(''); $('#clasiogurte').val(''); $('#acuiogurte').val(''); $('#tipoiogurte').val('0'); $('#classeiogurte').val('0'); $('#acucariogurte').val('0'); $('#iogurtemodal').modal('hide'); $('#valqualiogu').val(''); }else if(id == 'iogurte_liquido'){ $('#tipioguliquido').val(''); $('#tipoiogurteliquido').val('0'); $('#iogurteliquidomodal').modal('hide'); $('#valqualioguliq').val(''); } } }); /*$(".checka").click(function(){ var id = $(this).attr('id').substring(3);$('#val'+id).click();$('#qut'+id).hide();$('#chk'+id).hide(); $('input[name="copos_'+id+'"]').prop('checked', false); var x = $(this).prev().attr('id'); $('#acucar'+x).val(''); $('#val'+x).prop( "checked", false ); if(x == 'iogurte'){ $('#tipiogurte').val(''); $('#clasiogurte').val(''); $('#acuiogurte').val(''); }else if(x == 'iogurte_liquido'){ $('#tipioguliquido').val(''); $('#tipoiogurteliquido').val('0'); } });*/ $(".kidas").click(function(){ var id = $(this).attr('id').substring(11); $('#kid'+id).slideDown(); $(this).closest( ".contentor" ).slideUp(); $([document.documentElement, document.body]).animate({scrollTop: $('#crititulo2').offset().top - 110}, 500); }); $('.prepara').click(function(){ var id = $(this).attr('id').substring(11); $('#pre'+id).slideDown(); $(this).closest( ".contentor" ).slideUp(); $([document.documentElement, document.body]).animate({scrollTop: $('#crititulo3').offset().top - 110}, 500); }); $(".homes").click(function(){ var id = $(this).attr('id').substring(11); $('#env'+id).slideDown(); $(this).closest( ".contentor" ).slideUp(); $([document.documentElement, document.body]).animate({scrollTop: $('#crititulo4').offset().top - 110}, 500); }); $(".outras").change(function(){ var id = $(this).attr('id'); console.log($(this).val()); if($(this).val() == 1){ $('.'+id+'_qual').slideDown(); }else{ $('.'+id+'_qual').slideUp(); $('#'+id+'_qual').val(''); } }); $(".outras2").change(function(){ var id = $(this).attr('id'); console.log($(this).val()); if($(this).val() == 1){ $('.'+id+'_qual').slideDown(); }else{ $('.'+id+'_qual').slideUp(); $('#'+id+'_vezes').val(''); $('#'+id+'_tempo').val(''); $('#'+id+'_tipo').val(''); } }); $(".outras3").change(function(){ var id = $(this).attr('id'); console.log($(this).val()); if($(this).val() == 2){ $('.'+id+'_qual').slideDown(); }else{ $('.'+id+'_qual').slideUp(); $('#'+id+'_qual').val(''); } }); $("#acompanhacompras").change(function(){ if($(this).val() == 1){ $('.acompanhacompras').slideDown(); }else{ $('.acompanhacompras').slideUp(); $('.participacompras').slideUp(); $('.participacompras input').each(function () {$(this).val('');}); $('.participacompras select').each(function () {$(this).val('');}); $('#participacompras').val(''); } }); $("#participacompras").change(function(){ if($(this).val() == 1){ $('.participacompras').slideDown(); }else{ $('.participacompras').slideUp(); $('.participacompras input').each(function () { if(this.type=='checkbox'){$(this).prop('checked', false)}else{$(this).val('');}}); $('.participacompras select').each(function () {$(this).val('');}); } }); $("#podemexer").change(function(){ if($(this).val() == 1){ $('.podemexer').slideDown(); }else{ $('.podemexer').slideUp(); $('.podemexer input').each(function () { if(this.type=='checkbox'){$(this).prop('checked', false)}else{$(this).val('');}}); } }); $("#acessofridge").change(function(){ if($(this).val() == 1){ $('.acessofridge').slideDown(); }else{ $('.acessofridge').slideUp(); $('.acessofridge input').each(function () { if(this.type=='checkbox'){$(this).prop('checked', false)}else{$(this).val('');}}); } }); $("#escolhepeqalmoco").change(function(){ if($(this).val() == 1){ $('.escolhepeqalmoco').slideDown(); }else{ $('.escolhepeqalmoco').slideUp(); $('.escolhepeqalmoco input').each(function () { console.log(this.type);if(this.type=='checkbox'){$(this).prop('checked', false)}else{$(this).val('');}}); } }); $(".outris").change(function(){ var id = $(this).attr('id'); if( $(this).is(':checked')){ $('.'+id).slideDown(); }else{ $('.'+id).slideUp(); $('#'+id+'quais').val(""); } }); $(document).on('click', '.acompanhamentos', function() { var id = $(this).attr('id'); var tipo = $(this).attr('id').substr(9); var partes = $('#quais').val().split('£'); partes.sort(function(partes,b){return partes - b}) var tamanho = partes.length; var cleanpartes = partes.filter(function () { return true }); cleanpartes.shift(); tamanho = cleanpartes.length; var ultimo = tamanho-1; var saltar = 0; var inacabados = []; var nomedopai=''; if(id == 'acompanhapao'){nomedopai = 'fam5';}else{nomedopai = 'fam9';} $('#'+nomedopai+' input:checkbox.alimentovalue').each(function () { if ($(this).is(':checked')) {nomedosfilhos = 'quant_'+this.name.substring(3); if (!$("input[name='"+nomedosfilhos+"']:checked").val()) {inacabados.push(this.name.substring(3));}}}); if(inacabados.length > 0){alert('Por favor selecione as quantidades para os alimentos que escolheu.'); }else{ if($(this).closest('div.wella').prop('id').substr(3) == cleanpartes[ultimo]){ $('#confirmar').show('fast'); }else{ var qualseguinte = $(this).closest('div.wella').prop('id').substr(3)*1+1*1; $('#pro'+qualseguinte).show('fast'); } $('#especies'+ tipo +' input[type=checkbox]').each(function () { if ($(this).is(':checked')) { var nome = $(this).attr('id').substring(3); if(tipo == 'bolo'){ //console.log('zzzzzzzzzzzzzzz: '+tipo); if (nome == 'panquecas' || nome == 'waffles' || nome == 'scones' || nome == 'crepes'|| nome == 'croissantfolhado' || nome == 'croissantbrioche') { console.log(nome+' CHECKADO'); $('#bolosescolhidos').append($('',{id:'aef'+nome,class:'escolhidas',src:'images/alimentos/'+nome+'.png'})); saltar++; } }else{ $('#paesescolhidos').append($('',{id:'aef'+nome,class:'escolhidas',src:'images/alimentos/'+nome+'.png'})); saltar++; } } }); if(saltar > 0){ $('.'+id).slideDown('fast', function() { $('.tipos'+id).slideUp('fast', function() { $([document.documentElement, document.body]).animate({scrollTop: $('#myWizard').offset().top}, 500); }); }); }else{ //console.log('aaaaaaaaaa: '+tipo); if($(this).closest('div.wella').prop('id').substr(3) == cleanpartes[ultimo]){ $('#confirmar').click(); }else{ if(tipo == 'bolo'){ //$( "#fam9" ).slideUp(); $( "#pro10" ).click(); }else{ //$( "#fam5" ).slideUp(); $( "#pro6" ).click(); } } } $(this).hide(); } }); /* $(document).on('click', '#acompanhapao', function() { var nome = ''; $('#especiespao input[type=checkbox]').each(function () { if ($(this).is(':checked')) { nome = $(this).attr('id').substring(3); $('#paesescolhidos').append($('',{id:'aef'+nome,class:'escolhidas',src:'images/alimentos/'+nome+'.png'})); } }); }); $(document).on('click', '#acompanhabolo', function() { var nome = ''; $('#especiesbolo input[type=checkbox]').each(function () { if ($(this).is(':checked')) { nome = $(this).attr('id').substring(3); if (nome == 'panquecas' || nome == 'waffles' || nome == 'scones' || nome == 'crepes') { $('#bolosescolhidos').append($('',{id:'aef'+nome,class:'escolhidas',src:'images/alimentos/'+nome+'.png'})); } } }); }); */ $(document).on('click', '#linkoutros', function() { $('#fam16').slideDown(); $('#myfams').slideUp(); return false; }); $(document).on('click', '#iniciar', function() { if($("#concordo").is(':checked')){ if($("#user_login_status").val() == 1){ $('#sumoquestionario').slideDown(); $('#aviso').slideUp('fast', function() { $([document.documentElement, document.body]).animate({scrollTop: $('#crititulo1').offset().top-95 }, 500); }); }else{ $('#lembreteinscicao').text('Por favor registe-se para aceder ao questionário.'); $('#lembreteinscicao').show(); $('#inscrevermodal').modal('show'); } }else{ alert('Clique na caixa "Compreendi o âmbito deste Projeto, aceito participar e aceito a utilização dos dados por mim fornecidos no contexto acima descrito" para poder continuar, obrigado.'); } }); $(document).on('click', '.selectasugar', function() { $('#acucar'+$('#valqual').val()).val($(this).val()); $('#acucarmodal').modal('hide'); $('input[name="acucar"]').prop('checked', false); }); $(document).on('change', '.tiogi', function() { $('#tipiogurte').val($('#tipoiogurte').val()); $('#clasiogurte').val($('#classeiogurte').val()); $('#acuiogurte').val($('#acucariogurte').val()); if($('#tipoiogurte').val() > 0 && $('#classeiogurte').val() > 0 && $('#acucariogurte').val() > 0){$('#iogurtemodal').modal('hide'); }else{ } }); $(document).on('change', '.tiogiliq', function() { $('#tipioguliquido').val($('#tipoiogurteliquido').val()); if( $('#tipoiogurteliquido').val() > 0 ){$('#iogurteliquidomodal').modal('hide'); }else{ } }); /* $('.quantidadesradio').click(function(){ var id = $(this).attr('id'); $(this).prev("input").prop("checked", true).trigger("click"); console.log( $(this).prev("input").prop("name") ); console.log( $(this).prev("input").prop("value") ); }); */ $('.avista').change(function(){ var id = $(this).attr('id'); if( $(this).is(':checked') && id =='vistanenhum'){ $('.avista:not(#'+id+')').attr("checked", false); }else if( $(this).is(':checked')){ $('#vistanenhum').attr("checked", false); } }); $('.comquem').change(function(){ var id = $(this).attr('id'); if( $(this).is(':checked') && id =='peqalm_quem_sozinha'){ $('.comquem:not(#'+id+')').attr("checked", false); }else if( $(this).is(':checked')){ $('#peqalm_quem_sozinha').attr("checked", false); } }); $('#login_input_password_new').keyup(function(){ // alert('ssss'); $('#forcapass').html(checkPassStrength($(this).val())); $('#labelforcapass').show(); $('#mostraforca').show(); }); $('#login_input_password_new').change(function(){ if( $(this).val().length < 6){ alert('A password deve conter no mínimo 6 caracteres!'); } }); $('#login_input_password_repeat').change(function(){ if( $(this).val() != $('#login_input_password_new').val() ){ alert('As passwords têm que ser iguais!'); } }); $('#login_input_email').change(function(){ var id = $(this).attr('id'); $.ajax({ type: 'POST', url: 'duplicados.php', data: { email:$(this).val() }, success: function(resp) { if(resp > 0){ alert('Endereço de email já foi utilizado'); $(this).val(''); }else{ } } }); }); $('.timepicker').wickedpicker({twentyFour: true,title: 'Horas',minutesInterval: 15,now: "00:00"}); function checkPassStrength(pass) { var score = scorePassword(pass); if (score > 80) return 'Forte'; if (score > 60) return 'Boa'; if (score >= 30) return 'Média'; if (score < 30) return 'Fraca'; return ""; } function scorePassword(pass) { var score = 0; if (!pass) return score; // award every unique letter until 5 repetitions var letters = new Object(); for (var i=0; i 0){qtsok++} } if(qtsok == quantas){resultado=true;}else{resultado=false;} return resultado; }