$( document ).ready(function(e) { if ($('#button_select_ram').css('background-image') == 'none') { $('#pcb_ram_qty_box').hide(); } if ($('#button_select_gfx').css('background-image') == 'none') { $('#pcb_gfx_qty_box').hide(); } }); $(document).on('click',"#pcb_ram_qty_add",function(e) { e.preventDefault(); var qty=$('#pcb_ram_qty').val(); var newqty=parseInt(qty)+1; var data = {'pcb_ram_qty':newqty}; $.ajax({ url: "/js/pcbuilder_ajax.php", // link of your "whatever" php type: "POST", async: true, cache: false, data: data, // all data will be passed here success: function(data){ xmlDoc = $.parseXML(data); $(xmlDoc).find('qty').each(function(e){ var newqty = $(this).text(); $('#pcb_ram_qty').val(newqty); }); updateprice(); }, datatype: 'xml' }); }); $(document).on('click',"#pcb_gfx_qty_add",function(e) { e.preventDefault(); var qty=$('#pcb_gfx_qty').val(); var newqty=parseInt(qty)+1; var data = {'pcb_gfx_qty':newqty}; $.ajax({ url: "/js/pcbuilder_ajax.php", // link of your "whatever" php type: "POST", async: true, cache: false, data: data, // all data will be passed here success: function(data){ xmlDoc = $.parseXML(data); $(xmlDoc).find('qty').each(function(e){ var newqty = $(this).text(); $('#pcb_gfx_qty').val(newqty); }); updateprice(); }, datatype: 'xml' }); }); $(document).on('click',"#pcb_ram_qty_minus",function(e) { e.preventDefault(); var qty=$('#pcb_ram_qty').val(); var newqty=parseInt(qty)-1; var data = {'pcb_ram_qty':newqty}; $.ajax({ url: "/js/pcbuilder_ajax.php", // link of your "whatever" php type: "POST", async: true, cache: false, data: data, // all data will be passed here success: function(data){ xmlDoc = $.parseXML(data); $(xmlDoc).find('qty').each(function(e){ var newqty = $(this).text(); $('#pcb_ram_qty').val(newqty); }); updateprice(); }, datatype: 'xml' }); }); $(document).on('click',"#pcb_gfx_qty_minus",function(e) { e.preventDefault(); var qty=$('#pcb_gfx_qty').val(); var newqty=parseInt(qty)-1; var data = {'pcb_gfx_qty':newqty}; $.ajax({ url: "/js/pcbuilder_ajax.php", // link of your "whatever" php type: "POST", async: true, cache: false, data: data, // all data will be passed here success: function(data){ xmlDoc = $.parseXML(data); $(xmlDoc).find('qty').each(function(e){ var newqty = $(this).text(); $('#pcb_gfx_qty').val(newqty); }); updateprice(); }, datatype: 'xml' }); }); $(document).on('change',"#pcb_ram_qty",function(e) { e.preventDefault(); var qty=$('#pcb_ram_qty').val(); var newqty=parseInt(qty); var data = {'pcb_ram_qty':newqty}; $.ajax({ url: "/js/pcbuilder_ajax.php", // link of your "whatever" php type: "POST", async: true, cache: false, data: data, // all data will be passed here success: function(data){ xmlDoc = $.parseXML(data); $(xmlDoc).find('qty').each(function(e){ var newqty = $(this).text(); $('#pcb_ram_qty').val(newqty); }); updateprice(); }, datatype: 'xml' }); }); $(document).on('change',"#pcb_gfx_qty",function(e) { e.preventDefault(); var qty=$('#pcb_gfx_qty').val(); var newqty=parseInt(qty); var data = {'pcb_gfx_qty':newqty}; $.ajax({ url: "/js/pcbuilder_ajax.php", // link of your "whatever" php type: "POST", async: true, cache: false, data: data, // all data will be passed here success: function(data){ xmlDoc = $.parseXML(data); $(xmlDoc).find('qty').each(function(e){ var newqty = $(this).text(); $('#pcb_gfx_qty').val(newqty); }); updateprice(); }, datatype: 'xml' }); }); $(document).on('click',".select_psu",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('psu',selectedid); }); $(document).on('click',".select_mobo",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('mobo',selectedid); }); $(document).on('click',".select_case",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('case',selectedid); }); $(document).on('click',".select_cpu",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('cpu',selectedid); }); $(document).on('click',".select_bootd",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('bootd',selectedid); }); $(document).on('click',".select_ram",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('ram',selectedid); $('#pcb_ram_qty_box').show(); if (selected==0) $('#pcb_ram_qty_box').hide(); }); $(document).on('click',".select_gfx",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('gfx',selectedid); $('#pcb_gfx_qty_box').show(); if (selected==0) $('#pcb_gfx_qty_box').hide(); }); $(document).on('click',".select_opticald",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('opticald',selectedid); }); $(document).on('click',".select_soundcard",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('soundcard',selectedid); }); $(document).on('click',".select_lighting",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('lighting',selectedid); }); $(document).on('click',".select_build",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('build',selectedid); }); $(document).on('click',".select_os",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('os',selectedid); }); $(document).on('click',".select_inst",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('inst',selectedid); }); $(document).on('click',".select_cooling",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('cooling',selectedid); }); $(document).on('click',".select_wireless",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('wireless',selectedid); }); $(document).on('click',".select_casefan",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('casefan',selectedid); }); $(document).on('click',".select_extrad1",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('extrad1',selectedid); }); $(document).on('click',".select_extrad2",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('extrad2',selectedid); }); $(document).on('click',".select_extrad3",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('extrad3',selectedid); }); $(document).on('click',".select_extrad4",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('extrad4',selectedid); }); $(document).on('click',".select_extrad5",function(e) { e.preventDefault(); var selected=$(this).attr("id"); var selectedid=selected.replace("pcb_", ""); selectit('extrad5',selectedid); }); function applyfilters(type) { e.preventDefault(); //$('.pcb_'+type+'').hide(); // hide all $('.pcb_'+type+'').css("color","#ccc"); // just change the color for now to check whats hiding var data = {'checktype':type}; // post to check compatibility $.ajax({ url: "/js/pcbuilder_ajax.php", // link of your "whatever" php type: "POST", async: true, cache: false, data: data, // all data will be passed here success: function(data){ // xml of items to show returned //console.log(data); xmlDoc = $.parseXML(data); $(xmlDoc).find('res').each(function(e){ var id = $(this).text(); $('#pcb_'+id+'').css("color","#000"); }); }, datatype: 'xml' }); }; function selectit(type, selectedid) { // when a cpu is selected var data = {'selecttype':type, 'selected': selectedid}; $.ajax({ url: "/js/pcbuilder_ajax.php", // link of your "whatever" php type: "POST", async: true, cache: false, data: data, // all data will be passed here success: function(data){ console.log(data); var image = $($.parseXML(data)).find("image").text(); //console.log(image); //update the picture $('#button_select_'+type+'').text(""); $('#button_select_'+type+'').css("background-image", "url("+image+")"); $('#button_select_'+type+'').css("background-size", "auto 100%"); $('#button_select_'+type+'').css("background-repeat", "no-repeat"); $('#button_select_'+type+'').css("background-position", "50% 50%"); updateprice(); //highlight in case its opened again //$("#pcb_cpu_"+select_cpu+"").addClass("active"); }, datatype: 'xml' }); }; function updateprice() { var data = {'updateprice':'1'}; $.ajax({ url: "/js/pcbuilder_ajax.php", // link of your "whatever" php type: "POST", async: true, cache: false, data: data, // all data will be passed here success: function(data){ console.log(data); var price = $($.parseXML(data)).find("price").text(); $('.price').text(price); var checkout = $($.parseXML(data)).find("checkout").text(); if (checkout=='yes') $('#proceed').show(); if (checkout=='no') $('#proceed').hide(); }, datatype: 'xml' }); }; $(document).on('click',".open_cpu",function(e) { var selected=$(this).attr("id"); var data = {'brand':selected}; $.ajax({ url: "/js/pcbuilder_ajax.php", // link of your "whatever" php type: "POST", async: true, cache: false, data: data, // all data will be passed here success: function(data){ applyfilters('cpu'); //console.log(data); }, datatype: 'xml' }); }); $(document).on('click',".open",function(e) { var selected=$(this).attr("id"); type = selected.replace("button_select_", ""); $("#modal_"+type+"").html("

Loading, please wait...
"); var data = {'type':type}; $.ajax({ url: "/pcbuilder_inc/"+type+".php", // link of your "whatever" php type: "POST", async: true, cache: false, data: data, // all data will be passed here success: function(data){ $("#modal_"+type+"").html(data); //console.log(data); }, datatype: 'html' }); //applyfilters('psu'); }); $( document ).ready(function(e) { updateprice(); });