초소형기본 스위치(S 사이즈) | OMRON - Korea
'; //console.log("Header markup: " + markup); $('#part-param-table thead').append(markup); } }, error:function(data,textStatus, XMLHttpRequest){ alert("Create header request failed."); } }).done(function(data) { $('[data-toggle="popover"]').popover(); }); } /** * Function that creates the parametric search table sub-header filters row dynamically based on the data in table parametric_partdetails table */ function createFilters(){ console.log("Inside createFilters--->"); jQuery.ajax({ url :'https://www.omron-ecb.co.kr:443/parametric-search?p_p_id=com_omron_product_list_portlet_ProductListPortlet&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage', cache: false, data: { "_com_omron_product_list_portlet_ProductListPortlet_reqType": "createFilter", "_com_omron_product_list_portlet_ProductListPortlet_nodeId": 1001020, "buster":new Date().getTime() }, type: "POST", dataType: "json", //async: false, success:function(data,textStatus, XMLHttpRequest){ //alert("filter data length: " + data.length); var numOfColHeaders = $("#part-param-table thead tr:first th").length; if (data.length === 0) { console.log("No valid attributes defined for this nodeId: " + 1001020 + ". Please contact Admin."); var errorMarkup = 'Add proper error markup here and show in front end.';//'
'; } var str1 = '#' + $(this).attr("id") + '#'; dummyFilterMarkup = dummyFilterMarkup.replace(str1, filtersColMarkup); } }); }); //console.log("Filters row markup: " + dummyFilterMarkup); $('#part-param-table thead').append(dummyFilterMarkup); $('#totalType').empty().append('모든 제품:' + totalType); $('#matchingType').empty().append('해당 제품:' + matchingType); // START : For initialization of sliders // Iterate through each filter column data $.each(data, function(index, value) { // Iterate through each column headers $("#part-param-table thead th").each(function(){ var headerColId = $(this).attr("id"); var isIntegerOnly = 0.01; if(value.csvFilterValues.indexOf(".") > 0) { isIntegerOnly = 0.01; } else { isIntegerOnly = 1; } console.log("isIntegerOnly :: " + isIntegerOnly); // compare the id of header column and the id associated with the part details json data if(headerColId == value.colId){ if(value.elementType == 'slider'){ myslider["#ex" + value.colId] = new Slider("#ex" + value.colId, { range: true, step: isIntegerOnly, reversed : true }); var minSliderValue = $("#ex"+value.colId).data("slider-min"); var maxSliderValue = $("#ex"+value.colId).data("slider-max"); $('#ex'+ value.colId).on('slide', function(slider){ var currValsArr = $("#ex"+value.colId).attr('value').split(','); $("#parametrixMinInput"+ value.colId).val(currValsArr[0]); $("#parametrixMaxInput"+ value.colId).val(currValsArr[1]); }); $("#parametrixMaxInput"+ value.colId).on("keyup", function(e) { if (e.keyCode == 13) { var val = Math.abs(parseFloat(this.value, 10) || maxSliderValue); this.value = val > maxSliderValue ? maxSliderValue : (val < minSliderValue ? minSliderValue : val); var curSliderValues = myslider["#ex" + value.colId].getAttribute('value'); curSliderValues[1] = parseFloat(this.value); curSliderValues[0] = parseFloat(Math.abs(parseFloat($("#parametrixMinInput"+ value.colId).val(), 10) || minSliderValue)); myslider["#ex" + value.colId].setValue(curSliderValues, true, true); updateFilter(); } }); $("#parametrixMinInput"+ value.colId).on("keyup", function(e) { if (e.keyCode == 13) { var val = Math.abs(parseFloat(this.value, 10) || minSliderValue); this.value = val > maxSliderValue ? maxSliderValue : (val < minSliderValue ? minSliderValue : val); var curSliderValues = myslider["#ex" + value.colId].getAttribute('value'); curSliderValues[0] = parseFloat(this.value); curSliderValues[1] = parseFloat(Math.abs(parseFloat($("#parametrixMaxInput"+ value.colId).val(), 10) || maxSliderValue)); myslider["#ex" + value.colId].setValue(curSliderValues, true, true); updateFilter(); } }); /* $("#ex" + value.colId).on("slide", function(slideEvt) { console.log(slideEvt.value); }); */ myslider["#ex" + value.colId].on('slideStop', function(){ updateFilter(); }); /* myslider.on('change', function(){ updateFilter(); }); */ //console.log("slider getValue: " + myslider.slider('getValue')); } } }); }); // END : For initialization of sliders } }, error:function(data,textStatus, XMLHttpRequest){ alert("Create table filters request failed."); } }); } /* This function is called when filter checkboxes are checked/unchecked. */ function updateFilter(cb){ //console.log("updateFilter => tableSelector: " + tableSelector); processing=true; recordCount = 0; currentDataLength = 0; //$(tableSelector + ' tbody').empty(); $('#part-param-table tbody').empty(); // after emptying the body of the table, point the tableSelector back to original table i.e. part-param-table tableSelector = '#part-param-table'; $("#excelDownloadback").show(); $("#excelDownloadfront").hide(); searchByFilters(); } /** * Function that retrieves the records from database based on the filters selected and nodeId. */ function searchByFilters(type){ console.log("Inside searchByFilters--->"); // reset the comparison flag isCompare=false; // Get all checked filters var colIdList = ''; var colFiltersList = ''; if(type != 'reset'){ $('.checkBoxFilter:input[type="checkbox"]:checked').each(function(){ //alert("Column Id: " + $(this).attr('id') + ", Selected filter name: " + $(this).parent().text()); if(colIdList == ''){ colIdList = colIdList + $(this).attr('id') + "_String"; }else{ colIdList = colIdList + "##" + $(this).attr('id') + "_String"; } if(colFiltersList == ''){ colFiltersList = colFiltersList + $(this).parent().text(); }else{ colFiltersList = colFiltersList + "##" + $(this).parent().text(); } }); /* $('.param-slider-value').each(function(){ console.log("Slider Column Id: " + $(this).parent().attr('id') + ", current value: " + $(this).attr('value') + ", lower value: " + $(this).attr('data-slider-min') + ", upper value: " + $(this).attr('data-slider-max')); }); */ $('.param-slider-value').each(function(){ var currValsArr = $(this).attr('value').split(','); console.log("Slider Column Id: " + $(this).parent().attr('id') + ", current lower value: " + currValsArr[0] + ", current upper value: " + currValsArr[1] + ", orig lower value: " + $(this).attr('data-slider-min') + ", orig upper value: " + $(this).attr('data-slider-max')); if(colIdList == ''){ colIdList = colIdList + $(this).parent().attr('id') + "_Number"; }else{ colIdList = colIdList + "##" + $(this).parent().attr('id') + "_Number"; } var sliderValue = '@@slider=>;lower:' + currValsArr[0] + ';upper:' + currValsArr[1]; if(colFiltersList == ''){ colFiltersList = colFiltersList + sliderValue; }else{ colFiltersList = colFiltersList + "##" + sliderValue; } }); if('undefined' == colIdList){ colIdList = ''; colFiltersList = ''; } } console.log("colIdList: " + colIdList + ", colFiltersList: " + colFiltersList); jQuery.ajax({ url :'https://www.omron-ecb.co.kr:443/parametric-search?p_p_id=com_omron_product_list_portlet_ProductListPortlet&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage', cache: false, data: { "_com_omron_product_list_portlet_ProductListPortlet_reqType": "search", "_com_omron_product_list_portlet_ProductListPortlet_startCount": recordCount, "_com_omron_product_list_portlet_ProductListPortlet_nodeId": 1001020, "_com_omron_product_list_portlet_ProductListPortlet_colIdList": colIdList, "_com_omron_product_list_portlet_ProductListPortlet_colFiltersList": colFiltersList, "buster":new Date().getTime() }, type: "POST", dataType: "json", //async: false, success:function(data,textStatus, XMLHttpRequest){ if(isFirstCall){ if (data.totalResults === 1) { // If total results = 1 then don't show filters and sliders. $('.checkBoxScroll').hide(); $('.arrows').hide(); } totalType = data.totalResults; isFirstCall = false; } if(type != 'onScrollDown'){ matchingType = data.totalResults; } var numOfColHeaders = $("#part-param-table thead tr:first th").length; /* console.log("Searched results total: " + data.totalResults + ", start: " + data.start + ", end: " + data.end + ",nodeId: " + data.nodeId + ", numOfColHeaders: " + numOfColHeaders); */ if (data.totalResults === 0 && totalType === 0) { /* $("#error").empty(); $("#error").html("No Categories found"); $("#error").addClass("alert"); */ var errorMarkup = '
"; tab_text= tab_text.replace(/]*>|<\/a>/g, "");//remove if u want links in your table //tab_text= tab_text.replace(/]*>/gi,""); // remove if u want images in your table tab_text= tab_text.replace(/]*>|<\/input>/gi, ""); // removes input params var ua = window.navigator.userAgent; var msie = ua.indexOf("MSIE "); var downloadFileName = $('#nodeName').text().concat(' Type Search.xls'); if (msie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) // If Internet Explorer { txtArea1.document.open("txt/html","replace"); txtArea1.document.write(tab_text); txtArea1.document.close(); txtArea1.focus(); sa=txtArea1.document.execCommand("SaveAs",true, downloadFileName); } else { //other browser not tested on IE 11 //sa = window.open('data:application/vnd.ms-excel,' + encodeURIComponent(tab_text)); var url = 'data:application/vnd.ms-excel,'+ encodeURIComponent(tab_text); var link = document.createElement('a'); link.href = url; link.download = downloadFileName; document.body.appendChild(link); link.click(); } } function populateShowParamList(){ console.log("populateShowParamList"); var showActiveParamList = ''; var showInactiveParamList = ''; showActiveParamList = showActiveParamList + '정격(저항부하)'; showActiveParamList = showActiveParamList + '접촉사양'; showActiveParamList = showActiveParamList + '동작에 필요한 힘(최대)(N)'; showActiveParamList = showActiveParamList + '전기적내구성(최소)'; showActiveParamList = showActiveParamList + '액츄에이터'; showActiveParamList = showActiveParamList + '단자형상'; // console.log("showActiveParamList: " + showActiveParamList); $("#multiselect_to").html(showActiveParamList); showInactiveParamList = showInactiveParamList + '분류'; showInactiveParamList = showInactiveParamList + '보호구조'; showInactiveParamList = showInactiveParamList + '기계적내구성(최소)'; showInactiveParamList = showInactiveParamList + '어플리케이션'; //console.log("showInactiveParamList: " + showInactiveParamList); $("#multiselect").html(showInactiveParamList); } function populateEditCanonical(){ console.log("populateEditCanonical"); } function firstTimeSearch(){ $('#loaderDiv').show(); /* Create the table header */ createHeaders(); /* Create filter checkboxes */ createFilters(); /* Perform default parametric search */ setTimeout(function(){ searchByFilters();}, 3000); $('#loaderDiv').hide(); } $(document).ready(function(){ $(".floatThead-table thead").html(""); /* START : code to show hide loading image on ajax call */ var $loading = $('#loaderDiv'); $(document) .ajaxStart(function () { $loading.show(); }) .ajaxStop(function () { $loading.hide(); }); /* END : code to show hide loading image on ajax call */ firstTimeSearch(); //	setTimeout(function(){ $(".sticky-header").floatThead({scrollingTop:0}); }, 4000); /* START : code to handle the footer, header on 'resize, load, orientation change' events of the browser window */ $(window).bind("resize", ScaleContent); $(window).bind("load", ScaleContent); $(window).bind("orientationchange", ScaleContent); function ScaleContent() { current_width = $(window).width(); equalwidth = $("#part-param-table").width(); if(current_width >= 320 ){ //$(".omron header .container, .omron header, .omron footer").width(equalwidth); } } /* END : code to handle the footer, header on 'resize, load, orientation change' events of the browser window */ /* Download for catalog */ $(".grid-action-btns").delegate("#downloadCatalogue","click",function (e) { if($('input[name="modelNumberChk"]:checked').length < 1){ alert('Please select part(s) for download.'); }else{ // checked checkbox length = 2 var values = []; var selectedPartKeys = new Array(); $('input[name="modelNumberChk"]:checked').each(function() { var modelNumber = $(this).attr('value')+'~'; var anchor=''; $(this).parents('tr').find('.data a').each(function() { if($(this).attr('href')!='#' && $(this).text().trim()!='CAD' && $(this).text().trim()!='Precautions'){ var url = $(this).attr('href'); var url1 = url.split("/").join("*"); url1 = url1.split(".").join("^"); selectedPartKeys[selectedPartKeys.length]=url1; } }); }); var url = 'https://www.omron-ecb.co.kr:443/parametric-search?p_p_id=com_omron_product_list_portlet_ProductListPortlet&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage&_com_omron_product_list_portlet_ProductListPortlet_reqType=downloadCatalog&_com_omron_product_list_portlet_ProductListPortlet_fileList=' + selectedPartKeys.toString(); var link = document.createElement('a'); link.href = url; document.body.appendChild(link); link.click(); } }); $("#excelDownloadback").on("click",function (e) { var numOfColumns = $("#part-param-table tbody tr:first td").length; if (numOfColumns === 1) { alert("No records found."); } else { // reset the comparison flag // Get all checked filters var colIdList = ''; var colFiltersList = ''; $('.checkBoxFilter:input[type="checkbox"]:checked').each(function(){ //alert("Column Id: " + $(this).attr('id') + ", Selected filter name: " + $(this).parent().text()); if(colIdList == ''){ colIdList = colIdList + $(this).attr('id') + '_String'; }else{ colIdList = colIdList + "^^" + $(this).attr('id') + '_String'; } if(colFiltersList == ''){ colFiltersList = colFiltersList + $(this).parent().text(); }else{ colFiltersList = colFiltersList + "^^" + $(this).parent().text(); } //alert("Column Id: " + colIdList + ", Selected filter name: " + colFiltersList); }); $('.param-slider-value').each(function(){ var currValsArr = $(this).attr('value').split(','); console.log("Excel download => Slider Column Id: " + $(this).parent().attr('id') + ", current lower value: " + currValsArr[0] + ", current upper value: " + currValsArr[1] + ", orig lower value: " + $(this).attr('data-slider-min') + ", orig upper value: " + $(this).attr('data-slider-max')); if(colIdList == ''){ colIdList = colIdList + $(this).parent().attr('id') + '_Number'; }else{ colIdList = colIdList + "^^" + $(this).parent().attr('id') + '_Number'; } var sliderValue = '@@slider=>;lower:' + currValsArr[0] + ';upper:' + currValsArr[1]; if(colFiltersList == ''){ colFiltersList = colFiltersList + sliderValue; }else{ colFiltersList = colFiltersList + "^^" + sliderValue; } }); if('undefined' == colIdList){ colIdList = ''; colFiltersList = ''; } console.log("colIdList: " + colIdList + ", colFiltersList: " + colFiltersList); var partNumberList = ''; var partIdList = ''; var regExComma = new RegExp(',', 'g'); $('input[name="modelNumberChk"]:checked').each(function (rowIndex) { if(partNumberList == ''){ partNumberList = partNumberList + encodeURI($(this).val().replace(regExComma, '^')); }else{ partNumberList = partNumberList + ',' + encodeURI($(this).val().replace(regExComma, '^')); } if(partIdList == ''){ partIdList = partIdList + $(this).attr('data-value'); }else{ partIdList = partIdList + ',' + $(this).attr('data-value'); } }); var nodeId = 1001020; var url = 'https://www.omron-ecb.co.kr:443/parametric-search?p_p_id=com_omron_product_list_portlet_ProductListPortlet&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_cacheability=cacheLevelPage&_com_omron_product_list_portlet_ProductListPortlet_reqType=downloadExcel&_com_omron_product_list_portlet_ProductListPortlet_startCount=' + recordCount + '&_com_omron_product_list_portlet_ProductListPortlet_nodeId=' + nodeId + '&_com_omron_product_list_portlet_ProductListPortlet_colIdList=' + colIdList + '&_com_omron_product_list_portlet_ProductListPortlet_colFiltersList=' + colFiltersList + '&_com_omron_product_list_portlet_ProductListPortlet_partId=' + partIdList + '&_com_omron_product_list_portlet_ProductListPortlet_partNumber=' + partNumberList; var link = document.createElement('a'); link.href = url; document.body.appendChild(link); link.click(); } }); /* START : Code for comparing two records/rows */ $("#compareme").click(function(){ /*$("#excelDownloadback").hide(); $("#excelDownloadfront").show(); */ if($('input[name="modelNumberChk"]:checked').length < 2){ alert('Please select minimum 2 parts for comparison.'); }else{ // checked checkbox length = 2 isCompare = true; var numOfColHeaders = $("#part-param-table thead tr:first th").length; var cellToHighlightIndexArr = [];// empty array to store the column ids that have differences in values of selected rows for comparison var firstRowColValuesArr = []; // empty array to store the column values of first row of the selected rows for comparison var totalSelected = 0; // Get columns values of the first row selected for comparison and store in a array $('input[name="modelNumberChk"]:checked').each(function (rowIndex) { totalSelected = totalSelected + 1; if(rowIndex ==0){ $(this).parents('tr').find('td').each(function (colIndex) { firstRowColValuesArr.push($(this).text().trim()); }); } }); //console.log("firstRowColValuesArr: " + firstRowColValuesArr); // Compare the column values of first row retrieved above with the rest of the selected rows for comparison. And store the difference column id in an array $('input[name="modelNumberChk"]:checked').each(function (rowIndex) { if(rowIndex !=0){ $(this).parents('tr').find('td').each(function (colIndex) { var nextRowsCol = $(this); //console.log("compare firstSelectedRowsCol cell: =" + firstRowColValuesArr[colIndex] + "=, with nextRowsCol cell: =" + nextRowsCol.text() + "="); // No need to compare the 1,2 and second last,last columns if ( (colIndex != 0) && (colIndex != 1) && (colIndex != (numOfColHeaders - 1)) && (colIndex != (numOfColHeaders - 2)) && (firstRowColValuesArr[colIndex] !== nextRowsCol.text().trim())) { //console.log("compare firstSelectedRowsCol cell: =" + firstRowColValuesArr[colIndex] + "=, with nextRowsCol cell: =" + nextRowsCol.text() + "="); cellToHighlightIndexArr.push(colIndex); } }); } }); //console.log("cellToHighlightIndexArr: " + cellToHighlightIndexArr); //Remove duplicates from the array var uniqueColIds = []; $.each(cellToHighlightIndexArr, function(i, el){ if($.inArray(el, uniqueColIds) === -1) uniqueColIds.push(el); }); //console.log("uniqueColIds: " + uniqueColIds); // Loop through each row and highlight the column that has the column id same as the ids stored in the cellToHighlightIndexArr $('input[name="modelNumberChk"]:checked').each(function (rowIndex) { var currentRow = $(this); $.each(uniqueColIds, function(index,value){ currentRow.parents('tr').find('td').each(function (j) { //console.log("compare uniqueColIds: " + value + ", with: " + j); if(value == j){ $(this).css('backgroundColor', '#086fff'); $(this).css('color', '#ffffff'); } }); }); }); // remove all the unchecked checkboxes $('input[name="modelNumberChk"]:not(:checked)').each(function (rowIndex) { $(this).parents('tr').remove(); }); $('#matchingType').empty().append('Matching Type:' + totalSelected); } }); /* END : Code for comparing two records/rows */ /* START : code to handle scroll event. when scrolling down, load another set of records if exists. */ var timeout; $('.fakescroll').css('width', $('#part-param-table')[0].offsetWidth); var lastPos = 0; $('.fakescroll-wrapper').on('scroll', function(){ var currPos = $('.fakescroll-wrapper').scrollLeft(); console.log(currPos); if (lastPos < currPos) { console.log(currPos); $('#part-param-table').css('left', -currPos); $('#part-param-table thead').css('left', -currPos); } if (lastPos > currPos) { $('#part-param-table').css('left', -currPos); $('#part-param-table thead').css('left', -currPos); } lastPos = currPos; }); function loadmore_rows(){ console.log('loadmore_rows -- 1'); if (processing || isCompare){ console.log('loadmore_rows -- 2'); return false; } //console.log('$(document).height() :: ' + $(document).height() + '###### $(window).scrollTop() ::' + $(window).scrollTop() + '###### $(window).height() :: ' + $(window).height()); if($(document).height() <= $(window).scrollTop() + $(window).height()) { //if user scrolled to bottom of the page console.log('loadmore_rows -- 3'); processing = true; console.log("recordCount: " + recordCount + ", recordCount: " + recordCount + ", currentDataLength: " + currentDataLength + ", currentDataLength: " + currentDataLength); if((recordCount != 0) && (recordCount < matchingType) && (currentDataLength == 10)){ console.log('loadmore_rows -- 4'); // On scroll down, load more records if exists //console.log("calling scroll: " + ",processing: " + processing + ", recordCount: " + recordCount + ", currentDataLength: " + currentDataLength + ", matchingType: " + matchingType + ", totalType: " + totalType) // when the header gets fixed to top of the browser; the table headers are created under a new table by the jQuery.floatThead 1.2.10 js //tableSelector = '.floatThead-table'; searchByFilters('onScrollDown'); } } } /* END : code to handle scroll event. when scrolling down, load another set of records if exists. */ $(window).on('scroll', function() { if(typeof timeout == "number") { window.clearTimeout(timeout); delete timeout; } console.log('$(document).scrollTop() :: ' + $(document).scrollTop() + '### $("#part-param-table").height() :: ' + $("#part-param-table").height() + '### $(window).height() :: ' + $(window).height()); if($(document).scrollTop() > 300 && $("#part-param-table").height() > $(window).height()){ $('#part-param-table').addClass('fixed-header'); console.log('in') } if($(document).scrollTop() < 250){ $('#part-param-table').removeClass('fixed-header'); } timeout = window.setTimeout( loadmore_rows(), 300); // get all td width and store var tdArray = new Array(); $('#part-param-table tbody tr:first-child td').each( function () { var columnWidth = this.offsetWidth; tdArray.push(columnWidth); }); // get all th width and store var thArray = new Array(); $('#part-param-table thead tr:first-child th').each( function () { var columnWidth = this.offsetWidth; thArray.push(columnWidth); }); // get all th || td width comapre var outputArray = new Array(); $('#part-param-table tbody tr:first-child td').each(function(i){ var maxWidth = 0; if(thArray[i] >= tdArray[i]){ maxWidth = thArray[i]; }else{ maxWidth = tdArray[i]; } outputArray[i] = maxWidth; // reindex i for nth-child var cntr = i + 1; $('td:nth-child('+ cntr +')').css('min-width',outputArray[i]); $('th:nth-child('+ cntr +')').css('min-width',outputArray[i]); $('td:nth-child('+ cntr +')').css('width',outputArray[i]); $('th:nth-child('+ cntr +')').css('width',outputArray[i]); }); }); }); function applyHeaderChanges(){ var arrInactv = []; $("#multiselect > option").each(function(){ arrInactv.push(this.value); }); $("#inactvCols").val(arrInactv.join(',')); var arrActv = []; $("#multiselect_to > option").each(function(){ arrActv.push(this.value); }); $("#actvCols").val(arrActv.join(',')); //console.log("Inactive: " + $("#inactvCols").val() + ", Active: " + $("#actvCols").val()); document._com_omron_product_list_portlet_ProductListPortlet_showHideColForm.submit(); } function gotoNotFound(){ location.href = '/not-found'; }