/* e-mail ˻ */ String.prototype.is_mail = function(_cpText){ _cpText = this != window ? this : _cpText; var cpMatchText = /^[a-zA-Z0-9]{1}([_0-9a-zA-Z-]+)@[^\.@]+(\.[0-9a-zA-Z-]{2,})*(\.([a-zA-Z]{2,}))$/; return cpMatchText.test(_cpText) } /* Number Format Լ*/ String.prototype.num_format = function (_cpNo){ _cpNo = this != window ? this : _cpNo; var cpMatch = /[^0-9]/g; var cpMatchNo = /(-?[0-9]+)([0-9]{3})/; _cpNo = _cpNo.replace(cpMatch,''); while (cpMatchNo.test(_cpNo)) { _cpNo = _cpNo.replace(cpReNo, '$1,$2'); } return _cpNo; } /* ֹεϹȣ ˻*/ String.prototype.is_digit = function (_cpText){ _cpText = this != window ? this : _cpText; var cpMatch = /^[0-9]{13}$/; var cpGrep = "234567892345"; var nSum = 0, nYear = 0, dToday = new Date(); _cpText = _cpText.replace(/-/gi,''); if(!cpMatch.test(_cpText)) return false; /* * ** ˻ */ //-- , о´. 1, 2 => 1900 , 3,4=> 2000, 5,6=> 2100 var i = _cpText.substring(6,7) if(i > 7 || i < 1) return false; i = (i % 2) ? i : i -1;// ¦̸ -1 nYear = (19 + parseInt(i / 2)) * 100 + parseInt(_cpText.substring(0,2)); //-- ֹεϹȣ //-- 5 ̸ 90 ʰ ȿ ֹε ȣ óѴ if(dToday.getYear() - nYear < 5 || dToday.getYear() - nYear > 90 ) return false; /* * ** ¥˻ */ if(_cpText.substring(2,4) < 1 || 12 < _cpText.substring(2,4) ) return false; if(_cpText.substring(4,6) < 1 || 31 < _cpText.substring(4,6) ) return false; for(i = 0; i < 12; i++){ nSum += _cpText.substring(i, i+1) * cpGrep.substring(i ,i+1); } nSum = 11 - (nSum % 11); if (nSum > 9) nSum = nSum %10; if (nSum != _cpText.substring(12,13)) return false; return true; } /* key ˾Ƴ. */ function chk_key(e){ var browser = navigator.appName; if (browser != "Netscape"){ return event.keyCode; }else{ window.captureEvents(Event.KEYDOWN || Event.KEYPRESS); return e.which; } } /*ڿ Byte */ String.prototype.Byte = function(str){ str = this != window ? this : str; str = str.replace(/\r/gi, '');// CRLF str = str.replace(/\n/gi, '');// CRLF var chr = '', len = 0; for(var i=0;i < str.length; i++){ chr = str.charAt(i); // ѹھ б len += ((escape(chr)).toString().length > 4) ? 2 : 1; } return len; } /*ڿ Byte ŭ ڸ*/ function Left(str, chars){ var chr = "", retStr = ""; var len = 0; if(str.toString().Byte() >= chars){ for(var i = 0; i < str.length; i++){ chr = str.charAt(i); // ѹھ б if(escape(chr).length > 4) len +=2; else if(chr != '\r') len++; if(len > chars){ retStr = str.substring(0, i); break; } } }else{ retStr = str; } return retStr; } function checkMaxLength(obj, cutlen){ var len = obj.value.toString().Byte(); if(len >= cutlen) event.returnValue = false; } function isValueCheck(_oForm){ var retVal = true, cpValue = '' , cpErrMsg = '', cpText ='', cpMatch = '', aMatch = null, inVal = ''; for(var i = 0 ; i < _oForm.elements.length; i++){ with( _oForm.elements[i]){// -- Begin Of With if(getAttribute('errmsg') == null) continue;// ˻ ƴ skip if(getAttribute('errmsg').toString().isVoid() == true) continue; inVal = document.getElementsByName(getAttribute('name'))[0].value; // -- Begin Of Check /* Element ȿ ˻*/ if(getAttribute('chktype') == null){// ˻ ܼ Է // retVal = value.isVoid(); retVal = !inVal.toString().isVoid(); cpErrMsg = getAttribute('errmsg') + " Է ̽ϴ."; }else if(getAttribute('chktype').toLowerCase().indexOf('email') != -1){// ˻ ̸ cpErrMsg = "ȿ " + getAttribute('errmsg') + " Դϴ."; // ̸ Է ɼ if(getAttribute('chktype').toLowerCase() != "email|req" && inVal.toString().isVoid() == true) continue; // Element ˻ // ̸ Է ʼ if( getAttribute('chktype').toLowerCase() == "email|req" && inVal.toString().isVoid() == true){ cpErrMsg = getAttribute('errmsg') + " Է ̽ϴ."; retVal = false; // ̸ ˻ }else{ retVal = inVal.toString().is_mail(); } }else if(getAttribute('chktype').toLowerCase().indexOf('jumin') != -1){// ˻ ֹεϹȣ cpErrMsg = "ȿ " + getAttribute('errmsg') + " Դϴ."; // ֹεϹȣ Է ɼ if(getAttribute('chktype').toLowerCase() != "jumin|req" && inVal.toString().isVoid() == true) continue; // Element ˻ // ̸ Է ʼ if( getAttribute('chktype').toLowerCase() == "jumin|req" && inVal.toString().isVoid() == true){ cpErrMsg = getAttribute('errmsg') + " Է ̽ϴ."; retVal = false; // ̸ ˻ }else{ retVal = inVal.toString().is_digit(); } }else if(getAttribute('chktype').toLowerCase().indexOf('no') !== -1){// ˻ // Ӽ üũ cpText = getAttribute('chktype').toLowerCase().toString(); // ̿ ڸ ˻ if(cpText.indexOf('|') == -1){ retVal = (/^(\d+)$/).test(inVal.toString()); cpErrMsg = getAttribute('errmsg') + " ڸ Է մϴ."; // ̸ŭ ˻ }else{ // no|ּ[,ִ][,ʼ] aMatch = cpText.split('|').pop().toString(); // Է ɼ if(aMatch.toString().toLowerCase().indexOf("req") == -1 && inVal.toString().isVoid() == true) { continue; // Է ɼ ʼ̳ } // ̿ ʼ if(aMatch.toLowerCase() == 'req'){ if(inVal.toString().isVoid() == true){ cpErrMsg = getAttribute('errmsg') + " Է ̽ϴ."; retVal = false; }else{ retVal = (/^(\d+)$/).test(inVal.toString()); cpErrMsg = getAttribute('errmsg') + " ڸ Է մϴ."; } }else if(aMatch.toString().toLowerCase().indexOf("req") !== -1 && inVal.toString().isVoid() == true) { cpErrMsg = getAttribute('errmsg') + " Է ̽ϴ."; retVal = false; }else{ if(aMatch.indexOf(",") == -1){// ̰ cpErrMsg = aMatch + " ̳ ڸ Է մϴ."; cpMatch = "^(\\d){"+ aMatch +"}$"; }else{ // ̰ ּ~ִ밪 aMatch = aMatch.split(","); cpMatch = "^(\\d){" + aMatch[0] + "," + aMatch[1] + "}$"; cpErrMsg = aMatch[0] + " ̻ "+ aMatch[1] +" ̳ ڸ Է մϴ."; } var re = new RegExp(cpMatch); retVal = re.test(inVal.toString()) ; } } }else if(getAttribute('chktype').toLowerCase().indexOf('product') !== -1){// ˻ retVal = !inVal.toString().isVoid(); cpErrMsg = getAttribute('errmsg') + " Է ̽ϴ."; }else{ retVal = !inVal.toString().isVoid(); cpErrMsg = getAttribute('errmsg') + " Է ̽ϴ."; }// -- End Of Check if(retVal == false){// ˻ ȿ alert("\n" + cpErrMsg + "\n"); if(getAttribute('type') != 'hidden') focus(); if(getAttribute('type').toLowerCase() == 'text') select(); break; } }// -- End of Width }// -- End of For return retVal; } /*TextArea Լ*/ function setReSzArea(srcName, nIncrease){ var element = document.forms['frmWBConfig'].elements[srcName]; if(parseInt(element.style.height) < 480 && (parseInt(element.style.height) + (nIncrease) >= 19 )) element.style.height = parseInt(element.style.height) + (nIncrease); else if( parseInt(element.style.height) >= 480 && nIncrease < 0 ){ element.style.height = parseInt(element.style.height) + (nIncrease); }else if( (parseInt(element.style.height) + (nIncrease) <= 19 ) && nIncrease> 0 ){ element.style.height = parseInt(element.style.height) + (nIncrease); } } /* ư ̺Ʈ Լ*/ function setRadio(name, obj){ var pRadio = document.getElementsByName('IMG_' + name); for(var i = 0; i < pRadio.length; i++){ if(pRadio[i] == obj.childNodes[0]){ pRadio[i].src = pRadio[i].src.replace('off.gif', 'on.gif'); var element = document.getElementsByName(name); element[0].value = pRadio[i].getAttribute('value'); }else{ pRadio[i].src = pRadio[i].src.replace('on.gif', 'off.gif'); } } } /*üũ ڽ ư ̺Ʈ Լ*/ function setCheck(name){ var pCheckBox = document.getElementsByName(name); var oImg = document.images['IMG_' + name]; if(oImg == null) return false; var chkVal = oImg.getAttribute('checkValue'); var unchkVal = oImg.getAttribute('uncheckValue'); // üũ if(pCheckBox[0].value == chkVal){ pCheckBox[0].value = unchkVal; oImg.src = oImg.src.replace('on.gif', 'off.gif'); }else{ pCheckBox[0].value = chkVal; oImg.src = oImg.src.replace('off.gif', 'on.gif'); } } /*Cell */ function setRowBgColor(row, bgcolor){ for(var i =0; i < row.cells.length; i++){ row.cells[i].setAttribute("bgcolor", bgcolor,0); } } /*Ŭ*/ function copyToClipboard(cpText) { if(window.clipboardData) window.clipboardData.setData("Text", cpText); return true; } function GetClipboard(){ if(window.clipboardData) return window.clipboardData.getData("Text"); } /*TextArea Լ*/ function setReSzArea(srcName, nIncrease){ var element = document.forms['frmWrite'].elements[srcName]; if(parseInt(element.style.height) < 480 && (parseInt(element.style.height) + (nIncrease) >= 40 )) element.style.height = parseInt(element.style.height) + (nIncrease); else if( parseInt(element.style.height) >= 480 && nIncrease < 0 ){ element.style.height = parseInt(element.style.height) + (nIncrease); }else if( (parseInt(element.style.height) + (nIncrease) <= 40 ) && nIncrease> 0 ){ element.style.height = parseInt(element.style.height) + (nIncrease); } } /* ÷ Ͽ ̺Ʈ Լ */ var pAlreadyFiles = new Array(0); // 迭 var nMaxFiles = 0; var FileExtension = new String; var isDescript = false; var pickDescript = null; var pickRow = null; function FileInfo(){ this.FileNo = 0; this.FileName = ""; this.FilePath = ""; this.LocalPath = ""; this.FileElement = null; this.FileState = "Already"; } /*ʱȭ Լ*/ function xwzFileUploadInitialized(){ var pNewFileList = document.getElementsByName('NewFile[]'); var oRows = document.getElementById('FileUploadList').getElementsByTagName('TR'); var oFileInfo = null; nMaxFiles = document.forms['frmWrite'].MaxFiles.value * 1; FileExtension = document.forms['frmWrite'].FileExt.value.replace(/,/gi, '|').replace(/ /gi, ''); isDescript = (document.getElementById('IDS_FileDescript') !== null); // ִ о 迭 Ѵ. for(var i = 0; i < oRows.length;i++){ oFileInfo = new FileInfo(); oFileInfo.FileName = oRows[i].getAttribute("AlreadyName"); oFileInfo.FilePath = oRows[i].getAttribute("AlreadyFile"); oFileInfo.FileNo = oRows[i].getAttribute("AlreadyNo"); pAlreadyFiles.push(oFileInfo); } } /* ε ü Լ*/ function resetFile(oFile){ var oNewFile = document.createElement(""); oNewFile.className = "cssFileFlat"; oNewFile.style.cssText="width:100%;"; oNewFile.onchange=new Function("addFile(this)"); oFile.parentNode.appendChild(oNewFile); //oFile.removeNode(true); oFile.remove(); return oNewFile; } /*ε ߰*/ function addFile(oFile){ if(oFile.getAttribute('value') == "") return; var oNewFile = null; var oFileInfo = null; var FilePath = new String, FileName = new String, FileExt = new String; FilePath = oFile.value; FileName = FilePath.split('\\').pop(); // ߰ ̸ FileExt = FileName.split('.').pop(); //==== ε ִ Ȯ ˻ ====// if(FileExtension.isVoid() == true){ var re = new RegExp("(exe|com|bat|php|php3|php4|php5|inc|html|htm|js|phtml|asp|pl|jsp|shtm|ztx|dot|cgi)", "ig"); if( re.exec(FileExt) != null){ alert("ε Դϴ."); resetFile(oFile) return; } }else{ var re = new RegExp(FileExtension, "gi"); if( re.exec(FileExt) == null){ alert("ε Դϴ."); resetFile(oFile) return; } } //==== ִ ȮѴ. ====// for(var i in pAlreadyFiles){ if(pAlreadyFiles[i].LocalPath == FilePath){ resetFile(oFile);return; } } //==== Ʈ ü?߰. ====// oFile.style.display='none'; // ߰ var oFileInfo = new FileInfo(); oFileInfo.FileName = FileName; oFileInfo.LocalPath = FilePath; oFileInfo.FileElement = oFile; oFileInfo.FileState = "New"; pAlreadyFiles.push(oFileInfo); //==== Ʈ ̺ ߰. ====// var oTable = document.getElementById('FileUploadList'); var oRow = document.createElement("TR"); var oCell = document.createElement("TD"); var oImg = new Image; var oLink = document.createElement("A"); //var oDescript = document.createElement(""); var oDescript = document.createElement("input"); oDescript.setAttribute("type", "hidden"); oDescript.setAttribute("name", "FileDescript[]"); oImg.src = "http://image.babosarang.co.kr/images/bbs/icon_doc.gif"; oImg.style.width= 16; oImg.style.height= 16; oImg.setAttribute("align", "absmiddle"); oLink.onclick = new Function("setFileChecked(this);return false"); oLink.style.cssText = "cursor:pointer"; oLink.innerText = FileName; var oTBody = oTable.querySelector('tbody') || document.createElement('tbody'); //oTable.childNodes[0].appendChild(oRow); oTBody.appendChild(oRow); // TR //console.log(oTable); oCell.setAttribute('height', 19); oRow.appendChild(oCell); // TD oCell.appendChild(oImg); oCell.appendChild(oLink); oCell.appendChild(oDescript); setFileChecked(oLink); //==== ε ִ ʰߴ Ȯ ====// if(pAlreadyFiles.length >= nMaxFiles) return; var pFileList = document.getElementsByName("NewFile[]"); for(var i = 0; i < pFileList.length; i++){ if(pFileList[i].value.isVoid() == true) { pFileList[i].style.display = "block"; break; } } } /*ε */ function rmFile(){ if(pickRow == null) return; var rmIndex = pickRow.rowIndex; var pFileList = new Array(0); var oFileInfo = null; var delFile = null; pFileList = pAlreadyFiles; pAlreadyFiles = new Array(0); //==== Ʈ ü 迭ȭ ====// for(var i = 0; i < pFileList.length; i++){ if(i == rmIndex){// if(pFileList[i].FileElement !== null){// ű resetFile(pFileList[i].FileElement); // ü pFileList[i].FileElement = null; }else{ // ̹ ε //delFile = document.createElement(""); delFile = document.createElement("input"); delFile.setAttribute("type", "hidden"); delFile.setAttribute("name", "DeleteFile[]"); delFile.value = pFileList[i].FileNo.toString(); document.forms['frmWrite'].appendChild(delFile); } }else{ oFileInfo = new FileInfo(); oFileInfo = pFileList[i]; pAlreadyFiles.push(oFileInfo); } } //pickRow.removeNode(true); pickRow.remove(); pickRow = null; if(isDescript == true) document.getElementById('IDS_FileDescript').value = ''; with(document.getElementById('btnFileDelete')){disabled = true;filters.alpha.opacity = 50;} var pFileList = document.getElementsByName("NewFile[]"); for(var i = 0; i < pFileList.length; i++) pFileList[i].style.display = "none"; //==== ε ִ ʰߴ Ȯ ====// if(pAlreadyFiles.length >= nMaxFiles) return; for(var i = 0; i < pFileList.length; i++){ if(pFileList[i].value.isVoid() == true) { pFileList[i].style.display = "block"; break; } } } /* Ʈ ý */ function setFileChecked(obj){ var oRow = obj.parentNode.parentNode; if(pickRow == oRow) return; if(pickRow != null){ pickRow.setAttribute('checked', 'false'); pickRow.cells[0].childNodes[1].style.backgroundColor=""; pickRow.cells[0].childNodes[1].style.color=""; } oRow.setAttribute('checked', 'true'); obj.style.backgroundColor="#0066CC"; obj.style.color="#FFFFFF"; //==== Է ִ 츸 ====// if(isDescript == true){ var FileDescripts = document.getElementsByName('FileDescript[]'); pickDescript = FileDescripts[oRow.rowIndex]; document.getElementById('IDS_FileDescript').value = pickDescript.value } pickRow = oRow; with(document.getElementById('btnFileDelete')){ disabled = false; filters.alpha.opacity = 100; } } function applyDescript(txt){ if(pickDescript == null) return; pickDescript.value = txt } function isValidity(){ try{ var WebEdit = document.getElementById('GsWebEdit'); var memo = new String; with(document.forms['frmWrite']){ if(WebEdit != null){ Content.value = WebEdit.BodyIn.toString().replace(/<\/img>/gi, ''); } memo = Content.value.replace(/
<\/P>/gi, ''); memo = memo.replace(/
<\/P>/gi, '');
if(Writer.value.isVoid() == true){
alert('̸ Էϼ.');
Writer.focus(); return false;
}else if(elements['passwd'] != null){
if(passwd.value.isVoid() == true){
alert('йȣ Էϼ. Ȥ ʿմϴ.');
passwd.focus();
return false;
}else if(passwd.value.length < 4 ){
alert('йȣ ʹ ªϴ. 4 ̻ Էϼ.');
passwd.focus();
return false;
}
}else if(Subject.value.isVoid() == true){
alert(' Էϼ.');
Subject.focus(); return false;
}else if(isValueCheck(document.forms['frmWrite']) == false){
return false;
}else if(memo.toString().isVoid() == true){
alert(' Էϼ.');
if(Content.style.visibility != 'hidden') Content.focus();
else WebEdit.focus();
return false;
}
if(WebEdit != null){
var nCount = WebEdit.GetImageCount();
for(var ImgIndex = 0; ImgIndex < nCount; ImgIndex++){
if(WebEdit.IsLocalImage(ImgIndex) == false ){// ̹ ƴ
var oElement = document.createElement("");
document.forms['frmWrite'].appendChild(oElement);
oElement.value = WebEdit.GetImageFileName(ImgIndex+1);
}
}
if(WebEdit.UploadLocalImg("baboi.babosarang.co.kr", 80,"/images/upload.php", 'http://baboi.babosarang.co.kr/images/' + ImageDir.value + '/', 0, ImageDir.value) < 0 ){
alert(WebEdit.UploadImgError);
return false;
}
Content.value = WebEdit.BodyIn.toString().replace(/<\/img>/gi, '');
}
if(copycheck.value == 'Y'){
copyToClipboard(Content.value);
}
return true;
}
}catch(e){
alert(e.description);
}
return false;
}
function AlreadyImages(){
var WebEdit = document.getElementById('GsWebEdit');
if(WebEdit == null) return;
var nCount = WebEdit.GetImageCount();
for(var ImgIndex = 0; ImgIndex < nCount; ImgIndex++){
if(WebEdit.IsLocalImage(ImgIndex) == false ){// ̹ ƴ
var oElement = document.createElement("");
document.forms['frmWrite'].appendChild(oElement);
oElement.value = WebEdit.GetImageFileName(ImgIndex+1);
}
}
}
function checkCommentPuzzle()
{
if(document.getElementById('Content').value == '')
{
alert(' Էϼ.');
document.getElementById('Content').focus();
return false;
}
}
function checkComment(srcForm){
try{
with(srcForm){
var str = new String;
var nOver = 0;
str = Content.value.replace(/\t\s/gi, '').toString();//Tab, \r, \n
for(var i = 0; i < str.length; i++){
if(str.charAt(0) == str.substring(i, i+1)) ++nOver;
}
if(Writer.value.isVoid() == true){
alert('̸ Էϼ');
Writer.focus();
return false;
}else if(elements['Passwd'] != null){
if(Passwd.value.isVoid() == true){
alert('йȣ Էϼ.');
Passwd.focus();return false;
}
}
if(Content.value.isVoid() == true){
alert(' Էϼ.');
Content.focus();
return false;
}else if(nOver == str.length){
alert('ڸƮ ڷθ ۼϽ ϴ.');
Content.focus();
return false;
}
}
return true;
}catch(e){
alert(e.description);
}
return false;
}
function checkComment_poll(srcForm){
try{
with(srcForm){
var str = new String;
var nOver = 0;
str = Content.value.replace(/\t\s/gi, '').toString();//Tab, \r, \n
for(var i = 0; i < str.length; i++){
if(str.charAt(0) == str.substring(i, i+1)) ++nOver;
}
var choice = document.getElementsByName("vote");
for (var i=0, flag=0; i