Skip to content

Instantly share code, notes, and snippets.

@deltagolf
Created March 20, 2016 09:30
Show Gist options
  • Save deltagolf/b31eb398a65e265cc0d5 to your computer and use it in GitHub Desktop.
Save deltagolf/b31eb398a65e265cc0d5 to your computer and use it in GitHub Desktop.
Form1 Min
function requiredFields(e,o,n){$("#section-yui_3_17_2_1_1454415124886_124708").find(".title").attr("name","dirposttitle"),$("#section-yui_3_17_2_1_1454415124886_179740").find(".title").attr("name","creditstitle"),$("#section-yui_3_17_2_1_1454415124886_123767").find(".title").attr("name","personaltitle");var t=100,a=[{perkID:"PERK5",personaltitle:1,nombre:1,apellidos:1,DNI:0,creditstitle:0,creditos:0,dirposttitle:0,dir1:0,dir2:0,ciudad:0,cp:0,"select-yui_3_17_2_1_1454415124886_129495-field":0},{perkID:"PERK3",personaltitle:1,nombre:1,apellidos:1,DNI:0,creditstitle:1,creditos:1,dirposttitle:0,dir1:0,dir2:0,ciudad:0,cp:0,"select-yui_3_17_2_1_1454415124886_129495-field":0},{perkID:"PERK4",personaltitle:1,nombre:1,apellidos:1,DNI:0,creditstitle:1,creditos:1,dirposttitle:0,dir1:0,dir2:0,ciudad:0,cp:0,"select-yui_3_17_2_1_1454415124886_129495-field":0},{perkID:"PERK20",personaltitle:1,nombre:1,apellidos:1,DNI:1,creditstitle:1,creditos:1,dirposttitle:1,dir1:1,dir2:1,ciudad:1,cp:1,"select-yui_3_17_2_1_1454415124886_129495-field":1},{perkID:"PERK10",personaltitle:1,nombre:1,apellidos:1,DNI:1,creditstitle:1,creditos:1,dirposttitle:1,dir1:1,dir2:1,ciudad:1,cp:1,"select-yui_3_17_2_1_1454415124886_129495-field":1},{perkID:"PERK22",personaltitle:1,nombre:1,apellidos:1,DNI:1,creditstitle:1,creditos:1,dirposttitle:1,dir1:1,dir2:1,ciudad:1,cp:1,"select-yui_3_17_2_1_1454415124886_129495-field":1}],r=filterById(a,{perkID:n});o>=t&&(r[0].nombre=1,r[0].apellidos=1,r[0].DNI=1,r[0].personaltitle=1),delete r[0].perkID,$.each(r[0],function(e,o){0==o&&$("[name="+e+"]").parent().hide()})}var names=["nombre","apellidos","DNI","creditos","dir1","dir2","ciudad","cp"],redirectDomain="https://script.google.com/macros/s/AKfycbzICEw1n1BrsBsCgPMDL1VQ7bS9ka7O49s1pS4zkTLbM4g_CRNr/exec",responseCodes=["1F4","3F8","5DC","7D0","9C4","BB8","6D6","FA0","DAC"],query=window.updateCustomerData,BODY_TEXT=['<p><b>Alguno de los datos introducidos es incorrecto.</b> Te hemos enviado un email con los datos correctos. Comprueba tu bandeja de entrada y vuelve a intentarlo recargando la página en tu navegador o pulsando el botón "reintentar" que figura a continuación.</p>','<p><b>No existen registros con los datos introducidos</b>. Comprueba que sean correctos y vuelve a intentarlo recargando la página en tu navegador o pulsando el botón "reintentar" que figura a continuación.</p>','<p>Para poderte hacer entrega de tu obsequio y para otras cuestiones legales <b>necesitamos que rellenes el siguiente formulario</b>. </p><i>Si tienes alguna duda o crees que algún dato es incorrecto por favor escríbenos a <a href="[email protected]" target = "_top">[email protected]</a> indicándonos el número de referencia de tu donación o contesta al email que te acabamos de enviar a la dirección que nos has facilitado y pronto nos pondremos en contacto contigo.</i><br>',"","","","<p>Tus datos ya se encuentran registrados, pero <b>puedes actualizarlos si lo deseas</b>.</p>","","<p>El servidor está ocupado en estos momentos. Vuelve a intentarlo pasados unos minutos</p>"],CONTRIBUTION_DATA='<p>Estos son los datos que constan en nuestros registros sobre tu aportación:</p><br><p>Correo electrónico: <strong><span class = "perkEmailShow"></span></strong></p><p>Número de referencia: <strong><span class = "perkLocalizerShow"></span></strong></p><p>El día <span class = "perkDate"></span> a las <span class = "perkTime"></span> realizaste una donación de €<strong><span class = "perkAmountShow"></span></strong> para la producción de un documental sobre educación. Elegiste como obsequio "<strong><span class = "perkTitleShow"></span></strong>". <strong><span class = "perkDesigShow"></span></strong> La fecha estimada de entrega es: <strong><span class = "perkDeliveryShow"></span></strong>.</p>',UPDATED_DATA='<p>Estos son los datos que nos has facilitado:<p><br><p>Nombre: <strong><span class = "perkFirstNameShow"></span></strong></p><p>Apellidos: <strong><span class = "perkLastNameShow"></span></strong></p><p>DNI: <strong><span class = "perkIdShow"></span></strong></p><p>Email: <strong><span class = "perkEmailShow"></span></strong></p><p>Cómo figurarás en los créditos: <strong><span class = "perkCreditsShow"></span></strong></p><p>Dirección postal de envío: <strong><span class = "perkAddressShow"></span></strong></p><p>Ciudad: <strong><span class = "perkCityShow"></span></strong></p><p>Código postal: <strong><span class = "perkZipShow"></span></strong></p><p>Provincia: <strong><span class = "perkProvinceShow"></span></strong></p>',WARNING="<p>¡Todavía no has validado los datos que nos has facilitado! Por favor <strong>haz click en el enlace que te acabamos de enviar por email</strong> para que podamos hacerte entrega de tu obsequio. ¡Gracias!</p>",PERKS='<p>Diego, <strong>¿te gustaría implicarte aun más en este proyecto?</strong> Ahora tienes la posibilidad de hacerlo. Al elegir colaborar con alguna de estas aportaciones que hemos personalizado para ti, nos ayudarás a mejorar aún más el documental "Corriendo por las olas". Gracias de antemano.</p>';query=query.replace(/\+/g," ");var eQuery=window.btoa(unescape(encodeURIComponent(query))),Query={e:eQuery},request=$.ajax({type:"get",url:redirectDomain,jsonpCallback:"updateCustomer",contentType:"application/json",dataType:"jsonp",data:Query});$(".perkWait").show(),request.done(function(e){switch($(".perkWait").hide(),e.responsecode){case responseCodes[0]:var o=BODY_TEXT[0];$(".eneueBodyText").html(o),$(".eneueBodyText").show(),$("#block-yui_3_17_2_2_1455033745983_13062").show();break;case responseCodes[1]:var o=BODY_TEXT[1];$(".eneueBodyText").html(o),$(".eneueBodyText").show(),$("#block-yui_3_17_2_2_1455033745983_13062").show();break;case responseCodes[2]:var o=BODY_TEXT[2];window.eneueSupporterEmail=e.email,window.eneueTransactionLocalizer=e.localizer,window.eneueTransactionRegistry=e.registry,window.eneueQuantity=e.quantity,window.eneueDelivery=e.delivery,window.eneueDesig=e.desig,window.eneuePerkID=e.perkID,window.eneueTitle=e.title,window.eneueTimeStamp=e.timestamp;var n=new Date(e.timestamp),t=n.getDate(),a=n.getMonth()+1,r=n.getFullYear(),i=(n.getHours()<10?"0":"")+n.getHours(),s=(n.getMinutes()<10?"0":"")+n.getMinutes();window.eneueDateStampFormatted=t+"/"+a+"/"+r,window.eneueTimeStampFormatted=i+":"+s,requiredFields(names,window.eneueQuantity,window.eneuePerkID),$(".eneueBodyText").html(o),$(".eneueContributionData").html(CONTRIBUTION_DATA),$(".perkEmailShow").html(window.eneueSupporterEmail),$(".perkLocalizerShow").html(window.eneueTransactionLocalizer),$(".perkDate").html(window.eneueDateStampFormatted),$(".perkTime").html(window.eneueTimeStampFormatted),$(".perkAmountShow").html(window.eneueQuantity),$(".perkTitleShow").html(window.eneueTitle),$(".perkDesigShow").html(window.eneueDesig),$(".perkDeliveryShow").html(window.eneueDelivery),$(".eneueContributionData").show(),$("#block-yui_3_17_2_21_1454415124886_5895").show();break;case responseCodes[6]:var d="eneuePerks",l=e.perksJSON;l=JSON.parse(l),generatePerks(l,d),$("#block-yui_3_17_2_2_1456637596700_7472").show();var p=BODY_TEXT[6],u=UPDATED_DATA,c=CONTRIBUTION_DATA;window.eneueSupporterEmail=e.email,window.eneueTransactionLocalizer=e.localizer,window.eneueTransactionRegistry=e.registry,window.eneueQuantity=e.quantity,window.eneueDelivery=e.delivery,window.eneueDesig=e.desig,window.eneuePerkID=e.perkID,window.eneueTitle=e.title,window.eneueTimeStamp=e.timestamp,window.eneueValidated=e.valid,window.eneueFName=e.fname,window.eneueLName=e.lname,window.eneueId=e.id,window.eneueCredits=e.creditsPerks,window.eneueAddress=e.address,window.eneueCity=e.cityPerk,window.eneueZip=e.zipPerk,window.eneueProvince=e.provincePerk;var n=new Date(e.timestamp),t=n.getDate(),a=n.getMonth()+1,r=n.getFullYear(),i=(n.getHours()<10?"0":"")+n.getHours(),s=(n.getMinutes()<10?"0":"")+n.getMinutes();window.eneueDateStampFormatted=t+"/"+a+"/"+r,window.eneueTimeStampFormatted=i+":"+s,requiredFields(names,window.eneueQuantity,window.eneuePerkID),$(".eneueBodyText").html(p),$(".eneueUpdatedData").html(u),$(".eneueContributionData").html(c),$(".perkEmailShow").html(window.eneueSupporterEmail),$(".perkLocalizerShow").html(window.eneueTransactionLocalizer),$(".perkDate").html(window.eneueDateStampFormatted),$(".perkTime").html(window.eneueTimeStampFormatted),$(".perkAmountShow").html(window.eneueQuantity),$(".perkTitleShow").html(window.eneueTitle),$(".perkDesigShow").html(window.eneueDesig),$(".perkDeliveryShow").html(window.eneueDelivery),$(".perkFirstNameShow").html(window.eneueFName),$(".perkLastNameShow").html(window.eneueLName),$(".perkIdShow").html(window.eneueId),$(".perkCreditsShow").html(window.eneueCredits),$(".perkAddressShow").html(window.eneueAddress),$(".perkCityShow").html(window.eneueCity),$(".perkZipShow").html(window.eneueZip),$(".perkProvinceShow").html(window.eneueProvince),$(".eneuePerks").show();break;case responseCodes[8]:var o=BODY_TEXT[8];$(".eneueBodyText").html(o),$(".eneueBodyText").show()}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment