How to use splitKey method in wpt

Best JavaScript code snippet using wpt

calendar_beans_v2.0.js

Source:calendar_beans_v2.0.js Github

copy

Full Screen

1/*2* 2011.11.13 make by beans9(ahmax95@gmail.com)3* http://beans9.tistory.com4*/5var cssAddFlag = true;6function CalAddCss(){7 var cssHtml = "<style type='text/css'>";8 cssHtml += ".calLayout{ border:1px solid #DDDDDD; background-color:#ECEADF; position:absolute;padding:2px;display:none;z-index:9999 }"; 9 cssHtml += ".calTitle{ border:1px solid #D4D1BF; background-color: #ffffff; width:99%; font-size:9pt;}"; 10 cssHtml += ".calHeader{ padding:2px; padding-bottom:0px;text-align:center;}";11 cssHtml += ".calBody{padding:2px;padding-top:0px;text-align:center; }";12 cssHtml += ".calDay{background-color: #FBFBFB;border:1px solid #CBC7BD; width:20px;float:left;font-size:8pt;padding-top:3px;padding-bottom:2px;cursor:pointer;}";13 cssHtml += ".calSunDay{ background-color: #FBFBFB;border:1px solid #CBC7BD; width:20px;float:left;font-size:8pt;padding-top:3px;padding-bottom:2px;cursor:pointer;color:red;}";14 cssHtml += ".calSatDay{ background-color: #FBFBFB;border:1px solid #CBC7BD; width:20px;float:left;font-size:8pt;padding-top:3px;padding-bottom:2px;cursor:pointer; color:blue;}";15 cssHtml += ".calOtherDay{background-color: #FBFBFB; border:1px solid #CBC7BD;width:20px;float:left;font-size:8pt;padding-top:3px;padding-bottom:2px;cursor:pointer;color:#CBC7BD;}";16 cssHtml += ".dayToday{background-color: #368CFE;border:1px solid #CBC7BD;font-weight:bold;font-weight:bold;width:20px;float:left;font-size:8pt;padding-top:3px;padding-bottom:2px;cursor:pointer;color:white; }";17 cssHtml += ".calSelDay{ background-color: #CF4040;border:1px solid #CBC7BD;font-weight:bold;width:20px;float:left;font-size:8pt;padding-top:3px;padding-bottom:2px;cursor:pointer;text-decoration:underline;color:white;}";18 cssHtml += ".dayEvMon{font-size:8pt;width:25px; height:15px;background-color: #FBFBFB;border:1px solid #CBC7BD; padding:4px 4px 0px 3px;float:left;cursor:pointer;}"; 19 cssHtml += ".MonToday{font-size:8pt;width:25px; height:15px;background-color: #368CFE;border:1px solid #CBC7BD; font-weight:bold;padding:4px 4px 0px 3px;color:white;cursor:pointer;}";20 cssHtml += ".selMon{font-size:8pt;width:25px;height:15px;background-color: #CF4040;border:1px solid #CBC7BD;font-weight:bold;padding:4px 4px 0px 3px;text-decoration:underline;color:white;}";21 cssHtml += ".calOnDay{background-color: #006060;border:1px solid #4B22C0;float:left;cursor:pointer;color:white;}";22 cssHtml += ".calDaySpace{padding:1px;float:left;}";23 cssHtml += ".calDayBr{clear:both;height:2px;}";24 cssHtml += ".calDayTitle{padding-top:2px;width:22px;float:left; font-size:8pt;}"; 25 cssHtml += ".divHeadOnRigth{color:#18CCA8;cursor:pointer;}";26 cssHtml += ".todayBtn{clear:both;text-align: center;font-size:8pt;cursor:pointer;background-color: #FBFBFB;border:1px solid #CBC7BD;padding:4px 4px 0px 3px;height:15px;}";27 cssHtml += ".todayLay{padding-left:2px;}</style>";28 jQuery("head").append(cssHtml);29}30// 초기화 31function initCal(obj){32 if( cssAddFlag == true ){33 CalAddCss();34 cssAddFlag = false;35 }36 37 // id 정의38 var calId = "Cal" + obj.id; 39 40 // calendar type (day,mon)41 var calType = obj.type == null ? "day" : obj.type; 42 if( calType.toLowerCase() != "day" && calType.toLowerCase() != "mon"){43 calType = "day";44 }45 46 // 최소년도, 최대년도 47 var minYear = obj.min == null ? "2000" : obj.min;48 // maxYear 최대 년도 설정49 var maxYear = obj.max == null ? new Date().getFullYear() + 2: obj.max;50 var splitKey = obj.splitKey == null ? "-" : obj.splitKey; 51 var todayYN = obj.today == null ? "n" : "y";52 var iconYN = obj.icon == null ? "n" : "y";53 var iconUrl = obj.iconUrl == null ? "/manage/img/calendar_btn.gif" : obj.iconUrl ;54 var timeYN = obj.timeYN == null ? "n" : "y";55 // 달력 레이아웃(전체틀+월선택)그리기56 drawCalForm(calId,obj.id,calType,minYear,maxYear,todayYN,iconYN,iconUrl);57 58 if( calType == "day"){59 jQuery("#"+obj.id).attr("maxlength",timeYN == "y" ? 21 : 10);60 jQuery("#"+calId).css("width","170px");61 jQuery("#"+calId +"btn.todayBtn").css("width","157px"); 62 }else{63 jQuery("#"+obj.id).attr("maxlength",7);64 jQuery("#"+calId).css("width","146px");65 jQuery("#"+calId +"btn.todayBtn").css("width","133px");66 }67 68 // input box에 click event 69 jQuery("#"+ calId + "Icon").click(function(event){ 70 var datesVal = jQuery("#"+obj.id).val();71 if( calType == "mon") datesVal += splitKey + '1';72 73 var dates = isValidCheck(datesVal ,splitKey, timeYN);74 if( calType == "day"){75 makeCal(calId,dates,splitKey,timeYN);76 }else{77 makeCalMon(calId,dates,splitKey);78 }79 calPosition(obj.id,calId); 80 jQuery("#"+calId).show();81 82 });83 84 // 외부 화면 클릭시 달력감추기85 jQuery(document).click(function(event){86 var parentEls = jQuery( event.target).parents().map(function () { return this.id; }).get().join(", ");87 if(parentEls.indexOf(calId+",") == -1 && event.target.id != obj.id && parentEls.indexOf(calId+"Icon,")){88 jQuery("#"+calId).hide();89 }90 });91 92 jQuery(window).resize(function(event){93 calPosition(obj.id,calId);94 });95 96 // 달력상단 이전/다음 버튼 처리97 jQuery("#"+calId+"before,#"+calId+"next").click(function(event){98 var plus = -1;99 if(this.id.indexOf("next") > -1){ var plus = 1; }100 101 if( calType == "day"){102 var dates = calDate(jQuery("#"+ calId + "selYear").val(),jQuery("#"+calId + "selMon").val(),plus,isValidCheck(jQuery("#"+obj.id).val(),splitKey, timeYN)); 103 if((dates[0] >= minYear && plus == -1) || (dates[0] <= maxYear && plus == 1)){104 makeCal(calId,dates,splitKey,timeYN);105 } 106 }else{107 var dates = calDate(jQuery("#"+ calId + "selYear").val(),'1',plus*12,isValidCheck(jQuery("#"+obj.id).val()+splitKey+'1',splitKey, timeYN));108 if((dates[0] >= minYear && plus == -1) || (dates[0] <= maxYear && plus == 1)){109 makeCalMon(calId,dates,splitKey);110 }111 } 112 }).mouseover(function(){113 jQuery(this).addClass("divHeadOnRigth");114 }).mouseout(function(){115 jQuery(this).removeClass("divHeadOnRigth");116 });;117 118 // 월별선택시 필요없음119 if( calType == "day"){120 // 년도,월 selectbox 선택시 이벤트121 jQuery("#"+calId+"selYear,#"+calId+"selMon").change(function(event){122 var dates = calDate(jQuery("#"+ calId + "selYear").val(),jQuery("#"+calId + "selMon").val(),0,isValidCheck(jQuery("#"+obj.id).val(),splitKey, timeYN));123 makeCal(calId,dates,splitKey, timeYN);124 }); 125 }else{126 jQuery("#"+calId+"selYear").change(function(event){127 var dates = calDate(jQuery("#"+ calId + "selYear").val(),1,0,isValidCheck(jQuery("#"+obj.id).val()+splitKey+'1',splitKey, timeYN)); 128 makeCalMon(calId,dates,splitKey);129 }); 130 }131 132 jQuery("#"+calId+"btn").click(function(){133 jQuery("#"+obj.id).val("");134 var dates = isValidCheck('',splitKey, timeYN);135 if( calType == 'day'){136 makeCal(calId,dates,splitKey,timeYN);137 }else{138 makeCalMon(calId,dates,splitKey);139 }140 });141 142 calPosition(obj.id,calId);143}144//클릭 이벤트145function calClickEvent(id){146 jQuery("#" + id + " .calOtherDay,.calDay,.calSunDay,.calSatDay,.MonToday,.selMon,.dayEvMon").click(function(event) {147 jQuery("#" + id.substring(3)).val(this.id.replace(id,""));148 jQuery("#" + id).hide();149 }).mouseover(function(){150 jQuery(this).addClass("calOnDay");151 }).mouseout(function(){152 jQuery(this).removeClass("calOnDay");153 });154} 155// 달력 폼 그리기 156function drawCalForm(id,tId,calType,min,max,todayYN,iconYN,imageUrl){ // tId = 입력창ID 157 158 if(iconYN == "y"){159 jQuery(document.body).append("<div id='"+ id +"Icon' style='position:absolute; cursor:pointer; z-index:10000;'><img id='"+ id +"IconImg' src='"+ imageUrl +"'><div>");160 }161 162 // layout163 jQuery(document.body).append("<div id='"+ id +"' onselectstart='return false' class='calLayout'><div>");164 165 // 상단 년,달 이동 166 var html = "<div class='calTitle'><table width='100%'><tr><td id='"+ id +"before' width='10%' style='font-size: 10px'>◀</td><td width='80%' align='center'>";167 168 // 년선택169 html += "<select id='"+ id +"selYear'>";170 for(var i=min;i<=max;i++){ html += "<option value=" + i + ">" + i + "</option>"; }171 html += "</select>"172 173 // 월선택 (일별달력일 경우에만)174 if( calType == "day"){175 html += "<select id='"+ id +"selMon'>";176 for(var i=1;i<=12;i++){ html += "<option value=" + i + ">" + i + "월</option>"; }177 html += "</select>" 178 }179 180 html += "</td><td id='"+ id +"next' width='10%' style='font-size: 10px'>▶</td></tr></table></div>";181 if( calType == "day" )html += "<div id='" + id + "Header' class='calHeader'></div>";182 html += "<div id='" + id + "Content' class='calBody'></div>";183 184 if( todayYN == "y"){185 html += "<div class='todayLay'><div id='" + id + "btn' class='todayBtn'>Today</div></div>";186 }187 188 jQuery("#"+id).html(html); 189 190 // 월선택 (일별달력일 경우에만)191 if (calType == "day") {192 var tempHtml = ""; 193 var yoil = ["일", "월", "화", "수", "목", "금", "토"];194 for (i = 0; i < 7; i++) {195 tempHtml += "<div class='calDayTitle'>" + yoil[i] + "</div>";196 if (i == 6) { tempHtml += "<div class='calDayBr'></div>"; }197 else { tempHtml += "<div class='calDaySpace'></div>"; }198 }199 jQuery("#" + id + "Header").append(tempHtml);200 } 201 202 203}204// 날짜변경(달변경) 달력내용 그리기205function makeCal(id,dates,splitKey,timeYN){ 206 var timeTF = timeYN == "y" ? true : false;207 208 // 이번달 시작날짜,마지막날짜 209 var firstDay = new Date(dates[0],eval(dates[1]-1),1).getDay();210 211 // 이번달 마지막날짜212 var lastDate = new Date(dates[0],eval(dates[1]),0);213 var lastDateNum = lastDate.getDate();214 var lastDay = lastDate.getDay();215 216 // 이전달 마지막날짜217 var beforeMonDate = new Date(dates[0],eval(dates[1]-1),0);218 var beforeMonLastDay = beforeMonDate.getDate();219 var beforeYearMonText = beforeMonDate.getFullYear() + splitKey + strFormat(beforeMonDate.getMonth()+1) + splitKey;220 221 var nextMonDate = new Date(dates[0],eval(dates[1]),1);222 var nextYearMonText = nextMonDate.getFullYear() + splitKey + strFormat(nextMonDate.getMonth()+1) + splitKey;223 224 var nowYearMonText = dates[0] + splitKey + strFormat(dates[1]) + splitKey;225 226 var ndate = new Date();227 var today;228 if(timeTF){229 today = ndate.getFullYear() + splitKey + strFormat(ndate.getMonth()+1) + splitKey + strFormat(ndate.getDate()) + " " + strFormat(ndate.getHours()) + ":" + strFormat(ndate.getMinutes()) + ":" + strFormat(ndate.getSeconds());230 } else {231 today = ndate.getFullYear() + splitKey + strFormat(ndate.getMonth()+1) + splitKey + strFormat(ndate.getDate());232 }233 //----------------------------------------------------- 234 var html = ""; 235 var brCount = 1; // 줄넘김 count236 237 // before month238 for( i = 1; i<=firstDay; i++){239 html += "<div class='calOtherDay' id='"+ id + beforeYearMonText + (beforeMonLastDay-(firstDay-i)) +"'>"+ (beforeMonLastDay-(firstDay-i)) + "</div><div class='calDaySpace'></div>";240 brCount ++; 241 } 242 243 // now month244 for (i = 1; i <= lastDateNum; i++) { 245 var dayCss = "calDay"; 246 if (brCount % 7 == 1) { dayCss = "calSunDay" ; }247 else if(brCount % 7 == 0){ dayCss = "calSatDay" ; }248 249 if(timeTF){250 html += "<div class='"+ dayCss +"' id='"+ id + nowYearMonText + strFormat(i) + " " + strFormat(ndate.getHours()) + ":" + strFormat(ndate.getMinutes()) + ":" + strFormat(ndate.getSeconds()) + ".0" +"'>" + i + "</div>";251 }else{252 html += "<div class='"+ dayCss +"' id='"+ id + nowYearMonText + strFormat(i) +"'>" + i + "</div>";253 }254 255 if( brCount %7 == 0 && i != lastDateNum ){ html += "<div class='calDayBr'></div>"; }256 else{ html += "<div class='calDaySpace'></div>"; }257 brCount ++;258 }259 260 // next month261 var nexyStartDay = 1;262 for( i = lastDay; i<6; i++){263 html += "<div class='calOtherDay' id='" +id + nextYearMonText + strFormat(nexyStartDay) +"'>"+ nexyStartDay++ + "</div><div class='calDaySpace'></div>";264 }265 266 // 내용 삽입267 jQuery("#" + id + "Content").html(html);268 269 // 년도 select 설정270 jQuery("#" + id + "selYear").val(dates[0]);271 272 // 일별달력일 경우 월 select 선정273 jQuery("#" + id + "selMon").val(eval(dates[1]));274 275 // 오늘날짜 체크276 jQuery("#" + id+ today).addClass("dayToday");277 278 // 입력날짜 체크279 if(dates[4] == true){280 jQuery("#" +id + dates[3]).addClass("calSelDay"); 281 // 입력날짜가 유효한 날짜면 input쪽 데이터를 형식에 맞게 변경282 jQuery("#" + id.substring(3)).val(dates[3]);283 } 284 285 calClickEvent(id);286}287function makeCalMon(id,dates,splitKey){288 var nowYeaText = dates[0] + splitKey;289 290 var ndate = new Date();291 var today = ndate.getFullYear() + splitKey + strFormat(ndate.getMonth()+1);292 293 var html = "<div class='calDayBr'></div><div class='calDayBr'></div>"; 294 for(var i=1;i<13;i++){295 html += "<div class='dayEvMon' id='"+ id + nowYeaText + strFormat(i) +"'>" + i + "</div>";296 if( i %4 == 0 && i != 12){ html += "<div class='calDayBr'></div>"; }297 else{298 html += "<div class='calDaySpace'></div>"; 299 }300 } 301 // 내용 삽입302 jQuery("#" + id + "Content").html(html); 303 // 년도 select 설정304 jQuery("#" + id + "selYear").val(dates[0]);305 306 // 오늘날짜 체크307 jQuery("#" + id + today).addClass("MonToday");308 309 // 입력날짜 체크310 if(dates[4] == true){311 jQuery("#" +id + dates[3].substring(0,7)).addClass("selMon");312 313 // 입력날짜가 유효한 날짜면 input쪽 데이터를 형식에 맞게 변경314 jQuery("#" + id.substring(3)).val( dates[3].substring(0,7));315 } 316 317 calClickEvent(id);318}319// 날짜 유효성 체크320function isValidCheck(strDate,splitKey,timeYN,todayCheck){321 var timeTF = timeYN == "y" ? true : false;322 323 var date = strDate;324 var dates;325 var times;326 if(timeTF){327 times = date.substr(date.indexOf(" ")+1,8).split(":");328 dates = date.substr(0,date.indexOf(" ")).split(splitKey);329 } else {330 dates = date.split(splitKey);331 }332 var idate;333 if(timeTF){334 idate = new Date(dates[0],eval(dates[1])-1,eval(dates[2]),times[0],times[1],times[2],0);335 } else {336 idate = new Date(dates[0],eval(dates[1])-1,eval(dates[2]));337 }338 var ndate = new Date();339 340 var isValid = true;341 if( dates[0] != idate.getFullYear()) isValid = false; 342 else if( eval(dates[1])-1 != idate.getMonth()) isValid = false; 343 else if( eval(dates[2]) != idate.getDate()) isValid = false;344 if(timeTF){345 if( times[0] != idate.getHours()) isValid = false; 346 else if( times[1] != idate.getMinutes()) isValid = false; 347 else if( times[2] != idate.getSeconds()) isValid = false;348 }349 if( isValid == false ){350 dates[0] = ndate.getFullYear();351 dates[1] = strFormat(ndate.getMonth()+1);352 dates[2] = strFormat(ndate.getDate());353 if(timeTF){354 times[0] = strFormat(ndate.getHours());355 times[1] = strFormat(ndate.getMinutes());356 times[2] = strFormat(ndate.getSeconds());357 }358 } 359 360 if(timeTF){361 dates[3] = dates[0] +splitKey + strFormat(dates[1]) + splitKey + strFormat(dates[2]) + " " + strFormat(times[0]) + ":" + strFormat(times[1]) + ":" + strFormat(times[2]) + ".0";362 }else{363 dates[3] = dates[0] +splitKey + strFormat(dates[1]) + splitKey + strFormat(dates[2]);364 }365 dates[4] = isValid;366 return dates;367} 368function calDate(year,month,adjust,isValidDate){369 var date = new Date(year,(month-1)+adjust,1);370 var dates = [date.getFullYear(),date.getMonth()+1,date.getDate(),isValidDate[3],isValidDate[4]];371 return dates;372}373// 날짜 format 맞추기374function strFormat(str){375 if((str+"").length == 1) str = "0" + str;376 return str; 377}378// 달력위치변경 379function calPosition(target,id){380 var tInput = jQuery("#" + target).offset();381 var tHeight = jQuery("#" + target).outerHeight();382 var tWidth = jQuery("#" + target).outerWidth();383 384 var calHeight = jQuery("#" + id).outerHeight();385 386 if( tInput != null){387 jQuery("#" + id).css({"top":tInput.top+tHeight , "left":tInput.left});388 jQuery("#" + id + "Icon").css({"top":tInput.top+1,"left":tInput.left+tWidth+2});389 }...

