function reparaFechas(){ var locale = "en"; $('.tiempoLocalLargo').each(function(){ if(typeof($(this).attr('locale'))!='undefined'){ locale = $(this).attr('locale'); } var cuando = String($(this).text())+' Z'; var huy = cuando.replace(" ","T"); var momento = moment(huy); momento.locale(locale); $(this).text(momento.format('LLLL')); }); $('.tiempoLocalCorto').each(function(){ var cuando = String($(this).text())+' Z'; var huy = cuando.replace(" ","T"); $(this).text(moment(huy).locale(locale).format('D/MM/YYYY')); }); $('.tiempoLocalLargo2').each(function(){ var cuando = String($(this).text())+' Z'; var huy = cuando.replace(" ","T"); $(this).text(moment(huy).locale(locale).format('D/MM/YYYY h:mm a')); }); $('.tiempoLocalFromNow').each(function(){ var cuando = String($(this).text())+' Z'; var huy = cuando.replace(" ","T"); $(this).text(moment(huy).locale(locale).fromNow(true)); }); $(".soyMoneda").each(function(){ var currency = String($(this).text()); if(currency.indexOf('None') !== -1){ $(this).text(''); }else{ var number = Number(currency.replace(/[^0-9.-]+/g,"")); $(this).text(' $ ' +parseFloat(number, 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").toString());}; }); $('.soyMonedaPDFonly').each(function(){ var currency = String($(this).text()); var number = Number(currency.replace(/[^0-9.-]+/g,"")); $(this).text(' $ ' +parseFloat(number, 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").toString()); }); $("[type=file]:not([accept*='image/*'])").on("change", function(){ //este se usara en aquel input file q acepta cualquier file var fieldId = $(this).attr('id')+'-'; $(".nuevoFile."+fieldId).remove(); $(".overwrite."+fieldId).remove(); var $papa = $(this); var antiguos = ($(this).hasClass('singleFile'))? 0 : $papa.next("p.help-block").has("a").length; //para singleFiles debo (mas abajo) borrar todos los files y no dar opcion de overwrite var files = this.files; var totalSize = 0; if(files.length>10){ bootbox.alert({title:"Too many files!", message:"Please upload max 10 files at a time.
You may revisit this record and upload more files later."}); $(this).val(''); }else{ if(antiguos==0){ $papa.next().text(''); } $.each( files, function(i) { $papa.next().append( "" + files[i].name + "" ); totalSize += (parseFloat(files[i].size)/1024000); }); if($(this).val()!="" && antiguos>0){ $papa.next().after(""); }else if(($(this).val()=="" && antiguos==0)){ $(this).next().text('No file selected'); } if(totalSize>150){ var totalString = totalSize.toFixed(1).toString(); bootbox.alert({title:"Total file size is too large", message:"Maximum upload size per submit: 150Mb
Current file size: " + totalString + "Mb
Try uploading in multiple submits."}); } } }); $("[type=file][accept*='image/*']").on("change", function(){//este se usara en el q SOLO acepta imagenes var fieldId = $(this).attr('id')+'-'; var currentId = $(this).attr('id'); $(".nuevoFile."+fieldId).remove(); $(".overwrite."+fieldId).remove(); var $papa = $(this); var antiguos = ($(this).hasClass('singleFile'))? 0 : $papa.next("p.help-block").has("a,img").length; //para singleFiles debo (mas abajo) borrar todos los files y no dar opcion de overwrite var files = this.files; var totalSize = 0; if(files.length>10){ bootbox.alert({title:"Too many files!", message:"Please upload max 10 files at a time.
You may revisit this record and upload more files later."}); $(this).val(''); }else{ if(antiguos==0){ $papa.next().text(''); } $.each( files, function(i) { var reader = new FileReader(); reader.onload = function(event) { var clase = "uploadedImg nuevoFile " + fieldId var nuevaFoto = $($.parseHTML('')).attr('src', event.target.result).attr('class', clase).attr('onclick',"openTagger($(this));").attr('data-filename',files[i].name).appendTo($papa.next()); uploadFileToS3(files[i],currentId,nuevaFoto);//para mandar los files a S3 } reader.readAsDataURL(files[i]);//aƱadir foto en vez de un a tag totalSize += (parseFloat(files[i].size)/1024000); }); if($(this).val()!=""){//si subieron files muestre el 'click to tag' prompt $('div.tagprompt').removeClass('hidden'); } if($(this).val()!="" && antiguos>0){ $papa.next().after(""); }else if(($(this).val()=="" && antiguos==0)){ $(this).next().text('No file selected'); $('div.tagprompt').addClass('hidden');//remove el prompt de tagger fotos } if(totalSize>150){ var totalString = totalSize.toFixed(1).toString(); bootbox.alert({title:"Total file size is too large", message:"Maximum upload size per submit: 150Mb
Current file size: " + totalString + "Mb
Try uploading in multiple submits."}); } } }); } function datesFormatter(value, row, index, field) { var cuando = String(value)+' Z'; var huy = cuando.replace(" ","T"); return moment(huy).format('YYYY-MM-DD HH:mm:ss'); } function currencyFormatter(value, row, index, field) { var currency = value; if (currency.length>0) { var number = Number(currency.replace(/[^0-9.-]+/g, "")); return ' $ ' + parseFloat(number, 10).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1,").toString(); }else{ return '' } } function pdfConTimeZone(url) { var timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone; var locale = window.navigator.userLanguage || window.navigator.language; window.location = url + '&timeZone=' +timeZone+ '&locale=' +locale; }