$('#group_tree > ul').empty(); $('div.table_price table tbody').empty(); $('div.table_price div.comm').empty(); var tree_content_str = ' Ошибка 502 - Bad Gateway



Ошибка 502

Сервер не отвечает. Пожалуйста, повторите запрос через некоторое время.

'; var tree_content = JSON.parse(tree_content_str); var price_content_str = ' Ошибка 502 - Bad Gateway



Ошибка 502

Сервер не отвечает. Пожалуйста, повторите запрос через некоторое время.

'; var price_content = JSON.parse(price_content_str); if ((tree_content.price.length > 0) && (price_content.price_list.length > 0)){ for(var i = 0; i < tree_content.price.length; i++){ if (tree_content.price[i].parent == ''){ var str = '
  • '+ '
    '+delNum(DecodeURI(tree_content.price[i].name))+'
    '; var fl = false; for(var j = 0; j < tree_content.price.length; j++){ if (tree_content.price[i].folder_id == tree_content.price[j].parent){ if (!fl){ str += ''; str += '
  • '; $('#group_tree > ul').append(str); } } if (!ShowPrice($('#group_tree > ul > li:eq(0) > div').attr('folder_id'))) ShowPrice($('#group_tree > ul > li:eq(0) > ul > li:eq(0)').attr('folder_id')); } $('#group_tree > ul > li > div, #group_tree > ul > li > ul > li').click(function(){ var a = $(this); ShowPrice(a.attr('folder_id')); }) function ShowPrice(folder_id){ $('div.table_price table tbody').empty(); var str = ''; for (var i = 0; i < price_content.price_list.length; i++){ if (folder_id == price_content.price_list[i].folder_id){ str += ''+ '' + DecodeURI(price_content.price_list[i].name) + ''+ '' + DecodeURI(price_content.price_list[i].price) + ''+ ''; } } $('div.table_price div.comm').empty(); for(var i = 0; i < tree_content.price.length; i++){ if (tree_content.price[i].folder_id == folder_id){ var com = DecodeURI(tree_content.price[i].comm); com = com.replace(/\n\r/g, '
    '); com = com.replace(/\r\n/g, '
    '); com = com.replace(/\r/g, '
    '); com = com.replace(/\n/g, '
    '); $('div.table_price div.comm').append(com); break; } } if (str != ''){ $('div.table_price table tbody').append(str); return true; } return false; } function DecodeURI(srt){ try{ return decodeURIComponent(srt).replace(/[+]/g, ' '); }catch(e){ console.log(e.name + ' - ' + srt); return srt; } } function delNum(val){ var fl = false; for(var i = 0; i < 5; i++) if ((val[i] != undefined) && (val[i] == '.')) fl = true; if (fl){ val = val.replace(/\d/g, ''); if (val[0] == '.') val = val.slice(1); val = val.trim(); } return val; }