我需要解释一下javascript代码的实例,这是在opencart中估算产品的租赁方案。不幸的是我在javascript编码中也不流利,所以我只想了解片段中的主要功能是什么以及采取变量的内容
<script>
function creditiFull() {
var a = document.getElementById("showHideCrediti"),
b = "none" == a.style.display;
b ? a.style.display = "block" : a.style.display = "none"
}
Journal.updateProductPrice = function() {
$.ajax({
url: "index.php?route=journal2/ajax/price",
type: "post",
data: $(".product-info input[type='text'], .product-info input[type='hidden'], .product-info input[type='radio']:checked, .product-info input[type='checkbox']:checked, .product-info select, .product-info textarea"),
dataType: "json",
success: function(a) {
for ($("div.right ul.price li").hasClass("price-new") ? ($asd = a.special.replace(/\s+/g, ""), $asd = $asd.replace(",", "."), $asd = $asd.replace("лв.", ""), $asd = $asd.replace(/\s+/g, ""), $asd = (.8 * $asd).toFixed(2) + " лв.", $cifra = a.special.replace(/\s+/g, ""), $cifra = $cifra.replace(",", "."), $cifra = $cifra.replace("лв.", ""), $cifra = $cifra.replace(/\s+/g, "")) : ($asd = a.price.replace(/\s+/g, ""), $asd = $asd.replace(",", "."), $asd = $asd.replace("лв.", ""), $asd = $asd.replace(/\s+/g, ""), $asd = (.8 * $asd).toFixed(2) + " лв.", $cifra = a.price.replace(/\s/g, ""), $cifra = $cifra.replace(",", "."), $cifra = $cifra.replace("лв.", ""), $cifra = $cifra.replace(/\s+/g, "")), $i = 1; $i <= a.broiach - 1; $i++) $zmeseci = a.meseci1[$i], $ztbi = a.tbi1[$i], $zuni = a.uni1[$i], $zpariba = a.pariba1[$i], $blaat = ($cifra * (1 + $ztbi / 100) / $zmeseci).toFixed(2) + " лв.", $blaau = ($cifra * (1 + $zuni / 100) / $zmeseci).toFixed(2) + " лв.", $blaap = ($cifra * (1 + $zpariba / 100) / $zmeseci).toFixed(2) + " лв.", $(".creditiBank #tbi" + $i).html($blaat), $(".creditiBank #uni" + $i).html($blaau), $(".creditiBank #pariba" + $i).html($blaap);
if ($(".product-info .price .price-old, .product-info .price .product-price").html(a.price), $(".product-info .price .price-new").html(a.special), $(".product-info .price .price-tax").html(a.tax), $(".description .journal-stock").removeClass("outofstock").removeClass("instock").addClass(a.cls).html(a.stock), $(".product-info .price .reward small").html(a.points), Journal.isOC2) $(".product-info .discounts").each(function(b) {
$(this).html(a.discounts[b])
});
else {
var b = "";
$.each(a.discounts, function(a, c) {
b += c + "<br />"
}), $(".discount").html(b)
}
}
})
};