Skip to content

Instantly share code, notes, and snippets.

@Enelar
Created March 13, 2018 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Enelar/1f2ef48701fdcd7d29a21fe61ac50868 to your computer and use it in GitHub Desktop.
Save Enelar/1f2ef48701fdcd7d29a21fe61ac50868 to your computer and use it in GitHub Desktop.
Is this so hard????
function initializeResizeEvents() {
jQuery('#select_size').on("change", function(event) {
var data = jQuery("#select_size option:selected").attr('resize-data');
window.productPrice.resize = '';
if (typeof(data) != 'undefined') {
if (data == 'custom') {} else {
data = eval('(' + data + ')');
window.productHeight = data.height;
window.productWidth = data.width;
}
var p_price = Math.ceil((window.productPrice.permeter * (window.productWidth * window.productHeight) / 10000));
var total_price = Math.ceil(p_price + window.fixed_price);
window.productPrice.resize = Math.ceil(total_price);
if (total_price > 0) {
jQuery('#product-price-869 .price').text(window.productCurrency + Math.round(total_price * 100) / 100);
} else {
jQuery('#product-price-869 .price').text(window.productCurrency + Math.round(window.productPrice.main * 100) / 100);
}
calculateFinishPrice();
var weight = Math.round((window.productHeight * window.productWidth / 10000) * 18);
var marble_count = (window.productHeight * window.productWidth / 10000) * 11;
var pounds = Math.ceil(2.20462 * weight);
var shippingPrice = Math.ceil(weight * window.shippingCost)
jQuery("#shipping-calculated-price").html(window.productCurrency + shippingPrice);
jQuery("#attr-tile_count").html(Math.ceil(marble_count * 1000));
var thickness = jQuery("#attr-thickness").html().replace(/^\D+/g, '');
if (window.cminch == 'in') {
jQuery("#attr-weight").html(pounds + " Pounds " + "(" + weight + " kg )");
jQuery("#attr-dimension").html(Math.round(window.productWidth * 0.393701) + " W x " + Math.round(window.productHeight * 0.393701) + ' H inch');
jQuery("#attr-thickness").html(window.thickness + ' inch');
} else {
jQuery("#attr-weight").html(weight + " kg " + "(" + pounds + " Pounds)");
jQuery("#attr-dimension").html(window.productWidth + ' W x ' + window.productHeight + ' H cm');
jQuery("#attr-thickness").html((window.thickness * 2.54) + " cm");
}
}
});
}
function initializeResizeEvents() {
var $ = jQuery;
var select = jQuery('#select_size');
select.on("change", (event) =>
{
var data = select.find("option:selected").attr('resize-data');
window.productPrice.resize = '';
if (data !== undefined)
{
if (data !== 'custom')
{
data = eval('(' + data + ')');
window.productHeight = data.height;
window.productWidth = data.width;
}
var square = window.productWidth * window.productHeight / 10000;
var p_price = window.productPrice.permeter * square;
var total_price
= window.productPrice.resize
= Math.ceil(p_price + window.fixed_price);
var displayed_price
= total_price > 0
? total_price.toFixed(2)
: window.productPrice.main.toFixed(2);
$('#product-price-869 .price')
.text
(
window.productCurrency
+
displayed_price
)
calculateFinishPrice();
var weight = Math.round(square * 18);
var marble_count = square * 11;
var pounds = Math.ceil(2.20462 * weight);
var shippingPrice = Math.ceil(weight * window.shippingCost)
$("#shipping-calculated-price").html(window.productCurrency + shippingPrice);
$("#attr-tile_count").html(Math.ceil(marble_count * 1000));
var thickness = $("#attr-thickness").html().replace(/^\D+/g, '');
var lang =
[
[
"Pounds",
"kg",
],
[
'inch',
'cm',
],
[
0.393701,
1,
],
[
1,
2.54,
]
];
var index = window.cminch == 'in' ? 0 : 1;
index
? jQuery("#attr-weight").html(pounds + " Pounds " + "(" + weight + " kg )")
: jQuery("#attr-weight").html(weight + " kg " + "(" + pounds + " Pounds)");
$("#attr-dimension").html(Math.round(window.productWidth * lang[2][index]) + " W x " + Math.round(window.productHeight * lang[2][index]) + ' H ' + lang[1][index]);
$("#attr-thickness").html((window.thickness * lang[3][index]) + ' ' + lang[1][index]);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment