1//product 2 3var clickAnchor = -1; 4 5initGallery = function() { 6 if ($$(".pg-sd-thumbnails").length > 0) { 7 var allAnchors = $$(".pg-sd-thumbnails")[0].getElements('a'); 8 if (allAnchors.length > 0) allAnchors[0].fireEvent('click'); 9 } 10 if (clickAnchor != -1) { 11 setTimeout("clickAnchor.fireEvent('click')",500); 12 } 13} 14 15function updateProductInit() { 16 updateProduct(true); 17} 18 19updateProduct = function(initial) { 20 var form = document.id('atc-form'); 21 var productID = document.id('product-id').get('value'); 22 var groupingID = document.id('product-grouping-id').get('value'); 23 var requestPath = document.id('product-path').get('value'); 24 var imagesFolder = document.id('product-images-folder').get('value'); 25 var optionsArray = []; 26 //get options 27 var hasoptions = false; 28 form.getElements('select').each(function(select) { 29 if(select.hasClass('product-option') && !select.hasClass('issimple')) { 30 hasoptions = true; 31 optionsArray.push(select.get('value')); 32 } 33 }); 34 if (!hasoptions) return; 35 36 //reset errors 37 document.id('add-fields').setStyle('display', 'none'); 38 document.id('not-sold').setStyle('display', 'none'); 39 document.id('sold-out').setStyle('display', 'none'); 40 41 //loading... 42 document.id('checking-availability').setStyle('display', 'block'); 43 form.getElements('input,select').set('disabled', true); 44 45 optionsArray.sort(function(a, b) { 46 return a - b; 47 }); 48 49 //call 50 clickAnchor = -1; 51 new Request.JSON({ 52 url: requestPath, 53 method: 'post', 54 onSuccess: function(product) { 55 //document.id('ProductName').set('html', product.ProductName); 56 //document.id('ProductImage').set('src', product.ProductImage); 57 if (product.ProductImage != "") { 58 if ($$(".pg-sd-thumbnails").length > 0) { 59 var allAnchors = $$(".pg-sd-thumbnails")[0].getElements('a'); 60 for (var x=0; x<allAnchors.length; x++) { 61 if (allAnchors[x].getElement('img').get("src") == product.ProductImage) { 62 clickAnchor = allAnchors[x]; 63 startSlide = x; 64 if (!initial) clickAnchor.fireEvent('click'); 65 } 66 } 67 if (clickAnchor == -1) { 68 allAnchors[0].fireEvent('click'); 69 } 70 } 71 } else { 72 if ($$(".pg-sd-thumbnails").length > 0) { 73 var allAnchors = $$(".pg-sd-thumbnails")[0].getElements('a'); 74 allAnchors[0].fireEvent('click'); 75 } 76 } 77 document.id('ProductPrice').set('html', product.ProductPrice); 78 document.id('ProductSalePrice').set('html', product.ProductSalePrice); 79 if (product.ProductPrice != product.ProductSalePrice) { 80 document.id("details-sale-price").setStyle('display', 'block'); 81 document.id("details-orig-price").setStyle('text-decoration', 'line-through'); 82 } else { 83 document.id("details-sale-price").setStyle('display', 'none'); 84 document.id("details-orig-price").setStyle('text-decoration', 'none'); 85 } 86 /* 87 //retail price 88 if(parseFloat(product.ProductPrice) < parseFloat(product.ProductRetailPrice)) { 89 document.id('ProductRetailPrice').set('html', product.ProductRetailPrice); 90 document.id('ProductRetailPriceSave').set('html', (product.ProductRetailPrice - product.ProductPrice).toFixed(2)); 91 document.id('retail-price-row').setStyle('display', 'block'); 92 } 93 else { 94 document.id('retail-price-row').setStyle('display', 'none'); 95 } 96 */ 97 98 //set long description only for the default product 99 if(product.ProductLongDesc) { 100 if (document.id('ProductLongDesc')) document.id('ProductLongDesc').set('html', product.ProductLongDesc); 101 } 102 103 if(product.ProductSKU) { 104 if (document.id('the_sku')) document.id('the_sku').set('html',product.ProductSKU); 105 } 106 107 if(document.id('WA_Store_Cart_1_ID_Add')) document.id('WA_Store_Cart_1_ID_Add').set('value', product.ProductID); 108 document.id('product-id').set('value', product.ProductID); 109 110 //stock messages 111 if((product.ProductStock > 0 || product.ProductUnlimited == 1) && product.ProductLive == 1) { 112 document.id('add-fields').setStyle('display', 'block'); 113 } 114 if(product.ProductLive == 0) { 115 document.id('not-sold').setStyle('display', 'block'); 116 } 117 if(product.ProductStock <= 0 && product.ProductLive == 1 && product.ProductUnlimited == 0) { 118 document.id('sold-out').setStyle('display', 'block'); 119 } 120 121 //done loading 122 document.id('checking-availability').setStyle('display', 'none'); 123 form.getElements('input,select').set('disabled', false); 124 } 125 }).send(Hash.toQueryString({ 126 'grouping_id': groupingID, 127 'options': optionsArray.join(',') 128 })); 129};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.