This commit is contained in:
shim
2023-04-17 11:06:08 +09:00
parent d0b393aa97
commit 76264e09ad
4686 changed files with 552713 additions and 0 deletions

View File

@@ -0,0 +1,161 @@
/**
* --------------------------------------------------------------------------
* kimsQ Rb v2.4 데스크탑 시작하기 레이아웃 스크립트 (bs4-starter)
* Homepage: http://www.kimsq.com
* Licensed under RBL
* Copyright 2019 redblock inc
* --------------------------------------------------------------------------
*/
var noti_sort = 'uid';
var noti_orderby = 'desc';
var noti_recnum = '10';
$('[data-plugin="timeago"]').timeago(); // 상대시간 플러그인 초기화
// 사용자 액션에 대한 피드백 메시지 제공을 위해 액션 실행후 쿠키에 저장된 결과 메시지를 출력시키고 초기화 시킵니다.
putCookieAlert('site_common_result') // 실행결과 알림 메시지 출력
$(document).ready(function() {
// navbar dropdown 로그인 - 실행
$('#popover-loginform').submit(function(e){
e.preventDefault();
e.stopPropagation();
var form = $(this)
siteLogin(form)
});
// navbar dropdown 로그인 - 로그인 영역 내부 클릭시 dropdown 닫히지 않도록
$(document).on('click', '#navbarPopoverLogin .dropdown-menu', function (e) {
e.stopPropagation();
});
// navbar dropdown 로그인 - dropdown 열릴때
$('#navbarPopoverLogin').on('shown.bs.dropdown', function () {
$(this).find('[name=id]').focus() // 아이디 focus
$(this).find('.form-control').val('').removeClass('is-invalid') //에러이력 초기화
})
$(document).on('keyup','#popover-loginform .form-control',function(){
$(this).removeClass('is-invalid') //에러 흔적 초기화
});
// navbar dropdown 내알림보기 - dropdown 열릴때
$('#navbarPopoverNoti').on('show.bs.dropdown', function () {
var dropdown = $(this)
var mobile = ''
$('.js-tooltip').tooltip('hide')
dropdown.attr('data-original-title','')
dropdown.find('[data-role="noti-list"]').isLoading({
text: "불러오는중...",
position: "inside"
});
$.post(rooturl+'/?r='+raccount+'&m=notification&a=get_notiList',{
sort: noti_sort,
orderby: noti_orderby,
recnum: noti_recnum,
callMod: 'unread'
},function(response){
var result = $.parseJSON(response);
var content=result.content;
dropdown.find('[data-role="noti-list"]').html(content);
dropdown.find('[data-plugin="timeago"]').timeago();
dropdown.find('[data-role="noti-status"]').text('');
});
})
// navbar dropdown 알림보기 - dropdown 닫힐때
$('#navbarPopoverNoti').on('hidden.bs.dropdown', function () {
var dropdown = $(this)
dropdown.attr('data-original-title','알림')
dropdown.find('[data-role="noti-list"]').html('');
})
//modal 로그인 - 실행
$('#modal-login').find('form').submit(function(e){
e.preventDefault();
e.stopPropagation();
var form = $(this)
siteLogin(form)
});
// modal 로그인 - modal 열릴때
$('#modal-login').on('shown.bs.modal', function () {
$(this).find('[name=id]').focus() // 아이디 focus
$(this).find('.form-control').val('').removeClass('is-invalid') //에러 흔적 초기화
})
$("#modal-login").find('.form-control').keyup(function() {
$(this).removeClass('is-invalid') //에러 흔적 초기화
});
//modal 변경
$(document).on('click','[data-toggle="changeModal"]', function (e) {
var $this = $(this)
var href = $this.attr('href')
var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, '')))
var $start = $($this.closest('.modal'))
if ($this.is('a')) e.preventDefault()
$start.modal('hide')
setTimeout(function(){ $target.modal({show:true,backdrop:'static'}); }, 300);
});
$('[data-toggle="tooltip"]').tooltip() // 툴팁 플러그인 초기화
$('.js-tooltip').tooltip();
initPhotoSwipeFromDOM('[data-plugin="photoswipe"]'); // 포토갤러리 초기화
//외부서비스 사용자 인증요청
$('[data-connect]').on("click", function(){
var provider = $(this).data('connect')
// /core/engine/cssjs.engine.php 참고
if (provider=='naver') var target = connect_naver
if (provider=='kakao') var target = connect_kakao
if (provider=='google') var target = connect_google
if (provider=='facebook') var target = connect_facebook
if (provider=='instagram') var target = connect_instagram
var referer = window.location.href // 연결후, 원래 페이지 복귀를 위해
$("body").isLoading({
text: "연결 중..",
position: "overlay"
});
$.post(rooturl+'/?r='+raccount+'&m=connect&a=save_referer',{
referer : referer
},function(response,status){
if(status=='success'){
document.location = target;
}else{
alert(status);
}
});
});
// 로그아웃
$('[data-act="logout"]').click(function(){
$('body').isLoading({
position: 'inside',
text: '<div class="d-flex justify-content-center align-items-center"><div class="spinner-border" role="status"><span class="sr-only">Loading...</span></div></div>',
});
getIframeForAction('');
setTimeout(function(){
frames.__iframe_for_action__.location.href = '/?r=home&m=site&a=logout';
}, 100);
});
// history.back
$(document).on('click','[data-history="back"]',function(){
window.history.back();
});
$('[data-toggle="searchbox"]').click(function(){
$('.header').toggleClass('searching')
$('.header [data-role="searchbox"] input').val('').focus()
});
})

