////////////////////////////////////////////////////////////////////////////////////////////////// // 기본함수 ////////////////////////////////////////////////////////////////////////////////////////////////// function show( idname ) { try { document.getElementById( idname ).style.display = ""; } catch(e) {} } function hide( idname ) { try { document.getElementById( idname ).style.display = "none"; } catch(e) {} } function getID(id) { if(document.all) return document.all(id); if(document.getElementById) return document.getElementById(id); } function setID(id, value) { if(document.all) return document.all(id).value = value; if(document.getElementById) return document.getElementById(id).value = value; } // 숫자 타입에서 쓸 수 있도록 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(); }; var PageLoading = 0; function auth_phone(mem_id, phone) { if(PageLoading == 0) { PageLoading = 1; $("#auth_phone_btn").hide(); $("#auth_phone_text").html('문자메세지를 발송중입니다. 잠시만 기다려주세요.'); $.ajax({ type: "GET", url: "/util/join_auth.php?mem_id=" + mem_id + "&phone=" + phone, async: true, success : function(data) { PageLoading = 0; if(data == "OK") { $("#mem_phone").prop('disabled', true); $("#mem_phone").css('background-color', '#EEE'); alert('인증문자가 발송되었습니다.'); $("#auth_phone_text").html('인증문자가 발송되었습니다.'); } else if(data == "USE") { alert('이미 가입한 이력이 있는 핸드폰 번호입니다.'); $("#auth_phone_text").html(''); $("#auth_phone_btn").show(); } else if(data == "STAY") { $("#mem_phone").prop('disabled', true); $("#mem_phone").css('background-color', '#EEE'); alert('이미 인증문자가 발송되었습니다. 한번 발급된 인증번호는 5분간 유효합니다.'); $("#auth_phone_text").html('이미 인증문자가 발송되었습니다. 한번 발급된 인증번호는 5분간 유효합니다.'); } else if(data == "ERROR") { alert('전화번호가 형식에 맞지 않거나 유효하지 않은 번호입니다.'); $("#auth_phone_text").html(''); $("#auth_phone_btn").show(); } else { alert('알 수 없는 오류가 발생하였습니다.'); $("#auth_phone_text").html('알 수 없는 오류가 발생하였습니다.'); } }, error:function(request,status,error){ PageLoading = 0; alert("페이지 통신중 오류가 발생했습니다.\n\ncode:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error); } }); } } // 회원가입 함수 function mem_join() { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/join_ok.php", { proc: "join", join_id: $('#join_id').val(), join_pass1: $('#join_pass1').val(), join_pass2: $('#join_pass2').val(), join_birth1: $('#join_birth1').val(), join_birth2: $('#join_birth2').val(), join_nick: $('#join_nick').val(), join_phone: $('#join_phone').val(), join_grade: $('#join_grade').val(), join_title: $('#join_title').val(), join_team: $('#join_team').val(), join_sign: $(':radio[name="join_sign"]:checked').val(), join_auth: $('#join_auth').val(), time: temp }).done(function( data ) { if(data == "OK") { alert("회원가입 완료되었습니다"); PageLoading = 0; location = '/'; } else { PageLoading = 0; alert(data); } }); } } // 회원로그인 함수 function mem_login() { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/login_ok.php", { proc: "login", mem_id: $('#mem_id').val(), mem_pass: $('#mem_pass').val(), mem_save: $('#mem_save').is(':checked'), time: temp }).done(function( data ) { if(data == "OK") { PageLoading = 0; location = '/'; } else { PageLoading = 0; alert(data); } }); } } // 출석체크 function attend_check(date) { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/attend_ok.php", { proc: "attend", date: date, time: temp }).done(function( data ) { if(data == "NONE") { alert('이미 출석체크 하였습니다.'); PageLoading = 0; location = '/?load=attend'; } else if(data == "OK") { alert('출석체크 하였습니다.'); PageLoading = 0; location = '/?load=attend'; } else { PageLoading = 0; alert(data); } }); } } var gacha_s = ""; // 캐릭터 뽑기 function gacha_data() { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/gacha_get.php", { proc: "get", time: temp }).done(function( data ) { if(data == "ERROR1") { alert("로그인 후 가챠 이용이 가능합니다."); } else if(data == "ERROR2") { alert("소지하신 원두가 부족합니다."); } else { gacha_s = data; $("#gacha_data").hide( "blind", {}, 500, gacha_data2); } PageLoading = 0; }); } } function gacha_data2() { $('#gacha_data').html(gacha_s); $("#gacha_data").show( "blind", {}, 500, null ); $('#gacha_rebtn').show(); } // 캐릭터 장착 function character_set(no) { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/char_set.php", { char_no: no, time: temp }).done(function( data ) { if(data == "ERROR1") { alert("로그인 후 장착 가능합니다."); } else if(data == "ERROR2") { alert("본인이 소유한 캐릭터가 아니면 장착할 수 없습니다."); } else if(data == "OK") { alert("캐릭터가 장착되었습니다."); } else { alert("알 수 없는 오류가 발생했습니다."); } PageLoading = 0; }); } } // 캐릭터 인첸트 function enchant_exp(no, order) { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/char_enchant.php", { no: no, order: order, time: temp }).done(function( data ) { if(data == "ERROR1") { alert("로그인 후 강화 가능합니다."); } else if(data == "ERROR2") { alert("본인이 소유한 캐릭터가 아니면 강화 할 수 없습니다."); } else if(data == "ERROR_BATTLE") { alert("대전등록상태에서는 강화할 수 없습니다."); } else { $('#card_board').hide(); $('#char_list').hide(); $('#char_enchant_data').html(data); $('#char_enchant_board').show(); } PageLoading = 0; }); } } // 캐릭터 인첸트 선택 function enchant_exp_sel(no, target_no) { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/char_enchant_sel.php", { no: no, target_no: target_no, time: temp }).done(function( data ) { PageLoading = 0; if(data == "ERROR1") { alert("로그인 후 강화 가능합니다."); } else if(data == "ERROR2") { alert("본인이 소유한 캐릭터가 아니면 강화 할 수 없습니다."); } else if(data == "ERROR_BATTLE") { alert("대전 덱으로 설정된 카드는 재료로 사용할 수 없습니다."); } else if(data == "OK") { enchant_exp(no); alert("강화 되었습니다."); } else { alert("알 수 없는 오류가 발생하였습니다."); } }); } } // 캐릭터 진화 function buildup_star(no) { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/char_buildup.php", { no: no, time: temp }).done(function( data ) { if(data == "ERROR1") { alert("로그인 후 진화 가능합니다."); } else if(data == "ERROR2") { alert("본인이 소유한 캐릭터가 아니면 진화 할 수 없습니다."); } else if(data == "ERROR_BATTLE") { alert("대전등록상태에서는 진화할 수 없습니다."); } else { $('#char_list').hide(); $('#char_enchant_data').html(data); $('#char_enchant_board').show(); } PageLoading = 0; }); } } // 캐릭터 진화 선택 function buildup_star_sel(no, target_no) { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/char_buildup_sel.php", { no: no, target_no: target_no, time: temp }).done(function( data ) { PageLoading = 0; if(data == "ERROR1") { alert("로그인 후 진화 가능합니다."); } else if(data == "ERROR2") { alert("본인이 소유한 캐릭터가 아니면 진화 할 수 없습니다."); } else if(data == "ERROR3") { alert("상위 카드가 없습니다."); } else if(data == "ERROR_BATTLE") { alert("대전 덱으로 설정된 카드는 재료로 사용할 수 없습니다."); } else if(data == "OK2") { alert("안타깝게도 진화에 실패하였습니다."); location = '/?load=char_set'; } else if(data == "OK") { alert("진화 되었습니다."); location = '/?load=char_set'; } else { alert("알 수 없는 오류가 발생하였습니다."); } }); } } // 카드댁 구성 function select_deck(no) { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/char_deck.php", { starting: no, time: temp }).done(function( data ) { PageLoading = 0; if(data == "ERROR1") { alert("로그인 후 덱 설정이 가능합니다."); } else if(data) { $('#ajax_html').html(data); } else { alert("알 수 없는 오류가 발생하였습니다."); } }); } } // 캐릭터 진화 선택 function select_deck_sel(no, target_no) { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/char_deck_sel.php", { starting: no, target_no: target_no, time: temp }).done(function( data ) { PageLoading = 0; if(data == "ERROR1") { alert("로그인 후 덱 설정이 가능합니다."); } else if(data == "ERROR2") { alert("본인이 소유한 캐릭터가 아니면 덱 설정을 할 수 없습니다."); } else if(data == "ERROR3") { alert("이미 동일한 이름의 캐릭터가 덱에 있습니다."); } else if(data == "ERROR4") { alert("코스트를 초과하였습니다."); } else if(data == "ERROR_BATTLE") { alert("전투 등록중에는 덱을 바꿀 수 없습니다."); } else if(data == "OK") { location = '/?load=battle'; } else { alert("알 수 없는 오류가 발생하였습니다."); } }); } } // 캐릭터 전투 리스트/등록/취소 처리 function battle_list(proc, page) { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/char_battle.php", { proc: proc, page: page, time: temp }).done(function( data ) { PageLoading = 0; if(data == "ERROR1") { alert("로그인 후 가능합니다."); } else if(data == "ERROR2") { alert("대전이 등록되어 있지 않습니다."); } else if(data == "ERROR3") { alert("이미 등록하신 대전이 있습니다."); } else if(data == "ERROR4") { alert("코스트를 초과하였습니다."); } else if(data == "ERROR5") { alert("구성중이신 덱에 중복캐릭터가 있습니다."); } else if(data == "ERROR6") { alert("덱이 모두 구성되어 있지 않습니다."); } else if(data == "ERROR7") { alert("원두가 부족합니다."); } else if(data == "ERROR8") { alert("전투 쿨타임 중입니다."); } else if(data == "OK") { location="/?load=battle"; } else { $('#battle_data').html(data); } }); } } // 캐릭터 전투 도전 처리 function battle_on(no) { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/char_battle_on.php", { no: no, time: temp }).done(function( data ) { PageLoading = 0; if(data == "ERROR1") { alert("로그인 후 가능합니다."); } else if(data == "ERROR2") { alert("해당 전투가 존재하지 않습니다."); battle_list('', '1'); } else if(data == "ERROR3") { alert("이미 다른 캐릭터에 의해 전투가 종료되었습니다."); battle_list('', '1'); } else if(data == "ERROR4") { alert("코스트를 초과하였습니다."); battle_list('', '1'); } else if(data == "ERROR5") { alert("구성중이신 덱에 중복캐릭터가 있습니다."); battle_list('', '1'); } else if(data == "ERROR6") { alert("덱이 모두 구성되어 있지 않습니다."); battle_list('', '1'); } else if(data == "ERROR7") { alert("원두가 부족합니다."); } else if(data == "ERROR8") { alert("전투 쿨타임 중입니다."); } else if(data == "OK") { location="/?load=battle"; } else { alert("알 수 없는 오류 입니다."); } }); } } // 내 리스트 구성 function shop_list(proc, page, cate) { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/char_shop.php", { proc: proc, page: page, cate: cate, time: temp }).done(function( data ) { PageLoading = 0; if(data == "ERROR1") { alert("로그인 후 덱 설정이 가능합니다."); } else { if(proc == "my" || proc == "my_sell") { $('#my_shop_list').html(data); } else { $('#shop_data').html(data); } } }); } } // 내 리스트 구성 function shop_list_sel(proc, no, price) { if(PageLoading == 0) { PageLoading = 1; var temptime = new Date(); var temp = temptime.getTime(); $.post( "/util/char_shop_sel.php", { proc: proc, no: no, price: price, time: temp }).done(function( data ) { PageLoading = 0; if(proc == "sell") { if(data == "ERROR1") { alert("로그인 후 설정이 가능합니다."); } else if(data == "ERROR2") { alert("보유중인 카드가 아닙니다."); } else if(data == "ERROR3") { alert("20원두 미만으로 가격을 책정할 수 없습니다."); } else if(data == "ERROR4") { alert("10만원두 이상으로 가격을 책정할 수 없습니다."); } else if(data == "ERROR5") { alert("5개 이상 판매하실 수 없습니다."); } else if(data == "ERROR_BATTLE") { alert("덱에 추가되어 있는 카드는 판매할 수 없습니다."); } else if(data == "OK") { alert("판매리스트에 추가되었습니다."); } else { alert("알 수 없는 오류 입니다."); } shop_list('my_sell', '1'); } else if(proc == "sell_cancel") { if(data == "ERROR1") { alert("로그인 후 설정이 가능합니다."); } else if(data == "ERROR2") { alert("보유중인 카드가 아닙니다."); } else if(data == "OK") { alert("판매리스트에 제외 되었습니다."); } else { alert("알 수 없는 오류 입니다."); } shop_list('my_sell', '1'); } else if(proc == "buy") { if(data == "ERROR1") { alert("로그인 후 설정이 가능합니다."); } else if(data == "ERROR2") { alert("해당 물품이 팔렸거나 취소 되었습니다."); } else if(data == "ERROR3") { alert("소지중인 원두가 부족합니다."); } else if(data == "ERROR4") { alert("본인이 판매중인 캐릭터입니다."); } else if(data == "OK") { alert("구매 되었습니다."); } else { alert("알 수 없는 오류 입니다."); } shop_list('list', '1'); } }); } } // 게시판 추천 function board_vote(no, option) { var temptime = new Date(); var temp = temptime.getTime(); if(PageLoading == 0) { PageLoading = 1; $.post( "/util/board_vote.php", { proc: option, no: no, temp: temp }).done(function( data ) { if(data == "ERROR1") { alert('로그인 후 추천 가능합니다.'); } else if(data == "ERROR2") { alert('이미 추천/비추천을 누른 상태입니다.'); } else if(data == "ERROR3") { alert('존재하지 않는 글입니다.'); } else if(data == "ERROR4") { alert('알 수 없는 추천입니다.'); } else if(data == "ERROR5") { alert('본인글에 추천 비추천을 할 수 없습니다.'); } else if(data.substr(0, 3) == "OK1") { var data2 = data.split("|"); $('#vote_like_val').html(data2[1]); } else if(data.substr(0, 3) == "OK2") { var data2 = data.split("|"); $('#vote_unlike_val').html(data2[1]); } else { alert('알 수 없는 오류입니다.'); } PageLoading = 0; }); } } // 게시판 리 댓글 function comment_re(no, nickname) { $("html, body").animate({ scrollTop: $('#scroll_end').offset().top }, 1000); $('#comment_parent').val(no); $('#comment_re_target').html('' + nickname + '님에게 댓글'); $('#board_comment').focus(); } function PageLoad(load, cate, page) { if(PageLoading == 0) { PageLoading = 1; $('#html_show').html("

