2024-12-02 18:32:14 +09:00
|
|
|
|
|
|
|
|
onload = function() {
|
|
|
|
|
history.replaceState({}, null, location.pathname);
|
2025-03-20 17:57:55 +09:00
|
|
|
// var accToken = get_cookie("access")
|
|
|
|
|
// var refreshToken = get_cookie("refresh")
|
|
|
|
|
// console.log("access === " + accToken + " || " + accToken.length);
|
|
|
|
|
// console.log("refresh === " + refreshToken + " || " + refreshToken.length);
|
2025-03-10 17:55:48 +09:00
|
|
|
document.cookie = "access=; expires=Thu, 01 Jan 1970 00:00:01 GMT;"
|
|
|
|
|
document.cookie = "refresh=; expires=Thu, 01 Jan 1970 00:00:01 GMT;"
|
|
|
|
|
document.cookie = "CLEAR=; expires=Thu, 01 Jan 1970 00:00:01 GMT;"
|
2025-01-03 16:57:31 +09:00
|
|
|
}
|
2025-03-20 17:57:55 +09:00
|
|
|
// onbeforeunload = function () {
|
|
|
|
|
// var accToken = get_cookie("access")
|
|
|
|
|
// var refreshToken = get_cookie("refresh")
|
|
|
|
|
// console.log("access === " + accToken + " || " + accToken.length);
|
|
|
|
|
// console.log("refresh === " + refreshToken + " || " + refreshToken.length);
|
|
|
|
|
//
|
|
|
|
|
// if (accToken.length < 1) {
|
|
|
|
|
// document.cookie = "refresh="+ window.sessionStorage.getItem("REFRESH") + ";";
|
|
|
|
|
// }
|
|
|
|
|
// if (refreshToken.length < 1) {
|
|
|
|
|
// window.sessionStorage.setItem("REFRESH",get_cookie("refresh"))
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2025-01-03 16:57:31 +09:00
|
|
|
function get_cookie(name) {
|
|
|
|
|
var value = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
|
|
|
|
|
return value? value[2] : null;
|
2024-12-02 18:32:14 +09:00
|
|
|
}
|
|
|
|
|
|
2024-10-07 16:14:03 +09:00
|
|
|
function divider(key) {
|
|
|
|
|
return merge(padding(),key,padding())
|
|
|
|
|
}
|
|
|
|
|
function padding() {
|
|
|
|
|
return "%7C%2A-%2A%7C";
|
|
|
|
|
}
|
|
|
|
|
function merge(...args) {
|
|
|
|
|
return args.join("");
|
|
|
|
|
}
|
|
|
|
|
function unformat(type , data, key) {
|
|
|
|
|
var even = [];
|
|
|
|
|
var odd = [];
|
|
|
|
|
data.split("").forEach(function (v,idx,full) {if(idx % 2 === 0) {even.push(v)} else {odd.push(v)}});
|
|
|
|
|
switch (type) {
|
|
|
|
|
case "T0": return merge(odd.join(""),divider(key),even.join(""));
|
|
|
|
|
case "T1": return merge(odd.reverse().join(""),divider(key),even.join(""));
|
|
|
|
|
case "T2": return merge(odd.join(""),divider(key),even.reverse().join(""));
|
|
|
|
|
default: return merge(odd.reverse().join(""),divider(key),even.reverse().join(""));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function checkDebug(){
|
|
|
|
|
var debug = false
|
|
|
|
|
try {
|
|
|
|
|
debug = typeof v8debug === 'object'
|
|
|
|
|
|| /--debug|--inspect/.test(process.execArgv.join(' '));
|
|
|
|
|
alert(debug)
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const inspector = require('inspector');
|
|
|
|
|
debug = inspector.url() !== undefined;
|
|
|
|
|
alert(debug)
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-02 18:32:14 +09:00
|
|
|
var acpt_key = ""
|
2024-10-07 16:14:03 +09:00
|
|
|
function post(target,type, data, key,callBackResult) {
|
|
|
|
|
var httpRequest;
|
|
|
|
|
/* 통신에 사용 될 XMLHttpRequest 객체 정의 */
|
|
|
|
|
httpRequest = new XMLHttpRequest();
|
|
|
|
|
/* httpRequest의 readyState가 변화했을때 함수 실행 */
|
|
|
|
|
httpRequest.onreadystatechange = () => {
|
|
|
|
|
/* readyState가 Done이고 응답 값이 200일 때, 받아온 response로 name과 age를 그려줌 */
|
|
|
|
|
if (httpRequest.readyState === XMLHttpRequest.DONE) {
|
|
|
|
|
if (httpRequest.status === 200) {
|
|
|
|
|
callBackResult(httpRequest.response)
|
|
|
|
|
} else {
|
|
|
|
|
alert('Request Error!');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-12-02 18:32:14 +09:00
|
|
|
|
|
|
|
|
httpRequest.open('POST', target, true);
|
|
|
|
|
httpRequest.setRequestHeader("Content-Type", "text/plain");
|
|
|
|
|
var odd = []
|
|
|
|
|
var even = []
|
|
|
|
|
var dataStr = JSON.stringify(data)
|
|
|
|
|
var src = dataStr.split("")
|
|
|
|
|
src.forEach(function (s,i,a) {if (i % 2 === 0) {even.push(s)} else {odd.push(s)}})
|
|
|
|
|
httpRequest.send(btoa(JSON.stringify({
|
|
|
|
|
'data': unformat(type,data,key),
|
|
|
|
|
'key':key,
|
|
|
|
|
'type':type,
|
|
|
|
|
})));
|
|
|
|
|
}
|
|
|
|
|
function postLogin(target,type, data, key,callBackResult) {
|
|
|
|
|
var httpRequest;
|
|
|
|
|
/* 통신에 사용 될 XMLHttpRequest 객체 정의 */
|
|
|
|
|
httpRequest = new XMLHttpRequest();
|
|
|
|
|
/* httpRequest의 readyState가 변화했을때 함수 실행 */
|
|
|
|
|
httpRequest.onreadystatechange = () => {
|
|
|
|
|
/* readyState가 Done이고 응답 값이 200일 때, 받아온 response로 name과 age를 그려줌 */
|
|
|
|
|
if (httpRequest.readyState === XMLHttpRequest.DONE) {
|
|
|
|
|
if (httpRequest.status === 200) {
|
|
|
|
|
try {
|
2024-12-05 18:15:20 +09:00
|
|
|
var data = JSON.parse(httpRequest.response)
|
|
|
|
|
callBackResult(data)
|
2024-12-02 18:32:14 +09:00
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
alert('Request Error!');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-03 16:57:31 +09:00
|
|
|
|
2024-10-07 16:14:03 +09:00
|
|
|
httpRequest.open('POST', target, true);
|
|
|
|
|
httpRequest.setRequestHeader("Content-Type", "text/plain");
|
|
|
|
|
var odd = []
|
|
|
|
|
var even = []
|
|
|
|
|
var dataStr = JSON.stringify(data)
|
|
|
|
|
var src = dataStr.split("")
|
|
|
|
|
src.forEach(function (s,i,a) {if (i % 2 === 0) {even.push(s)} else {odd.push(s)}})
|
|
|
|
|
httpRequest.send(btoa(JSON.stringify({
|
|
|
|
|
'data': unformat(type,data,key),
|
|
|
|
|
'key':key,
|
|
|
|
|
'type':type,
|
|
|
|
|
})));
|
|
|
|
|
}
|
2024-10-23 17:06:27 +09:00
|
|
|
|
|
|
|
|
function mainPath() {
|
|
|
|
|
console.log(`location.port >> ${location.port}`)
|
|
|
|
|
if ('443' === location.port) {
|
2024-12-06 18:27:51 +09:00
|
|
|
document.location.replace(location.protocol + "//" + location.hostname + ":" + location.port)
|
2024-10-23 17:06:27 +09:00
|
|
|
} else {
|
2024-12-06 18:27:51 +09:00
|
|
|
document.location.replace(location.protocol + "//" + location.hostname)
|
2024-10-23 17:06:27 +09:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-04 18:01:50 +09:00
|
|
|
function gotoWrite() {
|
2024-12-06 18:27:51 +09:00
|
|
|
document.location.replace(getMainPath()+"/blog/write")
|
2024-12-04 18:01:50 +09:00
|
|
|
}
|
2024-10-25 18:28:25 +09:00
|
|
|
|
2024-12-04 18:01:50 +09:00
|
|
|
function gotoModify() {
|
2024-12-06 18:27:51 +09:00
|
|
|
document.location.replace(getMainPath()+"/blog/modify")
|
2024-12-04 18:01:50 +09:00
|
|
|
}
|
2024-12-02 18:32:14 +09:00
|
|
|
|
2024-12-04 18:01:50 +09:00
|
|
|
function gotoWhere() {
|
2024-12-06 18:27:51 +09:00
|
|
|
document.location.replace(getMainPath()+"/bums/where")
|
2024-12-04 18:01:50 +09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function logout() {
|
|
|
|
|
// retrieve all cookies
|
|
|
|
|
document.cookie = "access=; expires=Thu, 01 Jan 1970 00:00:01 GMT;"
|
|
|
|
|
document.cookie = "refresh=; expires=Thu, 01 Jan 1970 00:00:01 GMT;"
|
2025-03-10 17:55:48 +09:00
|
|
|
|
|
|
|
|
console.log(document.cookie["JSESSIONID"])
|
|
|
|
|
document.cookie = "JSESSIONID=; expires=Thu, 01 Jan 1970 00:00:01 GMT;"
|
|
|
|
|
document.cookie = "CLEAR="+Date.now()+"";
|
2024-12-02 18:32:14 +09:00
|
|
|
let logOutUrl = getMainPath() + "/user/logout.ajax";
|
|
|
|
|
post(logOutUrl,"","","", function (resultData) {
|
2024-12-05 18:15:20 +09:00
|
|
|
alert("로그아웃 됨요~! 빠염~!")
|
|
|
|
|
document.location.replace(document.location)
|
2024-12-02 18:32:14 +09:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-25 18:28:25 +09:00
|
|
|
function gotoLogin() {
|
|
|
|
|
console.log(`location.port >> ${location.port}`)
|
|
|
|
|
location.href = getMainPath()+"/login"
|
|
|
|
|
}
|
|
|
|
|
|
2024-12-05 18:15:20 +09:00
|
|
|
function gotoJoin() {
|
|
|
|
|
document.location.replace(getMainPath() + "/user/join")
|
|
|
|
|
}
|
2024-10-25 18:28:25 +09:00
|
|
|
|
|
|
|
|
function goToView(path,id) {
|
|
|
|
|
location.href = path + id;
|
|
|
|
|
}
|
|
|
|
|
function onclickLogin(type, keyword) {
|
|
|
|
|
let user_id = document.getElementById('user_id')
|
|
|
|
|
let user_pw = document.getElementById('user_pw')
|
|
|
|
|
let data = {
|
|
|
|
|
'user_id': user_id.value,
|
|
|
|
|
'user_pw': user_pw.value,
|
|
|
|
|
}
|
2024-12-05 18:15:20 +09:00
|
|
|
postLogin(getMainPath()+"/user/login.ajax",type,JSON.stringify(data),keyword, function (data) {
|
|
|
|
|
if (data.isOk) {
|
2025-01-03 16:57:31 +09:00
|
|
|
|
2024-12-05 18:15:20 +09:00
|
|
|
document.cookie = "access=" + data.token.split(";")[0]+";"
|
2025-01-03 16:57:31 +09:00
|
|
|
// document.cookie = "refresh=" + data.refresh.split(";")[0]+";"
|
|
|
|
|
// window.sessionStorage.setItem("ACCESS",data.refresh.split(";")[0])
|
|
|
|
|
window.sessionStorage.setItem("REFRESH",data.refresh.split(";")[0])
|
2024-12-05 18:15:20 +09:00
|
|
|
document.location.replace(document.location)
|
|
|
|
|
} else {
|
|
|
|
|
if (data.resultCode === 7100) {
|
|
|
|
|
if(confirm(`너 누구임 정보 없는데?!\n${data.resultMsg}[${data.resultCode}]\n가입 할래!?`)){
|
|
|
|
|
document.location.replace(getMainPath() + "/user/join")
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
alert(`너 누구임?!\n${data.resultMsg}[${data.resultCode}]`)
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-25 18:28:25 +09:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2024-10-23 17:06:27 +09:00
|
|
|
function getMainPath() {
|
|
|
|
|
console.log(`location.port >> ${location.port}`)
|
|
|
|
|
if ('443' === location.port) {
|
|
|
|
|
return location.protocol + "//" + location.hostname + ":" + location.port
|
|
|
|
|
} else {
|
|
|
|
|
return location.protocol + "//" + location.hostname
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openPopup(a) {
|
|
|
|
|
|
|
|
|
|
var $href = $(a).attr('to');
|
|
|
|
|
document.querySelectorAll('[id*=popLayer]').forEach(function (v,k,p) {
|
|
|
|
|
$(v).hide();
|
|
|
|
|
});
|
|
|
|
|
layer_popup($href);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function layer_popup(el){
|
|
|
|
|
var $el = $(el); //레이어의 id를 $el 변수에 저장
|
|
|
|
|
|
|
|
|
|
var isDim = true ;//$(document).hasClass('dimBg'); //dimmed 레이어를 감지하기 위한 boolean 변수
|
|
|
|
|
isDim ? $('.dim_layer').fadeIn() : $el.fadeIn();
|
|
|
|
|
$el.show()
|
|
|
|
|
var $elWidth = ~~($el.outerWidth()),
|
|
|
|
|
$elHeight = ~~($el.outerHeight()),
|
|
|
|
|
docWidth = $(document).width(),
|
|
|
|
|
docHeight = $(document).height();
|
|
|
|
|
|
|
|
|
|
// 화면의 중앙에 레이어를 띄운다.
|
|
|
|
|
if ($elHeight < docHeight || $elWidth < docWidth) {
|
|
|
|
|
$el.css({
|
|
|
|
|
marginTop: -$elHeight /2,
|
|
|
|
|
marginLeft: -$elWidth/2
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
$el.css({top: 0, left: 0});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$el.find('a.btn_layerClose').click(function(){
|
|
|
|
|
isDim ? $('.dim_layer').fadeOut() : $el.fadeOut(); // 닫기 버튼을 클릭하면 레이어가 닫힌다.
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('.dimBg').click(function(){
|
|
|
|
|
$('.dim_layer').fadeOut();
|
|
|
|
|
return false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function urldecode(t){
|
|
|
|
|
return decodeURI(t)
|
|
|
|
|
}
|