View File

@@ -0,0 +1,271 @@
/**
* --------------------------------------------------------------------------
* FCM(Firebase 클라우드 메시징)을 활용한 포그라운드 알림 처리 (데스크탑 전용)
* 참조코드 : https://github.com/firebase/quickstart-js/tree/master/messaging
* Licensed under an Apache-2 license.
* Firebase Quickstart Samples for Web https://firebase.google.com
* --------------------------------------------------------------------------
*/
firebase.initializeApp({'messagingSenderId': fcmSenderId});
const messaging = firebase.messaging();
messaging.usePublicVapidKey(fcmVAPID); //FCM 웹 푸시 인증서 키쌍(VAPID)
const permissionDivId = 'permission_div';
const permissionAlertId = 'permission_alert';
const tokenDivId = 'token_div';
const pushSettingId = 'push_setting';
const pushDisabledId = 'push_disabled';
const modalNoti = $('#modal-noti');
if (isNewUser(memberid)) {
console.log('새 사용자로 로그인 되었습니다.')
deleteToken() // 기존 토큰 삭제
window.localStorage.clear(); // 로컬 스토리지 초기화
}
// 인스턴스 ID 토큰이 업데이트되면 콜백이 시작됩니다.
messaging.onTokenRefresh(function() {
messaging.getToken().then(function(refreshedToken) {
console.log('토큰이 새로고침 되었습니다.'); // 새 인스턴스 ID 토큰이 아직 전송되지 않았 음을 나타냅니다.
setTokenSentToServer(false);
sendTokenToServer(refreshedToken); // 인스턴스 ID 토큰을 앱 서버로 전송합니다.
resetNotiUI(); // 새로운 인스턴스 ID 토큰을 표시하고 모든 이전 메시지의 UI를 지웁니다.
}).catch(function(err) {
console.log('새로 변경된 토큰을 검색 할 수 없습니다. ', err);
});
});
// - 앱에 포커스가 있는 동안 메시지가 수신됩니다.
messaging.onMessage(function(payload) {
console.log('메시지가 도착했습니다. ', payload);
var result = JSON.stringify(payload, null, 2);
var msg = JSON.parse(result);
var title=msg.notification.title;
var mbody=msg.notification.body;
var icon=msg.notification.icon;
var _mbody = mbody.replace(/(\n|\r\n)/g, '<br>');
console.log(_mbody)
$.notify({
icon: icon,
title: title,
message: mbody
}, {
type: 'media',
delay: 3000,
icon_type: 'image',
template: '<div data-notify="container" class="col-xs-11 col-sm-3 alert alert-{0}" role="alert">' +
'<img data-notify="icon" class="img-circle pull-left">' +
'<span data-notify="title">{1}</span>' +
'<span data-notify="message">{2}</span>' +
'</div>'
});
});
function resetNotiUI() {
clearMessages();
showToken('처리중...');
setMemberId(memberid) // 로그인 사용자의 아이디를 로컬 스토리지에 저장
// Get Instance ID token. Initially this makes a network call, once retrieved
// subsequent calls to getToken will return from cache. 이후의 getToken의 호출은 캐쉬로부터 돌아옵니다.
messaging.getToken().then(function(currentToken) {
if (currentToken) {
sendTokenToServer(currentToken);
updateUIForPushEnabled(currentToken);
} else {
// Show permission request.
if (!isRequestPermission()) {
setRequestPermission(false)
}
console.log('사용할수 있는 인스턴스 ID 토큰이 없습니다. 알림권한을 요청하십시오.');
// 알림권한요청 UI 를 보여줌.
setTimeout(function(){
updateUIForPushPermissionRequired();
}, 1000);
setTokenSentToServer(false);
}
}).catch(function(err) {
console.log('알림권한이 없거나 토큰을 검색하는 중 오류가 발생했습니다. ', err);
updateUIForPushDisabled()
setRequestPermission(false)
});
}
function showToken(currentToken) {
// 콘솔과 페이지에서 토큰을 보여줌
var tokenElement = document.querySelector('.token');
if (tokenElement) {
tokenElement.textContent = currentToken;
}
}
// Rb2에 인스턴스 ID 토큰을 보내세요.:
// - 이 앱으로 메시지를 다시 보내세요.
// - 주제 토큰 구독 / 탈퇴
function sendTokenToServer(currentToken) {
if (!isTokenSentToServer()) {
console.log('Rb2 서버에 토큰 보내기 중 ...');
var agent = navigator.userAgent, match;
var browser, version;
if((match = agent.match(/MSIE ([0-9]+)/)) || (match = agent.match(/Trident.*rv:([0-9]+)/))) browser = 'Internet Explorer';
else if(match = agent.match(/Chrome\/([0-9]+)/)) browser = 'Chrome';
else if(match = agent.match(/Firefox\/([0-9]+)/)) browser = 'Firefox';
else if(match = agent.match(/Safari\/([0-9]+)/)) browser = 'Safari';
else if((match = agent.match(/OPR\/([0-9]+)/)) || (match = agent.match(/Opera\/([0-9]+)/))) browser = 'Opera';
else browser = 'Unknown';
if(browser !== 'Unknown') version = match[1];
$.post(rooturl+'/?r='+raccount+'&m=notification&a=save_token',{
browser : browser,
version : version,
token : currentToken
},function(response){
var result = $.parseJSON(response);
console.log('토큰이 저장되었습니다.' + currentToken)
});
setTokenSentToServer(true);
} else {
console.log('토큰이 이미 서버에 전송 되었으므로 토큰이 변경되지 않는한 재전송되지 않습니다.');
}
}
function isTokenSentToServer() {
return window.localStorage.getItem('sentToServer') == 1;
}
function setTokenSentToServer(sent) {
window.localStorage.setItem('sentToServer', sent ? 1 : 0);
}
function isRequestPermission() {
return window.localStorage.getItem('setRequestPermission') == 1;
}
function setRequestPermission(allow) {
window.localStorage.setItem('setRequestPermission', allow ? 1 : 0);
}
function isNewUser(memberid) {
return window.localStorage.getItem('setMemberId') != memberid;
}
function setMemberId(memberid) {
window.localStorage.setItem('setMemberId', memberid ? memberid : 0);
}
function showHideDiv(divId, show) {
const div = document.querySelector('#' + divId);
if (div) {
if (show) {
div.style = 'display: visible';
} else {
div.style = 'display: none';
}
}
}
function requestPermission() {
console.log('권한 요청 중 ...');
messaging.requestPermission().then(function() {
var nt_web = ''; //알림수신
var nt_fcm = '1'; //푸시 알림수신
console.log('알림권한이 부여 되었습니다.');
$.notify({message: '알림권한이 부여 되었습니다.'});
resetNotiUI();
$.post(rooturl+'/?r='+raccount+'&m=notification&a=notice_config_user',{
sendAjax : true,
nt_web : nt_web,
nt_email : nt_email,
nt_fcm : nt_fcm
},function(response){
var result = $.parseJSON(response);
var error=result.error;
if (!error) console.log('웹알림/푸시알림 수신처리 되었습니다.')
});
}).catch(function(err) {
var nt_fcm = '';
showHideDiv(permissionAlertId, false);
showHideDiv(permissionDivId, false);
showHideDiv(pushDisabledId, true);
console.log('알림을 실행 할수있는 권한이 없습니다.', err);
$.notify({message: '알림 권한이 차단 되었습니다.'},{type: 'danger'});
});
}
function deleteToken() {
// 인스턴스 ID 토큰 삭제.
// [START delete_token]
messaging.getToken().then(function(currentToken) {
messaging.deleteToken(currentToken).then(function() {
console.log('토큰이 삭제 되었습니다.');
setTokenSentToServer(false);
// [START_EXCLUDE]
// 토큰이 삭제되면 관련 UI를 업데이트 합니다..
resetNotiUI();
// [END_EXCLUDE]
}).catch(function(err) {
console.log('토큰을 삭제할 수 없습니다. ', err);
});
// [END delete_token]
}).catch(function(err) {
console.log('인스턴스 ID 토큰을 가져 오는 중 오류가 발생했습니다. ', err);
});
}
// 메시지 모달을 닫고 내용을 초기화 합니다.
function clearMessages() {
modalNoti.modal('hide')
}
function updateUIForPushEnabled(currentToken) {
showHideDiv(permissionAlertId, false);
showHideDiv(tokenDivId, true);
showHideDiv(pushSettingId, true);
showHideDiv(permissionDivId, false);
showToken(currentToken);
}
function updateUIForPushDisabled() {
showHideDiv(pushDisabledId, true);
showHideDiv(permissionAlertId, false);
}
function updateUIForPushPermissionRequired() {
if (!isRequestPermission()) {
console.log('브라우저 알림 권한요청 이력이 없음')
if (!nt_web) {
showHideDiv(permissionAlertId, true);
} else {
console.log('사용자의 모든 알림수신을 차단하였습니다.')
}
} else {
console.log('브라우저 알림 권한요청 이력이 있음')
showHideDiv(permissionDivId, true);
}
}
//알림권한 요청 alert가 닫혔을때(나중에 설정)
$('#permission_alert').on('closed.bs.alert', function () {
$.notify({message: '설정 페이지에서 다시 권한설정 할 수 있습니다.'},{type: 'primary'});
setRequestPermission(true) // 요청이력을 로컬 스토리지에 저장하여 이후에 띄우지 않음
showHideDiv(permissionDivId, true);
})
resetNotiUI();

