153 lines
4.4 KiB
JavaScript
Raw Normal View History

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) {
}
}
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!');
}
}
}
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) {
location = location.protocol + "//" + location.hostname + ":" + location.port
} else {
location = location.protocol + "//" + location.hostname
}
}
2024-10-25 18:28:25 +09:00
function gotoLogin() {
console.log(`location.port >> ${location.port}`)
location.href = getMainPath()+"/login"
}
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,
}
post(getMainPath()+"/user/login.ajax",type,JSON.stringify(data),keyword, function (resultData) {
alert(resultData)
})
}
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)
}