Full Screen

Full Screen

compareTestCase.js

Source:compareTestCase.js Github

copy

Full Screen

...17 oneWord: function () {18 var keyT = 'nakano';19 var keyF = 'sapporo';20 var failed = {};21 if(compare(testDetails, splitKey(keyT)) == false)22 failed['keyT'] = keyT;23 if(compare(testDetails, splitKey(keyF)) == true)24 failed['keyF'] = keyF;25 if(Object.keys(failed).length > 0)26 {27 console.log('One Word: FAILED');28 console.log(failed);29 }30 else31 console.log('One Word: PASSED');32 console.log('----------------------');33 },34 35 phrase: function () {36 var keyT1 = 'nakano store figma';37 var keyT2 = 'マックスファクトリー アイギス 未開封・';38 var keyF1 = 'sapporo store figma';39 var keyF2 = 'ックスフナエ ック';40 var failed = {};41 if(compare(testDetails, splitKey(keyT1)) == false)42 failed['keyT1'] = keyT1;43 if(compare(testDetails, splitKey(keyT2)) == false)44 failed['keyT2'] = keyT2;45 if(compare(testDetails, splitKey(keyF1)) == true)46 failed['keyF1'] = keyF1;47 if(compare(testDetails, splitKey(keyF2)) == true)48 failed['keyF2'] = keyF2;49 if(Object.keys(failed).length > 0)50 {51 console.log('Phrase: FAILED');52 console.log(failed);53 }54 else55 console.log('Phrase: PASSED');56 console.log('----------------------');57 },58 foreign: function () {59 var keyT = 'アイギス';60 var keyF = 'ナナエ';61 var failed = {};62 if(compare(testDetails, splitKey(keyT)) == false)63 failed['keyT'] = keyT;64 if(compare(testDetails, splitKey(keyF)) == true)65 failed['keyF'] = keyF;66 if(Object.keys(failed).length > 0)67 {68 console.log('Foreign: FAILED');69 console.log(failed);70 }71 else72 console.log('Foreign: PASSED');73 console.log('----------------------');74 },75 literal: function () {76 var keyT1 = '\'マックスファクトリー figma\'';77 var keyT2 = '"nakano store"';78 var keyT3 = '"ペルソナ3 アイギス 未開封・箱"'79 var keyF1 = '"nakano stre"';80 var keyF2 = '\'nakano figma\'';81 var failed = {};82 if(compare(testDetails, splitKey(keyT1)) == false)83 failed['keyT1'] = keyT1;84 if(compare(testDetails, splitKey(keyT2)) == false)85 failed['keyT2'] = keyT2;86 if(compare(testDetails, splitKey(keyT3)) == false)87 failed['keyT3'] = keyT3;88 if(compare(testDetails, splitKey(keyF1)) == true)89 failed['keyF1'] = keyF1;90 if(compare(testDetails, splitKey(keyF2)) == true)91 failed['keyF2'] = keyF2;92 if(Object.keys(failed).length > 0)93 {94 console.log('Literal: FAILED');95 console.log(failed);96 }97 else98 console.log('Literal: PASSED');99 console.log('----------------------');100 },101 102 exact: function () {103 var keyT = testDetails;104 var keyF = testDetails + 'hello';105 var failed = {};106 if(compare(testDetails, splitKey(keyT)) == false) 107 failed['keyT'] = keyT;108 if(compare(testDetails,splitKey(keyF)) == true)109 failed['keyF'] = keyF;110 if(Object.keys(failed).length > 0)111 {112 console.log('Exact: FAILED');113 console.log(failed);114 }115 else116 console.log('Exact: PASSED');117 console.log('----------------------');118 },119 noOrder: function () {120 var keyT1 = 'figma "nakano store"';121 var keyT2 = 'nakano figma store';122 var keyF1 = 'nakano figma figure';123 var keyF2 = '"store nakano" figma"';124 var failed = {};125 if(compare(testDetails, splitKey(keyT1)) == false)126 failed['keyT1'] = keyT1;127 if(compare(testDetails, splitKey(keyT2)) == false)128 failed['keyT2'] = keyT2;129 if(compare(testDetails, splitKey(keyF1)) == true)130 failed['keyF1'] = keyF1;131 if(compare(testDetails, splitKey(keyF2)) == true) 132 failed['keyF2'] = keyF2;133 if(Object.keys(failed).length > 0)134 {135 console.log('No Order: FAILED');136 console.log(failed);137 }138 else139 console.log('No Order: PASSED');140 console.log('----------------------');141 },142 specialChar: function(){143 var keyT1 = '[ ]';144 var keyT2 = '3';145 var keyF1 = '【';146 var keyF2 = '&';147 var failed = {};148 if(compare(testDetails, splitKey(keyT1)) == false)149 failed['keyT1'] = keyT1;150 if(compare(testDetails, splitKey(keyT2)) == false)151 failed['keyT2'] = keyT2;152 if(compare(testDetails, splitKey(keyF1)) == true)153 failed['keyF1'] = keyF1;154 if(compare(testDetails, splitKey(keyF2)) == true) 155 failed['keyF2'] = keyF2;156 if(Object.keys(failed).length > 0)157 {158 console.log('Special Char: FAILED');159 console.log(failed);160 }161 else162 console.log('Special Char: PASSED');163 console.log('----------------------');164 165 },166 167 capitalize: function(){168 var keyT1 = 'FIGMA';169 var keyT2 = '"NaKaNO STORE"';170 var failed = {};171 if(compare(testDetails, splitKey(keyT1)) == false)172 failed['keyT1'] = keyT1;173 if(compare(testDetails, splitKey(keyT2)) == false)174 failed['keyT2'] = keyT2;175 if(Object.keys(failed).length > 0)176 {177 console.log('Capitalize: FAILED');178 console.log(failed);179 }180 else181 console.log('Capitalize: PASSED');182 console.log('----------------------');183 },184 185 exclude: function(){186 var keyT1 = 'figma |test|'; 187 var keyT2 = 'nakano |未開イタミ|';188 var keyF1 = 'nakano |アイギス|';189 var keyF2 = '|nakano store|';190 var failed = {};191 if(compare(testDetails,splitKey(keyT1)) == false)192 failed['keyT1'] = keyT1;193 if(compare(testDetails,splitKey(keyT2)) == false)194 failed['keyT2'] = keyT2;195 if(compare(testDetails,splitKey(keyF1)) == true)196 failed['keyF1'] = keyF1;197 if(compare(testDetails,splitKey(keyF2)) == true)198 failed['keyF2'] = keyF2; 199 if(Object.keys(failed).length > 0)200 {201 console.log('Exclude: FAILED');202 console.log(failed);203 }204 else205 console.log('Exclude: PASSED');206 console.log('----------------------');207 208 209 }210}211 function splitKey( key) {212 var newKey = key.toLowerCase().match(/[^"'\s\|]+|"[^"]+"|'[^']+'|\|[^\|]+\|/g);213 for (var j = 0; j < newKey.length; ++j) {214 newKey[j] = newKey[j].replace(/["']/g, '').replace(/\s{2,}|[\n\t]/g, ' ');215 }216 console.log(newKey);217 return newKey;218 }219 function compare(details, key) {220 for (var j = 0; j < key.length; ++j) {221 if(key[j].charAt(0) == '|'){222 if(details.toLowerCase().indexOf(key[j].substring(1, key[j].length-1)) > -1)223 return false;224 }225 else if(details.toLowerCase().indexOf(key[j]) == -1){...

Full Screen

Full Screen

object.js

Source:object.js Github

copy

Full Screen

1export const deepGet = (key, obj) => {2 if (!obj) {3 throw new TypeError('Object must be specified');4 }5 const splitKey = typeof key === 'string' && key !== '' ? key.split('.') : [];6 if (splitKey.length === 1) {7 return obj[splitKey[0]];8 }9 const k = splitKey.shift();10 return obj[k] ? deepGet(splitKey.join('.'), obj[k]) : false;11};12export const deepSet = (key, value = {}, obj = {}) => {13 if (!key) {14 throw new TypeError('Key must be specified');15 }16 const splitKey = typeof key === 'string' && key !== '' ? key.split('.') : [];17 if (splitKey.length === 1) {18 obj[splitKey[0]] = value;19 return;20 }21 const k = splitKey.shift();22 obj[k] = obj[k] ? obj[k] : {};23 deepSet(splitKey.join('.'), value, obj[k]);24 return obj;25};...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2wptools.splitKey('foo|bar');3var wptools = require('wptools');4wptools.splitKey('foo|bar');5var wptools = require('wptools');6wptools.splitKey('foo|bar');7var wptools = require('wptools');8wptools.splitKey('foo|bar');9var wptools = require('wptools');10wptools.splitKey('foo|bar');11var wptools = require('wptools');12wptools.splitKey('foo|bar');13var wptools = require('wptools');14wptools.splitKey('foo|bar');15var wptools = require('wptools');16wptools.splitKey('foo|bar');17var wptools = require('wptools');18wptools.splitKey('foo|bar');19var wptools = require('wptools');20wptools.splitKey('foo|bar');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var splitKey = wptools.splitKey;3var obj = splitKey('enwiki:Albert Einstein');4console.log(obj);5console.log(obj.lang);6console.log(obj.title);7var wptools = require('wptools');8var getLang = wptools.getLang;9var lang = getLang('enwiki:Albert Einstein');10console.log(lang);11var wptools = require('wptools');12var getTitle = wptools.getTitle;13var title = getTitle('enwiki:Albert Einstein');14console.log(title);15var wptools = require('wptools');16var getLangTitle = wptools.getLangTitle;17var langTitle = getLangTitle('enwiki:Albert Einstein');18console.log(langTitle);19var wptools = require('wptools');20var getLangTitle = wptools.getLangTitle;21var langTitle = getLangTitle('enwiki:Albert Einstein');22console.log(langTitle);23var wptools = require('wptools');24var getLangTitle = wptools.getLangTitle;25var langTitle = getLangTitle('enwiki:Albert Einstein');26console.log(langTitle);27var wptools = require('wptools');28var getLangTitle = wptools.getLangTitle;29var langTitle = getLangTitle('enwiki:Albert Einstein');30console.log(langTitle);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var splitKey = wptools.splitKey;3var str = 'foo|bar|baz|qux';4var arr = splitKey(str);5console.log(arr);6var str = 'foo|bar|baz|qux|';7var arr = splitKey(str);8console.log(arr);9var str = 'foo|bar|baz|qux||';10var arr = splitKey(str);11console.log(arr);12var str = 'foo|bar|baz|qux|quux|corge|grault|garply|waldo|fred|plugh|xyzzy|thud';13var arr = splitKey(str);14console.log(arr);15var str = 'foo|bar|baz|qux|quux|corge|grault|garply|waldo|fred|plugh|xyzzy|thud|';16var arr = splitKey(str);17console.log(arr);18var str = 'foo|bar|baz|qux|quux|corge|grault|garply|waldo|fred|plugh|xyzzy|thud||';19var arr = splitKey(str);20console.log(arr);21var str = 'foo|bar|baz|qux|quux|corge|grault|garply|waldo|fred|plugh|xyzzy|thud||||';22var arr = splitKey(str);23console.log(arr);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wikidata-sdk')2var keyParts = wptools.splitKey(key)3console.log(keyParts)4var wptools = require('wikidata-sdk')5var keyParts = wptools.splitKey(key)6console.log(keyParts)7var wptools = require('wikidata-sdk')8var keyParts = wptools.splitKey(key)9console.log(keyParts)

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful