$.fn.selectRange = function(start, end) { return this.each(function() { if(this.setSelectionRange) { this.focus(); this.setSelectionRange(start, end); } else if(this.createTextRange) { var range = this.createTextRange(); range.collapse(true); range.moveEnd('character', end); range.moveStart('character', start); range.select(); } }); }; function newWindow(url, target, width, height, sbar) { var top = (screen.height - height) / 2 -30; var left = (screen.width - width) / 2; if(sbar) sbar = 'yes'; else sbar = 'no'; var modaless = window.open(url, target, 'width='+width+',height='+height+',top='+top+',left='+left+',scrollbars='+sbar); modaless.focus(); } function Starthomepage(val) { if(document.all) { document.body.style.behavior='url(#default#homepage)'; document.body.setHomePage(val); } else { alert('IE 이외의 브라우저는 별도의 설정에서 변경해주세요.'); } } // 즐겨찾기 등록 function AddFavoritepage(val,val_name) { var agt = navigator.userAgent.toLowerCase(); if(agt.indexOf("msie") != -1 || agt.indexOf("rv:11") != -1) { external.AddFavorite(val,val_name); } else if(agt.indexOf("chrome") != -1) { alert('Ctrl+D 키를 누르시면 즐겨찾기에 추가할수 있습니다.'); } else { alert('IE 이외의 브라우저는 별도의 설정에서 변경해주세요.'); } } // 검색 function check_todoCheck_search() { if(event.keyCode==13) todoCheck_search(); } // 검색 function todoCheck_search() { jQuery('#search_value').val().replace(/(^\s*)/g,''); if(jQuery('#search_value').val()=='') { alert('검색어를 입력해주세요.'); return 0; } var reg = /[\{\}\/?.,;:|\*~`!^\-_+<>@\#$%&\\\=\'\"]/gi //특수문자 검증 if(reg.test(jQuery('#search_value').val())){ //특수문자가 있다면 back alert('검색어에 특수문자를 사용하실 수 없습니다.'); $('#sTitle').val(''); $('#sTitle').focus(); return false; } /*if(jQuery('#search_value').val().length == 1) { alert('검색어는 2자이상 입력하셔야 합니다.'); return 0; }*/ jQuery('#search_form').submit(); } // 카테고리 function menuOver(cate) { $('.topMenuBox li').removeClass('on'); $("#menuTop_"+cate).attr('class','menuTop_'+cate+' on'); $('.subMenuBox div').hide(); $('#menu_'+cate).show(); } // 금액 콤마표기 function comma(n) { var reg = /(^[+-]?\d+)(\d{3})/; n += ''; while (reg.test(n)) n = n.replace(reg, '$1' + ',' + '$2'); return n; } // 구매내역 삭제 - 공통 function purchaseDel(obj) { var arr_chk_list = new Array; if(obj=='null') { alert('삭제할 컨텐츠가 선택되지 않았습니다.'); return 0; } else { if(obj.length<=0) { alert('삭제할 구매내역이 없습니다.'); return 0; } for(var i=0;i= 0) browserIE = true; else if(agent.indexOf("msie 8") >= 0) browserIE = true; else if(agent.indexOf("msie 9") >= 0) browserIE = true; else if(agent.indexOf("msie 10") >= 0) if(agent.indexOf("Touch") >= 0) browserIE = true; else browserIE = true; else if(agent.indexOf("rv:11.0") >= 0) browserIE = true; if(downAppCheck == 'fail' && browserIE==false) { SLB("/popup/popup_install.htm?browser=chrome", "iframe", 830, $(document).height()-10); $('#SLB_content').css( {'top':50,'left':(parseInt($("#innerWidth").html( window.innerWidth ))/2)-415} ); $('html, body').animate({ scrollTop:0 }, 300); }else{ var idx = idx; $('#con_' + idx).addClass('std'); $('#episode_' + idx).addClass('on'); if(section) { idx = idx+"§ion="+section; } // 상단에 고정. 부모스크롤시에도 부모스크롤안되고 뷰창 스크롤되게 요청 parent.SLB("/storage/storage.php?todo=view&idx="+idx, 'iframe', 1260, window.innerHeight-10); $('#SLB_content').css({'position':'fixed', 'top':5}); $('#SLB_iframe').focus(); //뷰레이어에 포커스(ESC키입력시 레이어닫기) window.onresize = function () { try { document.getElementById('SLB_film').style.width = document.body.offsetWidth + 'px'; SLB_content_relocate(); // 창크기 리사이즈에 따라 위치변경 } catch (e) { } } } } // 컨텐츠복사 function CodeCopy(idx) { var code_url = 'http://sharebox.co.kr'; var browser = navigator.userAgent.toLowerCase(); var code = code_url+'/storage/storage.php?todo=view&idx='+idx; if(-1!= browser.indexOf('msie') ) { window.clipboardData.setData('Text',code); alert('코드를 클립보드에 복사하였습니다.'); } else { prompt("Ctrl+C를 눌러 클립보드로 복사하세요", code); } } function txtLength(data) { tot_text_len = 0; for(rof = 0; rof < data.length; rof++) { if(data.charCodeAt(rof) > 255) { tot_text_len++; } tot_text_len++; } return tot_text_len; } // 글자 패턴 확인 function strCheck(data, counts) { mem_strings = ''; mem_strings_count = 0; re_message_check = 0; for(rof = 0; rof < data.length; rof++) { if(data.charCodeAt(rof) > 255) { check_String = data.substr(rof, 1); } else { check_String = data.substr(rof, 1); } if(mem_strings == check_String) { mem_strings_count++; } else { mem_strings = check_String; mem_strings_count = 1; } if(mem_strings_count > counts) { re_message_check = 1; break; } } return re_message_check; } // 글자 패턴 확인 function strCheck2(data) { var sCheck = true; for(i = 0; i < data.length; i++) { if(data.charAt(i) < "가" || data.charAt(i) > "힣") { sCheck = false; } else { sCheck = true; return sCheck; } } return sCheck; } // 댓글작성 var aClickBtn = 0; function commentWrite(idx, pidx) { var f = document.commentForm; if(aClickBtn == 0) { if(txtLength($('#comment').val()) < 10) { alert("한글 5자이상 입력해주세요.\n\n불성실한 평가나 답변은 포인트가 몰수될 수 있음을 알려드립니다."); } else { if(strCheck2($('#comment').val()) == false) { alert("5글자 이상 입력해주세요~\n불성실한 평가나 초성반복 댓글, 욕설, 타인비방등의 댓글 등록시\n포인트 회수와 함께 7일간 댓글이 정지될 수 있습니다."); } else { if(strCheck($('#comment').val(), 3)) { if(!confirm("불성실한 댓글등록시 7일간 댓글이 정지됩니다.\n현재 댓글을 등록하시겠습니까?")) { return false; } } aClickBtn = 1; $.ajax({ type: "POST", url: "/storage/storage.php", async: true, data : { todo : 'commentWrite', idx : idx, purchase_idx : pidx, comment : $('#comment').val(), star_point : $('input[name=star_point]:checked').val() }, dataType :'json', success : function(data) { if(data.status == "NOTLOGIN") { alert(data.msg); jQuery('#popup_bg_layer').show(); jQuery('#popup_login_layer').show(); } else if(data.status == 200) { alert(data.msg); ViewPopup(idx); } else { alert(data.msg); } } }); } } } else { alert("처리중이오니 잠시만 기다려주세요."); return false; } } // 댓글삭제 function commentDelete(idx, nIdx) { if(confirm("해당 댓글 내용을 삭제하시겠습니까?")) { $.ajax({ type: "POST", url: "/storage/storage.php", data: { todo : 'commentDelete', idx : idx }, dataType : 'json', success : function(data) { if(data.status == "NOTLOGIN") { alert(data.msg); jQuery('#popup_bg_layer').show(); jQuery('#popup_login_layer').show(); } else if(data.status == 200) { alert(data.msg); ViewPopup(nIdx); } else { alert(data.msg); } } }); } } // 메모삭제 function memoDel(obj, todosub) { var arr_chk_list = new Array; if(obj=='null') { alert('삭제할 메모가 선택되지 않았습니다.'); return 0; } else { if(obj.length<=0) { alert('삭제할 메모가 없습니다.'); return 0; } for(var i=0;i 0) { var cipher = '1'; for(var i=0; i < Position; i++ ) cipher = cipher + '0'; var no = Number(cipher); if(Base=="F") return Math.round(Num * no) / no; else return Math.round(Num / no) * no; } } //용량계산 function parseSize(val,Position){ var size = parseInt(val); if(size==0) return "0Bytes"; if(size < 1024) return size + "Bytes"; else if (size < Math.pow(1024,2)) return Round(size / 1024,Position,'F') + "KB"; else if (size < Math.pow(1024,3)) return Round(size / (1024*1024),Position,'F') + "MB"; else if (size < Math.pow(1024,4)) return Round(size / (1024*1024*1000),Position,'F') + "GB"; else return Round(size / Math.pow(1024,4),Position,'F') + "TB"; } // 내가올린 끌어올리기 function articleTop(obj) { var f = document.base_form; var arr_chk_list = new Array; if(obj=='null') { alert('최상단 이동할 컨텐츠가 선택되지 않았습니다.'); return 0; } else { if(obj.length<=0) { alert('컨텐츠를 선택해주세요.'); return 0; } var j=0; for(var i=0;i1) { alert('끌어올리기는 한번에 한개의 컨텐츠만 가능합니다.'); return 0; } if(arr_chk_list=='') { alert('컨텐츠를 선택해주세요.'); return 0; } else { jQuery.post('/mypage/seller.php',{todo:"articleTop",arr_chk_list:arr_chk_list}, function(data){ var reg = /\s+/g; nStr = data.replace(reg, ''); var sTmp = nStr.split("|"); seq = sTmp[1]; if(sTmp[0]=='S') { alert(sTmp[1]); } else if(sTmp[0]=='E') { alert(sTmp[1]); } else { alert('error-02'); } location.reload(); }); } } } // 내가올린 삭제하기 function registChkDelete(obj) { var f = document.base_form; var arr_chk_list = new Array; if(obj=='null') { alert('삭제할 컨텐츠가 선택되지 않았습니다.'); return 0; } else { if(obj.length<=0) { alert('컨텐츠를 선택해주세요.'); return 0; } var j=0; for(var i=0;i list_sel_count) { list_sel_position = list_sel_count; } keyword_save = cDataList['data'][list_sel_position]['k']; jQuery('#search_value').val(cDataList['data'][list_sel_position]['k']); $('.keyword_td').css("background-color", ""); $('#keyc_' + list_sel_position).css("background-color", "#eee"); } } function ajax_complete() { var keyword_complete; if(keyword_complete == 0 && jQuery('#search_value').val().length > 0 && keyword_save != jQuery('#search_value').val()) { keyword_complete = 1; keyword_save = jQuery('#search_value').val(); $.ajax({ type: 'GET', url: "/storage/keyword_complete.php", data: { term:jQuery('#search_value').val() }, dataType: 'json', success: function (data) { cDataList = data; if(data['count'] > 0) { list_sel_position = -1; htmls = ""; $.each(data['data'], function(index, element) { htmls += ""; }); htmls += "
" + data['data'][index]['v'].replace(jQuery('#search_value').val(), "" + jQuery('#search_value').val() + "") + "
"; jQuery('#tags').html(htmls); $('.keyword_td').css("background-color", ""); jQuery('#search_tags').show(); list_sel_count = data['count']; } keyword_complete = 0; } }); } else if(keyword_complete == 0 && jQuery('#search_value').val().length == 0) { keyword_save = jQuery('#search_value').val(); jQuery('#search_tags').hide(); jQuery('#tags').html(''); } } function popup_layer_view(val) { if(val=='login') { jQuery("#popup_layer_view1").attr('class','tab01 on'); jQuery("#popup_layer_view2").attr('class','tab02'); jQuery('#popup_join_layer').hide(); jQuery('#popup_login_layer').show(); } else { jQuery("#popup_layer_view1").attr('class','tab01'); jQuery("#popup_layer_view2").attr('class','tab02 on'); jQuery('#popup_login_layer').hide(); jQuery('#popup_join_layer').show(); } } function seller_contetns_layer_close() { jQuery('#seller_contents_list').hide(); } function popup_bg_layer_close() { jQuery('#popup_bg_layer').hide(); } function add_group() { add_text = $('.input_friend').val(); if(add_text == '') { alert('추가할 그룹명을 입력해주세요'); return false; } $('#groups').append(""); add_text = $('.input_friend').val(''); } function group_action() { var i; var arr = ""; $('#groups').find('option').each(function() { arr = arr + encodeURIComponent($(this).val()) + "||"; }); if(arr == '') { alert('추가할 그룹이 없습니다.'); return false; } $.post('/friend/',{todo:"group_add",arr:arr}, function(data){ alert(data); location.reload(); } ); } function selected_del() { var val = $('select[name=add_groups] option:selected').val(); $('select[name=add_groups] option:selected').remove(); } function friend_move_group() { var friend_name = $('#friend_move option:selected').text(); var group_name = $('#group_move option:selected').text(); var param = "todo=friend_move_group_action&move_friend="+friend_name+"&move_group="+group_name; if(friend_name == '친구 선택') { alert('이동할 친구를 선택해 주세요.'); return false; } $.post('/friend/',{todo:"friend_move_group",friend_name:friend_name,group_name:group_name}, function(data){ alert(data); location.reload(); } ); } function text_friend_group() { var friend_name = $('#friend_move option:selected').text(); var group_name = $('#group_move option:selected').text(); if(friend_name == '친구 선택') { friend_name=''; } if(group_name == '그룹 선택') { group_name = '그룹 없음'; } $('#name_text').text(friend_name); $('#group_text').text(group_name); } function base64_encode(data) { var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, enc = '', tmp_arr = []; if (!data) { return data; } do { // pack three octets into four hexets o1 = data.charCodeAt(i++); o2 = data.charCodeAt(i++); o3 = data.charCodeAt(i++); bits = o1 << 16 | o2 << 8 | o3; h1 = bits >> 18 & 0x3f; h2 = bits >> 12 & 0x3f; h3 = bits >> 6 & 0x3f; h4 = bits & 0x3f; // use hexets to index into b64, and append result to encoded string tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4); } while (i < data.length); enc = tmp_arr.join(''); var r = data.length % 3; return (r ? enc.slice(0, r - 3) : enc) + '==='.slice(r || 3); } function lgt_event(phone) { $.post( "/event/index.php", { todo:'lgt_event_reg', phone:phone }, function(data, status){ ListLoading = 0; if(status == "success") { alert(data); $('.blackbg_gift').hide(); } } ); } function event_misson_proc(misson_step) { $.post( "/event/index.php", { todo:'event_misson_proc', misson_step:misson_step }, function(data, status) { if(status == "success") { alert(data); location.reload(); } } ); } // 링크 연결 function intro_click_send() { jQuery.post('/intro/click.php', { temp:'1' }, function(data){ // 리턴값 필요 없음 }); } // 쿠폰등록번호 쿠키처리 function coupon_temp_set(val) { SetCookie('coupon',val,1); } function is_me2disk_coupon(cpn) { if(cpn.substring(0,3)=='KYO') return true; else return false; } function goto_me2disk_coupon(cpn) { top.location.href = "http://me2disk.com/?coupon="+cpn; } function cateClickCount(cate) { if(cate != undefined && cate != ''){ jQuery.post('/storage/cateClick.php', { cate : cate }, function(data){ // 리턴값 필요 없음 }); } } // 매일 00시 기준 쿠키 생성 function setCookie00(name, value, expiredays) { var todayDate = new Date(); todayDate = new Date(parseInt(todayDate.getTime() / 86400000) * 86400000 + 54000000); if ( todayDate > new Date() ){ expiredays = expiredays - 1; } todayDate.setDate( todayDate.getDate() + expiredays); document.cookie = name + "=" + escape( value ) + "; path=/; expires=" + todayDate.toGMTString() + ";" } //날개배너 클릭카운트 function quickMenuClickCount(cate) { if(cate != undefined && cate != ''){ jQuery.post('/storage/cateClick.php', { 'mode':'quickmenu', cate : cate }, function(data){ // 리턴값 필요 없음 }); } } // 이관관련 레이어 상태값 변경 function unity_layer_event(sType, nIdx) { var sContentsChk = 'SE'; if(sType == 'S') { if($('#contents_agree_no').attr('class') == 'off' && $('#contents_agree_ok').attr('class') == 'off') { alert('자료이동의 여부를 선택해주세요.'); return false; } if($('#contents_agree_no').attr('class') == 'on') { sContentsChk = 'SY'; } if($('#contents_agree_ok').attr('class') == 'on') { sContentsChk = 'N'; } } $.post( "/event/index.php", { todo : 'layer_event_reg', sType : sType, nIdx : nIdx, sContentsChk : sContentsChk }, function(data, status) { location.href = '/'; } ); } // 2021-03-08 화이트데이 이벤트 - 사탕클릭 function eventWhiteDay() { $.ajax({ type: "POST", url: "/event/", data: { todo : 'event_whiteday2103_proc' }, dataType : 'json', success : function(response) { aClickBtn = 0; alert(response.message); window.location.reload(); } }); } function PasswdCheckSubmit() { if($('#userpw_check').val() == '') { alert('패스워드를 입력해주세요.'); return 0; } else { if($('#todoType').val() == 'ShieldChange') { $.ajax({ type: "POST", url: "/mypage/", type : "POST", data: { todo:'execPasswdCheckAjax', userpw_check: $('#userpw_check').val() }, success : function(res) { if(res == "NO_MATCH_PASSWORD") { alert("비밀번호가 일치하지 않습니다."); return false; } else if(res == "NEED_LOGIN") { $('#userpw_check_layer').hide(); $('#popup_bg_layer').show(); popup_layer_view('login'); } else if(res == "OK") { $.ajax({ type: "POST", url: "/mypage/", type : "POST", data: { todo:'execShieldAjax' }, success : function(res) { alert('청소년자녀보호 지킴이 설정이 변경되었습니다.'); location.reload(); }, error : function(request,status,error) { alert("에러가 발생했습니다. 다시 시도해주세요."); return false; } }); } }, error : function(request,status,error) { alert("에러가 발생했습니다. 다시 시도해주세요."); return false; } }); } else { $.ajax({ type: "POST", url: "/mypage/", type : "POST", data: { todo:'execPasswdCheckAjax', userpw_check: $('#userpw_check').val() }, success : function(res) { if(res == "NO_MATCH_PASSWORD") { alert("비밀번호가 일치하지 않습니다."); return false; } else if(res == "NEED_LOGIN") { $('#userpw_check_layer').hide(); $('#popup_bg_layer').show(); popup_layer_view('login'); } else if(res == "OK") { location.href = '/mypage/?todo='+$('#todo_set').val(); } }, error : function(request,status,error) { alert("에러가 발생했습니다. 다시 시도해주세요."); return false; } }); } } } function PasswdDownKey(key) { if(key == 13) { PasswdCheckSubmit(); } }