- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
// Обновление надписи "Мои покупки"
var file_f_basket = "/personal/cart/basket.php";
//удаление пробелов, возврата каретки
function trim(string)
{
	return string.replace(/(^\s+)|(\s+$)/g, "");
}
function BasketDeleteByID(id) {
	BX.showWait();
	jQuery.get(file_f_basket,{action:"DELETE",ID:id}, 
	 function(data) 
			{
				if (trim(data) == "Success") 
				{
					var old = document.getElementById("record_" + id);
					old.parentNode.removeChild(old);
					SaleBasketUpdateTotal();
				}
				else if (trim(data) == "Empty")
				{
					var old = document.getElementById("goods");
					old.parentNode.removeChild(old);
					var old = document.getElementById("basket");
					var mes = old.parentNode;
					old.parentNode.removeChild(old);
					var text = document.createTextNode("");
					text.nodeValue = "Ваша корзина пуста.";
					var elem = document.createElement("font");
					elem.appendChild(text);
					document.body.appendChild(elem);
					elem.className="errortext";
					mes.appendChild(elem);
				}
				
				BasketUpdateLine();
				BX.closeWait();
				}
				
	);
}
function SaleBasketUpdateTotal() {
    var meForm   = document.getElementById('goods');
    var spanArray  = meForm.getElementsByTagName('span');
    var allSumm = 0;
    for (j = 0; j < spanArray.length; j++) {
        if (spanArray[j].className == "goodtotal")
           allSumm = allSumm + parseFloat(spanArray[j].innerHTML);
    }
    document.getElementById('total_sum').innerHTML = allSumm;
}
/*
 * Входные параметры функции:
 *    quant     - количество товара
 *    prise     - стоимость за единицу
 *    updElemId - идентификатор элемента, в котором требуется обновить данные (по конкретному товару)
 **/
 function SaleBasketUpdateTotalById(quant, price, updElemId)
 {
       
     var anum = /(^\d+$)|(^\d+\.\d+$)/;
     if (!anum.test(quant)) {
       
         alert('Введенное значение не является числом!');
         return;
     }
       
     goodSum = quant * price;
  
     document.getElementById(updElemId).innerHTML = goodSum;
	 SaleBasketUpdateTotal();     
 }
 function isNumKeyPressed(_this,_event) {
		if (!_event) _event = event;
		var q = _this;
		
		if ((_event.keyCode > 8 || _event.keyCode < 57) & (_event.keyCode != 0)) return true;
		if ((_event.charCode < 8 || _event.charCode > 57)) return false;
		if (q.value.length >= 2) return false;	
	}
function BasketUpdateLine()
{
	jQuery.get(file_f_basket, {action: "COUNT"}, function(data)
			{
				if (parseInt(trim(data)) > 0 )
					jQuery("#basket_line").html("<a href='/personal/cart/' class='basket-line'>Мои покупки (" + trim(data) + ")</a>");
				else
					jQuery("#basket_line").html("Мои покупки");
			}
	);








 Follow us!
 Follow us!