// jquery validator jQuery.validator.setDefaults({ onfocusout: false , onkeyup: false , onclick: false , showErrors: function(errorMap, errorList) { if (errorList && errorList[0]) { //alert(errorList[0].message); alertify.error(errorList[0].message); $('#'+ errorList[0].element.id).focus(); //alertify.alert('Error', errorList[0].message); } } }); function HidePopupTagWindow(){ tag_set_rejoin.hide(); tag_stock_display.hide(); tag_set_attribute.hide(); tag_reserved_image.hide(); tag_matching_barcode.hide(); tag_set_nfc.hide(); tag_get_gateway_list.hide(); tag_display_page.hide(); } function HidePopupGatewayWindow(){ gateway_window.hide(); } function HidePopupUserWindow(){ user_window.hide(); user_passwd_window.hide(); } function fnGetDateTime() { var d = new Date(); return ''+ d.getFullYear() + d.getMonth() + d.getDate() + d.getHours() + d.getMinutes() + d.getSeconds() + d.getMilliseconds(); } function fnGetCookie( cookieName ) { var search = cookieName + "="; var cookie = document.cookie; if( cookie.length > 0 ) { startIndex = cookie.indexOf( cookieName ); if( startIndex != -1 ) { startIndex += cookieName.length; endIndex = cookie.indexOf( ";", startIndex ); if( endIndex == -1) endIndex = cookie.length; return unescape( cookie.substring( startIndex + 1, endIndex ) ); } else { return false; } } else { return false; } } function fnSetCookie( cookieName, cookieValue ) { var days = 365; var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); document.cookie = cookieName + "=" + escape( cookieValue ) + ";" + expires + "; path=/;"; } //browser detect var browser = (function() { var s = navigator.userAgent.toLowerCase(); var match = /(webkit)[ \/](\w.]+)/.exec(s) || /(opera)(?:.*version)?[ \/](\w.]+)/.exec(s) || /(msie) ([\w.]+)/.exec(s) || /(mozilla)(?:.*? rv:([\w.]+))?/.exec(s) || []; return { name: match[1] || "", version: match[2] || "0" }; }()); (function($) { $.fn.emptySelect = function(n) { return this.each(function() { if(n == 'undefined' || n == undefined) n = 1; if(this.tagName == 'SELECT') { this.options.length = n; } }); } $.fn.loadSelect = function(json, sIdName, sValueName, iDepth) { return this.emptySelect(iDepth).each(function() { if(this.tagName == 'SELECT') { var selectElement = this; $.each(json, function(i, item) { var sId = item[sIdName]; var sValue = item[sValueName]; var option = new Option(sValue, sId); if(browser.name == 'msie') { selectElement.add(option); } else { selectElement.add(option, null); } }); } }); } $.fn.loadCategoryTotal = function(json, sIdName, sValueName, iDepth) { return this.emptySelect(iDepth).each(function() { if(this.tagName == 'SELECT') { var selectElement = this; var totaloption = new Option(locale.full_view, ''); if(browser.name == 'msie') { selectElement.add(totaloption); } else { selectElement.add(totaloption, null); } var values = []; var cnt = 0; $.each(json, function(i, item) { var sValue = item[sValueName]; if(sValue != '') { values[cnt] = sValue; cnt++; } }); var uniqueValues = []; $.each(values, function(i, el){ if($.inArray(el, uniqueValues) === -1) uniqueValues.push(el); }); uniqueValues.sort(function(a, b) { return ab ? 1:0; }); $.each(uniqueValues, function(i, item) { var option = new Option(uniqueValues[i], uniqueValues[i]); if(browser.name == 'msie') { selectElement.add(option); } else { selectElement.add(option, null); } }); } }); } $.fn.loadSelectTotal = function(json, sIdName, sValueName, iDepth) { return this.emptySelect(iDepth).each(function() { if(this.tagName == 'SELECT') { var selectElement = this; var totaloption = new Option(locale.full_view, ''); if(browser.name == 'msie') { selectElement.add(totaloption); } else { selectElement.add(totaloption, null); } $.each(json, function(i, item) { var sId = item[sIdName]; var sValue = item[sValueName]; var option = new Option(sValue, sId); if(browser.name == 'msie') { selectElement.add(option); } else { selectElement.add(option, null); } }); } }); } })(jQuery); function fnExportToExcelFull(col_list, row_list, excel_name, type) { var htmls = ""; var SaveFileName = excel_name + "." + type; var rows = row_list; var cols = col_list.listColumn(); htmls += ''; htmls += ''; for(var j = 0; j < cols.length; j ++) { htmls += ' '; } htmls += ''; for(var i = 0; i < rows.length; i ++) { htmls += ''; switch (excel_name) { case locale.excel_productlist_fname : for(var j=0; j'+ rows[i][j] +''; } break; case locale.excel_taglist_fname : htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; break; case locale.excel_product_taglist_fname : htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; break; case locale.excel_alarm_his_list_fname : htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; break; case locale.excel_tag_his_list_fname : htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; break; case locale.excel_product_his_list_fname : htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; break; case locale.excel_pos_his_list_fname : htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; break; case locale.menu_pos_tag_status : if(rows[i].pre_trans_id != rows[i].trans_id) { htmls += ' '; } htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; break; case locale.excel_matching_his_list_fname : htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; htmls += ' '; break; } htmls += ' \n'; } htmls += '
'+ cols[j].element.innerText +'
'+ rows[i].no +''+ rows[i].device_id +''+ rows[i].type +''+ rows[i].version +''+ rows[i].state +''+ rows[i].battery_level +''+ rows[i].rf_version +''+ rows[i].current_download_page +''+ rows[i].image_state +''+ rows[i].currernt_control +''+ rows[i].fwupdate_state +''+ rows[i].gateway_name +''+ rows[i].template_name +''+ rows[i].imageUpdated_time +''+ rows[i].mcode +''+ rows[i].mname +''+ rows[i].mimage_page1 +''+ rows[i].no +''+ rows[i].filter_field_value +''+ rows[i].category1 +''+ rows[i].category2 +''+ rows[i].category3 +''+ rows[i].mcode +''+ rows[i].mname +''+ rows[i].custrom +''+ rows[i].device_id +''+ rows[i].state +''+ rows[i].type +''+ rows[i].mimage_page1 +''+ rows[i].battery_level +''+ rows[i].time +''+ rows[i].type +''+ rows[i].device_id +''+ rows[i].state +''+ rows[i].start_time +''+ rows[i].time +''+ rows[i].device_id +''+ rows[i].type +''+ rows[i].gateway +''+ rows[i].page_number +''+ rows[i].control_code +''+ rows[i].result +''+ rows[i].comment +''+ rows[i].index +''+ rows[i].retry +''+ rows[i].time +''+ rows[i].key +''+ rows[i].work +''+ rows[i].comment +''+ rows[i].pos_file +''+ rows[i].time +''+ rows[i].pos_file +''+ rows[i].result +''+ rows[i].comment +''+ rows[i].trans_id +''+ rows[i].page_number +''+ rows[i].modified_count +''+ rows[i].target_tag +''+ rows[i].in_progress +''+ rows[i].at_gateway +''+ rows[i].success +''+ rows[i].error +''+ rows[i].cancelled +''+ rows[i].time +''+ rows[i].mcode +''+ rows[i].mname +''+ rows[i].device_id +''+ rows[i].contents +''+ rows[i].user_id +'
'; var link = document.createElement("a"); var blob = new Blob(['\ufeff' + htmls], { encoding:"UTF-8", type: 'text/csv;charset=UTF-8;' }); if (navigator.msSaveBlob) { navigator.msSaveBlob(blob, SaveFileName); } else { if (link.download !== undefined) { var url = URL.createObjectURL(blob); link.setAttribute("href", url); link.setAttribute("download", SaveFileName); link.style.visibility = 'hidden'; document.body.appendChild(link); link.click(); document.body.removeChild(link); } } } function fnExportToExcel(table_name, excel_name) { var htmls = ""; var uri = 'data:application/vnd.ms-excel;base64,'; var template = '{table}
'; var template = ''; var base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }; var format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }; var rows = table_name.listData(); var cols = table_name.listColumn(); htmls += ''; htmls += ''; for(var j = 0; j < cols.length; j ++) { htmls += ' '; } htmls += ''; for(var i = 0; i < rows.length; i ++) { htmls += ''; for(var j = 0; j < cols.length; j ++) { htmls += ' '; } htmls += ''; } htmls += '
'+ cols[j].element.innerText +'
​'+ cols[j].list[i].innerText +'
'; var ctx = { worksheet : 'Worksheet', table : htmls } var link = document.createElement("a"); var SaveFileName = excel_name + ".xls"; var ua = window.navigator.userAgent; var msie = ua.indexOf("MSIE "); if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer { var oWin = window.open("about:blank",'_blank', 'toolbar=no,status=no,menubar=no,scrollbars=no,resizable=no,left=10000, top=10000, width=0, height=0, visible=none', ''); //var oWin = window.open("about:blank", "_blank"); //oWin.document.write(cssText); oWin.document.write(htmls); oWin.document.close(); // success = true, false var success = oWin.document.execCommand('SaveAs', false, SaveFileName); oWin.close(); } else { link.download = SaveFileName; link.href = uri + base64(format(template, ctx)); link.click(); } // 스타일 변경 수동 적용 가능 /*var cssText = ''; */ /* // ********************** // 방법 2 // 방법 2 if (document.all.excelExportFrame == null) // 프레임이 없으면 만들자~! { var excelFrame = document.createElement("iframe"); excelFrame.id = "excelExportFrame"; excelFrame.name = "excelExportFrame"; excelFrame.position = "absolute"; excelFrame.style.zIndex = -1; excelFrame.style.visibility = "hidden"; excelFrame.style.top = "-10px"; excelFrame.style.left = "-10px"; excelFrame.style.height = "0px"; excelFrame.style.width = "0px"; document.body.appendChild(excelFrame); // 아이프레임을 현재 문서에 쑤셔넣고.. } var frmTarget = document.all.excelExportFrame.contentWindow.document; // 해당 아이프레임의 문서에 접근 if (!SaveFileName) { SaveFileName = 'test.xls'; } frmTarget.open("text/html", "replace"); frmTarget.write(htmls); frmTarget.close(); frmTarget.charset="UTF-8"; // 자 코드셋을 원하는걸로 맞추시고.. //frmTarget.charset = "euc-kr"; //frmTarget.focus(); */ /* var htmls = ""; var uri = 'data:application/vnd.ms-excel;base64,'; var template = '{table}
'; var base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }; var format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }; var rows = table_name.listData(); var cols = table_name.listColumn(); htmls += ''; htmls += ''; for(var j = 0; j < cols.length; j ++) { htmls += ' '; } htmls += ''; for(var i = 0; i < rows.length; i ++) { htmls += ''; for(var j = 0; j < cols.length; j ++) { htmls += ' '; } htmls += ''; } htmls += '
'+ cols[j].element.innerText +'
​'+ cols[j].list[i].innerText +'
'; var ctx = { worksheet : 'Worksheet', table : htmls } var link = document.createElement("a"); link.download = excel_name +".xls"; link.href = uri + base64(format(template, ctx)); link.click(); /*var ua = window.navigator.userAgent; var msie = ua.indexOf("MSIE "); if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer { link.download = excel_name +".xls"; link.href = uri + base64(format(template, ctx)); link.click(); } else { link.download = excel_name +".xls"; link.href = uri + base64(format(template, ctx)); link.click(); */ } function fnGetCurrentDate() { var d = new Date() , year = d.getFullYear() , month = '0'+ (d.getMonth() + 1) , day = '0'+ d.getDate(); month = month.substring(month.length - 2, month.length); day = day.substring(day.length - 2, day.length); return year +'-'+ month +'-'+ day +'_00:00:00'; } function fnGetCurrentDateTime() { var d = new Date() , year = d.getFullYear() , month = '0'+ (d.getMonth() + 1) , day = '0'+ d.getDate() , hour = '0'+ d.getHours() , minute = '0'+ d.getMinutes() , second = '0'+ d.getSeconds(); month = month.substring(month.length - 2, month.length); day = day.substring(day.length - 2, day.length); hour = hour.substring(hour.length - 2, hour.length); minute = minute.substring(minute.length - 2, minute.length); second = second.substring(second.length - 2, second.length); return year +'-'+ month +'-'+ day +'_'+ hour +':'+ minute +':'+ second; } function fnGetNextDate() { var today = new Date(); var d = new Date(today.getTime() + (24 * 60 * 60 * 1000)) , year = d.getFullYear() , month = '0'+ (d.getMonth() + 1) , day = '0'+ d.getDate(); month = month.substring(month.length - 2, month.length); day = day.substring(day.length - 2, day.length); return year +'-'+ month +'-'+ day +'_00:00:00'; } function fnGetNextDayDateTime() { var today = new Date(); var d = new Date(today.getTime() + (24 * 60 * 60 * 1000)) , year = d.getFullYear() , month = '0'+ (d.getMonth() + 1) , day = '0'+ d.getDate() , hour = '0'+ d.getHours() , minute = '0'+ d.getMinutes() , second = '0'+ d.getSeconds(); month = month.substring(month.length - 2, month.length); day = day.substring(day.length - 2, day.length); hour = hour.substring(hour.length - 2, hour.length); minute = minute.substring(minute.length - 2, minute.length); second = second.substring(second.length - 2, second.length); return year +'-'+ month +'-'+ day +'_'+ hour +':'+ minute +':'+ second; } function fnCheckIP(strIP) { var expUrl = /^(?!0)(23[0-3]|2[0-3][0-3]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/; return expUrl.test(strIP); } function fnCheckHex(strHex) { var expHex = /^([0-9A-Fa-f]{10})$/; return expHex.test(strHex); } function fnCheckSSIDKor(strSSID) { //alert(strSSID); var expStr = /[ㄱ-ㅎ|ㅏ-ㅣ|가-힝]/; return expStr.test(strSSID); } function fnCheckSSID(strSSID) { //CvtStringSSID = strSSID.replace('[',''); //CvtStringSSID = CvtStringSSID.replace(']',''); //var expStr = /(([a-zA-Z0-9]|[!,@,#,$,%,^,&,*,?,_,~])|([!,@,#,$,%,^,&,*,?,_,~]|[a-zA-Z0-9]))$/; //var expStr = /^[a-zA-Z\d!@.()#$%<>&|/^*_ +{}.,?~-]{1,}$/; var expStr = /[`=\'"]/; return expStr.test(strSSID); } function fnCheckPWD(strPWD) { //CvtStringPwd = strPWD.replace('[',''); //CvtStringPwd = CvtStringPwd.replace(']',''); //var expStr = /^[a-zA-Z\d!@.()#$%<>&|/^*_ +{}.,?~-]{1,}$/; var expStr = /[`=\'"]/; return expStr.test(strPWD); } function fnCheckUserPWD(strPWD) { var chkCnt = 0; var isRst = false; var expStr = /^.*(?=^.{10,}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&+=]).*$/; var expStr1 = /^.*(?=.*\d).*$/; // 숫자 var expStr2 = /^.*(?=.*[a-z]).*$/; // 소문자 var expStr3 = /^.*(?=.*[A-Z]).*$/; // 대문자 var expStr4 = /^.*(?=.*[!@#$%^&+=]).*$/; // 특수기호 var expStr5 = /^.*(?=.*[|]).*$/; // 특수기호 if(expStr1.test(strPWD)) chkCnt++; if(expStr2.test(strPWD)) chkCnt++; if(expStr3.test(strPWD)) chkCnt++; if(expStr4.test(strPWD)) chkCnt++; if(chkCnt > 1) isRst = true; if(expStr5.test(strPWD)) isRst = false; return isRst; } function fnCheckSystemApiPWD(strPWD) { var chkCnt = 0; var isRst = false; var expStr = /^.*(?=^.{10,}$)(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%^&+=]).*$/; var expStr1 = /^.*(?=.*\d).*$/; // 숫자 var expStr2 = /^.*(?=.*[a-z]).*$/; // 소문자 var expStr3 = /^.*(?=.*[A-Z]).*$/; // 대문자 var expStr4 = /^.*(?=.*[!@#$%^&+=]).*$/; // 특수기호 if(expStr1.test(strPWD)) chkCnt++; if(expStr2.test(strPWD)) chkCnt++; if(expStr3.test(strPWD)) chkCnt++; if(expStr4.test(strPWD)) chkCnt++; if(chkCnt == 4) isRst = true; return isRst; } function fnCheckBase64(strString){ var expStr = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/; return expStr.test(strString); } function fnGetCategory1(page) { $.ajax({ url: '/restapi/merchandise/query_category1' , type: 'POST' , data: { }, success : function(json) { if(page == "products") { product_category_loading.hide(); }else if(page == "tag") { tag_category_loading.hide(); }else if(page == "pnt") { pnt_category_loading.hide(); } if(json.result.toLowerCase() == "invalid_token") { document.location.replace('./index.html'); }else if(json.result.toLowerCase() == "success") { if(page == "products") { $('#search_category1').loadCategoryTotal(json.data, 'category1','category1', 0); }else if(page == "tag") { $('#tag_search_category1').loadCategoryTotal(json.data, 'category1','category1', 0); }else if(page == "pnt") { $('#pnt_search_category1').loadCategoryTotal(json.data, 'category1','category1', 0); } } }, error:function(request,status,err){ if (request.status == 0) { alertify.error(locale.server_not_run); } else { // alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+err); alert(locale.service_error + "(" + request.status + ")"); } } }); } function fnGetCategory2(page, cate1) { $.ajax({ url: '/restapi/merchandise/query_category' , type: 'POST' , data: { 'category1': cate1 }, success : function(json) { if(page == "products") { product_category_loading.hide(); }else if(page == "tag") { tag_category_loading.hide(); }else if(page == "pnt") { pnt_category_loading.hide(); } if(json.result.toLowerCase() == "invalid_token") { document.location.replace('./index.html'); }else if(json.result.toLowerCase() == "success") { if(page == "products") { $('#search_category2').loadCategoryTotal(json.data, 'category2','category2', 0); }else if(page == "tag") { $('#tag_search_category2').loadCategoryTotal(json.data, 'category2','category2', 0); }else if(page == "pnt") { $('#pnt_search_category2').loadCategoryTotal(json.data, 'category2','category2', 0); } } }, error:function(request,status,err){ if (request.status == 0) { alertify.error(locale.server_not_run); } else { // alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+err); alert(locale.service_error + "(" + request.status + ")"); } } }); } function fnGetCategory3(page, cate1, cate2) { $.ajax({ url: '/restapi/merchandise/query_category' , type: 'POST' , data: { 'category1': cate1 ,'category2': cate2 }, success : function(json) { if(page == "products") { product_category_loading.hide(); }else if(page == "tag") { tag_category_loading.hide(); }else if(page == "pnt") { pnt_category_loading.hide(); } if(json.result.toLowerCase() == "invalid_token") { document.location.replace('./index.html'); }else if(json.result.toLowerCase() == "success") { if(page == "products") { $('#search_category3').loadCategoryTotal(json.data, 'category3','category3', 0); }else if(page == "tag") { $('#tag_search_category3').loadCategoryTotal(json.data, 'category3','category3', 0); }else if(page == "pnt") { $('#pnt_search_category3').loadCategoryTotal(json.data, 'category3','category3', 0); } } }, error:function(request,status,err){ if (request.status == 0) { alertify.error(locale.server_not_run); } else { // alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+err); alert(locale.service_error + "(" + request.status + ")"); } } }); } String.prototype.replaceAll = function(org, dest) { return this.split(org).join(dest); }