merge master into develop - CscListRForm.jsp FAQ 아코디언 버그 수정
This commit is contained in:
10
build/resources/main/static/js/sopmal/common.js
Normal file
10
build/resources/main/static/js/sopmal/common.js
Normal file
@@ -0,0 +1,10 @@
|
||||
$(document).ready(function () {
|
||||
var $headerNav = $('.header-nav__inner');
|
||||
var $fullMenu = $('.full-menu');
|
||||
|
||||
if ($fullMenu.outerWidth() > $headerNav.outerWidth()) {
|
||||
$fullMenu.addClass('wide-menu');
|
||||
} else {
|
||||
$fullMenu.removeClass('wide-menu');
|
||||
}
|
||||
});
|
||||
126
build/resources/main/static/js/sopmal/fileupload_comm.js
Normal file
126
build/resources/main/static/js/sopmal/fileupload_comm.js
Normal file
@@ -0,0 +1,126 @@
|
||||
$(document).ready(function () {
|
||||
|
||||
//$("#fileUpload").on("change", addFiles);
|
||||
});
|
||||
|
||||
var filesTempArr = [];
|
||||
|
||||
//파일추가
|
||||
function addFiles(event, mode){
|
||||
addFilesObj(event, mode,"fileList");
|
||||
}
|
||||
|
||||
function addFilesObj(event, mode, objId){
|
||||
if(!($(event.target).is('[multiple]'))) filesTempArr.splice(0, filesTempArr.length);
|
||||
|
||||
var files = event.target.files;
|
||||
var filesArr = Array.prototype.slice.call(files); //file객체 array추가
|
||||
var filesArrLen = filesArr.length;
|
||||
var filesTempArrSize = filesTempArr.length*1;
|
||||
|
||||
let obj = $('#'+objId);
|
||||
|
||||
if(mode === 1 && obj.find('li').length>0){
|
||||
alert("파일은 한개만 첨부할 수 있습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
var templist = '';
|
||||
for(var i=0; i<filesArrLen; i++){
|
||||
filesTempArr.push(filesArr[i]); //임시배열에 저장
|
||||
|
||||
if($(event.target).is('[multiple]')){
|
||||
//templist = "<div id='temp"+(i+filesTempArrSize)+"'><a href='#' onclick='downloadFile(this, "+(i+filesTempArrSize)+");'>"+ filesArr[i].name + "</a><span style='color:red;' onclick='deleteFile(this, event, "+(i+filesTempArrSize)+");'> [X]</span></div>";
|
||||
templist ="<li id='temp"+(i+filesTempArrSize)+"'>"
|
||||
+"<a href='#' onclick='downloadFile(this, "+(i+filesTempArrSize)+");'>"
|
||||
+ "<i class='icon icon_file-list mr-2'></i>"
|
||||
+ "<span class='file-list__item-title'>"+ filesArr[i].name + "</span>"
|
||||
+"</a>"
|
||||
+"<button type='button' class='file-list__delete' onclick='deleteFile(this,0,0, "+(i+filesTempArrSize)+");'/>"
|
||||
+"</li>";
|
||||
|
||||
obj.append(templist);
|
||||
}
|
||||
}
|
||||
}
|
||||
//드롭존 파일삭제(html 요소 조작 없이 단순 파일 삭제)
|
||||
function dropzoneDeleteFiles(fileId, shopCd, menuGb, orderParam, callbackNm) {
|
||||
if (fileId.indexOf('temp') != 0) { //임시등록파일은 화면에서 삭제
|
||||
if (confirm("파일을 삭제하시겠습니까?")) {
|
||||
ajaxFileDelete('', fileId, shopCd, menuGb, orderParam, callbackNm);
|
||||
return "Y";
|
||||
} else {
|
||||
return "N";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//파일삭제
|
||||
function deleteFile (obj, shopCd, menuGb, orderParam){
|
||||
deleteFiles (obj, shopCd, menuGb, orderParam, '#fileUpload');
|
||||
}
|
||||
|
||||
//파일삭제
|
||||
function deleteFiles (obj, shopCd, menuGb, orderParam, objNm){
|
||||
filesTempArr.splice(orderParam, 1);
|
||||
var $div = $(obj).closest('li');
|
||||
var $id = $div.attr('id');
|
||||
|
||||
if($id.indexOf('temp') == 0) { //임시등록파일은 화면에서 삭제
|
||||
$div.remove(); $(objNm).val('');
|
||||
}else{ //업로드된 파일은 서버삭제
|
||||
if(confirm("파일을 삭제하시겠습니까?")){
|
||||
ajaxFileDelete($div,$id,shopCd, menuGb,orderParam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var ajaxFileDelete = function(obj,fileId,shopCd, menuGb,orderParam){
|
||||
$.ajax({
|
||||
// url: '/file/deleteUploadedFile/'+shopCd+'/'+menuGb+'/'+fileId+'/ajax',
|
||||
url: '/file/deleteUploadedFile?sopCd='+shopCd+'&menuGb='+menuGb+'&fileKey='+fileId,
|
||||
data: {fileId:fileId},
|
||||
type: 'get',
|
||||
success : function(data){
|
||||
if(obj !== ''){
|
||||
obj.remove();
|
||||
}
|
||||
},
|
||||
error: function(){
|
||||
alert("삭제에 실패하였습니다.");
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
//다운로드
|
||||
var downloadFile = function(obj,shopCd, menuGb,orderParam){
|
||||
filesTempArr.splice(orderParam, 1);
|
||||
var $div = $(obj).closest('li');
|
||||
var fileId = $div.attr('id'); // <li>태그id - 파일글번호
|
||||
var orgFileId = obj.id; //선택된 파일명. 즉 <a>태그id - 원본파일명
|
||||
|
||||
if(fileId.indexOf('temp') == 0){
|
||||
alert("등록된 파일만 다운로드 가능합니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
//$(location).attr('href','/file/download/'+shopCd+'/'+menuGb+'/'+fileId+'/'+orgFileId+'/ajax');
|
||||
//$(location).attr('href','/file/download/'+shopCd+'/'+menuGb+'/'+fileId+'/ajax');
|
||||
$(location).attr('href','/file/fileDownload?sopCd='+shopCd+'&menuGb='+menuGb+'&fileKey='+fileId);
|
||||
}
|
||||
|
||||
|
||||
//다운로드
|
||||
var linkDownloadFile = function(key, fileName ,shopCd, menuGb,orderParam){ //파일글번호, 원본파일명
|
||||
filesTempArr.splice(orderParam, 1);
|
||||
|
||||
if(key.indexOf('temp') == 0){
|
||||
alert("등록된 파일만 다운로드 가능합니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
//$(location).attr('href','/file/download/'+shopCd+'/'+menuGb+'/'+key+'/ajax');
|
||||
$(location).attr('href','/file/fileDownload?sopCd='+shopCd+'&menuGb='+menuGb+'&fileKey='+key);
|
||||
}
|
||||
|
||||
1318
build/resources/main/static/js/sopmal/gcone.js
Normal file
1318
build/resources/main/static/js/sopmal/gcone.js
Normal file
File diff suppressed because it is too large
Load Diff
167
build/resources/main/static/js/sopmal/lotteryScratch.js
Normal file
167
build/resources/main/static/js/sopmal/lotteryScratch.js
Normal file
@@ -0,0 +1,167 @@
|
||||
$(document).ready(function() {
|
||||
setTimeout(function() {
|
||||
let $canvas = $('#scratchCanvas');
|
||||
|
||||
if ($canvas.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const ctx = $canvas[0].getContext('2d');
|
||||
const canvas = $canvas[0];
|
||||
canvas.width = canvas.offsetWidth;
|
||||
canvas.height = canvas.offsetHeight;
|
||||
const gridSize = 30;
|
||||
const cols = Math.ceil(canvas.width / gridSize);
|
||||
const rows = Math.ceil(canvas.height / gridSize);
|
||||
const scratchedGrid = Array.from({ length: rows }, () => Array(cols).fill(false));
|
||||
|
||||
const coverImg = new Image();
|
||||
const imgTag = document.getElementById('coverImg');
|
||||
coverImg.src = imgTag.src;
|
||||
coverImg.onload = function () {
|
||||
ctx.drawImage(coverImg, 0, 0, canvas.width, canvas.height);
|
||||
};
|
||||
|
||||
let isDrawing = false;
|
||||
let isSwitched = false;
|
||||
|
||||
$canvas.on('mousedown touchstart', function () {
|
||||
loginCheck();
|
||||
canvas.style.cursor = 'url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSczMicgaGVpZ2h0PSczMicgdmlld0JveD0nMCAwIDMyIDMyJz48Y2lyY2xlIGN4PScxNicgY3k9JzE2JyByPScxNicgZmlsbD0nI2VkYjE2MycvPjwvc3ZnPg=="), auto';
|
||||
isDrawing = true;
|
||||
});
|
||||
|
||||
$canvas.on('mouseup mouseleave touchend', function () {
|
||||
canvas.style.cursor = 'url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSczMicgaGVpZ2h0PSczMicgdmlld0JveD0nMCAwIDMyIDMyJz48Y2lyY2xlIGN4PScxNicgY3k9JzE2JyByPScxNicgZmlsbD0nI2VkYjE2MycvPjwvc3ZnPg=="), auto';
|
||||
isDrawing = false;
|
||||
});
|
||||
|
||||
$canvas.on('mousemove touchmove', function (e) {
|
||||
if (!isDrawing || isSwitched) return;
|
||||
|
||||
e.preventDefault();
|
||||
let x, y;
|
||||
|
||||
const rect = $canvas[0].getBoundingClientRect();
|
||||
if (e.originalEvent.touches) {
|
||||
x = e.originalEvent.touches[0].clientX - rect.left;
|
||||
y = e.originalEvent.touches[0].clientY - rect.top;
|
||||
} else {
|
||||
x = e.clientX - rect.left;
|
||||
y = e.clientY - rect.top;
|
||||
}
|
||||
const col = Math.floor(x / gridSize);
|
||||
const row = Math.floor(y / gridSize);
|
||||
|
||||
scratchedGrid[row][col] = true;
|
||||
|
||||
ctx.globalCompositeOperation = 'destination-out';
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, 30, 0, Math.PI * 2);
|
||||
ctx.fill();
|
||||
const scratchedPercent = calculateScratchedPercent();
|
||||
if (scratchedPercent >= 30) {
|
||||
isSwitched = true;
|
||||
scratchLottery();
|
||||
}
|
||||
});
|
||||
|
||||
// 긁힌 퍼센테이지 구하기
|
||||
function calculateScratchedPercent() {
|
||||
let scratchedCount = 0;
|
||||
let totalCount = rows * cols;
|
||||
|
||||
for (let r = 0; r < rows; r++) {
|
||||
for (let c = 0; c < cols; c++) {
|
||||
if (scratchedGrid[r][c]) scratchedCount++;
|
||||
}
|
||||
}
|
||||
return ((scratchedCount / totalCount) * 100).toFixed(2);
|
||||
}
|
||||
|
||||
// 로그인체크
|
||||
function loginCheck () {
|
||||
var device = $('#adScriptDeviceTy').val();
|
||||
if ($('#mbrInnb').val() == 0) {
|
||||
if (device == 'sopmal_m') {
|
||||
openModal('modal-error-confirm-move-login');
|
||||
return;
|
||||
} else {
|
||||
fn_wish_modal();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 복권긁기 결과
|
||||
function scratchLottery() {
|
||||
const promInnb = $('#promInnb').val();
|
||||
const promRule = $('#promRule').val();
|
||||
$.ajax({
|
||||
url:"/sopmal/prom/promJoin",
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
contentType: "application/json",
|
||||
data: JSON.stringify({ promInnb: promInnb, promRule: promRule }),
|
||||
success : function(res) {
|
||||
console.log('서버 응답:', res);
|
||||
|
||||
const resBody = res?.resBody;
|
||||
let resultObj = resBody?.result;
|
||||
|
||||
if (typeof resultObj === "string") {
|
||||
try {
|
||||
resultObj = JSON.parse(resultObj);
|
||||
} catch (e) {
|
||||
console.warn('JSON 파싱 실패', e);
|
||||
resultObj = {};
|
||||
}
|
||||
}
|
||||
|
||||
// 오류 방지: 응답이 비정상일 경우 종료
|
||||
if (!resultObj || typeof resultObj.selected === "undefined") {
|
||||
alert("응답이 잘못되었습니다. 다시 시도해주세요.");
|
||||
spinning = false;
|
||||
return;
|
||||
}
|
||||
|
||||
const selected = Number(resultObj.selected) || 0;
|
||||
const message = resultObj.message || "";
|
||||
|
||||
if (resultObj.alreadySpun === true) {
|
||||
if (message) alert(message);
|
||||
$canvas.hide();
|
||||
return;
|
||||
} else {
|
||||
$(`.common-winning${selected}`).show();
|
||||
if (getDeviceType() === 'sopmal_m') {
|
||||
$(`.mobile-winning${selected}`).show();
|
||||
} else {
|
||||
$(`.winning${selected}`).show();
|
||||
}
|
||||
showWinningModal(selected);
|
||||
$canvas.hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function getDeviceType() {
|
||||
return $('#adScriptDeviceTy').val();
|
||||
}
|
||||
|
||||
function showWinningModal(index) {
|
||||
if (getDeviceType() === 'sopmal_m') {
|
||||
console.log(typeof MicroModal);
|
||||
console.log('모바일 - Micromodal 실행');
|
||||
MicroModal.show('event_winning2');
|
||||
} else {
|
||||
$('#event_winning').modal();
|
||||
}
|
||||
}
|
||||
|
||||
}, 300);
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user