View File

@@ -0,0 +1,199 @@
/*! PhotoSwipe
* http://photoswipe.com
* Copyright (c) 2017 Dmitry Semenov; */
var initPhotoSwipeFromDOM = function(gallerySelector) {
// parse slide data (url, title, size ...) from DOM elements
// (children of gallerySelector)
var parseThumbnailElements = function(el) {
var thumbElements = el.childNodes,
numNodes = thumbElements.length,
items = [],
figureEl,
linkEl,
size,
item;
for(var i = 0; i < numNodes; i++) {
figureEl = thumbElements[i]; // <figure> element
// include only element nodes
if(figureEl.nodeType !== 1) {
continue;
}
linkEl = figureEl.children[0]; // <a> element
size = linkEl.getAttribute('data-size').split('x');
// create slide object
item = {
src: linkEl.getAttribute('href'),
w: parseInt(size[0], 10),
h: parseInt(size[1], 10)
};
if(figureEl.children.length > 1) {
// <figcaption> content
item.title = figureEl.children[1].innerHTML;
}
if(linkEl.children.length > 0) {
// <img> thumbnail element, retrieving thumbnail url
item.msrc = linkEl.children[0].getAttribute('src');
}
item.el = figureEl; // save link to element for getThumbBoundsFn
items.push(item);
}
return items;
};
// find nearest parent element
var closest = function closest(el, fn) {
return el && ( fn(el) ? el : closest(el.parentNode, fn) );
};
// triggers when user clicks on thumbnail
var onThumbnailsClick = function(e) {
e = e || window.event;
e.preventDefault ? e.preventDefault() : e.returnValue = false;
var eTarget = e.target || e.srcElement;
// find root element of slide
var clickedListItem = closest(eTarget, function(el) {
return (el.tagName && el.tagName.toUpperCase() === 'FIGURE');
});
if(!clickedListItem) {
return;
}
// find index of clicked item by looping through all child nodes
// alternatively, you may define index via data- attribute
var clickedGallery = clickedListItem.parentNode,
childNodes = clickedListItem.parentNode.childNodes,
numChildNodes = childNodes.length,
nodeIndex = 0,
index;
for (var i = 0; i < numChildNodes; i++) {
if(childNodes[i].nodeType !== 1) {
continue;
}
if(childNodes[i] === clickedListItem) {
index = nodeIndex;
break;
}
nodeIndex++;
}
if(index >= 0) {
// open PhotoSwipe if valid index found
openPhotoSwipe( index, clickedGallery );
}
return false;
};
// parse picture index and gallery index from URL (#&pid=1&gid=2)
var photoswipeParseHash = function() {
var hash = window.location.hash.substring(1),
params = {};
if(hash.length < 5) {
return params;
}
var vars = hash.split('&');
for (var i = 0; i < vars.length; i++) {
if(!vars[i]) {
continue;
}
var pair = vars[i].split('=');
if(pair.length < 2) {
continue;
}
params[pair[0]] = pair[1];
}
if(params.gid) {
params.gid = parseInt(params.gid, 10);
}
return params;
};
var openPhotoSwipe = function(index, galleryElement, disableAnimation, fromURL) {
var pswpElement = document.querySelectorAll('.pswp-gallery')[0],
gallery,
options,
items;
items = parseThumbnailElements(galleryElement);
// define options (if needed)
options = {
// define gallery index (for URL)
galleryUID: galleryElement.getAttribute('data-pswp-uid'),
};
// PhotoSwipe opened from URL
if(fromURL) {
if(options.galleryPIDs) {
// parse real index when custom PIDs are used
// http://photoswipe.com/documentation/faq.html#custom-pid-in-url
for(var j = 0; j < items.length; j++) {
if(items[j].pid == index) {
options.index = j;
break;
}
}
} else {
// in URL indexes start from 1
options.index = parseInt(index, 10) - 1;
}
} else {
options.index = parseInt(index, 10);
}
// exit if index not found
if( isNaN(options.index) ) {
return;
}
if(disableAnimation) {
options.showAnimationDuration = 0;
}
// Pass data to PhotoSwipe and initialize it
gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
gallery.init();
};
// loop through all gallery elements and bind events
var galleryElements = document.querySelectorAll( gallerySelector );
for(var i = 0, l = galleryElements.length; i < l; i++) {
galleryElements[i].setAttribute('data-pswp-uid', i+1);
galleryElements[i].onclick = onThumbnailsClick;
}
// Parse URL and open gallery if it contains #&pid=3&gid=1
var hashData = photoswipeParseHash();
if(hashData.pid && hashData.gid) {
openPhotoSwipe( hashData.pid , galleryElements[ hashData.gid - 1 ], true, true );
}
};