How to use _start method in Playwright Internal

Best JavaScript code snippet using playwright-internal

jquery.touchSlider.js

Source:jquery.touchSlider.js Github

copy

Full Screen

1/**2 * @name jQuery.touchSlider3 * @version 201209_24 * @since 2011065 * @param Object settings 환경변수 오브젝트6 * roll - 순환 (default true)7 * flexible - 유동 레이아웃 (default false)8 * view - 다중 컬럼 (default 1)9 * speed - 애니메이션 속도 (default 75)10 * range - 넘김 판정 범위 (default 0.15)11 * page - 초기 페이지 (default 1)12 * transition - CSS3 transition 사용 (default false)13 * btn_prev - prev 버튼 (jQuery Object, default null)14 * btn_next - next 버튼 (jQuery Object, default null)15 * paging - page 버튼 (jQuery Object, default null)16 * initComplete - 초기화 콜백17 * counter - 슬라이드 콜백, 카운터18 *19 * @example20 $("#target").touchSlider({21 flexible : true22 });23*/24(function ($) {25 26 $.fn.touchSlider = function (settings) {27 28 settings.supportsCssTransitions = (function (style) {29 var prefixes = ['Webkit','Moz','Ms'];30 for(var i=0, l=prefixes.length; i < l; i++ ) {31 if( typeof style[prefixes[i] + 'Transition'] !== 'undefined') {32 return true;33 }34 }35 return false;36 })(document.createElement('div').style);37 38 settings = jQuery.extend({39 roll : true,40 flexible : false,41 btn_prev : null,42 btn_next : null,43 paging : null,44 speed : 75,45 view : 1,46 range : 0.15,47 page : 1,48 autoplay: true,49 transition : false,50 initComplete : null,51 counter : null,52 multi : false53 54 }, settings);55 56 var opts = [];57 opts = $.extend({}, $.fn.touchSlider.defaults, settings);58 59 return this.each(function () {60 61 $.fn.extend(this, touchSlider);62 63 var _this = this;64 65 this.opts = opts;66 this._view = this.opts.view;67 this._speed = this.opts.speed;68 this._tg = $(this);69 this._list = this._tg.children().children();70 this._width = parseInt(this._tg.css("width"));71 this._item_w = parseInt(this._list.css("width"));72 this._len = this._list.length;73 this._range = this.opts.range * this._width;74 this._pos = [];75 this._start = [];76 this._startX = 0;77 this._startY = 0;78 this._left = 0;79 this._top = 0;80 this._drag = false;81 this._scroll = false;82 this._btn_prev;83 this._btn_next;84 85 this.init();86 87 $(this)88 .bind("touchstart", this.touchstart)89 .bind("touchmove", this.touchmove)90 .bind("touchend", this.touchend)91 .bind("dragstart", this.touchstart)92 .bind("drag", this.touchmove)93 .bind("dragend", this.touchend)94 95 $(window).bind("orientationchange resize", function () {96 _this.resize(_this);97 });98 });99 100 };101 102 var touchSlider = {103 104 init : function () {105 var _this = this;106 107 $(this).children().css({108 "width":this._width + "px",109 "overflow":"visible"110 });111 112 if(this.opts.flexible) this._item_w = this._width / this._view;113 if(this.opts.roll) this._len = Math.ceil(this._len / this._view) * this._view;114 115 var page_gap = (this.opts.page > 1 && this.opts.page <= this._len) ? (this.opts.page - 1) * this._item_w : 0;116 117 for(var i=0; i<this._len; ++i) {118 this._pos[i] = this._item_w * i - page_gap;119 this._start[i] = this._pos[i];120 this._list.eq(i).css({121 "float" : "none",122 "display" : "block",123 "position" : "absolute",124 "top" : "0",125 "left" : this._pos[i] + "px",126 "width" : this._item_w + "px"127 });128 if(this.opts.supportsCssTransitions && this.opts.transition) {129 this._list.eq(i).css({130 "-moz-transition" : "0ms",131 "-moz-transform" : "",132 "-ms-transition" : "0ms",133 "-ms-transform" : "",134 "-webkit-transition" : "0ms",135 "-webkit-transform" : "",136 "transition" : "0ms",137 "transform" : ""138 });139 }140 }141 142 if(this.opts.btn_prev && this.opts.btn_next) {143 this.opts.btn_prev.bind("click", function() {144 _this.animate(1, true);145 return false;146 })147 this.opts.btn_next.bind("click", function() {148 _this.animate(-1, true);149 return false;150 });151 }152 153 if(this.opts.paging) {154 $(this._list).each(function (i, el) {155 //var btn_page = _this.opts.paging.eq(0).clone();156 var btn_page = _this.opts.paging.eq(i);157 //_this.opts.paging.before(btn_page);158 159 btn_page.bind("click", function(e) {160 _this.go_page(i, e);161 return false;162 });163 });164 165 //this.opts.paging.remove();166 }167 168 this.counter();169 this.initComplete();170 },171 172 initComplete : function () {173 if(typeof(this.opts.initComplete) == "function") {174 this.opts.initComplete(this);175 }176 },177 178 resize : function (e) {179 if(e.opts.flexible) {180 var tmp_w = e._item_w;181 182 e._width = parseInt(e._tg.css("width"));183 e._item_w = e._width / e._view;184 e._range = e.opts.range * e._width;185 186 for(var i=0; i<e._len; ++i) {187 e._pos[i] = e._pos[i] / tmp_w * e._item_w;188 e._start[i] = e._start[i] / tmp_w * e._item_w;189 e._list.eq(i).css({190 "left" : e._pos[i] + "px",191 "width" : e._item_w + "px"192 });193 if(this.opts.supportsCssTransitions && this.opts.transition) {194 e._list.eq(i).css({195 "-moz-transition" : "0ms",196 "-moz-transform" : "",197 "-ms-transition" : "0ms",198 "-ms-transform" : "",199 "-webkit-transition" : "0ms",200 "-webkit-transform" : "",201 "transition" : "0ms",202 "transform" : ""203 });204 }205 }206 }207 208 this.counter();209 },210 211 touchstart : function (e) { 212 if((e.type == "touchstart" && e.originalEvent.touches.length <= 1) || e.type == "dragstart") {213 this._startX = e.pageX || e.originalEvent.touches[0].pageX;214 this._startY = e.pageY || e.originalEvent.touches[0].pageY;215 this._scroll = false;216 217 this._start = [];218 for(var i=0; i<this._len; ++i) {219 this._start[i] = this._pos[i];220 }221 }222 },223 224 touchmove : function (e) { 225 if((e.type == "touchmove" && e.originalEvent.touches.length <= 1) || e.type == "drag") {226 this._left = (e.pageX || e.originalEvent.touches[0].pageX) - this._startX;227 this._top = (e.pageY || e.originalEvent.touches[0].pageY) - this._startY;228 var w = this._left < 0 ? this._left * -1 : this._left;229 var h = this._top < 0 ? this._top * -1 : this._top;230 231 if (w < h || this._scroll) {232 this._left = 0;233 this._drag = false;234 this._scroll = true;235 } else {236 e.preventDefault();237 this._drag = true;238 this._scroll = false;239 this.position(e);240 }241 242 for(var i=0; i<this._len; ++i) {243 var tmp = this._start[i] + this._left;244 245 if(this.opts.supportsCssTransitions && this.opts.transition) {246 var trans = "translate3d(" + tmp + "px,0,0)";247 this._list.eq(i).css({248 "left" : "",249 "-moz-transition" : "0ms",250 "-moz-transform" : trans,251 "-ms-transition" : "0ms",252 "-ms-transform" : trans,253 "-webkit-transition" : "0ms",254 "-webkit-transform" : trans,255 "transition" : "0ms",256 "transform" : trans257 });258 } else {259 this._list.eq(i).css("left", tmp + "px");260 }261 262 this._pos[i] = tmp;263 }264 }265 },266 267 touchend : function (e) {268 if((e.type == "touchend" && e.originalEvent.touches.length <= 1) || e.type == "dragend") {269 if(this._scroll) {270 this._drag = false;271 this._scroll = false;272 return false;273 }274 275 this.animate(this.direction());276 this._drag = false;277 this._scroll = false;278 }279 },280 281 position : function (d) { 282 var gap = this._view * this._item_w;283 284 if(d == -1 || d == 1) {285 this._startX = 0;286 this._start = [];287 for(var i=0; i<this._len; ++i) {288 this._start[i] = this._pos[i];289 }290 this._left = d * gap;291 } else {292 if(this._left > gap) this._left = gap;293 if(this._left < - gap) this._left = - gap;294 }295 296 if(this.opts.roll) {297 var tmp_pos = [];298 for(var i=0; i<this._len; ++i) {299 tmp_pos[i] = this._pos[i];300 }301 tmp_pos.sort(function(a,b){return a-b;});302 303 var max_chk = tmp_pos[this._len-this._view];304 var p_min = $.inArray(tmp_pos[0], this._pos);305 var p_max = $.inArray(max_chk, this._pos);306 307 if(this._view <= 1) max_chk = this._len - 1;308 if(this.opts.multi) {309 if((d == 1 && tmp_pos[0] >= 0) || (this._drag && tmp_pos[0] >= 100)) {310 for(var i=0; i<this._view; ++i, ++p_min, ++p_max) {311 this._start[p_max] = this._start[p_min] - gap;312 this._list.eq(p_max).css("left", this._start[p_max] + "px");313 }314 } else if((d == -1 && tmp_pos[0] <= 0) || (this._drag && tmp_pos[0] <= -100)) {315 for(var i=0; i<this._view; ++i, ++p_min, ++p_max) {316 this._start[p_min] = this._start[p_max] + gap;317 this._list.eq(p_min).css("left", this._start[p_min] + "px");318 }319 }320 } else {321 if((d == 1 && tmp_pos[0] >= 0) || (this._drag && tmp_pos[0] > 0)) {322 for(var i=0; i<this._view; ++i, ++p_min, ++p_max) {323 this._start[p_max] = this._start[p_min] - gap;324 this._list.eq(p_max).css("left", this._start[p_max] + "px");325 }326 } else if((d == -1 && tmp_pos[max_chk] <= 0) || (this._drag && tmp_pos[max_chk] <= 0)) {327 for(var i=0; i<this._view; ++i, ++p_min, ++p_max) {328 this._start[p_min] = this._start[p_max] + gap;329 this._list.eq(p_min).css("left", this._start[p_min] + "px");330 }331 }332 }333 } else {334 if(this.limit_chk()) this._left = this._left / 2;335 }336 },337 338 animate : function (d, btn_click) {339 if(this._drag || !this._scroll || btn_click) {340 var _this = this;341 var speed = this._speed;342 343 if(btn_click) this.position(d);344 345 var gap = d * (this._item_w * this._view);346 if(this._left == 0 || (!this.opts.roll && this.limit_chk()) ) gap = 0;347 348 this._list.each(function (i, el) {349 _this._pos[i] = _this._start[i] + gap;350 351 if(_this.opts.supportsCssTransitions && _this.opts.transition) {352 var transition = speed + "ms";353 var transform = "translate3d(" + _this._pos[i] + "px,0,0)";354 355 if(btn_click) transition = "0ms";356 357 $(this).css({358 "left" : "",359 "-moz-transition" : transition,360 "-moz-transform" : transform,361 "-ms-transition" : transition,362 "-ms-transform" : transform,363 "-webkit-transition" : transition,364 "-webkit-transform" : transform,365 "transition" : transition,366 "transform" : transform367 });368 } else {369 $(this).stop();370 $(this).animate({"left": _this._pos[i] + "px"}, speed);371 }372 }); 373 374 this.counter();375 }376 },377 378 direction : function () { 379 var r = 0;380 381 if(this._left < -(this._range)) r = -1;382 else if(this._left > this._range) r = 1;383 384 if(!this._drag || this._scroll) r = 0;385 386 return r;387 },388 389 limit_chk : function () {390 var last_p = parseInt((this._len - 1) / this._view) * this._view;391 return ( (this._start[0] == 0 && this._left > 0) || (this._start[last_p] == 0 && this._left < 0) );392 },393 394 go_page : function (i, e) {395 var crt = ($.inArray(0, this._pos) / this._view) + 1;396 var cal = crt - (i + 1);397 398 while(cal != 0) {399 if(cal < 0) {400 this.animate(-1, true);401 cal++;402 } else if(cal > 0) {403 this.animate(1, true);404 cal--;405 }406 }407 },408 409 counter : function () {410 if(typeof(this.opts.counter) == "function") {411 var param = {412 total : Math.ceil(this._len / this._view),413 current : ($.inArray(0, this._pos) / this._view) + 1414 };415 this.opts.counter(param);416 }417 }418 419 };420})(jQuery);421$(document).ready(function(){422 423 424 $dragBln = false;425 426 $(".main_image").touchSlider({427 flexible : true,428 speed : 200,429 btn_prev : $("#btn_prev"),430 btn_next : $("#btn_next"),431 paging : $(".flicking_con a"),432 counter : function (e){433 $(".flicking_con a").removeClass("on").eq(e.current-1).addClass("on");434 }435 });436 437 $(".main_image").bind("mousedown", function() {438 $dragBln = false;439 });440 441 $(".main_image").bind("dragstart", function() {442 $dragBln = true;443 });444 445 $(".main_image a").click(function(){446 if($dragBln) {447 return false;448 }449 });450 451 timer = setInterval(function(){452 $("#btn_next").click();453 }, 3000);454 455 $(".main_visual").hover(function(){456 clearInterval(timer);457 },function(){458 timer = setInterval(function(){459 $("#btn_next").click();460 },3000);461 });462 463 $(".main_image").bind("touchstart",function(){464 clearInterval(timer);465 }).bind("touchend", function(){466 timer = setInterval(function(){467 $("#btn_next").click();468 }, 3000);469 });470 ...

Full Screen

Full Screen

WideInterval.js

Source:WideInterval.js Github

copy

Full Screen

1/*2 * This file is part of YoHours.3 * 4 * YoHours is free software: you can redistribute it and/or modify5 * it under the terms of the GNU Affero General Public License as published by6 * the Free Software Foundation, either version 3 of the License, or7 * any later version.8 * 9 * YoHours is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the12 * GNU Affero General Public License for more details.13 * 14 * You should have received a copy of the GNU Affero General Public License15 * along with YoHours. If not, see <http://www.gnu.org/licenses/>.16 */17//IMPORTS18let Constants = require("./Constants");19/**20 * A wide interval is an interval of one or more days, weeks, months, holidays.21 * Use WideInterval.days/weeks/months/holidays methods to construct one object.22 */23class WideInterval {24//CONSTRUCTOR25 constructor() {26 /** The start of the interval **/27 this._start = null;28 29 /** The end of the interval **/30 this._end = null;31 /** The kind of interval **/32 this._type = null;33 }34//CONSTRUCTORS35 /**36 * @return a day-based interval37 */38 day(startDay, startMonth, endDay, endMonth) {39 if(startDay == null || startMonth == null) {40 throw Error("Start day and month can't be null");41 }42 this._start = { day: startDay, month: startMonth };43 this._end = (endDay != null && endMonth != null && (endDay != startDay || endMonth != startMonth)) ? { day: endDay, month: endMonth } : null;44 this._type = "day";45 return this;46 }47 48 /**49 * @return a week-based interval50 */51 week(startWeek, endWeek) {52 if(startWeek == null) {53 throw Error("Start week can't be null");54 }55 this._start = { week: startWeek };56 this._end = (endWeek != null && endWeek != startWeek) ? { week: endWeek } : null;57 this._type = "week";58 return this;59 }60 61 /**62 * @return a month-based interval63 */64 month(startMonth, endMonth) {65 if(startMonth == null) {66 throw Error("Start month can't be null");67 }68 this._start = { month: startMonth };69 this._end = (endMonth != null && endMonth != startMonth) ? { month: endMonth } : null;70 this._type = "month";71 return this;72 }73 74 /**75 * @return a holiday-based interval76 */77 holiday(holiday) {78 if(holiday == null || (holiday != "PH" && holiday != "SH" && holiday != "easter")) {79 throw Error("Invalid holiday, must be PH, SH or easter");80 }81 this._start = { holiday: holiday };82 this._end = null;83 this._type = "holiday";84 return this;85 }86 87 /**88 * @return a holiday-based interval89 */90 always() {91 this._start = null;92 this._end = null;93 this._type = "always";94 return this;95 }96//ACCESSORS97 /**98 * @return The kind of wide interval (always, day, month, week, holiday)99 */100 getType() {101 return this._type;102 }103 104 /**105 * @return The start moment106 */107 getStart() {108 return this._start;109 }110 111 /**112 * @return The end moment113 */114 getEnd() {115 return this._end;116 }117 118 /**119 * @return True if the given object concerns the same interval as this one120 */121 equals(o) {122 if(!o instanceof WideInterval) { return false; }123 if(this === o) { return true; }124 if(o._type == "always") { return this._type == "always"; }125 let result = false;126 127 switch(this._type) {128 case "always":129 result = o._start == null;130 break;131 case "day":132 result =133 (134 o._type == "day"135 && o._start.month == this._start.month136 && o._start.day == this._start.day137 && (138 (o._end == null && this._end == null)139 || (o._end != null && this._end != null && this._end.month == o._end.month && this._end.day == o._end.day)140 ))141 ||142 (143 o._type == "month"144 && o._start.month == this._start.month145 && (this.isFullMonth() && o.isFullMonth())146 || (o._end != null && this._end != null && this._end.month == o._end.month && this.endsMonth() && o.endsMonth())147 );148 break;149 case "week":150 result =151 o._start.week == this._start.week152 && (o._end == this._end || (this._end != null && o._end != null && o._end.week == this._end.week));153 break;154 case "month":155 result = 156 (157 o._type == "day"158 && this._start.month == o._start.month159 && o.startsMonth()160 && (161 (this._end == null && o._end != null && this._start.month == o._end.month && o.endsMonth())162 ||163 (this._end != null && o._end != null && this._end.month == o._end.month && o.endsMonth())164 )165 )166 ||167 (168 o._type == "month"169 && o._start.month == this._start.month170 && (171 (this._end == null && o._end == null)172 ||173 (this._end != null && o._end != null && this._end.month == o._end.month)174 )175 );176 break;177 case "holiday":178 result = o._start.holiday == this._start.holiday;179 break;180 default:181 }182 183 return result;184 }185 186 /**187 * @return The human readable time188 */189 getTimeForHumans() {190 let result;191 192 switch(this._type) {193 case "day":194 if(this._end != null) {195 result = "every week from "+Constants.IRL_MONTHS[this._start.month-1]+" "+this._start.day+" to ";196 if(this._start.month != this._end.month) { result += Constants.IRL_MONTHS[this._end.month-1]+" "; }197 result += this._end.day;198 }199 else {200 result = "day "+Constants.IRL_MONTHS[this._start.month-1]+" "+this._start.day;201 }202 break;203 case "week":204 if(this._end != null) {205 result = "every week from week "+this._start.week+" to "+this._end.week;206 }207 else {208 result = "week "+this._start.week;209 }210 break;211 case "month":212 if(this._end != null) {213 result = "every week from "+Constants.IRL_MONTHS[this._start.month-1]+" to "+Constants.IRL_MONTHS[this._end.month-1];214 }215 else {216 result = "every week in "+Constants.IRL_MONTHS[this._start.month-1];217 }218 break;219 case "holiday":220 if(this._start.holiday == "SH") {221 result = "every week during school holidays";222 }223 else if(this._start.holiday == "PH") {224 result = "every public holidays";225 }226 else if(this._start.holiday == "easter") {227 result = "each easter day";228 }229 else {230 throw new Error("Invalid holiday type: "+this._start.holiday);231 }232 break;233 case "always":234 result = "every week of year";235 break;236 default:237 result = "invalid time";238 }239 240 return result;241 }242 243 /**244 * @return The time selector for OSM opening_hours245 */246 getTimeSelector() {247 let result;248 249 switch(this._type) {250 case "day":251 result = Constants.OSM_MONTHS[this._start.month-1]+" "+((this._start.day < 10) ? "0" : "")+this._start.day;252 if(this._end != null) {253 //Same month as start ?254 if(this._start.month == this._end.month) {255 result += "-"+((this._end.day < 10) ? "0" : "")+this._end.day;256 }257 else {258 result += "-"+Constants.OSM_MONTHS[this._end.month-1]+" "+((this._end.day < 10) ? "0" : "")+this._end.day;259 }260 }261 break;262 case "week":263 result = "week "+((this._start.week < 10) ? "0" : "")+this._start.week;264 if(this._end != null) {265 result += "-"+((this._end.week < 10) ? "0" : "")+this._end.week;266 }267 break;268 case "month":269 result = Constants.OSM_MONTHS[this._start.month-1];270 if(this._end != null) {271 result += "-"+Constants.OSM_MONTHS[this._end.month-1];272 }273 break;274 case "holiday":275 result = this._start.holiday;276 break;277 case "always":278 default:279 result = "";280 }281 282 return result;283 }284 285 /**286 * Does this interval corresponds to a full month ?287 */288 isFullMonth() {289 if(this._type == "month" && this._end == null) {290 return true;291 }292 else if(this._type == "day") {293 return (this._start.day == 1 && this._end != null && this._end.month == this._start.month && this._end.day != undefined && this._end.day == Constants.MONTH_END_DAY[this._end.month-1]);294 }295 else {296 return false;297 }298 }299 300 /**301 * Does this interval starts the first day of a month302 */303 startsMonth() {304 return this._type == "month" || this._type == "always" || (this._type == "day" && this._start.day == 1);305 }306 307 /**308 * Does this interval ends the last day of a month309 */310 endsMonth() {311 return this._type == "month" || this._type == "always" || (this._type == "day" && this._end != null && this._end.day == Constants.MONTH_END_DAY[this._end.month-1]);312 }313 314 /**315 * Does this interval strictly contains the given one (ie the second is a refinement of the first, and not strictly equal)316 * @param o The other wide interval317 * @return True if this date contains the given one (and is not strictly equal to)318 */319 contains(o) {320 let result = false;321 322 /*323 * Check if it is contained in this one324 */325 if(this.equals(o)) {326 result = false;327 }328 else if(this._type == "always") {329 result = true;330 }331 else if(this._type == "day") {332 if(o._type == "day") {333 //Starting after334 if(o._start.month > this._start.month || (o._start.month == this._start.month && o._start.day >= this._start.day)) {335 //Ending before336 if(o._end != null) {337 if(this._end != null && (o._end.month < this._end.month || (o._end.month == this._end.month && o._end.day <= this._end.day))) {338 result = true;339 }340 }341 else {342 if(this._end != null && (o._start.month < this._end.month || (o._start.month == this._end.month && o._start.day <= this._end.day))) {343 result = true;344 }345 }346 }347 }348 else if(o._type == "month"){349 //Starting after350 if(o._start.month > this._start.month || (o._start.month == this._start.month && this._start.day == 1)) {351 //Ending before352 if(o._end != null && this._end != null && (o._end.month < this._end.month || (o._end.month == this._end.month && this._end.day == Constants.MONTH_END_DAY[end.month-1]))) {353 result = true;354 }355 else if(o._end == null && (this._end != null && o._start.month < this._end.month)) {356 result = true;357 }358 }359 }360 }361 else if(this._type == "week") {362 if(o._type == "week") {363 if(o._start.week >= this._start.week) {364 if(o._end != null && this._end != null && o._end.week <= this._end.week) {365 result = true;366 }367 else if(o._end == null && ((this._end != null && o._start.week <= this._end.week) || o._start.week == this._start.week)) {368 result = true;369 }370 }371 }372 }373 else if(this._type == "month") {374 if(o._type == "month") {375 if(o._start.month >= this._start.month) {376 if(o._end != null && this._end != null && o._end.month <= this._end.month) {377 result = true;378 }379 else if(o._end == null && ((this._end != null && o._start.month <= this._end.month) || o._start.month == this._start.month)) {380 result = true;381 }382 }383 }384 else if(o._type == "day") {385 if(o._end != null) {386 if(this._end == null) {387 if(388 o._start.month == this._start.month389 && o._end.month == this._start.month390 && ((o._start.day >= 1 && o._end.day < Constants.MONTH_END_DAY[o._start.month-1])391 || (o._start.day > 1 && o._end.day <= Constants.MONTH_END_DAY[o._start.month-1]))392 ) {393 result = true;394 }395 }396 else {397 if(o._start.month >= this._start.month && o._end.month <= this._end.month) {398 if(399 (o._start.month > this._start.month && o._end.month < this._end.month)400 || (o._start.month == this._start.month && o._end.month < this._end.month && o._start.day > 1)401 || (o._start.month > this._start.month && o._end.month == this._end.month && o._end.day < Constants.MONTH_END_DAY[o._end.month-1])402 || (o._start.day >= 1 && o._end.day < Constants.MONTH_END_DAY[o._end.month-1])403 || (o._start.day > 1 && o._end.day <= Constants.MONTH_END_DAY[o._end.month-1])404 ) {405 result = true;406 }407 }408 }409 }410 else {411 if(this._end == null) {412 if(this._start.month == o._start.month) {413 result = true;414 }415 }416 else {417 if(o._start.month >= this._start.month && o._start.month <= this._end.month) {418 result = true;419 }420 }421 }422 }423 }424 425 return result;426 }427}...

Full Screen

Full Screen

beta-u-animation-to.js

Source:beta-u-animation-to.js Github

copy

Full Screen

1 // style2 // stroke, fill, 3 // attributes4 // x1, x2, y1, y2, r, cx, cy, d, x, y5 // stroke, stroke-width, fill, stroke-dash-array6 7 // CURRENT THINGS TO CONSIDER8 9 // if animation is running, should new function call take over or work "on top"/"side-by-side"10 // css transitions take over11 u.a.parseSVGPolygon = function(value) {12// u.bug("parseSVGPolygon:" + value)13 // values required for each type14 var pairs = value.trim().split(" ");15 var sets = [];16 var part;17 for(x in pairs) {18 parts = pairs[x].trim().split(",");19 for(part in parts) {20 parts[part] = Number(parts[part]);21 }22 sets[x] = parts;23// if(parts && pairs[parts[0].toLowerCase()] == parts.length-1) {24// // u.bug("valid set:" + parts);25// }26// else {27// // u.bug("invalid set - could be 'dual' set with only one identifier")28// }29 }30// u.bug("sets:" + sets.join("#"));31 // u.bug("value:" + value);32 return sets;33 34 }35 u.a.parseSVGPath = function(value) {36 // values required for each type37 var pairs = {"m":2, "l":2, "a":7, "c":6, "s":4, "q":4, "z":0};38 var x, sets;39 // add structure to string for parsability40 value = value.replace(/-/g, " -");41 value = value.replace(/,/g, " ");42 value = value.replace(/(m|l|a|c|s|q|M|L|A|C|S|Q)/g, " $1 ");43 value = value.replace(/ /g, " ");44 // check values45 sets = value.match(/(m|l|a|c|s|q|M|L|A|C|S|Q)([0-9 \-\.]+)/g);46 for(x in sets) {47 parts = sets[x].trim().split(" ");48 sets[x] = parts;49 if(parts && pairs[parts[0].toLowerCase()] == parts.length-1) {50// u.bug("valid set:" + parts);51 }52 else {53// u.bug("invalid set - could be 'dual' set with only one identifier")54 }55 }56 // u.bug("values:" + sets);57 // u.bug("value:" + value);58 return sets;59 60 }61 u.a.getInitialValue = function(node, attribute) {62 var value = (node.getAttribute(attribute) ? node.getAttribute(attribute) : u.gcs(node, attribute)).replace(node._unit[attribute], "")63 if(attribute.match(/^(d|points)$/)) {64// u.bug("getInitialValue:" +value)65 return value;66// value.split("m|l|a|c|s|M|L|A|C|S");67 }68 else {69 return Number(value.replace(/auto/, 0));70 }71 }72 u.a.to = function(node, transition, attributes) {73// u.bug("to:" + u.nodeId(node) + ", " + transition + ", " + attributes);74 // get duration75// var transition_parts = transition.match(/([a-zA-Z]+) ([0-9.]+[ms]+) ([a-zA-Z\-]+) ([0-9.]+[ms]+)/g);76 var transition_parts = transition.split(" ");77// u.bug(transition_parts)78 if(transition_parts.length >= 3) {79 // u.bug(duration[0]);80 node._target = transition_parts[0];81 node.duration = transition_parts[1].match("ms") ? parseFloat(transition_parts[1]) : (parseFloat(transition_parts[1]) * 1000);82 node._ease = transition_parts[2];83 if(transition_parts.length == 4) {84 node.delay = transition_parts[3].match("ms") ? parseFloat(transition_parts[3]) : (parseFloat(transition_parts[3]) * 1000);85 }86 }87 var value, d;88// u.bug("node._ease:" + node._ease);89 node._start = {};90 node._end = {};91 node._unit = {};92 for(attribute in attributes) {93 // path definitions are 94 if(attribute.match(/^(d)$/)) {95 node._start[attribute] = this.parseSVGPath(this.getInitialValue(node, attribute));96 node._end[attribute] = this.parseSVGPath(attributes[attribute]);97// u.bug("start:" + node._start[attribute].join("#"))98// u.bug("end:" + node._end[attribute])99 // d_parts = this.getInitialValue(node, attribute);100 //101 // u.bug("d_parts:" + d_parts)102 //103 //104 // node._start[attribute] = d_parts.split("m|l|a|c|s|M|L|A|C|S");105 //106 // u.bug("node._start:" + node._start[attribute])107 }108 // polygons109 else if(attribute.match(/^(points)$/)) {110// u.bug("to points:" + u.nodeId(node) + ", " + attributes[attribute])111 node._start[attribute] = this.parseSVGPolygon(this.getInitialValue(node, attribute));112 node._end[attribute] = this.parseSVGPolygon(attributes[attribute]);113// u.bug("start:" + node._start[attribute].join("#"))114 }115 // plain number svg shapes116 else {117 node._unit[attribute] = attributes[attribute].toString().match(/\%|px/);118 node._start[attribute] = this.getInitialValue(node, attribute);119 //(node.getAttribute(attribute) ? node.getAttribute(attribute) : u.gcs(node, attribute)).replace(node._unit[attribute], "");120 node._end[attribute] = attributes[attribute].toString().replace(node._unit[attribute], "");121 }122// u.bug("attributes["+attribute+"] = "+attributes[attribute] + "::"+ node._start[attribute] + " -> " + node._end[attribute]);123 }124// u.bug("duration:" + node.duration);125// u.bug(u.easings);126// u.bug(node._ease + ", " + u.easings[node._ease]);127 node.easing = u.easings[node._ease];128// u.bug(node.easing);129 node.transitionTo = function(progress) {130 var easing = node.easing(progress);131// u.bug("easing:" + easing + ", " + progress)132 for(attribute in attributes) {133 // transform value134 if(attribute.match(/^(translate|rotate|scale)$/)) {135 if(attribute == "translate") {136 u.a.translate(this, Math.round((this._end_x - this._start_x) * easing), Math.round((this._end_y - this._start_y) * easing))137 }138 else if(attribute == "rotate") {139 }140 }141 // plain svg value142 else if(attribute.match(/^(x1|y1|x2|y2|r|cx|cy|stroke-width)$/)) {143 var new_value = (this._start[attribute] + ((this._end[attribute] - this._start[attribute]) * easing)) + this._unit[attribute]144// u.bug("update:" + attribute + ":" + new_value);145 this.setAttribute(attribute, new_value);146 }147 // path d attribute148 else if(attribute.match(/^(d)$/)) {149// u.bug("path")150// var d_parts = this._start[attribute].split("m|l|a|c|s|M|L|A|C|S");151// u.bug("d_parts:" + d_parts)152 var new_value = "";153 for(x in this._start[attribute]) {154 for(y in this._start[attribute][x]) {155// u.bug("pf:" + this._start[attribute][x][y] + " :: " + parseFloat(this._start[attribute][x][y]) + ", " + typeof(this._start[attribute][x][y]))156 if(parseFloat(this._start[attribute][x][y]) == this._start[attribute][x][y]) {157 new_value += (Number(this._start[attribute][x][y]) + ((Number(this._end[attribute][x][y]) - Number(this._start[attribute][x][y])) * easing)) + " ";158 }159 else {160 new_value += this._end[attribute][x][y] + " ";161 }162 }163 }164 // var new_value = (this._start[attribute] + ((this._end[attribute] - this._start[attribute]) * easing)) + this._unit[attribute]165//166// u.bug("set new:" + new_value);167 this.setAttribute(attribute, new_value);168 }169 // polygon point attribute170 else if(attribute.match(/^(points)$/)) {171// u.bug("path")172// var d_parts = this._start[attribute].split("m|l|a|c|s|M|L|A|C|S");173// u.bug("d_parts:" + d_parts)174 var new_value = "";175 for(x in this._start[attribute]) {176 new_value += (this._start[attribute][x][0] + ((this._end[attribute][x][0] - this._start[attribute][x][0]) * easing)) + ",";177 new_value += (this._start[attribute][x][1] + ((this._end[attribute][x][1] - this._start[attribute][x][1]) * easing)) + " ";178 }179 // var new_value = (this._start[attribute] + ((this._end[attribute] - this._start[attribute]) * easing)) + this._unit[attribute]180//181// u.bug("set new:" + new_value);182 this.setAttribute(attribute, new_value);183 }184 // regular attribute185 else {186 //u.bug("update:" + this._end[attribute] + "-" + this._start[attribute] + " * " + easing + " " + this._unit[attribute])187 var new_value = (this._start[attribute] + ((this._end[attribute] - this._start[attribute]) * easing)) + this._unit[attribute]188// u.bug("update:" + attribute + ":" + new_value);189 u.as(node, attribute, new_value, false);190 }191 192 }193 }194// u.bug(u.nodeId(this) + ":easing:" + easing + " ("+(this._end_x - this._start_x) * easing+","+(this._end_y - this._start_y) * easing+")")195 196// u.bug(node.duration);197 u.a.requestAnimationFrame(node, "transitionTo", node.duration);198 }199// this.animationFrame = function(node, callback) {200//201// if(!window._animationframe) {202// window._animationframe = window[this.vendor("requestAnimationFrame")]203//204// }205//206// }207//208//209// window.cancelRequestAnimFrame = ( function() {210// return window.cancelAnimationFrame ||211// window.webkitCancelRequestAnimationFrame ||212// window.mozCancelRequestAnimationFrame ||213// window.oCancelRequestAnimationFrame ||214// window.msCancelRequestAnimationFrame ||215// clearTimeout216// } )();217//218// window.requestAnimFrame = (function() {219// return window.requestAnimationFrame ||220// window.webkitRequestAnimationFrame ||221// window.mozRequestAnimationFrame ||222// window.oRequestAnimationFrame ||223// window.msRequestAnimationFrame ||224// function(callback, element){225// return window.setTimeout(callback, 1000 / 60);226// };227// })();228//229// (function() {230// var lastTime = 0;231// var vendors = ['ms', 'moz', 'webkit', 'o'];232// for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {233// window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];234// window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame']235// || window[vendors[x]+'CancelRequestAnimationFrame'];236// }237//238// if (!window.requestAnimationFrame)239// window.requestAnimationFrame = function(callback, element) {240// var currTime = new Date().getTime();241// var timeToCall = Math.max(0, 16 - (currTime - lastTime));242// var id = window.setTimeout(function() { callback(currTime + timeToCall); },243// timeToCall);244// lastTime = currTime + timeToCall;245// return id;246// };247//248// if (!window.cancelAnimationFrame)249// window.cancelAnimationFrame = function(id) {250// clearTimeout(id);251// };...

Full Screen

Full Screen

array-slice.js

Source:array-slice.js Github

copy

Full Screen

1/**2 * An array proxy that exposes only selected slice of real EmberArray.3 * 4 * See tests for usage examples.5 *6 * @module utils/array-slice7 * @author Jakub Liput8 * @copyright (C) 2018 ACK CYFRONET AGH9 * @license This software is released under the MIT license cited in 'LICENSE.txt'.10 */11import Ember from 'ember';12const {13 ArrayProxy,14 computed,15 observer,16} = Ember;17export default ArrayProxy.extend({18 startIndex: 0,19 endIndex: 0,20 indexMargin: 0,21 22 _startCache: undefined,23 _endCache: undefined,24 25 sourceArray: computed.alias('content'),26 27 /**28 * @type {Ember.ComputedProperty<number>}29 */30 maxLength: computed('startIndex', 'endIndex', function getMaxLength() {31 return this.get('endIndex') - this.get('startIndex');32 }),33 34 _start: computed('startIndex', 'indexMargin', function () {35 const {36 startIndex,37 indexMargin,38 } = this.getProperties(39 'startIndex',40 'indexMargin'41 );42 const _start = Math.max(0, startIndex - indexMargin);43 44 this.set('_startCache', _start);45 return _start;46 }),47 48 _end: computed('endIndex', 'indexMargin', 'sourceArray.length', function () {49 const {50 endIndex,51 indexMargin,52 } = this.getProperties(53 'endIndex',54 'indexMargin'55 );56 57 const sourceLength = this.get('sourceArray.length');58 return Math.min(sourceLength, endIndex + indexMargin);59 }),60 61 _startChanged: observer('_start', function _startChanged() {62 const {63 _startCache,64 _start,65 } = this.getProperties(66 '_startCache',67 '_start'68 );69 70 if (_startCache !== undefined && _start !== _startCache) {71 let removeAmt = 0;72 let addAmt = 0;73 if (_start > _startCache) {74 removeAmt = _start - _startCache;75 } else {76 addAmt = _startCache - _start;77 }78 this.arrayContentDidChange(_start, removeAmt, addAmt);79 }80 81 this.set('_startCache', _start);82 }),83 84 _endChanged: observer('_end', function _endChanged() {85 const {86 _endCache,87 _end,88 } = this.getProperties(89 '_endCache',90 '_end'91 );92 if (_endCache !== undefined && _end !== _endCache) {93 let removeAmt = 0;94 let addAmt = 0;95 if (_end > _endCache) {96 addAmt = _end - _endCache;97 } else {98 removeAmt = _endCache - _end;99 }100 this.arrayContentDidChange(_endCache - removeAmt, removeAmt, addAmt);101 }102 103 this.set('_endCache', _end);104 }),105 106 /**107 * @override 108 */109 replace(idx, amt, objects) {110 const sourceArray = this.get('sourceArray');111 return sourceArray.replace(this._translateIndex(idx), amt, objects);112 },113 114 /**115 * @override116 */117 objectAt(idx) {118 const sourceArray = this.get('sourceArray');119 if (sourceArray) {120 return sourceArray.objectAt(this._translateIndex(idx));121 }122 },123 124 /**125 * @override 126 */127 length: computed('_start', '_end', function () {128 const {129 _start,130 _end,131 } = this.getProperties(132 '_start',133 '_end'134 );135 return _end - _start;136 }),137 _arrayContentChange(startIdx, removeAmt, addAmt, fun) {138 const {139 _start,140 _end,141 } = this.getProperties(142 '_start',143 '_end'144 );145 if (_start <= startIdx && startIdx <= _end) {146 const sliceStartIdx = startIdx - _start;147 const sliceRemoveAmt = Math.min(_end, sliceStartIdx + removeAmt) - sliceStartIdx;148 const sliceAddAmt = Math.min(_end, sliceStartIdx + addAmt) - sliceStartIdx;149 return fun.bind(this)(sliceStartIdx, sliceRemoveAmt, sliceAddAmt);150 } else {151 return this;152 }153 },154 155 /**156 * @override157 */158 arrayContentWillChange(startIdx, removeAmt, addAmt) {159 return this._arrayContentChange(startIdx, removeAmt, addAmt, this._super);160 },161 162 /**163 * @override164 */165 arrayContentDidChange(startIdx, removeAmt, addAmt) {166 return this._arrayContentChange(startIdx, removeAmt, addAmt, this._super);167 },168 169 _translateIndex(index) {170 const {171 _start,172 _end,173 } = this.getProperties(174 '_start',175 '_end'176 );177 const translatedIndex = _start + index;178 return translatedIndex > _end ? -1 : translatedIndex;179 },180 181 init() {182 this._super(...arguments);183 // activate observers184 this.getProperties('_start', '_end');185 this._startChanged();186 this._endChanged();187 },...

Full Screen

Full Screen

cubeList.js

Source:cubeList.js Github

copy

Full Screen

1define([],function(){2 function cubeList(){3 this._start = null;4 this.length = 0;5 this._range = {x:[0,0],y:[0,0],z:[0,0]};6 this._order = ['z','x','y',1,1,1]; //z draws over every other lower z, then x draws over every lower x, but not higher z, then y draws over lower y, but none others...7 };8 cubeList.prototype = {9 push: function(cube,spot){10 if(!cube) return;11 if(this.length==0)12 this._start = cube;13 else if(spot){14 cube._next = spot._next;15 spot._next = cube;16 }17 else{18 var pos = this._start;19 if(pos)while(pos._next!=null) pos = pos._next;20 pos._next=cube;21 }22 var axis = ['x','y','z']; //shoutouts to my 4d pals, gotta make this a variable.23 for(var i=0; i<axis.length;i++){24 if(cube._pos[axis[i]]<this._range[axis[i]][0]) this._range[axis[i]][0]=cube._pos[axis[i]]25 else if(cube._pos[axis[i]]>this._range[axis[i]][1]) this._range[axis[i]][1]=cube._pos[axis[i]]26 }27 cube._list = this;28 this.length++;29 },30 pop: function(cube){31 if(this.length==0)32 throw("No nodes left to pop");33 if(cube==this._start){34 if(!cube._next){35 this._start=null;36 this.length=0;37 return cube;38 }39 this._start = this._start._next;40 }41 else{42 var pos = this._start;43 while(pos._next!=cube)44 pos=pos._next;45 if(cube)46 pos._next=cube._next;47 else pos._next = null;48 }49 this.length--;50 return cube;51 },52 mergeSort: function(order = this._order){53 this._order = order; //if someone sets it, I GOTTA KNOW.54 if(this.length<=1) return; //end if its only 1.55 var left = new cubeList(),56 right = new cubeList(),57 pos = this._start;58 for(i=0;i<this.length&&pos;i++){59 if(i<this.length/2)60 left.push(copy(pos));61 else62 right.push(copy(pos));63 pos=pos._next;64 };65 left.mergeSort(order);66 right.mergeSort(order);67 this._start = mergeList(left,right,this._order)._start;68 },69 forEach: function(execute){70 var pos = this._start;71 while(pos){72 execute(pos,this);73 pos=pos._next;74 }75 },76 newCube: function(ent,pos,list=this){77 this.push(new cubeNode(ent,pos,list));78 }79 };80 function mergeList(left, right, order = ['z','x','y',1,1,1]){81 var list = new cubeList();82 while(left._start && right._start){83 for(i=0;i<order.length/2;i++){84 if(left._start._pos[order[i]]*order[i+3]<right._start._pos[order[i]]*order[i+3]){85 list.push(copy(left._start));86 left.pop(left._start);87 i=3;88 }89 else if(left._start._pos[order[i]]*order[i+3]==right._start._pos[order[i]]*order[i+3]){90 if(i==2) throw(["Two cubes are in the same space.",left._start,right._start]);91 }92 else{93 list.push(copy(right._start));94 right.pop(right._start);95 i=3;96 }97 }98 }99 while(left._start){100 list.push(copy(left._start));101 left.pop(left._start);102 }103 while(right._start){104 list.push(copy(right._start));105 right.pop(right._start);106 }107 return list;108 }109 function cubeNode(ent=null,pos = {x: null, y: null, z: null},list=null,direction = [0,0,0,false], command = null,next=null){110 this._ent = ent;111 this._pos = pos;112 this._list = list;113 this._direction = direction;//basically the direction its pointing in. if it has stuff, it poitns. if not, it doesnt point.114 if(this._ent) this._ent._cube = this;115 this._command = command; //this is going to cointain the line that defines this block.116 //i guess since if its drawing, it goes in order of lowest z to lowest y to lowest x,117 //it can act sort of like a line???118 //1d is easy to deal with, as in this case i only really need a start.119 //and then i can easily sort it as well.120 //and even easier, drawing!121 this._next = next;122 };123 function copy(cube){124 if(cube)125 return new cubeNode(cube._ent,cube._pos,cube._list);126 else return null;127 };128 return cubeList;...

Full Screen

Full Screen

handler.js

Source:handler.js Github

copy

Full Screen

1/* the following require must be ignored */2var fs = require("fs");3 var Handle_Constants = {4 5 6 7 8 };9 var Middle_Components = {10 // the middle components, 11 // didive the handling process 12 // into several steps 13 14 _content_for_parse : "",15 16 // cache the parse results 17 FILENAME :/* new filenamecomponent() */{18 parse : function (){19 // a parser for parsing filename from the post content 20 var FILENAMEtag = "FILENAME";21 var _start = _content_for_parse.indexOf(FILENAMEtag)+FILENAMEtag.length;22 var _end = _content_for_parse.substring(_start).indexOf(FILENAMEtag)+_start;23 // for debug only 24 // console.log(_content_for_parse.substring(_start,_end)); 25 return _content_for_parse.substring(_start,_end);26 }27 },28 29 FILEADDR :/* new fileaddrcomponent() */{30 parse : function (){31 // a parser for parsing fileaddr from the post content 32 var FILEADDRtag = "FILEADDR";33 var _start = _content_for_parse.indexOf(FILEADDRtag)+FILEADDRtag.length;34 var _end = _content_for_parse.substring(_start).indexOf(FILEADDRtag)+_start;35 // for debug only 36 // console.log(_content_for_parse.substring(_start,_end)); 37 return _content_for_parse.substring(_start,_end);38 }39 },40 41 FILECONTENT :/* new filecontentcomponent() */{42 parse : function (){43 // a parser for parsing filecontent from the post content44 var FILECONTENTtag = "FILECONTENT";45 var _start = _content_for_parse.indexOf(FILECONTENTtag)+FILECONTENTtag.length;46 var _end = _content_for_parse.substring(_start).indexOf(FILECONTENTtag)+_start;47 // for debug only 48 // console.log(_content_for_parse.substring(_start,_end)); 49 return _content_for_parse.substring(_start,_end);50 }51 },52 53 PATCHTYPE :/* new patchtypecomponent() */{54 parse : function (){55 // a parser for parsing patchtype from the post content56 var PATCHTYPEtag = "PATCHTYPE";57 var _start = _content_for_parse.indexOf(PATCHTYPEtag)+PATCHTYPEtag.length;58 var _end = _content_for_parse.substring(_start).indexOf(PATCHTYPEtag)+_start;59 // for debug only 60 // console.log(_content_for_parse.substring(_start,_end)); 61 return _content_for_parse.substring(_start,_end);62 }63 },64 65 66 TOPARSE :/* new loadcomponent() */{67 load : function (content){68 // a parser for parsing filecontent from the post content69 _content_for_parse = content;70 }71 },72 73 };74 75 function run_test(){76 inner_test();77 }78 79 80 function inner_test(){81 // the actual codes for running tests 82 var content = "FILENAMEtmp.txtFILENAME";83 84 85 var _tag = "FILENAME"; 86 var _start = content.indexOf(_tag)+_tag.length;87 var _end = content.substring(_start).indexOf(_tag)+_start;88 return content.substring(_start,_end);89 90 91 }92 93 94 function getHandler(){95 96 // return a handler 97 var Handler = {98 99 handle : function(content){100 // temporarily add contents 101 // the function name for TOPARSE i havn't think out a good one , use 102 // it temporarily 103 Middle_Components.TOPARSE.load(content);104 var fileName = Middle_Components.FILENAME.parse();105 var fileAddr = Middle_Components.FILEADDR.parse();106 var fileContent = Middle_Components.FILECONTENT.parse();107 var patchType = Middle_Components.PATCHTYPE.parse();108 // now left work is so easy to be done 109 // for debug only 110 console.log(" fileName is : "+fileName);111 console.log(" fileAddr is : "+fileAddr);112 console.log(" fileContent is : "+fileContent);113 console.log(" patchType is : "+patchType);114 // make a wrapper function for this fs operations 115 // do some prechecks here 116 fs.writeFileSync(fileAddr+"/"+fileName,fileContent);117 118 },119 };120 121 return Handler;122 123 }124 125 126 module.exports = {127 128 getHandler : getHandler,129 130 run_test : run_test131 ...

Full Screen

Full Screen

route.js

Source:route.js Github

copy

Full Screen

1export default class List{2 constructor(){3 this._start = null;4 }5 AddBase(base){6 if(!this._start){7 this._start = base;8 this._start.setPrev(this._start);9 this._start.setNext(this._start);10 return true;11 }12 13 let exist = this._search(base.getName());14 let last = this._start.prev;15 if(!exist){16 last.setNext(base);17 base.setPrev(last);18 base.setNext(this._start);19 this._start.setPrev(base);20 return true;21 }22 return false;23 }24 deleteBase(name){25 let exist = this._search(name);26 if(!exist){27 return null;28 }29 30 let temp = this._start;31 if(this._start.getName() == name){32 if(this._start.next == this._start){33 this._start = null;34 return temp;35 } else {36 this._start = this._start.next;37 temp.prev.setNext(temp.next);38 temp.next.setPrev(temp.prev);39 temp.setPrev(null);40 temp.setNext(null);41 return temp;42 }43 }44 while(temp.getName() != name){45 temp = temp.next;46 }47 temp.prev.setNext(temp.next);48 temp.next.setPrev(temp.prev);49 temp.setPrev(null);50 temp.setNext(null);51 return temp;52 }53 listBases(){54 if(!this._start){55 return "No se ha registrado ninguna base.";56 }57 let temp = this._start;58 let result = "";59 let n = 1;60 do{61 result += ` <b>${n}</b>. ${temp.showInfo()}`;62 temp = temp.next;63 n++;64 } while(temp != this._start);65 return result;66 }67 createCard(name, timeStart, time, message){68 let exist = this._search(name);69 if(!exist || !this._start){70 return "No existe esa base.";71 }72 exist = exist.next;73 let min = exist.getMin();74 let msg = "";75 do{76 if(min >= 60){77 timeStart++;78 min -= 60;79 }80 msg += `${exist.getName()}: ${timeStart}:${min}.<br>`;81 exist = exist.next;82 time -= exist.getMin();83 min += exist.getMin();84 } while(exist.getMin() <= time);85 return message += msg;86 }87 _search(name){88 if(this._start == null){89 return null;90 }91 92 let temp = this._start;93 do{94 if(temp.getName() == name){95 return temp;96 }97 temp = temp.next;98 } while (temp != this._start);99 return null;100 }...

Full Screen

Full Screen

deque.js

Source:deque.js Github

copy

Full Screen

1class Deque {2 constructor() {3 this._start = null4 this._end = null5 this._size = 06 }7 get size() {8 return this._size9 }10 push(el) {11 if (this._start === null) {12 const newNode = new Node(el, null, null)13 this._start = newNode14 this._end = newNode15 } else {16 const newNode = new Node(el, this._end, null)17 this._end.next = newNode18 this._end = newNode19 }20 this._size++21 }22 pop() {23 if (this._end === null) {24 return null25 }26 const removeElem = this._end27 this._end = removeElem.prev28 if (this._end === null) {29 this._start = null30 } else {31 this._end.next = null32 }33 this._size--34 return removeElem.val35 }36 unshift(el) {37 if (this._start === null) {38 const newNode = new Node(el, null, null)39 this._start = newNode40 this._end = newNode41 } else {42 const newNode = new Node(el, null, this._start)43 this._start.prev = newNode44 this._start = newNode45 }46 this._size++47 }48 shift() {49 if (this._start === null) {50 return null51 }52 const removeElem = this._start53 this._start = removeElem.next54 if (this._start === null) {55 this._end = null56 } else {57 this._start.prev = null58 }59 this._size--60 return removeElem.val61 }62 forEach(fn) {63 if (this._start === null) {64 return65 }66 let currentElem = this._start67 while (currentElem !== null) {68 fn(currentElem.val)69 currentElem = currentElem.next70 }71 }72 toArray() {73 if (this._start === null) {74 return []75 }76 let current = this._start77 let index = 078 const result = Array(this._size)79 while (current) {80 result[index] = current.val81 current = current.next82 index++83 }84 return result85 }86}87class Node {88 constructor(val, prev, next) {89 this.val = val90 this.prev = prev91 this.next = next92 }93}...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright._start({headless: false});4 const context = await browser.newContext();5 const page = await context.newPage();6 await page.screenshot({path: 'example.png'});7 await browser.close();8})();9const playwright = require('playwright');10(async () => {11 const browser = await playwright._start({headless: false});12 const context = await browser.newContext();13 const page = await context.newPage();14 await page.screenshot({path: 'example.png'});15 await browser.close();16})();17const playwright = require('playwright');18(async () => {19 const browser = await playwright._start({headless: false});20 const context = await browser.newContext();21 const page = await context.newPage();22 await page.screenshot({path: 'example.png'});23 await browser.close();24})();25const playwright = require('playwright');26(async () => {27 const browser = await playwright._start({headless: false});28 const context = await browser.newContext();

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium.launch({ headless: false });4 const page = await browser.newPage();5 await page.screenshot({ path: 'example.png' });6 await browser.close();7})();8const playwright = require('playwright');9(async () => {10 const browser = await playwright.chromium.launch({ headless: false });11 const page = await browser.newPage();12 await page.screenshot({ path: 'example.png' });13 await browser.close();14})();15const playwright = require('playwright');16(async () => {17 const browser = await playwright.chromium.launch({ headless: false });18 const page = await browser.newPage();19 await page.screenshot({ path: 'example.png' });20 await browser.close();21})();22const playwright = require('playwright');23(async () => {24 const browser = await playwright.chromium.launch({ headless: false });25 const page = await browser.newPage();26 await page.screenshot({ path: 'example.png' });27 await browser.close();28})();29const playwright = require('playwright');30(async () => {31 const browser = await playwright.chromium.launch({ headless: false });32 const page = await browser.newPage();33 await page.screenshot({ path: 'example.png' });34 await browser.close();35})();36const playwright = require('playwright');37(async () => {38 const browser = await playwright.chromium.launch({ headless: false });39 const page = await browser.newPage();40 await page.screenshot({ path: 'example.png' });41 await browser.close();42})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { PlaywrightInternal } = require('playwright-core/lib/server/playwright.js');2const playwright = new PlaywrightInternal();3(async () => {4 await playwright._start();5 const browser = await playwright.chromium.launch({6 });7 const context = await browser.newContext();8 const page = await context.newPage();9 await page.screenshot({ path: 'google.png' });10 await browser.close();11 await playwright._stop();12})();13const { PlaywrightInternal } = require('playwright-core/lib/server/playwright.js');14const playwright = new PlaywrightInternal();15(async () => {16 await playwright._start();17 const browser = await playwright.chromium.launch({18 });19 const context = await browser.newContext();20 const page = await context.newPage();21 await page.screenshot({ path: 'google.png' });22 await browser.close();23 await playwright._stop();24})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright.chromium._start({4 });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: 'example.png' });8 await browser.close();9})();10 const file = document.getElementById('file');11 file.addEventListener('change', (event) => {12 const reader = new FileReader();13 reader.onload = (event) => {14 console.log(event.target.result);15 };16 reader.readAsText(event.target.files[0]);17 });18@aslushnikov, I am not able to reproduce this issue using the latest version of Playwright (1.15.0). Can you please confirm if this issue is fixed in the latest version of Playwright?

Full Screen

Using AI Code Generation

copy

Full Screen

1const { _start } = require('playwright/lib/server/browserType');2const { chromium } = require('playwright');3(async () => {4 const browserServer = await _start(chromium, {}, false);5 const wsEndpoint = browserServer.wsEndpoint();6 console.log(wsEndpoint);7 const browser = await chromium.connect({ wsEndpoint });8 const context = await browser.newContext();9 const page = await context.newPage();10 await page.screenshot({ path: 'example.png' });11 await browser.close();12})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const { Playwright } = require('playwright');2const { chromium } = require('playwright');3(async () => {4 const browserServer = await chromium._start({5 });6 const browser = await browserServer.connect();7 const context = await browser.newContext();8 const page = await context.newPage();9 await page.screenshot({ path: 'example.png' });10 await browser.close();11})();12 at CDPSession.send (/home/ashish/Downloads/playwright-1.0.0-alpha.0/lib/cjs/pw-run.js:1:1320)13 at CDPSession.send (/home/ashish/Downloads/playwright-1.0.0-alpha.0/lib/cjs/pw-run.js:1:1320)14 at CDPSession.send (/home/ashish/Downloads/playwright-1.0.0-alpha.0/lib/cjs/pw-run.js:1:1320)15 at CDPSession.send (/home/ashish/Downloads/playwright-1.0.0-alpha.0/lib/cjs/pw-run.js:1:1320)16 at CDPSession.send (/home/ashish/Downloads/playwright-1.0.0-alpha.0/lib/cjs/pw-run.js:1:1320)17 at CDPSession.send (/home/ashish/Downloads/playwright-1.0.0-alpha.0/lib/cjs/pw-run.js:1:1320)18 at CDPSession.send (/home/ashish/Downloads/playwright-1.0.0-alpha.0/lib/cjs/pw-run.js:1:1320)19 at CDPSession.send (/home/ashish/Downloads/playwright-1.0.0-alpha.0/lib/cjs/pw-run.js:1:1320)20 at CDPSession.send (/home/ashish/Downloads/playwright-1.0.0-alpha.0/lib/cjs/pw-run.js:1:1320)21 at CDPSession.send (/home/ashish/Downloads/playwright-1.0.0-alpha.0/lib/cjs/p

Full Screen

Using AI Code Generation

copy

Full Screen

1const { _start } = require('playwright');2const browser = await _start('chromium');3const page = await browser.newPage();4await page.screenshot({ path: 'example.png' });5await browser.close();6const { _launch } = require('playwright');7const browser = await _launch('chromium');8const page = await browser.newPage();9await page.screenshot({ path: 'example.png' });10await browser.close();11const { _launchServer } = require('playwright');12const server = await _launchServer('chromium');13const browser = await server._launch();14const page = await browser.newPage();15await page.screenshot({ path: 'example.png' });16await browser.close();17await server.close();18const { _launchPersistent } = require('playwright');19const browser = await _launchPersistent('chromium');20const page = await browser.newPage();21await page.screenshot({ path: 'example.png' });22await browser.close();23const { _launchPersistentServer } = require('playwright');24const server = await _launchPersistentServer('chromium');25const browser = await server._launch();26const page = await browser.newPage();27await page.screenshot({ path: 'example.png' });28await browser.close();29await server.close();30const { _launchPersistentContext } = require('playwright');31const context = await _launchPersistentContext('chromium');32const page = await context.newPage();

Full Screen

Using AI Code Generation

copy

Full Screen

1const playwright = require('playwright');2(async () => {3 const browser = await playwright._start({4 });5 const context = await browser.newContext();6 const page = await context.newPage();7 await page.screenshot({ path: `example.png` });8 await browser.close();9})();10#### playwright.executablePath()11#### playwright.launch([options])12#### playwright.connect([options])13#### playwright._start([options])14#### browser.newContext([options])15#### browser.contexts()16#### browser.isConnected()

Full Screen

Playwright tutorial

LambdaTest’s Playwright tutorial will give you a broader idea about the Playwright automation framework, its unique features, and use cases with examples to exceed your understanding of Playwright testing. This tutorial will give A to Z guidance, from installing the Playwright framework to some best practices and advanced concepts.

Chapters:

  1. What is Playwright : Playwright is comparatively new but has gained good popularity. Get to know some history of the Playwright with some interesting facts connected with it.
  2. How To Install Playwright : Learn in detail about what basic configuration and dependencies are required for installing Playwright and run a test. Get a step-by-step direction for installing the Playwright automation framework.
  3. Playwright Futuristic Features: Launched in 2020, Playwright gained huge popularity quickly because of some obliging features such as Playwright Test Generator and Inspector, Playwright Reporter, Playwright auto-waiting mechanism and etc. Read up on those features to master Playwright testing.
  4. What is Component Testing: Component testing in Playwright is a unique feature that allows a tester to test a single component of a web application without integrating them with other elements. Learn how to perform Component testing on the Playwright automation framework.
  5. Inputs And Buttons In Playwright: Every website has Input boxes and buttons; learn about testing inputs and buttons with different scenarios and examples.
  6. Functions and Selectors in Playwright: Learn how to launch the Chromium browser with Playwright. Also, gain a better understanding of some important functions like “BrowserContext,” which allows you to run multiple browser sessions, and “newPage” which interacts with a page.
  7. Handling Alerts and Dropdowns in Playwright : Playwright interact with different types of alerts and pop-ups, such as simple, confirmation, and prompt, and different types of dropdowns, such as single selector and multi-selector get your hands-on with handling alerts and dropdown in Playright testing.
  8. Playwright vs Puppeteer: Get to know about the difference between two testing frameworks and how they are different than one another, which browsers they support, and what features they provide.
  9. Run Playwright Tests on LambdaTest: Playwright testing with LambdaTest leverages test performance to the utmost. You can run multiple Playwright tests in Parallel with the LammbdaTest test cloud. Get a step-by-step guide to run your Playwright test on the LambdaTest platform.
  10. Playwright Python Tutorial: Playwright automation framework support all major languages such as Python, JavaScript, TypeScript, .NET and etc. However, there are various advantages to Python end-to-end testing with Playwright because of its versatile utility. Get the hang of Playwright python testing with this chapter.
  11. Playwright End To End Testing Tutorial: Get your hands on with Playwright end-to-end testing and learn to use some exciting features such as TraceViewer, Debugging, Networking, Component testing, Visual testing, and many more.
  12. Playwright Video Tutorial: Watch the video tutorials on Playwright testing from experts and get a consecutive in-depth explanation of Playwright automation testing.

Run Playwright Internal 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