servermgrv2/public/js/admin.js
2023-07-17 21:09:49 +09:00

104 lines
3.0 KiB
JavaScript

/* ------------------------------------------------------------
* Name : admin.js
* Desc : Admin Javascrip
* Created : 2016/9/11 Tri-aBility by Junheum,Choi
* Updated :
------------------------------------------------------------ */
function trim(str){
return this.replace(/(^\s*)|(\s*$)/gi, "");
}
//오른쪽에 위 화살표 방향버튼용
/*$(document).ready(function(){
$('body').append('<div id="toTop"><i class="fa fa-angle-double-up fa-4x"></i></div>');
$("#toTop").bind("click", function () {$("body").animate({ scrollTop: 0 }, 200);});
$(window).scroll(function () {
if ($(this).scrollTop() != 0) {
$('#toTop').fadeIn();
} else {
$('#toTop').fadeOut();
}
});
});
//오른쪽에 위 화살표 방향버튼용
//오른쪽에 아래 화살표 방향버튼용
$(document).ready(function(){
$('body').append('<div id="toBottom"><i class="fa fa-angle-double-down fa-4x"></i></div>');
$("#toBottom").bind("click", function () {$("body").animate({ scrollTop: 200000 }, 200);});
$(window).scroll(function () {
if ($(this).scrollTop() != 0) {
$('#toBottom').fadeIn();
} else {
$('#toBottom').fadeIn();
}
});
});*/
//오른쪽에 아래 화살표 방향버튼용
function is_NumericKey(evt,obj){
var charCode = (evt.which) ? evt.which : event.keyCode;
switch(charCode){
case 48://0
case 49://1
case 50://2
case 51://3
case 52://4
case 53://5
case 54://6
case 55://7
case 56://8
case 57://9
case 96://KeyPad:0
case 97://KeyPad:1
case 98://KeyPad:2
case 99://KeyPad:3
case 100://KeyPad:4
case 101://KeyPad:5
case 102://KeyPad:6
case 103://KeyPad:7
case 104://KeyPad:8
case 105://KeyPad:9
break;
default:
alert('숫자만 가능합니다['+charCode+']');
obj.value = obj.value.substring(0,obj.value.length-1);
break;
}
}
function is_NumericType(data){
if(!data.match(/^[0-9]+$/)){
throw (new Error('숫자가 아닌값['+data+']이 있습니다'));
}
return true;
}//
function change_CurrencyFormat(obj,currencies){
//var currencies = document.getElementsByClassName("currency");
var total_currency = 0;
for(i=0; i<currencies.length; i+2){
try {
is_NumericType(currencies[i].value)//값이 숫자형식인지 판단
} catch(err) {
alert(err.message);
currencies[i].focus();
return false;
}
total_currency += parseInt(currencies[i].value);
currencies[i].parentElement.innerHTML=currencies[i].value.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+'원';
}
obj.parentElement.innerHTML=total_currency.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+'원'
return true;
}
//해당하는 클래스의 내용을 메모리에 Copy
async function getElementsByClassNameCopyToClipboard(className)
{
var x = document.getElementsByClassName(className);
var textToCopy = '';
for (var i = 0; i < x.length; i++) {
textToCopy += x[i].textContent+'\n';
}
await navigator.clipboard.writeText(textToCopy)
.then(() => { alert("복사가 완료되었습니다."); })
.catch(err => { console.log('복사가 오류', err); })
}