function goBack() { window.history.back(); } var defaultCSS = document.getElementById('bootstrap-css'); function changeCSS(css) { if (css) $('head > link').filter(':first').replaceWith(''); else $('head > link').filter(':first').replaceWith(defaultCSS); } var ajaxVal = []; var ControllerType; var hash = window.location.hash; if (hash != "") { $(".user-menu").find('.active').removeClass('active'); $(".tab-content").find('.active').removeClass('active'); $("." + hash.substr(1)).addClass('active'); $("#" + hash.substr(1)).addClass('active'); if (hash.substr(1) == "myads") { advs('advs');//ilan çağırma fonksiyonunu çalıştır } if (hash.substr(1) == "archived_ads") { advs('archived'); } if (hash.substr(1) == "pending_ads") { advs('pending'); } } $('a[data-panel="my_adv"]').add('li[data-panel="my_adv"]').on('click', function () { advs('advs'); }); $('.tab-btn').on('click', function () { if ($(this).attr('aria-controls') == "my_ads") { advs('advs'); } if ($(this).attr('aria-controls') == "archived_ads") { advs('archived'); } if ($(this).attr('aria-controls') == "pending_ads") { advs('pending'); } }); function advs(type) { var url = '/profile/getAdv'; var includeTab; if (type == 'advs') { var add_url = 'advs'; includeTab = 'myAdvsList'; } if (type == 'archived') { var add_url = 'archived'; includeTab = 'archivedAdvsList'; } else if (type == 'pending') { var add_url = 'pending'; includeTab = 'pendingAdvsList'; } $.ajax({ type: 'get', contentType: "application/json; charset=utf-8", dataType: "json", url: url + "?type=" + add_url, success: function (response) { hideLoader() $('.' + includeTab).html(""); var ads = response.content; $.each(ads, function (index, advs) { var top = ""; var resim = resimNone; if (response.files[index] != "") { resim = "/files/" + response.files[index][0].path; } priceFormat(advs.price.toString()) top += "
" + "
" + "
" + "Image" + "
" + "

" + priceFormat(advs.price.toString()) + " " + advs.currency + "

" + "

" + advs.name.slice(0, 38) + "...

" + "" + "
Status:" + ""; if (advs.status == "pending_user" || advs.status == "passive") { var date = advs.created_at.split(' '); top += "Passive
" + "
" + "
" + "Posted On: " + date[0] + "" + "Approved"; } else if (advs.status == "pending_admin") { top += "Pending
" + "
" + "
" + "Posted On: " + advs.created_at + "" + "Passive"; } else { top += "Approved
" + "
" + "
" + "Posted On: " + advs.created_at + ""; } top += "
"; if (type == 'advs') { top += "" + ""; } if (type == "archived") { top += ""; } top += "" + "" + "" + "
"; $('.' + includeTab).append(top); }); }, beforeSend: function () { showLoader() } }).promise().done(function () { $('.approve').on('click', function () { ControllerType = "status"; ajaxVal['id'] = $(this).data('id'); ajaxVal['type'] = $(this).data('content'); advsController(ajaxVal, ControllerType); }); $('.extendTime').on('click', function () { ControllerType = "extendTime"; ajaxVal['id'] = $(this).data('id'); ajaxVal['type'] = "pending_admin"; advsController(ajaxVal, ControllerType); }); }); } function priceFormat(num) { var arr = num.split("."); if (arr.length > 1) { return parseInt(arr[0]).toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,').slice(0,-2)+arr[1] } else { return parseInt(num).toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,') } } function advsController(ajaxVal, ControllerType) { var id = ajaxVal['id']; var type = ajaxVal['type']; var menu = $(".ads-menu").find('.active').find(".tab-btn").attr('aria-controls'); $.ajax({ type: 'get', contentType: "application/json; charset=utf-8", dataType: "json", url: '/profile/class/' + ControllerType + '/' + id + "," + type, success: function (response) { hideLoader() if (response.success == false) { alert(response.msg); } console.log(menu) if (menu == "my_ads") { advs('advs'); } if (menu == "archived_ads") { advs('archived'); } if (menu == "pending_ads") { advs('pending'); } }, beforeSend: function () { showLoader() } }); } if(window.location.pathname == "/profile") { $('input[name="gsm_phone"]').intlTelInput(); } // $('a[data-target="#file-modal"]').on('click', function () { // setInterval(addSubmitFileModal, 1000); // // }); // function addSubmitFileModal() { // $('a[data-file]').on('click', function () { // setInterval(submitForm, 1000); // }); // } // // function submitForm() { // $('form[data-name="profile"]').submit(); // }