Best JavaScript code snippet using webdriverio-monorepo
block_expansion_weather.js
Source:block_expansion_weather.js
...36 param.converter = Entry.block.converters.returnStringValue;37 }38 return param;39 },40 getLocation(isPython = false) {41 const param = {42 type: 'Dropdown',43 options: getStateOptions(),44 value: 'Seoul',45 fontSize: 11,46 bgColor: EntryStatic.colorSet.block.darken.EXPANSION,47 arrowColor: EntryStatic.colorSet.common.WHITE,48 };49 if (isPython) {50 param.converter = Entry.block.converters.returnStringValue;51 }52 return param;53 },54 getSubLocation(targetIndex = 0, isPython = false) {55 const param = {56 type: 'DropdownDynamic',57 value: null,58 menuName(value) {59 if (value) {60 return getCityOptions(value);61 }62 if (this._contents.options) {63 return this._contents.options;64 } else {65 return getCityOptions(this._block.data.params[targetIndex]);66 }67 },68 targetIndex,69 needDeepCopy: true,70 fontSize: 11,71 bgColor: EntryStatic.colorSet.block.darken.EXPANSION,72 arrowColor: EntryStatic.colorSet.common.WHITE,73 };74 if (isPython) {75 param.converter = Entry.block.converters.returnStringValue;76 }77 return param;78 },79 getSky(isPython = false) {80 const param = {81 type: 'Dropdown',82 options: [83 [Lang.Blocks.EXPANSION_WEATHER_sunny, 'sunny'],84 [Lang.Blocks.EXPANSION_WEATHER_partly_cloudy, 'partly_cloudy'],85 [Lang.Blocks.EXPANSION_WEATHER_mostly_cloudy, 'mostly_cloudy'],86 [Lang.Blocks.EXPANSION_WEATHER_cloudy, 'cloudy'],87 [Lang.Blocks.EXPANSION_WEATHER_rainy, 'rainy'],88 [Lang.Blocks.EXPANSION_WEATHER_sleet, 'sleet'],89 [Lang.Blocks.EXPANSION_WEATHER_snowy, 'snowy'],90 ],91 value: 'sunny',92 fontSize: 11,93 bgColor: EntryStatic.colorSet.block.darken.EXPANSION,94 arrowColor: EntryStatic.colorSet.common.WHITE,95 };96 if (isPython) {97 param.converter = Entry.block.converters.returnStringValue;98 }99 return param;100 },101 getFineDust(isPython = false) {102 const param = {103 type: 'Dropdown',104 options: [105 [Lang.Blocks.EXPANSION_WEATHER_finedust_good, 'good'],106 [Lang.Blocks.EXPANSION_WEATHER_finedust_normal, 'normal'],107 [Lang.Blocks.EXPANSION_WEATHER_finedust_bad, 'bad'],108 [Lang.Blocks.EXPANSION_WEATHER_finedust_very_bad, 'very_bad'],109 ],110 value: 'good',111 fontSize: 11,112 bgColor: EntryStatic.colorSet.block.darken.EXPANSION,113 arrowColor: EntryStatic.colorSet.common.WHITE,114 };115 if (isPython) {116 param.converter = Entry.block.converters.returnStringValue;117 }118 return param;119 },120 getWeatherElements(isPython = false) {121 const param = {122 type: 'Dropdown',123 options: [124 [Lang.Blocks.EXPANSION_WEATHER_lowest_temperature, 'the_lowest_temperature'],125 [Lang.Blocks.EXPANSION_WEATHER_highest_temperature, 'the_highest_temperature'],126 [Lang.Blocks.EXPANSION_WEATHER_humidity, 'humidity'],127 [Lang.Blocks.EXPANSION_WEATHER_precipitation, 'precipitation'],128 [129 Lang.Blocks.EXPANSION_WEATHER_precipitation_probability,130 'precipitation_probability',131 ],132 [Lang.Blocks.EXPANSION_WEATHER_wind_speed, 'wind_speed'],133 ],134 value: 'the_lowest_temperature',135 fontSize: 11,136 bgColor: EntryStatic.colorSet.block.darken.EXPANSION,137 arrowColor: EntryStatic.colorSet.common.WHITE,138 };139 if (isPython) {140 param.converter = Entry.block.converters.returnStringValue;141 }142 return param;143 },144 getNowWeatherElement(isPython = false) {145 const param = {146 type: 'Dropdown',147 options: [148 [Lang.Blocks.EXPANSION_WEATHER_temperature, 'temperature'],149 [Lang.Blocks.EXPANSION_WEATHER_finedust, 'concentration_of_fine_dust'],150 ],151 value: 'temperature',152 fontSize: 11,153 bgColor: EntryStatic.colorSet.block.darken.EXPANSION,154 arrowColor: EntryStatic.colorSet.common.WHITE,155 };156 if (isPython) {157 param.converter = Entry.block.converters.returnStringValue;158 }159 return param;160 },161 getTime(isPython = false) {162 const param = {163 type: 'Dropdown',164 options: [165 ['00', '00'],166 ['03', '03'],167 ['06', '06'],168 ['09', '09'],169 ['12', '12'],170 ['15', '15'],171 ['18', '18'],172 ['21', '21'],173 ],174 value: '00',175 fontSize: 11,176 bgColor: EntryStatic.colorSet.block.darken.EXPANSION,177 arrowColor: EntryStatic.colorSet.common.WHITE,178 };179 if (isPython) {180 param.converter = Entry.block.converters.returnStringOrNumberByValue;181 }182 return param;183 },184 };185 function pad2(n) {186 return n < 10 ? `0${n}` : n;187 }188 return {189 weather_title: {190 skeleton: 'basic_text',191 color: EntryStatic.colorSet.common.TRANSPARENT,192 params: [193 {194 type: 'Text',195 text: Lang.template.weather_title_text,196 color: EntryStatic.colorSet.common.TEXT,197 align: 'center',198 },199 ],200 def: {201 type: 'weather_title',202 },203 class: 'weather',204 isNotFor: ['weather'],205 events: {},206 },207 check_city_weather: {208 color: EntryStatic.colorSet.block.default.EXPANSION,209 outerLine: EntryStatic.colorSet.block.darken.EXPANSION,210 skeleton: 'basic_boolean_field',211 statements: [],212 params: [213 params.getDate(),214 params.getLocation(),215 params.getSubLocation(1),216 params.getSky(),217 ],218 events: {},219 def: {220 params: [221 params.getDate().value,222 params.getLocation().value,223 params.getSubLocation().value,224 params.getSky().value,225 ],226 type: 'check_city_weather',227 },228 pyHelpDef: {229 params: ['B&value', 'C&value', 'D&value', null],230 type: 'check_city_weather',231 },232 paramsKeyMap: {233 DATE: 0,234 LOCATION: 1,235 SUBLOCATION: 2,236 WEATHER: 3,237 },238 class: 'weather',239 isNotFor: ['weather'],240 async func(sprite, script) {241 const location = {242 parent: script.getField('LOCATION', script),243 sub: script.getField('SUBLOCATION', script),244 };245 const apiResult = await Entry.EXPANSION_BLOCK.weather.getData(246 'week',247 location,248 script.getField('DATE', script),249 );250 return Entry.EXPANSION_BLOCK.weather.checkWeather(251 apiResult.sky_code,252 script.getField('WEATHER', script),253 );254 },255 syntax: {256 js: [],257 py: [258 {259 syntax: 'Weather.is_condition_sunny(%1, %2, %3)',260 params: [null, null, null, 'sunny'],261 blockType: 'param',262 textParams: [263 params.getDate(true),264 params.getLocation(true),265 params.getSubLocation(1, true),266 params.getSky(true),267 ],268 },269 {270 syntax: 'Weather.is_condition_partly_cloudy(%1, %2, %3)',271 params: [null, null, null, 'partly_cloudy'],272 blockType: 'param',273 textParams: [274 params.getDate(true),275 params.getLocation(true),276 params.getSubLocation(1, true),277 params.getSky(true),278 ],279 },280 {281 syntax: 'Weather.is_condition_mostly_cloudy(%1, %2, %3)',282 params: [null, null, null, 'mostly_cloudy'],283 blockType: 'param',284 textParams: [285 params.getDate(true),286 params.getLocation(true),287 params.getSubLocation(1, true),288 params.getSky(true),289 ],290 },291 {292 syntax: 'Weather.is_condition_cloudy(%1, %2, %3)',293 params: [null, null, null, 'cloudy'],294 blockType: 'param',295 textParams: [296 params.getDate(true),297 params.getLocation(true),298 params.getSubLocation(1, true),299 params.getSky(true),300 ],301 },302 {303 syntax: 'Weather.is_condition_rainy(%1, %2, %3)',304 params: [null, null, null, 'rainy'],305 blockType: 'param',306 textParams: [307 params.getDate(true),308 params.getLocation(true),309 params.getSubLocation(1, true),310 params.getSky(true),311 ],312 },313 {314 syntax: 'Weather.is_condition_sleet(%1, %2, %3)',315 params: [null, null, null, 'sleet'],316 blockType: 'param',317 textParams: [318 params.getDate(true),319 params.getLocation(true),320 params.getSubLocation(1, true),321 params.getSky(true),322 ],323 },324 {325 syntax: 'Weather.is_condition_snowy(%1, %2, %3)',326 params: [null, null, null, 'snowy'],327 blockType: 'param',328 textParams: [329 params.getDate(true),330 params.getLocation(true),331 params.getSubLocation(1, true),332 params.getSky(true),333 ],334 },335 ],336 },337 },338 check_city_finedust: {339 color: EntryStatic.colorSet.block.default.EXPANSION,340 outerLine: EntryStatic.colorSet.block.darken.EXPANSION,341 skeleton: 'basic_boolean_field',342 statements: [],343 params: [params.getLocation(), params.getSubLocation(0), params.getFineDust()],344 events: {},345 def: {346 params: [params.getLocation().value, null, params.getFineDust().value],347 type: 'check_city_finedust',348 },349 pyHelpDef: {350 params: ['B&value', 'C&value', null],351 type: 'check_city_finedust',352 },353 paramsKeyMap: {354 LOCATION: 0,355 SUBLOCATION: 1,356 FINEDUST: 2,357 },358 class: 'weather',359 isNotFor: ['weather'],360 async func(sprite, script) {361 const location = {362 parent: script.getField('LOCATION', script),363 sub: script.getField('SUBLOCATION', script),364 };365 const apiResult = await Entry.EXPANSION_BLOCK.weather.getData(366 'now',367 location,368 null,369 );370 return Entry.EXPANSION_BLOCK.weather.checkFineDust(371 apiResult.pm10,372 script.getField('FINEDUST', script),373 );374 },375 syntax: {376 js: [],377 py: [378 {379 syntax: 'Weather.is_current_finedust_grade_good(%1, %2)',380 params: [null, null, 'good'],381 blockType: 'param',382 textParams: [383 params.getLocation(true),384 params.getSubLocation(0, true),385 params.getFineDust(true),386 ],387 },388 {389 syntax: 'Weather.is_current_finedust_grade_normal(%1, %2)',390 params: [null, null, 'normal'],391 blockType: 'param',392 textParams: [393 params.getLocation(true),394 params.getSubLocation(0, true),395 params.getFineDust(true),396 ],397 },398 {399 syntax: 'Weather.is_current_finedust_grade_bad(%1, %2)',400 params: [null, null, 'bad'],401 blockType: 'param',402 textParams: [403 params.getLocation(true),404 params.getSubLocation(0, true),405 params.getFineDust(true),406 ],407 },408 {409 syntax: 'Weather.is_current_finedust_grade_very_bad(%1, %2)',410 params: [, null, null, 'very_bad'],411 blockType: 'param',412 textParams: [413 params.getLocation(true),414 params.getSubLocation(0, true),415 params.getFineDust(true),416 ],417 },418 ],419 },420 },421 get_city_weather_data: {422 color: EntryStatic.colorSet.block.default.EXPANSION,423 outerLine: EntryStatic.colorSet.block.darken.EXPANSION,424 skeleton: 'basic_string_field',425 statements: [],426 params: [427 params.getDate(),428 params.getLocation(),429 params.getSubLocation(1),430 params.getWeatherElements(),431 ],432 events: {},433 def: {434 params: [435 params.getDate().value,436 params.getLocation().value,437 null,438 params.getWeatherElements().value,439 ],440 type: 'get_city_weather_data',441 },442 pyHelpDef: {443 params: ['B&value', 'C&value', 'D&value', null],444 type: 'get_city_weather_data',445 },446 paramsKeyMap: {447 DATE: 0,448 LOCATION: 1,449 SUBLOCATION: 2,450 TYPE: 3,451 },452 class: 'weather',453 isNotFor: ['weather'],454 async func(sprite, script) {455 const location = {456 parent: script.getField('LOCATION', script),457 sub: script.getField('SUBLOCATION', script),458 };459 const apiResult = await Entry.EXPANSION_BLOCK.weather.getData(460 'week',461 location,462 script.getField('DATE', script),463 );464 const type =465 Entry.EXPANSION_BLOCK.weather.propertyMap[script.getField('TYPE', script)];466 return apiResult[type];467 },468 syntax: {469 js: [],470 py: [471 {472 syntax: 'Weather.get_lowest_temperature(%1, %2, %3)',473 params: [null, null, null, 'the_lowest_temperature'],474 blockType: 'param',475 textParams: [476 params.getDate(true),477 params.getLocation(true),478 params.getSubLocation(1, true),479 params.getWeatherElements(true),480 ],481 },482 {483 syntax: 'Weather.get_highest_temperature(%1, %2, %3)',484 params: [null, null, null, 'the_highest_temperature'],485 blockType: 'param',486 textParams: [487 params.getDate(true),488 params.getLocation(true),489 params.getSubLocation(1, true),490 params.getWeatherElements(true),491 ],492 },493 {494 syntax: 'Weather.get_humidity(%1, %2, %3)',495 params: [null, null, null, 'humidity'],496 blockType: 'param',497 textParams: [498 params.getDate(true),499 params.getLocation(true),500 params.getSubLocation(1, true),501 params.getWeatherElements(true),502 ],503 },504 {505 syntax: 'Weather.get_precipitation(%1, %2, %3)',506 params: [null, null, null, 'precipitation'],507 blockType: 'param',508 textParams: [509 params.getDate(true),510 params.getLocation(true),511 params.getSubLocation(1, true),512 params.getWeatherElements(true),513 ],514 },515 {516 syntax: 'Weather.get_precipitation_probability(%1, %2, %3)',517 params: [null, null, null, 'precipitation_probability'],518 blockType: 'param',519 textParams: [520 params.getDate(true),521 params.getLocation(true),522 params.getSubLocation(1, true),523 params.getWeatherElements(true),524 ],525 },526 {527 syntax: 'Weather.get_wind_speed(%1, %2, %3)',528 params: [null, null, null, 'wind_speed'],529 blockType: 'param',530 textParams: [531 params.getDate(true),532 params.getLocation(true),533 params.getSubLocation(1, true),534 params.getWeatherElements(true),535 ],536 },537 ],538 },539 },540 get_current_city_weather_data: {541 color: EntryStatic.colorSet.block.default.EXPANSION,542 outerLine: EntryStatic.colorSet.block.darken.EXPANSION,543 skeleton: 'basic_string_field',544 statements: [],545 params: [params.getLocation(), params.getSubLocation(0), params.getNowWeatherElement()],546 events: {},547 def: {548 params: [params.getLocation().value, null, params.getNowWeatherElement().value],549 type: 'get_current_city_weather_data',550 },551 pyHelpDef: {552 params: ['B&value', 'C&value', null],553 type: 'get_current_city_weather_data',554 },555 paramsKeyMap: {556 LOCATION: 0,557 SUBLOCATION: 1,558 TYPE: 2,559 },560 class: 'weather',561 isNotFor: ['weather'],562 func(sprite, script) {563 const location = {564 parent: script.getField('LOCATION', script),565 sub: script.getField('SUBLOCATION', script),566 };567 const type =568 Entry.EXPANSION_BLOCK.weather.propertyMap[script.getField('TYPE', script)];569 return new Promise((resolve) => {570 Entry.EXPANSION_BLOCK.weather.getData('now', location, null).then((data) => {571 return resolve(data[type]);572 });573 });574 },575 syntax: {576 js: [],577 py: [578 {579 syntax: 'Weather.get_current_finedust(%1, %2)',580 params: [null, null, 'concentration_of_fine_dust'],581 blockType: 'param',582 textParams: [583 params.getLocation(true),584 params.getSubLocation(0, true),585 params.getNowWeatherElement(true),586 ],587 },588 {589 syntax: 'Weather.get_current_temperature(%1, %2)',590 params: [null, null, 'temperature'],591 blockType: 'param',592 textParams: [593 params.getLocation(true),594 params.getSubLocation(0, true),595 params.getNowWeatherElement(true),596 ],597 },598 ],599 },600 },601 get_today_city_temperature: {602 color: EntryStatic.colorSet.block.default.EXPANSION,603 outerLine: EntryStatic.colorSet.block.darken.EXPANSION,604 skeleton: 'basic_string_field',605 statements: [],606 params: [params.getLocation(), params.getSubLocation(0), params.getTime()],607 events: {},608 def: {609 params: [params.getLocation().value, null, params.getTime().value],610 type: 'get_today_city_temperature',611 },612 pyHelpDef: {613 params: ['A&value', 'B&value', 'C&value'],614 type: 'get_today_city_temperature',615 },616 paramsKeyMap: {617 LOCATION: 0,618 SUBLOCATION: 1,619 TIME: 2,620 },621 class: 'weather',622 isNotFor: ['weather'],623 async func(sprite, script) {624 const location = {625 parent: script.getField('LOCATION', script),626 sub: script.getField('SUBLOCATION', script),627 };628 const date = Entry.EXPANSION_BLOCK.weather.date629 .toISOString()630 .slice(0, 10)631 .replace(/-/g, '');632 let time = script.getField('TIME', script);633 // dbì ì ì¥íì§ ìì¼ë©´ì 00ìê° ìì´ì ¸ì 03ìë¶í° ê°ë¥..634 if (time == '00') {635 time = '03';636 }637 const apiResult = await Entry.EXPANSION_BLOCK.weather.getData(638 'hour',639 location,640 date + pad2(time - time % 3),641 );642 return apiResult.temp;643 },644 syntax: {645 js: [],646 py: [647 {648 syntax: 'Weather.get_today_temperature(%1, %2, %3)',649 blockType: 'param',650 textParams: [651 params.getLocation(true),652 params.getSubLocation(0, true),653 params.getTime(true),654 ],655 },656 ],657 },658 },659 //ì군구 ì¶ê°ë¡ ì¸í legacy code 기존 ë¸ëì ì§ë¥¼ ìí´ íì.660 check_weather: {661 color: EntryStatic.colorSet.block.default.EXPANSION,662 outerLine: EntryStatic.colorSet.block.darken.EXPANSION,663 skeleton: 'basic_boolean_field',664 statements: [],665 params: [params.getDate(), params.getLocation(), params.getSky()],666 events: {},667 def: {668 params: [params.getDate().value, params.getLocation().value, params.getSky().value],669 type: 'check_weather',670 },671 pyHelpDef: {672 params: ['B&value', 'C&value', null],673 type: 'check_weather',674 },675 paramsKeyMap: {676 DATE: 0,677 LOCATION: 1,678 WEATHER: 2,679 },680 class: 'weather_legacy',681 isNotFor: ['weather_legacy'],682 async func(sprite, script) {683 const apiResult = await Entry.EXPANSION_BLOCK.weather.getData(684 'week',685 script.getField('LOCATION', script),686 script.getField('DATE', script),687 );688 return Entry.EXPANSION_BLOCK.weather.checkWeather(689 apiResult.sky_code,690 script.getField('WEATHER', script),691 );692 },693 syntax: {694 js: [],695 py: [696 {697 syntax: 'Legacy.Weather.is_condition_sunny(%1, %2)',698 params: [null, null, 'sunny'],699 blockType: 'param',700 textParams: [701 params.getDate(true),702 params.getLocation(true),703 params.getSky(true),704 ],705 },706 {707 syntax: 'Legacy.Weather.is_condition_partly_cloudy(%1, %2)',708 params: [null, null, 'partly_cloudy'],709 blockType: 'param',710 textParams: [711 params.getDate(true),712 params.getLocation(true),713 params.getSky(true),714 ],715 },716 {717 syntax: 'Legacy.Weather.is_condition_mostly_cloudy(%1, %2)',718 params: [null, null, 'mostly_cloudy'],719 blockType: 'param',720 textParams: [721 params.getDate(true),722 params.getLocation(true),723 params.getSky(true),724 ],725 },726 {727 syntax: 'Legacy.Weather.is_condition_cloudy(%1, %2)',728 params: [null, null, 'cloudy'],729 blockType: 'param',730 textParams: [731 params.getDate(true),732 params.getLocation(true),733 params.getSky(true),734 ],735 },736 {737 syntax: 'Legacy.Weather.is_condition_rainy(%1, %2)',738 params: [null, null, 'rainy'],739 blockType: 'param',740 textParams: [741 params.getDate(true),742 params.getLocation(true),743 params.getSky(true),744 ],745 },746 {747 syntax: 'Legacy.Weather.is_condition_sleet(%1, %2)',748 params: [null, null, 'sleet'],749 blockType: 'param',750 textParams: [751 params.getDate(true),752 params.getLocation(true),753 params.getSky(true),754 ],755 },756 {757 syntax: 'Legacy.Weather.is_condition_snowy(%1, %2)',758 params: [null, null, 'snowy'],759 blockType: 'param',760 textParams: [761 params.getDate(true),762 params.getLocation(true),763 params.getSky(true),764 ],765 },766 ],767 },768 },769 check_finedust: {770 color: EntryStatic.colorSet.block.default.EXPANSION,771 outerLine: EntryStatic.colorSet.block.darken.EXPANSION,772 skeleton: 'basic_boolean_field',773 statements: [],774 params: [params.getLocation(), params.getFineDust()],775 events: {},776 def: {777 params: [params.getLocation().value, params.getFineDust().value],778 type: 'check_finedust',779 },780 pyHelpDef: {781 params: ['B&value', null],782 type: 'check_finedust',783 },784 paramsKeyMap: {785 LOCATION: 0,786 FINEDUST: 1,787 },788 class: 'weather_legacy',789 isNotFor: ['weather_legacy'],790 async func(sprite, script) {791 const apiResult = await Entry.EXPANSION_BLOCK.weather.getData(792 'now',793 script.getField('LOCATION', script),794 null,795 );796 return Entry.EXPANSION_BLOCK.weather.checkFineDust(797 apiResult.pm10,798 script.getField('FINEDUST', script),799 );800 },801 syntax: {802 js: [],803 py: [804 {805 syntax: 'Legacy.Weather.is_current_finedust_grade_good(%1)',806 params: [null, 'good'],807 blockType: 'param',808 textParams: [params.getLocation(true), params.getFineDust(true)],809 },810 {811 syntax: 'Legacy.Weather.is_current_finedust_grade_normal(%1)',812 params: [null, 'normal'],813 blockType: 'param',814 textParams: [params.getLocation(true), params.getFineDust(true)],815 },816 {817 syntax: 'Legacy.Weather.is_current_finedust_grade_bad(%1)',818 params: [null, 'bad'],819 blockType: 'param',820 textParams: [params.getLocation(true), params.getFineDust(true)],821 },822 {823 syntax: 'Legacy.Weather.is_current_finedust_grade_very_bad(%1)',824 params: [, null, 'very_bad'],825 blockType: 'param',826 textParams: [params.getLocation(true), params.getFineDust(true)],827 },828 ],829 },830 },831 get_weather_data: {832 color: EntryStatic.colorSet.block.default.EXPANSION,833 outerLine: EntryStatic.colorSet.block.darken.EXPANSION,834 skeleton: 'basic_string_field',835 statements: [],836 params: [params.getDate(), params.getLocation(), params.getWeatherElements()],837 events: {},838 def: {839 params: [840 params.getDate().value,841 params.getLocation().value,842 params.getWeatherElements().value,843 ],844 type: 'get_weather_data',845 },846 pyHelpDef: {847 params: ['B&value', 'C&value', null],848 type: 'get_weather_data',849 },850 paramsKeyMap: {851 DATE: 0,852 LOCATION: 1,853 TYPE: 2,854 },855 class: 'weather_legacy',856 isNotFor: ['weather_legacy'],857 async func(sprite, script) {858 const apiResult = await Entry.EXPANSION_BLOCK.weather.getData(859 'week',860 script.getField('LOCATION', script),861 script.getField('DATE', script),862 );863 const type =864 Entry.EXPANSION_BLOCK.weather.propertyMap[script.getField('TYPE', script)];865 return apiResult[type];866 },867 syntax: {868 js: [],869 py: [870 {871 syntax: 'Legacy.Weather.get_lowest_temperature(%1, %2)',872 params: [null, null, 'the_lowest_temperature'],873 blockType: 'param',874 textParams: [875 params.getDate(true),876 params.getLocation(true),877 params.getWeatherElements(true),878 ],879 },880 {881 syntax: 'Legacy.Weather.get_highest_temperature(%1, %2)',882 params: [null, null, 'the_highest_temperature'],883 blockType: 'param',884 textParams: [885 params.getDate(true),886 params.getLocation(true),887 params.getWeatherElements(true),888 ],889 },890 {891 syntax: 'Legacy.Weather.get_humidity(%1, %2)',892 params: [null, null, 'humidity'],893 blockType: 'param',894 textParams: [895 params.getDate(true),896 params.getLocation(true),897 params.getWeatherElements(true),898 ],899 },900 {901 syntax: 'Legacy.Weather.get_precipitation(%1, %2)',902 params: [null, null, 'precipitation'],903 blockType: 'param',904 textParams: [905 params.getDate(true),906 params.getLocation(true),907 params.getWeatherElements(true),908 ],909 },910 {911 syntax: 'Legacy.Weather.get_precipitation_probability(%1, %2)',912 params: [null, null, 'precipitation_probability'],913 blockType: 'param',914 textParams: [915 params.getDate(true),916 params.getLocation(true),917 params.getWeatherElements(true),918 ],919 },920 {921 syntax: 'Legacy.Weather.get_wind_speed(%1, %2)',922 params: [null, null, 'wind_speed'],923 blockType: 'param',924 textParams: [925 params.getDate(true),926 params.getLocation(true),927 params.getWeatherElements(true),928 ],929 },930 ],931 },932 },933 get_current_weather_data: {934 color: EntryStatic.colorSet.block.default.EXPANSION,935 outerLine: EntryStatic.colorSet.block.darken.EXPANSION,936 skeleton: 'basic_string_field',937 statements: [],938 params: [params.getLocation(), params.getNowWeatherElement()],939 events: {},940 def: {941 params: [params.getLocation().value, params.getNowWeatherElement().value],942 type: 'get_current_weather_data',943 },944 pyHelpDef: {945 params: ['B&value', null],946 type: 'get_current_weather_data',947 },948 paramsKeyMap: {949 LOCATION: 0,950 TYPE: 1,951 },952 class: 'weather_legacy',953 isNotFor: ['weather_legacy'],954 async func(sprite, script) {955 const apiResult = await Entry.EXPANSION_BLOCK.weather.getData(956 'now',957 script.getField('LOCATION', script),958 null,959 );960 const type =961 Entry.EXPANSION_BLOCK.weather.propertyMap[script.getField('TYPE', script)];962 return apiResult[type];963 },964 syntax: {965 js: [],966 py: [967 {968 syntax: 'Legacy.Weather.get_current_finedust(%1)',969 params: [null, 'concentration_of_fine_dust'],970 blockType: 'param',971 textParams: [params.getLocation(true), params.getNowWeatherElement(true)],972 },973 {974 syntax: 'Legacy.Weather.get_current_temperature(%1)',975 params: [null, 'temperature'],976 blockType: 'param',977 textParams: [params.getLocation(true), params.getNowWeatherElement(true)],978 },979 ],980 },981 },982 get_today_temperature: {983 color: EntryStatic.colorSet.block.default.EXPANSION,984 outerLine: EntryStatic.colorSet.block.darken.EXPANSION,985 skeleton: 'basic_string_field',986 statements: [],987 params: [params.getLocation(), params.getTime()],988 events: {},989 def: {990 params: [params.getLocation().value, params.getTime().value],991 type: 'get_today_temperature',992 },993 pyHelpDef: {994 params: ['A&value', 'B&value'],995 type: 'get_today_temperature',996 },997 paramsKeyMap: {998 LOCATION: 0,999 TIME: 1,1000 },1001 class: 'weather_legacy',1002 isNotFor: ['weather_legacy'],1003 async func(sprite, script) {1004 const date = Entry.EXPANSION_BLOCK.weather.date1005 .toISOString()1006 .slice(0, 10)1007 .replace(/-/g, '');1008 let time = script.getField('TIME', script);1009 // dbì ì ì¥íì§ ìì¼ë©´ì 00ìê° ìì´ì ¸ì 03ìë¶í° ê°ë¥..1010 if (time == '00') {1011 time = '03';1012 }1013 const apiResult = await Entry.EXPANSION_BLOCK.weather.getData(1014 'hour',1015 script.getField('LOCATION', script),1016 date + pad2(time - time % 3),1017 );1018 return apiResult.temp;1019 },1020 syntax: {1021 js: [],1022 py: [1023 {1024 syntax: 'Legacy.Weather.get_today_temperature(%1, %2)',1025 blockType: 'param',1026 textParams: [params.getLocation(true), params.getTime(true)],1027 },1028 ],1029 },1030 },1031 };...
equip.js
Source:equip.js
...102 this.down = false103 control.equip = null104 var map = cc.find("map4")105 this.parent = map.getChildByName("itemlist")106 var node = self.getequiphold(event.getLocation().x, event.getLocation().y)107 if(node == null)108 {109 console.log("add to map")110 var json1 = {"type":"equip", "x":event.getLocation().x- map.x, "y":event.getLocation().y- map.y, "action":"off", "id":self.gid}111 self.socket.getComponent("socket_l").sendmsg(JSON.stringify(json1))112 // var map = cc.find("map4")113 // this.parent = map.getChildByName("itemlist")114 // this.x = event.getLocation().x - map.x115 // this.y = event.getLocation().y - map.y116 // this.runAction(cc.scaleTo(0.1, 0.5,0.5))117 // this.maptype = "item" 118 }119 else120 {121 console.log("add to equip")122 var json1 = {"id":self.gid, "type":"equip", "x":event.getLocation().x, "y":event.getLocation().y, "action":"on"}123 console.log("json1 is " + json1)124 self.socket.getComponent("socket_l").sendmsg(JSON.stringify(json1))125 // this.parent = node126 // this.x = 0127 // this.y = 0128 // this.runAction(cc.scaleTo(0.1, 1,1))129 // this.maptype = "equip"130 // var map = cc.find("map4")131 // var uid = map.getComponent("map").get_main_hero_id()132 // var node = map.getComponent("map").get_role_by_id(uid)133 // node.getComponent("global").addequip(self.uid)134 }135 })136 this.node.on('mouseleave', function(event){137 if(this.down == true) 138 {139 //this.down = false140 // this.parent = null141 var node = self.getequiphold(event.getLocation().x, event.getLocation().y)142 var equips = cc.find("equips")143 self.x = event.getLocation().x - equips.x144 self.y = event.getLocation().y - equips.y145 if(node == null)146 {147 // console.log("add to map")148 // var map = cc.find("map4")149 // this.parent = map.getChildByName("itemlist")150 // this.x = event.getLocation().x - map.x151 // this.y = event.getLocation().y - map.y152 // this.runAction(cc.scaleTo(0.1, 0.5,0.5))153 // this.maptype = "item" 154 }155 else156 {157 // this.parent = node158 // this.x = 0159 // this.y = 0160 // this.runAction(cc.scaleTo(0.1, 1,1))161 // this.maptype = "equip"162 }163 }164 else165 {166 var itemdesc = cc.find("itemdesc")167 itemdesc.active = false168 }169 })170 this.node.on('mousedown', function(event){171 if(event.getButton() != cc.Event.EventMouse.BUTTON_RIGHT) return172 console.log("maptype is " + this.maptype)173 var equips = cc.find("equips")174 this.parent = null175 this.parent = equips176 this.x = event.getLocation().x - equips.x 177 this.y = event.getLocation().y - equips.y 178 this.down = true179 control.equip = this180 this.runAction(cc.scaleTo(0.1, 0.8,0.8))181 // if (this.maptype == "item")182 // {183 // this.down = true184 // this.xd = event.getLocation().x - this.x185 // this.xy = event.getLocation().y - this.y186 // this.runAction(cc.scaleTo(0.1, 0.8,0.8))187 // }188 // else189 // {190 // this.down = true191 // var lx = event.getLocation().x - this.parent.x - this.parent.parent.x192 // var ly = event.getLocation().y - this.parent.y - this.parent.parent.y193 // this.xd = lx 194 // this.yd = ly 195 // // var x = event.getLocation().x - self.map.x196 // // var y = event.getLocation().y - self.map.y197 // this.runAction(cc.scaleTo(0.1, 0.8,0.8))198 // }199 })200 this.node.on('mousemove', function(event){201 202 203 var equips = cc.find("equips")204 if (this.down == true)205 {206 207 this.x = event.getLocation().x - equips.x 208 this.y = event.getLocation().y - equips.y 209 // if (this.maptype == "item")210 // {211 // var map = cc.find("map4")212 // this.parent = map.getChildByName("itemlist")213 // this.x = event.getLocation().x - map.x214 // this.y = event.getLocation().y - map.y215 // }216 // else217 // {218 // var lx = event.getLocation().x 219 // var ly = event.getLocation().y 220 // this.x = lx - this.parent.x - this.parent.parent.x - this.xd221 // this.y = ly - this.parent.y - this.parent.parent.y - this.yd222 // }223 }224 else{225 var itemdesc = cc.find("itemdesc")226 self.setdesc(itemdesc)227 itemdesc.x = this.x + this.parent.x + this.parent.parent.x + 75228 //itemdesc.y = this.y + this.parent.y + this.parent.parent.y 229 itemdesc.active = true230 }231 })232 // self.node.on(cc.Node.EventType.TOUCH_START, function(event){233 // var x = event.getLocation().x - self.map.x234 // var y = event.getLocation().y- self.map.y235 // var json1 = {"type":"move", "x":x, "y":y}236 // self.socket.getComponent("socket_l").sendmsg(JSON.stringify(json1))237 // })238 },239 setattr: function (uid) {240 uid = parseInt(uid)241 var confmod = require("equipconf")242 var equipconf = confmod[uid]243 console.log(equipconf)244 for (var prop in equipconf )245 {246 this[prop] = equipconf[prop]247 } 248 // if (uid.indexOf("204") != -1)...
herodesc.js
Source:herodesc.js
...64 if(event.getButton() != cc.Event.EventMouse.BUTTON_RIGHT) return65 if(this.down == false) return66 this.down = false67 this.parent = null68 var node = self.getequiphold(event.getLocation().x, event.getLocation().y)69 if(node == null)70 {71 console.log("add to map")72 var map = cc.find("map4")73 this.parent = map.getChildByName("itemlist")74 this.x = event.getLocation().x - map.x75 this.y = event.getLocation().y - map.y76 this.runAction(cc.scaleTo(0.1, 0.5,0.5))77 this.maptype = "item" 78 }79 else80 {81 console.log("add to equip")82 this.parent = node83 this.x = 084 this.y = 085 this.runAction(cc.scaleTo(0.1, 1,1))86 this.maptype = "equip"87 }88 var map = cc.find("map4")89 var uid = map.getComponent("map").get_main_hero_id()90 var node = map.getComponent("map").get_role_by_id(uid)91 node.getComponent("global").addequip(self.uid)92 })93 this.node.on('mouseleave', function(event){94 if(this.down == true) 95 {96 this.down = false97 this.parent = null98 var node = self.getequiphold(event.getLocation().x, event.getLocation().y)99 100 if(node == null)101 {102 console.log("add to map")103 var map = cc.find("map4")104 this.parent = map.getChildByName("itemlist")105 this.x = event.getLocation().x - map.x106 this.y = event.getLocation().y - map.y107 this.runAction(cc.scaleTo(0.1, 0.5,0.5))108 this.maptype = "item" 109 }110 else111 {112 this.parent = node113 this.x = 0114 this.y = 0115 this.runAction(cc.scaleTo(0.1, 1,1))116 this.maptype = "equip"117 }118 }119 else120 {121 var itemdesc = cc.find("itemdesc")122 itemdesc.active = false123 }124 })125 this.node.on('mousedown', function(event){126 if(event.getButton() != cc.Event.EventMouse.BUTTON_RIGHT) return127 console.log("maptype is " + this.maptype)128 var equips = cc.find("equips")129 this.parent = null130 this.parent = equips131 this.x = event.getLocation().x - equips.x 132 this.y = event.getLocation().y - equips.y 133 this.down = true134 this.runAction(cc.scaleTo(0.1, 0.8,0.8))135 // if (this.maptype == "item")136 // {137 // this.down = true138 // this.xd = event.getLocation().x - this.x139 // this.xy = event.getLocation().y - this.y140 // this.runAction(cc.scaleTo(0.1, 0.8,0.8))141 // }142 // else143 // {144 // this.down = true145 // var lx = event.getLocation().x - this.parent.x - this.parent.parent.x146 // var ly = event.getLocation().y - this.parent.y - this.parent.parent.y147 // this.xd = lx 148 // this.yd = ly 149 // // var x = event.getLocation().x - self.map.x150 // // var y = event.getLocation().y - self.map.y151 // this.runAction(cc.scaleTo(0.1, 0.8,0.8))152 // }153 })154 this.node.on('mousemove', function(event){155 if (this.down == true)156 {157 var equips = cc.find("equips")158 this.x = event.getLocation().x - equips.x 159 this.y = event.getLocation().y - equips.y 160 // if (this.maptype == "item")161 // {162 // var map = cc.find("map4")163 // this.parent = map.getChildByName("itemlist")164 // this.x = event.getLocation().x - map.x165 // this.y = event.getLocation().y - map.y166 // }167 // else168 // {169 // var lx = event.getLocation().x 170 // var ly = event.getLocation().y 171 // this.x = lx - this.parent.x - this.parent.parent.x - this.xd172 // this.y = ly - this.parent.y - this.parent.parent.y - this.yd173 // }174 }175 else{176 var itemdesc = cc.find("itemdesc")177 self.setdesc(itemdesc)178 itemdesc.x = this.x + this.parent.x + this.parent.parent.x + 75179 //itemdesc.y = this.y + this.parent.y + this.parent.parent.y 180 itemdesc.active = true181 }182 })183 // self.node.on(cc.Node.EventType.TOUCH_START, function(event){184 // var x = event.getLocation().x - self.map.x185 // var y = event.getLocation().y- self.map.y186 // var json1 = {"type":"move", "x":x, "y":y}187 // self.socket.getComponent("socket_l").sendmsg(JSON.stringify(json1))188 // })189 },190 setattr: function (uid) {191 uid = parseInt(uid)192 var confmod = require("equipconf")193 var equipconf = confmod[uid]194 console.log(equipconf)195 for (var prop in equipconf )196 {197 this[prop] = equipconf[prop]198 } 199 // if (uid.indexOf("204") != -1)...
align-test.js
Source:align-test.js
...47 48 const rectlocation = await app.client.$('#svg_1');49 const rect2location = await app.client.$('#svg_2');50 const rect3location = await app.client.$('#svg_3');51 expect(await rectlocation.getLocation('y')).toEqual(await rect2location.getLocation('y'));52 expect(await rectlocation.getLocation('y')).toEqual(await rect3location.getLocation('y'));53 // console.log(await rectlocation.getLocation('y'));54 await app.client.execute(() =>{55 svgCanvas.undoMgr.undo();56 });57});58test('Check Middle align', async function() {59 const { app } = require('../../../test');60 await mouseAction([61 { type: 'pointerMove', x: 100, y: 100, duration: 100, },62 { type: 'pointerDown', button: 0, },63 { type: 'pointerMove', x: 600, y: 600, duration: 1000, },64 { type: 'pointerUp', button: 0, },65 ]);66 const middlealign = await app.client.$('#qa-middle_align');67 await middlealign.click();68 69 const rectlocation = await app.client.$('#svg_1');70 const rect2location = await app.client.$('#svg_2');71 const rect3location = await app.client.$('#svg_3');72 // console.log(await rectlocation.getLocation('y'));73 expect(await rectlocation.getLocation('y')).toEqual(await rect2location.getLocation('y'));74 expect(await rectlocation.getLocation('y')).toEqual(await rect3location.getLocation('y'));75 76 await app.client.execute(() =>{77 svgCanvas.undoMgr.undo();78 });79});80test('Check bottom align', async function() {81 const { app } = require('../../../test');82 await mouseAction([83 { type: 'pointerMove', x: 100, y: 100, duration: 100, },84 { type: 'pointerDown', button: 0, },85 { type: 'pointerMove', x: 600, y: 600, duration: 1000, },86 { type: 'pointerUp', button: 0, },87 ]);88 const bottomalign = await app.client.$('#qa-bottom_align');89 await bottomalign.click();90 const rectlocation = await app.client.$('#svg_1');91 const rect2location = await app.client.$('#svg_2');92 const rect3location = await app.client.$('#svg_3');93 // console.log(await rectlocation.getLocation('y'));94 expect(await rectlocation.getLocation('y')).toEqual(await rect2location.getLocation('y'));95 expect(await rectlocation.getLocation('y')).toEqual(await rect3location.getLocation('y'));96 97 await app.client.execute(() =>{98 svgCanvas.undoMgr.undo();99 });100});101test('Check Left align', async function() {102 const { app } = require('../../../test');103 await mouseAction([104 { type: 'pointerMove', x: 100, y: 100, duration: 100, },105 { type: 'pointerDown', button: 0, },106 { type: 'pointerMove', x: 600, y: 600, duration: 1000, },107 { type: 'pointerUp', button: 0, },108 ]);109 const leftalign = await app.client.$('#qa-left_align');110 await leftalign.click();111 const rectlocation = await app.client.$('#svg_1');112 const rect2location = await app.client.$('#svg_2');113 const rect3location = await app.client.$('#svg_3');114 expect(await rectlocation.getLocation('x')).toEqual(await rect2location.getLocation('x'));115 expect(await rectlocation.getLocation('x')).toEqual(await rect3location.getLocation('x'));116 // console.log(await rectlocation.getLocation('x'));117 await app.client.execute(() =>{118 svgCanvas.undoMgr.undo();119 });120});121test('check Center align', async function() {122 const { app } = require('../../../test');123 await mouseAction([124 { type: 'pointerMove', x: 100, y: 100, duration: 100, },125 { type: 'pointerDown', button: 0, },126 { type: 'pointerMove', x: 600, y: 600, duration: 1000, },127 { type: 'pointerUp', button: 0, },128 ]);129 const centeralign = await app.client.$('#qa-center_align');130 await centeralign.click();131 132 const rectlocation = await app.client.$('#svg_1');133 const rect2location = await app.client.$('#svg_2');134 const rect3location = await app.client.$('#svg_3');135 expect(await rectlocation.getLocation('x')).toEqual(await rect2location.getLocation('x'));136 expect(await rectlocation.getLocation('x')).toEqual(await rect3location.getLocation('x'));137 // console.log(await rectlocation.getLocation('x'));138 await app.client.execute(() =>{139 svgCanvas.undoMgr.undo();140 });141});142test('check Right align', async function() {143 const { app } = require('../../../test');144 145 await mouseAction([146 { type: 'pointerMove', x: 100, y: 100, duration: 100, },147 { type: 'pointerDown', button: 0, },148 { type: 'pointerMove', x: 600, y: 600, duration: 1000, },149 { type: 'pointerUp', button: 0, },150 ]);151 152 const rightalign = await app.client.$('#qa-right_align');153 await rightalign.click();154 155 const rectlocation = await app.client.$('#svg_1');156 const rect2location = await app.client.$('#svg_2');157 const rect3location = await app.client.$('#svg_3');158 expect(await rectlocation.getLocation('x')).toEqual(await rect2location.getLocation('x'));159 expect(await rectlocation.getLocation('x')).toEqual(await rect3location.getLocation('x'));160 // console.log(await rectlocation.getLocation('x'));161 await app.client.execute(() =>{162 svgCanvas.undoMgr.undo();163 });...
getLocation.js
Source:getLocation.js
1/******************************************************************************/2/* getLocation.js */3/* Author: Seung Jae Lee */4/* */5/* This is a mocha test file that tests getLocation() function in scraper.js. */6/******************************************************************************/7var assert = require("assert");8var scraper = require('../scraper.js');9describe('getLocation()', function() {10 describe('no match', function() {11 it('getLocation(\"\") should equal \"\"', function() {12 assert.equal(scraper.getLocation(""), "");13 })14 it('getLocation(\"qqq\") should equal \"\"', function() {15 assert.equal(scraper.getLocation("xyz"), "");16 })17 })18 describe('one match', function() {19 it('getLocation(\"clapp\") should equal \"1927 - Clapp Hall\"', function() {20 assert.equal(scraper.getLocation("clapp"), "1927 - Clapp Hall");21 })22 it('getLocation(\"come to dod hall!\") should equal \"Dod Hall\"', function() {23 assert.equal(scraper.getLocation("come to dod hall!"), "Dod Hall");24 })25 })26 describe('case-insensitive match', function() {27 it('getLocation(\"EQuad has food\") should equal \"Enginerring QUAD\"', function() {28 assert.equal(scraper.getLocation("EQuad has food"), "Enginerring QUAD");29 })30 it('getLocation(\"FRIST HAS FOOD\") should equal \"Frist Campus Center\"', function() {31 assert.equal(scraper.getLocation("FRIST HAS FOOD"), "Frist Campus Center");32 })33 it('getLocation(\"Pizza at CoLoNiAl ClUb\") should equal \"Colonial Club\"', function() {34 assert.equal(scraper.getLocation("Pizza at CoLoNiAl ClUb"), "Colonial Club");35 })36 })37 describe('punctuation deletion', function() {38 it('getLocation(\"Come to F,r,i,s,t\") should equal \"Frist Campus Center\"', function() {39 assert.equal(scraper.getLocation("Come to F,r,i,s,t"), "Frist Campus Center");40 })41 it('getLocation(\"Edward\'s Hall\") should equal \"Edwards Hall\"', function() {42 assert.equal(scraper.getLocation("Edward\'s Hall"), "Edwards Hall");43 })44 })45 describe('regex match', function() {46 it('getLocation(\"Friend 112\") should equal \"Friend Center\"', function() {47 assert.equal(scraper.getLocation("Friend 112"), "Friend Center");48 })49 it('getLocation(\"Lewis 123\") should equal \"Lewis Library\"', function() {50 assert.equal(scraper.getLocation("Lewis 123"), "Lewis Library");51 })52 })53 describe('biggest substring', function(){54 it('getLocation(\"Ticket holders to Friend Center\") should equal \"Friend Center\"', function() {55 assert.equal(scraper.getLocation("Ticket holders to Friend Center"), "Friend Center");56 })57 it('getLocation(\"Lewis 123, Bring your spoon!\") should equal \"Lewis Library\"', function() {58 assert.equal(scraper.getLocation("Lewis 123, Bring your spoon!"), "Lewis Library");59 })60 });...
Wire.js
Source:Wire.js
...42 drawSelf() {43 super.drawSelf();44 stroke(this.startPin.getSignalColor());45 strokeWeight(2 * WIRE_WIDTH);46 line(this.startPin.getLocation().x,this.startPin.getLocation().y,this.endPin.getLocation().x,this.endPin.getLocation().y);47 }48 //Overridden method49 getPins() {50 let returnedPins = [];51 returnedPins.push(this.startPin);52 returnedPins.push(this.endPin);53 return returnedPins;54 }55 //Overridden method56 getClone() {57 return new Wire(this.startPin.getLocation().x,this.startPin.getLocation().y,this.endPin.getLocation().x,this.endPin.getLocation().y);58 }59 60 getJSON() {61 return {62 type : this.COMPONENT_TYPE,63 x1 : this.startPin.getLocation().x,64 y1 : this.startPin.getLocation().y,65 x2 : this.endPin.getLocation().x,66 y2 : this.endPin.getLocation().y67 };68 }69 pointInBounds(x,y) {70 let x1 = this.startPin.getLocation().x;71 let y1 = this.startPin.getLocation().y;72 let x2 = this.endPin.getLocation().x;73 let y2 = this.endPin.getLocation().y;74 let minX = min(x1,x2);75 let maxX = max(x1,x2);76 if (x < minX && x > maxX) {77 return false;78 }79 if (this.startPin.getLocation().x == this.endPin.getLocation().x) {80 let topX = min(this.startPin.getLocation().y,this.endPin.getLocation().y);81 let bottomX = max(this.startPin.getLocation().y,this.endPin.getLocation().y);82 return (x > this.startPin.getLocation().x - WIRE_WIDTH && x < this.startPin.getLocation().x + WIRE_WIDTH &&83 y > topX && y < bottomX);84 }85 else {86 let slope = (y2 - y1) / (x2 - x1);87 let targetY = (slope * (x - x1)) + y1;88 let diffY = y - targetY;89 return (diffY >= -1 * WIRE_WIDTH && diffY <= WIRE_WIDTH);90 }91 }92 resetConnections() {93 this.startPin.clearListeners();94 this.endPin.clearListeners();95 this.startPin = new ReceivingPin(this.startPin.getLocation().x,this.startPin.getLocation().y,SIGNAL_NONE);96 this.startPin.addListener(this);97 98 this.endPin = new ReceivingPin(this.endPin.getLocation().x,this.endPin.getLocation().y,SIGNAL_NONE);99 this.endPin.addListener(this);100 }...
overrideBaseIntersectionMethod.js
Source:overrideBaseIntersectionMethod.js
1//// [overrideBaseIntersectionMethod.ts]2// Repro from #146153type Constructor<T> = new (...args: any[]) => T;4const WithLocation = <T extends Constructor<Point>>(Base: T) => class extends Base {5 getLocation(): [number, number] {6 const [x,y] = super.getLocation();7 return [this.x | x, this.y | y];8 }9}10class Point {11 constructor(public x: number, public y: number) { }12 getLocation(): [number, number] {13 return [0,0];14 }15}16class Foo extends WithLocation(Point) {17 calculate() {18 return this.x + this.y;19 }20 getLocation() {21 return super.getLocation()22 }23 whereAmI() {24 return this.getLocation();25 }26}272829//// [overrideBaseIntersectionMethod.js]30"use strict";31// Repro from #1461532var __extends = (this && this.__extends) || (function () {33 var extendStatics = function (d, b) {34 extendStatics = Object.setPrototypeOf ||35 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||36 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };37 return extendStatics(d, b);38 };39 return function (d, b) {40 extendStatics(d, b);41 function __() { this.constructor = d; }42 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());43 };44})();45var WithLocation = function (Base) { return /** @class */ (function (_super) {46 __extends(class_1, _super);47 function class_1() {48 return _super !== null && _super.apply(this, arguments) || this;49 }50 class_1.prototype.getLocation = function () {51 var _a = _super.prototype.getLocation.call(this), x = _a[0], y = _a[1];52 return [this.x | x, this.y | y];53 };54 return class_1;55}(Base)); };56var Point = /** @class */ (function () {57 function Point(x, y) {58 this.x = x;59 this.y = y;60 }61 Point.prototype.getLocation = function () {62 return [0, 0];63 };64 return Point;65}());66var Foo = /** @class */ (function (_super) {67 __extends(Foo, _super);68 function Foo() {69 return _super !== null && _super.apply(this, arguments) || this;70 }71 Foo.prototype.calculate = function () {72 return this.x + this.y;73 };74 Foo.prototype.getLocation = function () {75 return _super.prototype.getLocation.call(this);76 };77 Foo.prototype.whereAmI = function () {78 return this.getLocation();79 };80 return Foo;
...
08-resolutions.js
Source:08-resolutions.js
...16 Global.setWindowSize(1600, 1600);17 sideNav.spotlightSearchIcon.should('be.visible');18 });19 it('it should close the sidenav', () => {20 mainContent.mainContent.getLocation().its('x').should('be', 0);21 sideNav.sideNavBar.getLocation().its('x').should('not.be', 0);22 });23 describe('moving elements:', () => {24 beforeEach(() => {25 cy.wait(100);26 sideNav.sideNavBar.getLocation().its('x').then((x) => {27 if (x !== 0) {28 sideNav.burgerBtn.click();29 }30 });31 cy.wait(100);32 });33 it('it should open de sidenav', () => {34 mainContent.mainContent.getLocation().its('x').should('be', 0);35 sideNav.sideNavBar.getLocation().its('x').should('be', 0);36 });37 it('it should not close sidebar on pressing the sidebar item menu', () => {38 sideNav.firstSidebarItemMenu.invoke('show');39 sideNav.firstSidebarItemMenu.click();40 mainContent.mainContent.getLocation().its('x').should('be', 0);41 sideNav.sideNavBar.getLocation().its('x').should('be', 0);42 sideNav.popoverOverlay.click();43 });44 it('it should close the sidenav when open general channel', () => {45 sideNav.openChannel('general');46 sideNav.sideNavBar.getLocation().its('x').should('not.be', 0);47 });48 it('it should open the user preferences screen', () => {49 sideNav.sidebarUserMenu.click();50 sideNav.account.click();51 });52 it('it should close the sidenav when press the preferences link', () => {53 sideNav.preferences.click();54 sideNav.sideNavBar.getLocation().its('x').should('not.be', 0);55 });56 it('it should close the sidenav when press the profile link', () => {57 sideNav.profile.click();58 sideNav.sideNavBar.getLocation().its('x').should('not.be', 0);59 });60 it('it should close the preferences nav', () => {61 sideNav.preferencesClose.click();62 });63 });64 });...
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(options);7 .init()8 .getLocation('#hplogo', function(err, result) {9 })10 .end();11var webdriverio = require('webdriverio');12var options = {13 desiredCapabilities: {14 }15};16var client = webdriverio.remote(options);17 .init()18 .getLocationInView('#hplogo', function(err, result) {19 })20 .end();21var webdriverio = require('webdriverio');22var options = {23 desiredCapabilities: {24 }25};26var client = webdriverio.remote(options);27 .init()28 .getTagName('#hplogo', function(err, result) {29 })30 .end();31var webdriverio = require('webdriverio');32var options = {33 desiredCapabilities: {34 }35};36var client = webdriverio.remote(options);37 .init()38 .getSize('#hplogo', function(err, result) {39 })40 .end();41var webdriverio = require('webdriverio');42var options = {43 desiredCapabilities: {44 }45};46var client = webdriverio.remote(options);47 .init()48 .getText('#hplogo', function(err, result) {49 })
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4 .init()5 .getLocation('input[name="q"]', function(err, location) {6 })7 .end();8var webdriverio = require('webdriverio');9var options = { desiredCapabilities: { browserName: 'chrome' } };10var client = webdriverio.remote(options);11 .init()12 .getLocationInView('input[name="q"]', function(err, location) {13 })14 .end();15var webdriverio = require('webdriverio');16var options = { desiredCapabilities: { browserName: 'chrome' } };17var client = webdriverio.remote(options);18 .init()19 .getLog('browser', function(err, logs) {20 console.log(logs);21 })22 .end();23var webdriverio = require('webdriverio');24var options = { desiredCapabilities: { browserName: 'chrome' } };25var client = webdriverio.remote(options);26 .init()27 .getLogTypes(function(err, logTypes) {28 })29 .end();30var webdriverio = require('webdriverio');31var options = { desiredCapabilities: { browserName: 'chrome' } };32var client = webdriverio.remote(options);33 .init()34 .getOrientation(function(err, orientation) {35 })36 .end();37var webdriverio = require('webdriverio');38var options = { desiredCapabilities:
Using AI Code Generation
1var webdriverio = require('webdriverio');2var options = { desiredCapabilities: { browserName: 'chrome' } };3var client = webdriverio.remote(options);4 .init()5 .getLocation('input[name="q"]', function(err, result) {6 console.log(err);7 console.log(result);8 })9 .end();10var webdriverio = require('webdriverio');11var options = { desiredCapabilities: { browserName: 'chrome' } };12var client = webdriverio.remote(options);13 .init()14 .getLocationInView('input[name="q"]', function(err, result) {15 console.log(err);16 console.log(result);17 })18 .end();19var webdriverio = require('webdriverio');20var options = { desiredCapabilities: { browserName: 'chrome' } };21var client = webdriverio.remote(options);22 .init()23 .getSize('input[name="q"]', function(err, result) {24 console.log(err);25 console.log(result);26 })27 .end();28var webdriverio = require('webdriverio');29var options = { desiredCapabilities: { browserName: 'chrome' } };30var client = webdriverio.remote(options);31 .init()32 .getTagName('input[name="q"]', function(err, result) {33 console.log(err);34 console.log(result);35 })36 .end();37var webdriverio = require('webdriverio');38var options = { desiredCapabilities: { browserName: 'chrome' } };39var client = webdriverio.remote(options);40 .init()41 .getText('input[name="q"]', function(err, result) {42 console.log(err);43 console.log(result);44 })45 .end();46var webdriverio = require('webdriverio');47var options = { desiredCapabilities: { browserName: 'chrome' } };48var client = webdriverio.remote(options);
Using AI Code Generation
1describe('webdriver.io page', () => {2 it('should have the right title - the fancy generator way', async () => {3 const title = await browser.getTitle();4 console.log(await browser.getUrl());5 expect(title).toBe('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js');6 });7});8Syntax: getLocation()9describe('webdriver.io page', () => {10 it('should have the right title - the fancy generator way', async () => {11 const title = await browser.getTitle();12 console.log(await browser.getLocation());13 expect(title).toBe('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js');14 });15});16Syntax: getUrl()17describe('webdriver.io page', () => {18 it('should have the right title - the fancy generator way', async () => {19 const title = await browser.getTitle();20 console.log(await browser.getUrl());21 expect(title).toBe('WebdriverIO · Next-gen browser and mobile automation test framework for Node.js');22 });23});24Syntax: getUrlAndTitle()
Using AI Code Generation
1const assert = require('assert');2const { remote } = require('webdriverio');3(async () => {4 const browser = await remote({5 capabilities: {6 }7 })8 await browser.pause(3000)9 const url = await browser.getUrl()10 console.log('Current URL is: ' + url)11 const title = await browser.getTitle()12 console.log('Current page title is: ' + title)13 const windowHandle = await browser.getWindowHandle()14 console.log('Current window handle is: ' + windowHandle)15 const windowHandles = await browser.getWindowHandles()16 console.log('Current window handles are: ' + windowHandles)17 const orientation = await browser.getOrientation()18 console.log('Current orientation is: ' + orientation)19 const location = await browser.getLocation()20 console.log('Current geolocation is: ' + location)21 await browser.setLocation({22 })23 await browser.deleteSession()24})().catch((e) => console.error(e))
Wondering what could be a next-gen browser and mobile test automation framework that is also simple and concise? Yes, that’s right, it's WebdriverIO. Since the setup is very easy to follow compared to Selenium testing configuration, you can configure the features manually thereby being the center of attraction for automation testing. Therefore the testers adopt WedriverIO to fulfill their needs of browser testing.
Learn to run automation testing with WebdriverIO tutorial. Go from a beginner to a professional automation test expert with LambdaTest WebdriverIO tutorial.
Running Your First Automation Script - Learn the steps involved to execute your first Test Automation Script using WebdriverIO since the setup is very easy to follow and the features can be configured manually.
Selenium Automation With WebdriverIO - Read more about automation testing with WebdriverIO and how it supports both browsers and mobile devices.
Browser Commands For Selenium Testing - Understand more about the barriers faced while working on your Selenium Automation Scripts in WebdriverIO, the ‘browser’ object and how to use them?
Handling Alerts & Overlay In Selenium - Learn different types of alerts faced during automation, how to handle these alerts and pops and also overlay modal in WebdriverIO.
How To Use Selenium Locators? - Understand how Webdriver uses selenium locators in a most unique way since having to choose web elements very carefully for script execution is very important to get stable test results.
Deep Selectors In Selenium WebdriverIO - The most popular automation testing framework that is extensively adopted by all the testers at a global level is WebdriverIO. Learn how you can use Deep Selectors in Selenium WebdriverIO.
Handling Dropdown In Selenium - Learn more about handling dropdowns and how it's important while performing automated browser testing.
Automated Monkey Testing with Selenium & WebdriverIO - Understand how you can leverage the amazing quality of WebdriverIO along with selenium framework to automate monkey testing of your website or web applications.
JavaScript Testing with Selenium and WebdriverIO - Speed up your Javascript testing with Selenium and WebdriverIO.
Cross Browser Testing With WebdriverIO - Learn more with this step-by-step tutorial about WebdriverIO framework and how cross-browser testing is done with WebdriverIO.
Get 100 minutes of automation test minutes FREE!!