통계 정보를 불러오고 있습니다.
"); $('.on_menu').removeClass('on_menu'); $('#cate_' + cate ).addClass('on_menu'); var gotourl; gotourl = ""; gotourl += "load=" + load; if(cate != undefined) { gotourl += "&cate=" + cate; } if(page != undefined) { gotourl += "&page=" + page; } if($('#userid').val() != undefined) { gotourl += "&userid=" + $('#userid').val(); } if($('#cate1').val() != undefined && $('#cate1').val() != "") { gotourl += "&cate1=" + $('#cate1').val(); } if($('#cate2').val() != undefined && $('#cate2').val() != "") { gotourl += "&cate2=" + $('#cate2').val(); } if($('#cate3').val() != undefined && $('#cate3').val() != "") { gotourl += "&cate3=" + $('#cate3').val(); } if($('#datediff_day').val() != undefined && $('#datediff_day').val() != "") { gotourl += "&datediff_day=" + $('#datediff_day').val(); } if($('#date_diff_week').val() != undefined && $('#date_diff_week').val() != "") { gotourl += "&date_diff_week=" + $('#date_diff_week').val(); } if($('#date_seach').val() != undefined && $('#date_seach').val() != "") { gotourl += "&date_seach=" + $('#date_seach').val(); } $.ajax({ type: "GET", url: "/view.php?" + gotourl, async: true, success : function(data) { PageLoading = 0; $('#html_show').html(data); }, error:function(request,status,error){ PageLoading = 0; alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error); } }); } else { $('#html_show').html("

조금만 기다려주세요.
"); } } ////////////////////////////////////////////////////////////////////////////////////////////////// // 기타 편의함수 ////////////////////////////////////////////////////////////////////////////////////////////////// function InStr(strSearch, charSearchFor) { for (i=0; i < strSearch.length; i++) { if (charSearchFor == Mid(strSearch, i, 1)) { return i; } } return -1; } function Mid(str, start, len) { if (start < 0 || len < 0) return ""; var iEnd, iLen = String(str).length; if (start + len > iLen) iEnd = iLen; else iEnd = start + len; return String(str).substring(start,iEnd); } function requestFullScreen(element) { // Supports most browsers and their versions. var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullScreen; if (requestMethod) { // Native full screen. requestMethod.call(element); } else if (typeof window.ActiveXObject !== "undefined") { // Older IE. var wscript = new ActiveXObject("WScript.Shell"); if (wscript !== null) { wscript.SendKeys("{F11}"); } } }