/** * Created by PhpStorm. * User: acerunner * Date: 16. 2. 4. * Time: 오후 6:05 */ /** * for old ie * */ if (!window.console) console = {log: function() {}}; /** * 상품등록시 브랜드(3차 카테고리 브랜드 가져오기) * 사용안함 */ function getBrandOptions(obj, brand_obj) { var ca_no = $(obj).val(); $.ajax({ url: "/service/public/common/common_process.php", type: "get", data: "proc=getBrandOptions&id=" + ca_no, cache: false, dataType: 'json', async: true, success: function (data) { var selected_value = $(brand_obj).attr('data-selected'); $(brand_obj).find('option').remove(); $(brand_obj).append(""); $(data).each(function (value) { selected = selected_value == this.value ? 'selected' : ''; $(brand_obj).append(""); }); } }); } /** * 상품등록시 브랜드 직접입력 * */ function checkBrand(obj) { if($(obj).val() == 'direct') { $('#brand_input').attr('disabled', false); $('#brand_input').removeClass('disabled'); } else { $('#brand_input').val(''); $('#brand_input').attr('disabled', true); $('#brand_input').addClass('disabled'); } } /** * 다단계 카테고리 콤보박스 */ function getCategoryOptions(cur_obj) { var value = $(cur_obj).val(); var tmp = String(value).split(','); if(tmp.length > 1) value = ''; value = value == null ? '' : value; if($(cur_obj).attr('data-next')) { $.ajax({ url: "/service/public/common/common_process.php", type: "get", data: "proc=getCategoryChild&id=" + value, cache: false, dataType: 'json', async: true, success: function (data) { var next_id = $(cur_obj).attr('data-next'); var obj_next = $('#' + next_id); var set_value = $(obj_next).attr('data-value'); $(obj_next).find('option').remove(); $(obj_next).append(""); $(data).each(function (value) { $(obj_next).append(""); }); if($(data).size() > 0 && $(obj_next).attr('data-check') == 'true') { $(obj_next).attr('required', true); } else { $(obj_next).attr('required', false); } if (set_value) { $(obj_next).val(set_value).trigger('change'); $(obj_next).attr('data-value', ''); } else { $(obj_next).val('').trigger('change'); } } }); } } $(document).ready(function() { if($(".zip_area1").length > 0) { $('.zip_area1').each(function () { var self = $(this); var data_selected1 = $(this).attr('data-value'); $.ajax({ url: "/service/public/common/common_process.php", type: "post", data: "proc=getSido", cache: false, async: true, dataType: 'json', success: function (data) { $(self).find('option').remove(); $(self).append(""); $(data).each(function (index, value) { $(self).append(""); if (data_selected1 && value.SIDO == data_selected1) { console.log(data_selected1) $(self).val(value.SIDO).attr("selected", "true").trigger('change'); } }); } }); $(self).on('change', function() { var next = $(self).next(".zip_area2"); var data_selected2 = $(next).attr('data-value'); $.ajax({ url: "/service/public/common/common_process.php", type: "post", data: "proc=getGugun&sido="+$(self).val(), cache: false, async: true, dataType: 'json', success: function (data) { $(next).find('option').remove(); $(next).append(""); $(data).each(function (index, value) { $(next).append(""); if (data_selected2 && value.GUGUN == data_selected2) { $(next).val(value.GUGUN).attr("selected", "true"); } }); } }); }); }); } $('.img-zoom').hover(function() { $(this).addClass('transition-zoom'); //$(this).css('height', 'auto'); }, function() { //$(this).css('height', '30px'); $(this).removeClass('transition-zoom'); }); // 가격 input mask if(typeof Inputmask != 'undefined') { Inputmask.extendAliases({ won: { prefix: "", groupSeparator: ",", alias: "numeric", placeholder: "0", autoGroup: !0, clearMaskOnLostFocus: !1 } }); } // 목록 체크 $('#check_all').on('click', function() { if($(this).attr('checked')) { $('input[name="chk[]"]').attr('checked', true); } else { $('input[name="chk[]"]').attr('checked', false); } }); // 상품상세 이미지 리사이즈 $('.pdt-detail').find('img').each(function() { var src = $(this).attr('src'); var self = $(this); var pic_real_width, pic_real_height; $("") // Make in memory copy of image to avoid css issues .attr("src", src) .load(function() { pic_real_width = this.width; // Note: $(this).width() will not pic_real_height = this.height; // work for in memory images. if(parseInt(pic_real_width) > 850) { $(self).attr('width', '850px'); } }); }); // datetimepicker set locale if(jQuery.datetimepicker) jQuery.datetimepicker.setLocale('ko'); }); function addViewLog(com_id, log_type, type_id, type_content, type_model) { $.ajax({ url: "/ns/service/public/common/common_process.php", type: "post", cache: false, async: true, data: {'proc':'addViewLog', 'com_id':com_id, 'log_type':log_type, 'type_id':type_id, 'type_content':type_content, 'type_model':type_model}, success: function(data) { } }) } function addSearchKeyword(keyword) { $.ajax({ url: "/ns/service/public/common/common_process.php", type: "post", cache: false, async: true, data: {'proc':'addSearchKeyword', 'keyword':keyword}, success: function(data) { } }) } function goUrl(url) { if(url) { window.open(url); } else { alert("준비중입니다."); } } function number_format(number, decimals, dec_point, thousands_sep) { // http://kevin.vanzonneveld.net // + original by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) // + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) // + bugfix by: Michael White (http://getsprink.com) // + bugfix by: Benjamin Lupton // + bugfix by: Allan Jensen (http://www.winternet.no) // + revised by: Jonas Raoni Soares Silva (http://www.jsfromhell.com) // + bugfix by: Howard Yeend // + revised by: Luke Smith (http://lucassmith.name) // + bugfix by: Diogo Resende // + bugfix by: Rival // + input by: Kheang Hok Chin (http://www.distantia.ca/) // + improved by: davook // + improved by: Brett Zamir (http://brett-zamir.me) // + input by: Jay Klehr // + improved by: Brett Zamir (http://brett-zamir.me) // + input by: Amir Habibi (http://www.residence-mixte.com/) // + bugfix by: Brett Zamir (http://brett-zamir.me) // + improved by: Theriault // + improved by: Drew Noakes // * example 1: number_format(1234.56); // * returns 1: '1,235' // * example 2: number_format(1234.56, 2, ',', ' '); // * returns 2: '1 234,56' // * example 3: number_format(1234.5678, 2, '.', ''); // * returns 3: '1234.57' // * example 4: number_format(67, 2, ',', '.'); // * returns 4: '67,00' // * example 5: number_format(1000); // * returns 5: '1,000' // * example 6: number_format(67.311, 2); // * returns 6: '67.31' // * example 7: number_format(1000.55, 1); // * returns 7: '1,000.6' // * example 8: number_format(67000, 5, ',', '.'); // * returns 8: '67.000,00000' // * example 9: number_format(0.9, 0); // * returns 9: '1' // * example 10: number_format('1.20', 2); // * returns 10: '1.20' // * example 11: number_format('1.20', 4); // * returns 11: '1.2000' // * example 12: number_format('1.2000', 3); // * returns 12: '1.200' var n = !isFinite(+number) ? 0 : +number, prec = !isFinite(+decimals) ? 0 : Math.abs(decimals), sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep, dec = (typeof dec_point === 'undefined') ? '.' : dec_point, toFixedFix = function (n, prec) { // Fix for IE parseFloat(0.55).toFixed(0) = 0; var k = Math.pow(10, prec); return Math.round(n * k) / k; }, s = (prec ? toFixedFix(n, prec) : Math.round(n)).toString().split('.'); if (s[0].length > 3) { s[0] = s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g, sep); } if ((s[1] || '').length < prec) { s[1] = s[1] || ''; s[1] += new Array(prec - s[1].length + 1).join('0'); } return s.join(dec); } function fnChkByte(obj, maxByte){ var str = obj.value; var str_len = str.length; var rbyte = 0; var rlen = 0; var one_char = ""; var str2 = ""; for(var i=0; i 4){ rbyte += 2; //한글2Byte }else{ rbyte++; //영문 등 나머지 1Byte } if(rbyte <= maxByte){ rlen = i+1; //return할 문자열 갯수 } } if(rbyte > maxByte){ alert("한글 "+(maxByte/2)+"자 / 영문 "+maxByte+"자를 초과 입력할 수 없습니다."); str2 = str.substr(0,rlen); //문자열 자르기 obj.value = str2; fnChkByte(obj, maxByte); }else{ document.getElementById('byteInfo').innerText = rbyte; } } function send_sms(id) { checkLogin(sms_win, id); } function sms_win(id) { window.open("/service/public/user/request_sms.php?id="+id, "send_sms", "width=570, height=435"); } function showContactInfo(mb_id) { $.magnificPopup.open({ items: { src: './contact_info.php?id='+mb_id, // can be a HTML string, jQuery object, or CSS selector type: 'ajax', ajax: { settings: {cache:false, async:false}, // Ajax settings object that will extend default one - http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings // For example: // settings: {cache:false, async:false} cursor: 'mfp-ajax-cur', // CSS class that will be added to body during the loading (adds "progress" cursor) tError: 'The content could not be loaded.' // Error message, can contain %curr% and %total% tags if gallery is enabled } } }); } function checkLogin(callback) { var id = arguments[1]; var callback_name = (callback) ? callback.name : ''; $.ajax({ url: "/service/public/common/common_process.php", type: "post", cache: false, async: true, data: {'proc':'checkLogin'}, success: function(data) { if(data == 'true') { if(callback) callback(id); return true; } else { $.magnificPopup.open({ items: { src: './quick_login_alone.php?callback='+callback_name+'&id='+id, // can be a HTML string, jQuery object, or CSS selector type: 'ajax', ajax: { settings: null, // Ajax settings object that will extend default one - http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings // For example: // settings: {cache:false, async:false} cursor: 'mfp-ajax-cur', // CSS class that will be added to body during the loading (adds "progress" cursor) tError: 'The content could not be loaded.' // Error message, can contain %curr% and %total% tags if gallery is enabled } } }); } } }) } function showOverlay(url) { $.magnificPopup.open({ items: { src: url, type: 'ajax', closeOnContentClick: false, ajax: { settings: {cache:false, async:false}, // Ajax settings object that will extend default one - http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings // For example: // settings: {cache:false, async:false} cursor: 'mfp-ajax-cur', // CSS class that will be added to body during the loading (adds "progress" cursor) tError: 'The content could not be loaded.' // Error message, can contain %curr% and %total% tags if gallery is enabled } } }); } function view_popup(bo_table, wr_id) { window.open('/ns/service/public/user/board_view_popup.php?bo_table='+bo_table+'&wr_id='+wr_id, 'view', 'width=750, height=600, scrollbars=yes'); } // 날짜계산 function dateInput(n,m){ document.getElementById("s_date").value = ""; document.getElementById("e_date").value = ""; var date = new Date(); var start = new Date(Date.parse(date) - n * 1000 * 60 * 60 * 24); var today = new Date(Date.parse(date) - m * 1000 * 60 * 60 * 24); var yyyy = start.getFullYear(); var mm = start.getMonth()+1; var dd = start.getDate(); if(mm<10){ mm = "0" + mm; }if(dd<10){ dd = "0" + dd; } var t_yyyy = today.getFullYear(); var t_mm = today.getMonth()+1; var t_dd = today.getDate(); if(t_mm<10){ t_mm = "0" + t_mm; }if(t_dd<10){ t_dd = "0" + t_dd; } document.getElementById("s_date").value = yyyy + "-" + mm + "-" + dd; document.getElementById("e_date").value = t_yyyy + "-" + t_mm + "-" + t_dd; } // 숫자 타입에서 쓸 수 있도록 format() 함수 추가 Number.prototype.format = function(){ if(this==0) return 0; var reg = /(^[+-]?\d+)(\d{3})/; var n = (this + ''); while (reg.test(n)) n = n.replace(reg, '$1' + ',' + '$2'); return n; }; // 문자열 타입에서 쓸 수 있도록 format() 함수 추가 String.prototype.format = function(){ var num = parseFloat(this); if( isNaN(num) ) return "0"; return num.format(); }; // 문자열을 정수로 변환 String.prototype.toInt = function() { var pm = /^-/.test(this) ? -1 : 1; return this.replace(/\..*$/g, '').replace(/[^\d]/g, '') * pm; } // 숫자 한글읽기로 변환 function viewKorean(num, id) { var num = num.replace(/,/g , ""); var hanA = new Array("","일","이","삼","사","오","육","칠","팔","구","십"); var danA = new Array("","십","백","천","","십","백","천","","십","백","천","","십","백","천"); var result = ""; for(i=0; i 0) { setTimeout(function() { progress(timeleft - 1, timetotal, $element); }, 1000); } }; //progress(180, 180, $('#progressBar')); // zeroPad(1,10); //=> 01 // zeroPad(1,100); //=> 001 // zeroPad(1,1000); //=> 0001 function zeroPad(nr,base){ var len = (String(base).length - String(nr).length)+1; return len > 0? new Array(len).join('0')+nr : nr; }