Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var models = {
- 'MKQJ2QL/A' : 'iPhone 6s 16GB Gris espacial , 749,00 €',
- 'MKQN2QL/A' : 'iPhone 6s 64GB Gris espacial , 859,00 €',
- 'MKQT2QL/A' : 'iPhone 6s 128GB Gris espacial , 969,00 €',
- 'MKQL2QL/A' : 'iPhone 6s 16GB Oro , 749,00 €',
- 'MKQQ2QL/A' : 'iPhone 6s 64GB Oro , 859,00 €',
- 'MKQV2QL/A' : 'iPhone 6s 128GB Oro , 969,00 €',
- 'MKQM2QL/A' : 'iPhone 6s 16GB Oro rosa , 749,00 €',
- 'MKQR2QL/A' : 'iPhone 6s 64GB Oro rosa , 859,00 €',
- 'MKQW2QL/A' : 'iPhone 6s 128GB Oro rosa , 969,00 €',
- 'MKQK2QL/A' : 'iPhone 6s 16GB Plata , 749,00 €',
- 'MKQP2QL/A' : 'iPhone 6s 64GB Plata , 859,00 €',
- 'MKQU2QL/A' : 'iPhone 6s 128GB Plata , 969,00 €',
- 'MKU12QL/A' : 'iPhone 6s Plus 16GB Gris espacial , 859,00 €',
- 'MKU62QL/A' : 'iPhone 6s Plus 64GB Gris espacial , 969,00 €',
- 'MKUD2QL/A' : 'iPhone 6s Plus 128GB Gris espacial , 1.079,00 €',
- 'MKU32QL/A' : 'iPhone 6s Plus 16GB Oro , 859,00 €',
- 'MKU82QL/A' : 'iPhone 6s Plus 64GB Oro , 969,00 €',
- 'MKUF2QL/A' : 'iPhone 6s Plus 128GB Oro , 1.079,00 €',
- 'MKU52QL/A' : 'iPhone 6s Plus 16GB Oro rosa , 859,00 €',
- 'MKU92QL/A' : 'iPhone 6s Plus 64GB Oro rosa , 969,00 €',
- 'MKUG2QL/A' : 'iPhone 6s Plus 128GB Oro rosa , 1.079,00 €',
- 'MKU22QL/A' : 'iPhone 6s Plus 16GB Plata , 859,00 €',
- 'MKU72QL/A' : 'iPhone 6s Plus 64GB Plata , 969,00 €',
- 'MKUE2QL/A' : 'iPhone 6s Plus 128GB Plata , 1.079,00 €'
- };
- var looper = null;
- var alertme = '';
- function updateInfo(){
- $.get( "https://reserve.cdn-apple.com/ES/es_ES/reserve/iPhone/stores.json", function( data ) {
- var stores = {};
- data.stores.forEach(function(store) {
- stores[store.storeNumber] = store;
- });
- var html = '';
- $.get( "https://reserve.cdn-apple.com/ES/es_ES/reserve/iPhone/availability.json", function( data ) {
- html += '<div><input type="radio" id="radiodisp_disp" name="radiodisp" value="disp" checked> Disponible<br><input type="radio" id="radiodisp_nodisp" name="radiodisp" value="nodisp"> No Disponible<br><input type="radio" id="radiodisp_todo" name="radiodisp" value="todo"> Todo</div><div style="font-size: 12px;">';
- for (var store in data) {
- if (data.hasOwnProperty(store) && stores.hasOwnProperty(store)) {
- html += '<div style="float: left; margin-top: 10px; margin-right: 25px;"><div style="font-weight:bold; font-size: 16px;">'+stores[store].storeName+' - '+stores[store].storeCity+'</div><div style="font-weight:bold;">Horas de reserva a partir de las: <span style="color: #D00;">'+data[store].timeSlot.es_ES.timeslotTime+'h</span> (por contrato: <span style="color: #D00;">'+data[store].timeSlot.es_ES.contractTimeslotTime+'h</span>)</div>';
- for (var model in data[store]) {
- if (data[store].hasOwnProperty(model) && models.hasOwnProperty(model)) {
- if( data[store][model] == 'ALL' ){
- html += '<div style="padding-left: 25px;" class="disp"><input type="radio" id="alertme_'+store+'_'+model+'" name="alertme" value="'+store+'_'+model+'" model="'+model+'" store="'+store+'" model_r="'+models[model]+'" store_r="'+stores[store].storeName+' - '+stores[store].storeCity+'" '+( (alertme == 'alertme_'+store+'_'+model) ? 'checked':'' )+'> <span style="font-weight: bold; color: #0F0;" model="'+model+'" store="'+store+'">DISPONIBLE</span> - '+models[model]+'</div>';
- }
- if( data[store][model] == 'NONE' ){
- html += '<div style="padding-left: 25px; display: none;" class="nodisp"><input type="radio" id="alertme_'+store+'_'+model+'" name="alertme" value="'+store+'_'+model+'" model="'+model+'" store="'+store+'" model_r="'+models[model]+'" store_r="'+stores[store].storeName+' - '+stores[store].storeCity+'" '+( (alertme == 'alertme_'+store+'_'+model) ? 'checked':'' )+'> <span style="font-weight: bold; color: #F00;" model="'+model+'" store="'+store+'">NO DISPONIBLE</span> - '+models[model]+'</div>';
- }
- }
- }
- html += '</div>';
- }
- }
- html += '</div><div style="clear:both;"></div>';
- $("#sectionHero .section-content").html('<div>'+html+'</div>');
- //EXTRAS:
- $('input[name="radiodisp"][type="radio"]').change(function(){
- if( $(this).val() == 'disp' ){
- $(".disp").show();
- $(".nodisp").hide();
- }else if( $(this).val() == 'nodisp' ){
- $(".disp").hide();
- $(".nodisp").show();
- }else{
- $(".disp").show();
- $(".nodisp").show();
- }
- });
- $('input[name="alertme"][type="radio"]').change(function(){
- alertme = $(this).prop("id");
- });
- //CONTROLLING ALERTME:
- var id_escapado = "#"+alertme.replace( /(:|\.|\[|\]|,|\/)/g, "\\$1" );
- var alerted = false;
- if( alertme && $(id_escapado).parent("div").is('.disp') ){
- var audioAlert = new Audio('https://sfxcontent.s3.amazonaws.com/soundfx/Submarine-Klaxon.mp3');
- audioAlert.oncanplaythrough = function() {
- clearInterval(looper);
- this.currentTime = 0;
- this.loop = true;
- this.play();
- if(!alerted){
- alerted = true;
- var md = $(id_escapado).attr("model_r");
- var st = $(id_escapado).attr("store_r");
- $(window).scrollTop(0);
- $("#sectionHero .section-content").html("<div style='background: #D00; padding: 25px; color: #FFF; border-radius: 10px; box-shadow: 0px 10px 12px rgba(0,0,0,.3); text-shadow: 1px 1px rgba(0,0,0,.5);'>El teléfono modelo:<br><br><span style='padding-left: 25px; font-weight:bold; font-size: 25px;'>"+md+"</span><br><br>Se encuentra disponible para su reserva en estos instantes en la store de:<br><br><span style='padding-left: 25px; font-weight:bold; font-size: 25px;'>"+st+"</span></div>");
- alert( "El teléfono modelo:\n\n "+md+"\n\nSe encuentra disponible para su reserva en estos instantes en la store de:\n\n "+st );
- }
- };
- }
- }, "json" );
- }, "json" );
- }
- updateInfo();
- looper = setInterval(updateInfo, 30000); //cada medio minuto.
Advertisement
Add Comment
Please, Sign In to add comment