Fixup js/order-opc.js

Error fixes:
1. Added missing var on line 89
2. Added missing semicolons on lines 98, 104, 110, 181, 766, 781

General fixes:
1. Replace == with === and != with !==
2. Added missing var to for loops
3. Moved a few var scopes to the correct location
This commit is contained in:
Milow
2012-11-23 22:23:28 -06:00
parent 41371b1938
commit c57c53711a
+73 -68
View File
@@ -45,8 +45,8 @@ function updatePaymentMethods(json)
function updateAddressSelection() function updateAddressSelection()
{ {
var idAddress_delivery = ($('#opc_id_address_delivery').length == 1 ? $('#opc_id_address_delivery').val() : $('#id_address_delivery').val()); var idAddress_delivery = ($('#opc_id_address_delivery').length === 1 ? $('#opc_id_address_delivery').val() : $('#id_address_delivery').val());
var idAddress_invoice = ($('#opc_id_address_invoice').length == 1 ? $('#opc_id_address_invoice').val() : ($('#addressesAreEquals:checked').length == 1 ? idAddress_delivery : ($('#id_address_invoice').length == 1 ? $('#id_address_invoice').val() : idAddress_delivery))); var idAddress_invoice = ($('#opc_id_address_invoice').length === 1 ? $('#opc_id_address_invoice').val() : ($('#addressesAreEquals:checked').length === 1 ? idAddress_delivery : ($('#id_address_invoice').length === 1 ? $('#id_address_invoice').val() : idAddress_delivery)));
$('#opc_account-overlay').fadeIn('slow'); $('#opc_account-overlay').fadeIn('slow');
$('#opc_delivery_methods-overlay').fadeIn('slow'); $('#opc_delivery_methods-overlay').fadeIn('slow');
@@ -64,9 +64,9 @@ function updateAddressSelection()
if (jsonData.hasError) if (jsonData.hasError)
{ {
var errors = ''; var errors = '';
for(error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error != 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += jsonData.errors[error] + "\n";
alert(errors); alert(errors);
} }
@@ -86,7 +86,7 @@ function updateAddressSelection()
if ($(this).find('.cart_quantity_input').length > 0 && $(this).find('.cart_quantity_input').attr('name').length > 0) if ($(this).find('.cart_quantity_input').length > 0 && $(this).find('.cart_quantity_input').attr('name').length > 0)
{ {
name = $(this).find('.cart_quantity_input').attr('name')+'_hidden'; var name = $(this).find('.cart_quantity_input').attr('name')+'_hidden';
$(this).find('.cart_quantity_input').attr('name', $(this).find('.cart_quantity_input').attr('name').replace(/_\d+$/, '_'+idAddress_delivery)); $(this).find('.cart_quantity_input').attr('name', $(this).find('.cart_quantity_input').attr('name').replace(/_\d+$/, '_'+idAddress_delivery));
if ($(this).find('[name='+name+']').length > 0) if ($(this).find('[name='+name+']').length > 0)
$(this).find('[name='+name+']').attr('name', name.replace(/_\d+_hidden$/, '_'+idAddress_delivery+'_hidden')); $(this).find('[name='+name+']').attr('name', name.replace(/_\d+_hidden$/, '_'+idAddress_delivery+'_hidden'));
@@ -95,19 +95,19 @@ function updateAddressSelection()
if ($(this).find('.cart_quantity_delete').length > 0 && $(this).find('.cart_quantity_delete').attr('id').length > 0) { if ($(this).find('.cart_quantity_delete').length > 0 && $(this).find('.cart_quantity_delete').attr('id').length > 0) {
$(this).find('.cart_quantity_delete') $(this).find('.cart_quantity_delete')
.attr('id', $(this).find('.cart_quantity_delete').attr('id').replace(/_\d+$/, '_'+idAddress_delivery)) .attr('id', $(this).find('.cart_quantity_delete').attr('id').replace(/_\d+$/, '_'+idAddress_delivery))
.attr('href', $(this).find('.cart_quantity_delete').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&')) .attr('href', $(this).find('.cart_quantity_delete').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&'));
} }
if ($(this).find('.cart_quantity_down').length > 0 && $(this).find('.cart_quantity_down').attr('id').length > 0) { if ($(this).find('.cart_quantity_down').length > 0 && $(this).find('.cart_quantity_down').attr('id').length > 0) {
$(this).find('.cart_quantity_down') $(this).find('.cart_quantity_down')
.attr('id', $(this).find('.cart_quantity_down').attr('id').replace(/_\d+$/, '_'+idAddress_delivery)) .attr('id', $(this).find('.cart_quantity_down').attr('id').replace(/_\d+$/, '_'+idAddress_delivery))
.attr('href', $(this).find('.cart_quantity_down').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&')) .attr('href', $(this).find('.cart_quantity_down').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&'));
} }
if ($(this).find('.cart_quantity_up').length > 0 && $(this).find('.cart_quantity_up').attr('id').length > 0) { if ($(this).find('.cart_quantity_up').length > 0 && $(this).find('.cart_quantity_up').attr('id').length > 0) {
$(this).find('.cart_quantity_up') $(this).find('.cart_quantity_up')
.attr('id', $(this).find('.cart_quantity_up').attr('id').replace(/_\d+$/, '_'+idAddress_delivery)) .attr('id', $(this).find('.cart_quantity_up').attr('id').replace(/_\d+$/, '_'+idAddress_delivery))
.attr('href', $(this).find('.cart_quantity_up').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&')) .attr('href', $(this).find('.cart_quantity_up').attr('href').replace(/id_address_delivery=\d+&/, 'id_address_delivery='+idAddress_delivery+'&'));
} }
}); });
@@ -120,7 +120,7 @@ function updateAddressSelection()
updateCartSummary(jsonData.summary); updateCartSummary(jsonData.summary);
updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART); updateHookShoppingCart(jsonData.HOOK_SHOPPING_CART);
updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA); updateHookShoppingCartExtra(jsonData.HOOK_SHOPPING_CART_EXTRA);
if ($('#gift-price').length == 1) if ($('#gift-price').length === 1)
$('#gift-price').html(jsonData.gift_price); $('#gift-price').html(jsonData.gift_price);
$('#opc_account-overlay').fadeOut('slow'); $('#opc_account-overlay').fadeOut('slow');
$('#opc_delivery_methods-overlay').fadeOut('slow'); $('#opc_delivery_methods-overlay').fadeOut('slow');
@@ -128,7 +128,7 @@ function updateAddressSelection()
} }
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) { error: function(XMLHttpRequest, textStatus, errorThrown) {
if (textStatus != 'abort') if (textStatus !== 'abort')
alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
$('#opc_account-overlay').fadeOut('slow'); $('#opc_account-overlay').fadeOut('slow');
$('#opc_delivery_methods-overlay').fadeOut('slow'); $('#opc_delivery_methods-overlay').fadeOut('slow');
@@ -152,9 +152,9 @@ function getCarrierListAndUpdate()
if (jsonData.hasError) if (jsonData.hasError)
{ {
var errors = ''; var errors = '';
for(error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error != 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += jsonData.errors[error] + "\n";
alert(errors); alert(errors);
} }
@@ -177,8 +177,8 @@ function updateCarrierSelectionAndGift()
if ($(this).prop('checked')) if ($(this).prop('checked'))
delivery_option_params += $(delivery_option_radio[i]).attr('name') + '=' + $(delivery_option_radio[i]).val() + '&'; delivery_option_params += $(delivery_option_radio[i]).attr('name') + '=' + $(delivery_option_radio[i]).val() + '&';
}); });
if (delivery_option_params == '&') if (delivery_option_params === '&')
delivery_option_params = '&delivery_option=&' delivery_option_params = '&delivery_option=&';
if ($('input#recyclable:checked').length) if ($('input#recyclable:checked').length)
recyclablePackage = 1; recyclablePackage = 1;
@@ -202,9 +202,9 @@ function updateCarrierSelectionAndGift()
if (jsonData.hasError) if (jsonData.hasError)
{ {
var errors = ''; var errors = '';
for(error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error != 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += jsonData.errors[error] + "\n";
alert(errors); alert(errors);
} }
@@ -221,7 +221,7 @@ function updateCarrierSelectionAndGift()
} }
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) { error: function(XMLHttpRequest, textStatus, errorThrown) {
if (textStatus != 'abort') if (textStatus !== 'abort')
alert("TECHNICAL ERROR: unable to save carrier \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); alert("TECHNICAL ERROR: unable to save carrier \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
$('#opc_payment_methods-overlay').fadeOut('slow'); $('#opc_payment_methods-overlay').fadeOut('slow');
$('#opc_delivery_methods-overlay').fadeOut('slow'); $('#opc_delivery_methods-overlay').fadeOut('slow');
@@ -231,7 +231,7 @@ function updateCarrierSelectionAndGift()
function confirmFreeOrder() function confirmFreeOrder()
{ {
if ($('#opc_new_account-overlay').length != 0) if ($('#opc_new_account-overlay').length !== 0)
$('#opc_new_account-overlay').fadeIn('slow'); $('#opc_new_account-overlay').fadeIn('slow');
else else
$('#opc_account-overlay').fadeIn('slow'); $('#opc_account-overlay').fadeIn('slow');
@@ -256,7 +256,7 @@ function confirmFreeOrder()
} }
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) { error: function(XMLHttpRequest, textStatus, errorThrown) {
if (textStatus != 'abort') if (textStatus !== 'abort')
alert("TECHNICAL ERROR: unable to confirm the order \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); alert("TECHNICAL ERROR: unable to confirm the order \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
} }
}); });
@@ -264,26 +264,26 @@ function confirmFreeOrder()
function saveAddress(type) function saveAddress(type)
{ {
if (type != 'delivery' && type != 'invoice') if (type !== 'delivery' && type !== 'invoice')
return false; return false;
var params = 'firstname='+encodeURIComponent($('#firstname'+(type == 'invoice' ? '_invoice' : '')).val())+'&lastname='+encodeURIComponent($('#lastname'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; var params = 'firstname='+encodeURIComponent($('#firstname'+(type === 'invoice' ? '_invoice' : '')).val())+'&lastname='+encodeURIComponent($('#lastname'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
params += 'company='+encodeURIComponent($('#company'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; params += 'company='+encodeURIComponent($('#company'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
params += 'vat_number='+encodeURIComponent($('#vat_number'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; params += 'vat_number='+encodeURIComponent($('#vat_number'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
params += 'dni='+encodeURIComponent($('#dni'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; params += 'dni='+encodeURIComponent($('#dni'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
params += 'address1='+encodeURIComponent($('#address1'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; params += 'address1='+encodeURIComponent($('#address1'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
params += 'address2='+encodeURIComponent($('#address2'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; params += 'address2='+encodeURIComponent($('#address2'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
params += 'postcode='+encodeURIComponent($('#postcode'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; params += 'postcode='+encodeURIComponent($('#postcode'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
params += 'city='+encodeURIComponent($('#city'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; params += 'city='+encodeURIComponent($('#city'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
params += 'id_country='+encodeURIComponent($('#id_country').val())+'&'; params += 'id_country='+encodeURIComponent($('#id_country').val())+'&';
if ($('#id_state'+(type == 'invoice' ? '_invoice' : '')).val()) if ($('#id_state'+(type === 'invoice' ? '_invoice' : '')).val())
{ {
params += 'id_state='+encodeURIComponent($('#id_state'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; params += 'id_state='+encodeURIComponent($('#id_state'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
} }
params += 'other='+encodeURIComponent($('#other'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; params += 'other='+encodeURIComponent($('#other'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
params += 'phone='+encodeURIComponent($('#phone'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; params += 'phone='+encodeURIComponent($('#phone'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
params += 'phone_mobile='+encodeURIComponent($('#phone_mobile'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; params += 'phone_mobile='+encodeURIComponent($('#phone_mobile'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
params += 'alias='+encodeURIComponent($('#alias'+(type == 'invoice' ? '_invoice' : '')).val())+'&'; params += 'alias='+encodeURIComponent($('#alias'+(type === 'invoice' ? '_invoice' : '')).val())+'&';
// Clean the last & // Clean the last &
params = params.substr(0, params.length-1); params = params.substr(0, params.length-1);
@@ -302,9 +302,9 @@ function saveAddress(type)
{ {
var tmp = ''; var tmp = '';
var i = 0; var i = 0;
for(error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error != 'indexOf') if(error !== 'indexOf')
{ {
i = i+1; i = i+1;
tmp += '<li>'+jsonData.errors[error]+'</li>'; tmp += '<li>'+jsonData.errors[error]+'</li>';
@@ -327,7 +327,7 @@ function saveAddress(type)
} }
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) { error: function(XMLHttpRequest, textStatus, errorThrown) {
if (textStatus != 'abort') if (textStatus !== 'abort')
alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); alert("TECHNICAL ERROR: unable to save adresses \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
$('#opc_new_account-overlay').fadeOut('slow'); $('#opc_new_account-overlay').fadeOut('slow');
$('#opc_delivery_methods-overlay').fadeOut('slow'); $('#opc_delivery_methods-overlay').fadeOut('slow');
@@ -353,13 +353,13 @@ function updateNewAccountToAddressBlock()
success: function(json) success: function(json)
{ {
isLogged = 1; isLogged = 1;
if (json.no_address == 1) if (json.no_address === 1)
document.location.href = addressUrl; document.location.href = addressUrl;
$('#opc_new_account').fadeOut('fast', function() { $('#opc_new_account').fadeOut('fast', function() {
$('#opc_new_account').html(json.order_opc_adress); $('#opc_new_account').html(json.order_opc_adress);
// update block user info // update block user info
if (json.block_user_info != '' && $('#header_user').length == 1) if (json.block_user_info !== '' && $('#header_user').length === 1)
{ {
$('#header_user').fadeOut('slow', function() { $('#header_user').fadeOut('slow', function() {
$(this).attr('id', 'header_user_old').after(json.block_user_info).fadeIn('slow'); $(this).attr('id', 'header_user_old').after(json.block_user_info).fadeIn('slow');
@@ -377,7 +377,7 @@ function updateNewAccountToAddressBlock()
updateAddressesDisplay(true); updateAddressesDisplay(true);
updateCarrierList(json.carrier_data); updateCarrierList(json.carrier_data);
updatePaymentMethods(json); updatePaymentMethods(json);
if ($('#gift-price').length == 1) if ($('#gift-price').length === 1)
$('#gift-price').html(json.gift_price); $('#gift-price').html(json.gift_price);
$('#opc_delivery_methods-overlay').fadeOut('slow'); $('#opc_delivery_methods-overlay').fadeOut('slow');
$('#opc_payment_methods-overlay').fadeOut('slow'); $('#opc_payment_methods-overlay').fadeOut('slow');
@@ -385,7 +385,7 @@ function updateNewAccountToAddressBlock()
}); });
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) { error: function(XMLHttpRequest, textStatus, errorThrown) {
if (textStatus != 'abort') if (textStatus !== 'abort')
alert("TECHNICAL ERROR: unable to send login informations \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); alert("TECHNICAL ERROR: unable to send login informations \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
$('#opc_delivery_methods-overlay').fadeOut('slow'); $('#opc_delivery_methods-overlay').fadeOut('slow');
$('#opc_payment_methods-overlay').fadeOut('slow'); $('#opc_payment_methods-overlay').fadeOut('slow');
@@ -471,9 +471,9 @@ $(function() {
if (jsonData.hasError) if (jsonData.hasError)
{ {
var errors = '<b>'+txtThereis+' '+jsonData.errors.length+' '+txtErrors+':</b><ol>'; var errors = '<b>'+txtThereis+' '+jsonData.errors.length+' '+txtErrors+':</b><ol>';
for(error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error != 'indexOf') if(error !== 'indexOf')
errors += '<li>'+jsonData.errors[error]+'</li>'; errors += '<li>'+jsonData.errors[error]+'</li>';
errors += '</ol>'; errors += '</ol>';
$('#opc_login_errors').html(errors).slideDown('slow'); $('#opc_login_errors').html(errors).slideDown('slow');
@@ -486,7 +486,7 @@ $(function() {
} }
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) { error: function(XMLHttpRequest, textStatus, errorThrown) {
if (textStatus != 'abort') if (textStatus !== 'abort')
alert("TECHNICAL ERROR: unable to send login informations \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); alert("TECHNICAL ERROR: unable to send login informations \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
} }
}); });
@@ -498,7 +498,7 @@ $(function() {
if ($('#invoice_address:checked').length > 0) if ($('#invoice_address:checked').length > 0)
{ {
$('#opc_invoice_address').slideDown('slow'); $('#opc_invoice_address').slideDown('slow');
if ($('#company_invoice').val() == '') if ($('#company_invoice').val() === '')
$('#vat_number_block_invoice').hide(); $('#vat_number_block_invoice').hide();
updateState('invoice'); updateState('invoice');
updateNeedIDNumber('invoice'); updateNeedIDNumber('invoice');
@@ -517,15 +517,18 @@ $(function() {
// RESET ERROR(S) MESSAGE(S) // RESET ERROR(S) MESSAGE(S)
$('#opc_account_errors').html('').slideUp('slow'); $('#opc_account_errors').html('').slideUp('slow');
if ($('#opc_id_customer').val() == 0) var callingFile = '';
var params = '';
if ($('#opc_id_customer').val() === 0)
{ {
var callingFile = authenticationUrl; callingFile = authenticationUrl;
var params = 'submitAccount=true&'; params = 'submitAccount=true&';
} }
else else
{ {
var callingFile = orderOpcUrl; callingFile = orderOpcUrl;
var params = 'method=editCustomer&'; params = 'method=editCustomer&';
} }
$('#opc_account_form input:visible, #opc_account_form input[type=hidden]').each(function() { $('#opc_account_form input:visible, #opc_account_form input[type=hidden]').each(function() {
@@ -566,9 +569,9 @@ $(function() {
{ {
var tmp = ''; var tmp = '';
var i = 0; var i = 0;
for(error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error != 'indexOf') if(error !== 'indexOf')
{ {
i = i+1; i = i+1;
tmp += '<li>'+jsonData.errors[error]+'</li>'; tmp += '<li>'+jsonData.errors[error]+'</li>';
@@ -579,9 +582,9 @@ $(function() {
$.scrollTo('#opc_account_errors', 800); $.scrollTo('#opc_account_errors', 800);
} }
isGuest = ($('#is_new_customer').val() == 1 ? 0 : 1); isGuest = ($('#is_new_customer').val() === 1 ? 0 : 1);
if (jsonData.id_customer != undefined && jsonData.id_customer != 0 && jsonData.isSaved) if (jsonData.id_customer !== undefined && jsonData.id_customer !== 0 && jsonData.isSaved)
{ {
// update token // update token
static_token = jsonData.token; static_token = jsonData.token;
@@ -591,7 +594,7 @@ $(function() {
$('#opc_id_address_invoice').val(jsonData.id_address_invoice); $('#opc_id_address_invoice').val(jsonData.id_address_invoice);
// It's not a new customer // It's not a new customer
if ($('#opc_id_customer').val() != '0') if ($('#opc_id_customer').val() !== '0')
{ {
if (!saveAddress('delivery')) if (!saveAddress('delivery'))
return false; return false;
@@ -600,7 +603,7 @@ $(function() {
// update id_customer // update id_customer
$('#opc_id_customer').val(jsonData.id_customer); $('#opc_id_customer').val(jsonData.id_customer);
if ($('#invoice_address:checked').length != 0) if ($('#invoice_address:checked').length !== 0)
{ {
if (!saveAddress('invoice')) if (!saveAddress('invoice'))
return false; return false;
@@ -625,7 +628,7 @@ $(function() {
$('#opc_payment_methods-overlay').fadeOut('slow'); $('#opc_payment_methods-overlay').fadeOut('slow');
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) { error: function(XMLHttpRequest, textStatus, errorThrown) {
if (textStatus != 'abort') if (textStatus !== 'abort')
alert("TECHNICAL ERROR: unable to save account \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); alert("TECHNICAL ERROR: unable to save account \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
$('#opc_new_account-overlay').fadeOut('slow'); $('#opc_new_account-overlay').fadeOut('slow');
$('#opc_delivery_methods-overlay').fadeOut('slow'); $('#opc_delivery_methods-overlay').fadeOut('slow');
@@ -665,9 +668,9 @@ function bindInputs()
if (jsonData.hasError) if (jsonData.hasError)
{ {
var errors = ''; var errors = '';
for(error in jsonData.errors) for(var error in jsonData.errors)
//IE6 bug fix //IE6 bug fix
if(error != 'indexOf') if(error !== 'indexOf')
errors += jsonData.errors[error] + "\n"; errors += jsonData.errors[error] + "\n";
alert(errors); alert(errors);
} }
@@ -675,7 +678,7 @@ function bindInputs()
$('#opc_delivery_methods-overlay').fadeOut('slow'); $('#opc_delivery_methods-overlay').fadeOut('slow');
}, },
error: function(XMLHttpRequest, textStatus, errorThrown) { error: function(XMLHttpRequest, textStatus, errorThrown) {
if (textStatus != 'abort') if (textStatus !== 'abort')
alert("TECHNICAL ERROR: unable to save message \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus); alert("TECHNICAL ERROR: unable to save message \n\nDetails:\nError thrown: " + XMLHttpRequest + "\n" + 'Text status: ' + textStatus);
$('#opc_delivery_methods-overlay').fadeOut('slow'); $('#opc_delivery_methods-overlay').fadeOut('slow');
} }
@@ -708,10 +711,12 @@ function bindInputs()
// Term Of Service (TOS) // Term Of Service (TOS)
$('#cgv').click(function() { $('#cgv').click(function() {
if ($('#cgv:checked').length != 0) var checked = '';
var checked = 1;
if ($('#cgv:checked').length !== 0)
checked = 1;
else else
var checked = 0; checked = 0;
$('#opc_payment_methods-overlay').fadeIn('slow'); $('#opc_payment_methods-overlay').fadeIn('slow');
$.ajax({ $.ajax({
@@ -758,7 +763,7 @@ function multishippingMode(it)
cache: false, cache: false,
success: function(data) { success: function(data) {
$('#cart_summary').replaceWith($(data).find('#cart_summary')); $('#cart_summary').replaceWith($(data).find('#cart_summary'));
$('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, true, this.el) } }); $('.cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, true, this.el); } });
} }
}); });
updateCarrierSelectionAndGift(); updateCarrierSelectionAndGift();
@@ -773,7 +778,7 @@ function multishippingMode(it)
}, },
'onComplete': function() 'onComplete': function()
{ {
$('#fancybox-content .cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, false, this.el)} }); $('#fancybox-content .cart_quantity_input').typeWatch({ highlight: true, wait: 600, captureLength: 0, callback: function(val) { updateQty(val, false, this.el);} });
cleanSelectAddressDelivery(); cleanSelectAddressDelivery();
$('#fancybox-content').append($('<div class="multishipping_close_container"><a id="multishipping-close" class="button_large" href="#">' + CloseTxt + '</a></div>')); $('#fancybox-content').append($('<div class="multishipping_close_container"><a id="multishipping-close" class="button_large" href="#">' + CloseTxt + '</a></div>'));
$('#multishipping-close').click(function() { $('#multishipping-close').click(function() {
@@ -781,7 +786,7 @@ function multishippingMode(it)
$('#fancybox-content .cart_quantity_input').each(function(){ $('#fancybox-content .cart_quantity_input').each(function(){
newTotalQty += parseInt($(this).val()); newTotalQty += parseInt($(this).val());
}); });
if (newTotalQty != totalQty) { if (newTotalQty !== totalQty) {
if(!confirm(QtyChanged)) { if(!confirm(QtyChanged)) {
return false; return false;
} }
@@ -835,12 +840,12 @@ $(document).ready(function() {
// If the multishipping mode is off assure us the checkbox "I want to specify a delivery address for each products I order." is unchecked. // If the multishipping mode is off assure us the checkbox "I want to specify a delivery address for each products I order." is unchecked.
$('#multishipping_mode_checkbox').attr('checked', false); $('#multishipping_mode_checkbox').attr('checked', false);
// If the multishipping mode is on, check the box "I want to specify a delivery address for each products I order.". // If the multishipping mode is on, check the box "I want to specify a delivery address for each products I order.".
if (typeof(multishipping_mode) != 'undefined' && multishipping_mode) { if (typeof(multishipping_mode) !== 'undefined' && multishipping_mode) {
$('#multishipping_mode_checkbox').click(); $('#multishipping_mode_checkbox').click();
$('.addressesAreEquals').hide(); $('.addressesAreEquals').hide();
$('.addressesAreEquals').find('input').attr('checked', false); $('.addressesAreEquals').find('input').attr('checked', false);
} }
if (typeof(open_multishipping_fancybox) != 'undefined' && open_multishipping_fancybox) if (typeof(open_multishipping_fancybox) !== 'undefined' && open_multishipping_fancybox)
$('#link_multishipping_form').click(); $('#link_multishipping_form').click();
}); });