Best JavaScript code snippet using puppeteer
GwxPhotoCutter_1126_d.js
Source:GwxPhotoCutter_1126_d.js
...77 //getComputedStyle("å
ç´ ", "伪类"ænull);78 //è·åå½åå
ç´ æææç»ä½¿ç¨çCSSå±æ§å¼ãè¿åçæ¯ä¸ä¸ªCSSæ ·å¼å£°æ对象()ï¼åªè¯»ã79 width = window.getComputedStyle(obj, null)[[type]];80 }81 width = self.parseIntValue(width);//æ°å¼å82 return width;83 };84 //å建æå¤å±div85 self.createOuter = function () {86 //å建ä¸ä¸ªâDIVâ对象87 var outer = self.outer = document.createElement("div");88 //è¿ä¸ªâDIVâç ç±»åï¼89 outer.className = "gwx_photo_cutter_outer";90 outer.style.width = self.maxWidth + "px";91 outer.style.height = self.maxHeight + "px";92 //å¨self.renderæ«å°¾æ·»å è¿ä¸ªâDIVâ对象93 self.render.appendChild(outer); 94 };95 //å建âå¾çé¢è§â96 self.createPreviews = function () {97 //å°config["previews"] èµå¼ç»panels98 var panels = config["previews"];99 for (var i = 0, len = panels.length; i < len; i++) {100 //å°config["previews"]ä¸çpreviewséåç» preview101 var preview = panels[i];102 //éè¿idä¾æ¬¡è·å¾ preview103 preview = document.getElementById(preview);104 //设置 é¢è§åºç 尺寸ï¼ï¼å¯è§åºåç宽度ï¼æï¼100ï¼105 preview.viewSize = preview.clientWidth || 100;106 self.previews[i] = preview;107 }108 };109 //å建ä¸ä¸ª é®ç½©å±ï¼Maskï¼110 self.createMask = function () {111 //åå§åmaskï¼å
容åºåï¼ä¸ºä¸ä¸ª æ°å»ºçâDIVâ112 var mask = self.mask = document.createElement("div");113 //åå«å建maskï¼å
容åºåï¼çä¸ãä¸ãå·¦ãå³çå个é»è²é®ç½©âDIVâ114 var mask_north = mask.mask_north = document.createElement("div");115 var mask_south = mask.mask_south = document.createElement("div");116 var mask_west = mask.mask_west = document.createElement("div");117 var mask_east = mask.mask_east = document.createElement("div");118 self.outer.insertBefore(mask, self.outer.firstChild);//æ¾å°photoåé¢119 //maskï¼å
容åºåï¼çä¸ãä¸ãå·¦ãå³åå«æ·»å 以ä¸å个é»è²é®ç½©âDIVâ120 mask.appendChild(mask_north);121 mask.appendChild(mask_west);122 mask.appendChild(mask_east);123 mask.appendChild(mask_south);124 //ä¸ãä¸ãå·¦ãå³åå«ä¸ºä»¥ä¸å个é»è²é®ç½©âDIVâæ·»å ç±»å125 mask.className = "gwx_photo_cutter_mask";126 mask_north.className = "gwx_photo_cutter_mask_sub gwx_photo_cutter_mask_north";127 mask_south.className = "gwx_photo_cutter_mask_sub gwx_photo_cutter_mask_south";128 mask_west.className = "gwx_photo_cutter_mask_sub";129 mask_east.className = "gwx_photo_cutter_mask_sub gwx_photo_cutter_mask_east";130 //onselectstart(éä¸å¨ä½åå¼å§ï¼å°æªå®è´¨æ§è¢«éä¸)131 mask.onselectstart = function () {//ç¦æ¢ç¹å»éä¸132 return false;133 };134 };135 //å建ä¸å¿çâDIVâ136 self.createCenter = function () {137 //åå§åcenter为ä¸ä¸ªæ°å»ºçâDIVâ138 var center = self.center = document.createElement("div");139 //åå§åfake为ä¸ä¸ªæ°å»ºçâDIVâ140 var fake = self.fake = document.createElement("div");141 fake.className = "gwx_photo_cutter_fake";142 //å¨maskçæ«å°¾èç¹ï¼æ·»å centerè¿ä¸ªDIV143 self.mask.appendChild(center);144 //å¨centerçæ«å°¾èç¹ï¼æ·»å fakeè¿ä¸ªDIV145 center.appendChild(fake);146 for (var i = 0; i < 8; i++) {147 //ä¾æ¬¡å建8 个blockï¼divï¼148 var block = self["block_" + i] = document.createElement("div");149 block.className = "gwx_photo_cutter_block gwx_photo_cutter_block_" + i;150 //å¨centeråèç¹æ«å°¾ä¾æ¬¡æ·»å è¿8个blockï¼divï¼151 center.appendChild(block);152 //mode153 block.mode = i;154 }155 //åå«è®¾ç½®centerãblockçcsså±æ§156 center.className = "gwx_photo_cutter_center";157 self.centerOffset = self.getStyleValue(center, "borderLeftWidth") * 2;//两个ä¸å¿è¾¹æ¡158 self.blockOffset = self["block_1"].offsetWidth;//ä¸ä¸ªblockç宽度159 /* var l =0;160 var t=0;*/161 //ä¾åï¼162 // <input type= "text" id="t1" onclick="aaa(event)">163 164 // function aaa(e){165 // e = e || window.event;166 // var tar = e.target || e.srcElement;167 // alert(tar.id);//触åonclickäºä»¶çå
ç´ å³è¿ä¸ªtextæ¡ çid168 // }169 center.onmousedown = function (e) {//z注åäºä»¶170 //åå§åe171 e = e || window.event;172 //e.targetï¼FFï¼åe.srcElement(IE)æ¯è§¦åeventäºä»¶çå
ç´ å¯¹è±¡173 var el = e.target || e.srcElement;174 //pageXæé¼ æ å¨é¡µé¢ä¸çä½ç½®ï¼ä»¥é¡µé¢å·¦ä¾§ä¸ºåèç¹175 //clientXæå¯è§åºåå
离左侧çè·ç¦»ï¼ä»¥æ»å¨æ¡æ»å¨å°çä½ç½®ä¸ºåèç¹ã176 var x = e.pageX || (e.clientX + self.docOffsetX);177 var y = e.pageY || (e.clientY + self.docOffsetY);178 //179 center.tag = true;180 //181 center.ox = x;182 center.oy = y;183 /*l =self.outer.offsetLeft+self.render.offsetLeft;184 t =self.outer.offsetTop+self.render.offsetTop;*/185 186 //el.className 为对象添å ç±»å187 //el.className.indexOf("block"):å
¼å®¹ieéè¿ç±»åæ¥æ¾çé®é¢188 if (el.className.indexOf("block") > -1) {189 center.mode = el.mode;190 self.fake.style.cursor = self.cursorMap[center.mode];//ææ¶ä¿®æ¹centerä¸é¢çé¼ æ ææ191 } else {192 center.mode = "m";193 }194 document.body.style.cursor = self.cursorMap[center.mode];//ææ¶ä¿®æ¹documentä¸é¢çé¼ æ ææ195 document.onselectstart = function () {196 return false;197 };198 document.onmouseup = function () {199 center.tag = false;200 self.fake.style.cursor = self.cursorMap["m"];//è¿åä¿®æ¹documentä¸é¢çé¼ æ ææ201 document.body.style.cursor = "";//self.docCursor;//è¿åcenterä¸é¢çé¼ æ ææ202 document.onselectstart = self.docMosSel;203 document.onmousemove = self.docMosMove;204 document.onmouseup = self.docMosUp;205 };206 document.onmousemove = function (e) {207 if (center.tag) {208 e = e || window.event;209 var x = e.pageX || (e.clientX + self.docOffsetX);210 var y = e.pageY || (e.clientY + self.docOffsetY);211 /*x=x<l?(l):x;212 y=y<t?(t):y;*/213 // self.pos=x+" "+y+" "+l+" "+t;214 var dx = x - center.ox;215 var dy = y - center.oy;216 center.ox = x;217 center.oy = y;218 self.resizeHandler(center.mode, dx, dy);219 }220 };221 };222 };223 //224 self.resizeHandler = function (mode, dx, dy) {225 //226 var mw = self.photoWidth;227 var mh = self.photoHeight;228 //style.left:左边è·ãæ¯è¯»åçï¼offsetLeftæ¯åªè¯»ç229 var ol = self.parseIntValue(self.center.style.left);230 var ot = self.parseIntValue(self.center.style.top);231 var newX = ol;232 var newY = ot;233 var isIn = true;234 var handlers = {235 mode_m: function () {//移å¨236 newX = ol + dx;237 newY = ot + dy;238 dx = dy = 0;239 if (newX < 0 || newX > (mw - self.centerWidth)) {240 newX = (newX < 0) ? 0 : (mw - self.centerWidth);241 }242 if (newY < 0 || newY > (mh - self.centerHeight)) {243 newY = (newY < 0) ? 0 : (mh - self.centerHeight);244 }245 },246 mode_0: function () {//西åæ¹å移å¨247 //dx = dy = self.parseIntValue((dy + dx) /2);248 dy = dx;249 newX = ol + dx;250 newY = ot + dy;251 },252 mode_1: function () {//åé¨ç§»å¨253 dx = dy = self.parseIntValue(dy / 2) * 2;254 newX = ol + dx / 2;255 newY = ot + dy;256 },257 mode_2: function () {//ä¸å移å¨258 dx = dy = -dx;// -self.parseIntValue((dx - dy) / 2);259 newY = ot + dy;260 },261 mode_3: function () {//西é¨ç§»å¨262 dx = dy = (self.parseIntValue(dx / 2) * 2);263 newX = ol + dx;264 newY = ot + dx / 2;265 },266 mode_4: function () {//ä¸é¨ç§»å¨267 dx = dy = -self.parseIntValue(dx / 2) * 2;268 newY = ot + dy / 2;269 },270 mode_5: function () {//西å移å¨271 dy = dx;//= self.parseIntValue(dx);272 newX = ol + dx;273 },274 mode_6: function () {//åé¨ç§»å¨275 dx = dy = -self.parseIntValue(dy / 2) * 2;276 newX = ol + dx / 2;277 },278 mode_7: function () {//ä¸å移å¨279 dx = dy = -dx;//-self.parseIntValue((dx + dy) / 2);280 }281 };282 handlers["mode_" + mode]();//æ ¹æ®modeè°ç¨ç¸åºäºä»¶283 if (mode != "m") {284 isIn = !(newX < 0 || newY < 0);//å¤æå·¦ä¸è§è¶ç285 isIn = !isIn ? isIn : newX < (mw - self.centerWidth + dx + 1);//å¤æå³é¨è¶ç286 isIn = !isIn ? isIn : newY < (mh - self.centerHeight + dy + 1);//å¤æåºé¨è¶ç287 isIn = !isIn ? isIn : (!((self.centerWidth - dx) < self.minCenterSize && dx > 0));//å¤æcenteræå°æé288 }289 if (isIn) {//å¦æå·²ç»è¶çï¼åæ¢ç§»å¨ï¼moveé¤å¤290 self.centerWidth -= dx;291 self.centerHeight -= dy;292 self.freshMask(newX, newY);293 }294 };295 //æ¾ç¤ºç
§ç296 self.show = function () {297 var photo = self.photo = document.createElement("img");298 photo.className = "gwx_photo_cutter_photo";299 photo.onload = self.loadPhotoSuccessed;300 photo.onerror = self.loadPhotoFailed;301 setTimeout(function () {302 photo.src = config["photo"];303 }, 200);304 self.outer.appendChild(photo);305 };306 //é¢è§åº çæ¾ç¤º307 self.showPreview = function () {308 for (var i = 0, len = self.previews.length; i < len; i++) {309 var previewPanel = self.previews[i];310 var previewPhoto = document.createElement("img");311 previewPanel.style.overflow = "hidden";//éèé¢è§åºdivçæ»å¨æ¡312 previewPhoto.src = config["photo"];313 previewPanel.innerHTML = "";314 previewPanel.appendChild(previewPhoto);315 }316 };317 //æ示è¯âloading...â318 self.showTip = function (content) {319 if (!self.tipMain) {320 var tipMain = self.tipMain = document.createElement("div");321 var createTip4Preview = function () {322 var tipPreview = document.createElement("div");323 tipPreview.className = "gwx_photo_cutter_tip";324 tipPreview.innerHTML = "loading...";325 return tipPreview;326 };327 tipMain.className = "gwx_photo_cutter_tip";328 tipMain.style.lineHeight = self.maxHeight * 4 / 5 + "px";329 self.outer.appendChild(tipMain);330 }331 self.tipMain.innerHTML = content || "loading...";332 /* for (var i = 0, len = self.previews.length; i < len; i++) {333 var previewPanel = self.previews[i];334 var tip = createTip4Preview();335 tip.style.lineHeight = previewPanel.viewSize * 4 / 5 + "px";336 previewPanel.appendChild(tip);337 }*/338 };339 //æ°å¾ççä½ç½®å¸å±340 self.freshMask = function (newX, newY) {341 var mask = self.mask;342 mask.mask_north.style.height = mask.mask_west.style.top = mask.mask_east.style.top = newY + "px";343 mask.mask_west.style.width = newX + "px";344 mask.mask_east.style.width = (self.photoWidth - self.centerWidth - newX) + "px";345 mask.mask_south.style.height = (self.photoHeight - self.centerHeight - newY) + "px";346 mask.mask_west.style.height = mask.mask_east.style.height = self.centerHeight + "px";347 self.freshCenter(newX, newY);348 if (self["showStatus"]) {//å·æ°ç¶æä¿¡æ¯349 self["showStatus"](self.getStatus());350 }351 self.freshPreview();352 };353 //æ°å¾ççä¸å¿ä½ç½®354 self.freshCenter = function (newX, newY) {355 var center = self.center;356 var centerSize = self.centerHeight - self.centerOffset;357 var blockPos = (centerSize - self.blockOffset) / 2;358 center.style.left = newX + "px";359 center.style.top = newY + "px";360 center.style.width = (self.centerWidth - self.centerOffset) + "px";361 center.style.height = (self.centerHeight - self.centerOffset) + "px";362 self["block_1"].style.left = self["block_4"].style.top = self["block_6"].style.left = self["block_3"].style.top = blockPos + "px";363 };364 //æ°å¾ç çé¢è§365 self.freshPreview = function () {366 var cLeft = self.parseIntValue(self.center.style.left);367 var cTop = self.parseIntValue(self.center.style.top);368 for (var i = 0, len = self.previews.length; i < len; i++) {369 var previewPanel = self.previews[i];370 var previewPhoto = previewPanel.getElementsByTagName("img")[0];371 var scale = (previewPanel.viewSize / self.centerWidth);372 var npw = scale * self.photoWidth;373 var nph = scale * self.photoHeight;374 previewPhoto.width = npw;375 previewPhoto.height = nph;376 previewPhoto.style.marginLeft = -(cLeft * scale) + "px";377 previewPhoto.style.marginTop = -(cTop * scale) + "px";378 }379 };380 //å 载失败381 self.loadPhotoFailed = function () {382 self.tipMain.innerHTML = "Load failed!";383 /*for (var i = 0, len = self.previews.length; i < len; i++) {384 self.previews[i].firstChild.innerHTML = "Load failed!";385 }*/386 this["onerror"] = null;387 };388 //å è½½æå389 self.loadPhotoSuccessed = function () {390 var photo = this;391 var width = self.realPhotoWidth = photo.width;392 var height = self.realPhotoHeight = photo.height;393 //å¦æå¾çæ¾å è½½åºæ¥äº394 if (self.outer) {395 //self.outer.removeChild(self.tipMain);396 self.tipMain.style.display = "none";397 }398 //å建边æ¡åºãä¸å¿å¾çåºãå¾çé¢è§399 self.createMask();400 self.createCenter();401 self.showPreview();402 //è·åå¾çåéç宽é«403 if (width > height) {404 photo.width = self.maxWidth;405 } else {406 photo.height = self.maxHeight;407 }408 //设置ç¸å
³ç宽é«409 self.photoWidth = photo.width;410 self.photoHeight = photo.height;411 self.outer.style.width = self.photoWidth + "px";412 self.centerWidth = self.centerHeight = self.parseIntValue(0.8 * Math.min(photo.width, photo.height));413 self.centerX = self.parseIntValue((self.photoWidth - self.centerWidth) / 2);414 self.centerY = self.parseIntValue((self.photoHeight - self.centerWidth) / 2);415 self.mask.style.width = self.photoWidth + "px";416 self.mask.style.height = self.photoHeight + "px";417 //418 photo.className = photo.className.replace(/\s*gwx_photo_cutter_photo/g, "");419 //420 self.freshMask(self.centerX, self.centerY);421 //422 //offsetXï¼IEç¹æ,é¼ æ ç¸æ¯è¾äºè§¦åäºä»¶çå
ç´ çä½ç½®423 //scrollTop代表页é¢å©ç¨æ»å¨æ¡æ»å¨å°ä¸æ¹æ¶ï¼éèå¨æ»å¨æ¡ä¸æ¹ç页é¢çé«åº¦ï¼424 //scrollLeft代表页é¢å©ç¨æ»å¨æ¡æ»å¨å°å³ä¾§æ¶ï¼éèå¨æ»å¨æ¡å·¦ä¾§ç页é¢ç宽度 425 //scrollLeft() æ¹æ³è¿åæ设置å¹é
å
ç´ çæ»å¨æ¡çæ°´å¹³ä½ç½®ã426 self.docOffsetX = document.body.scrollLeft - document.body.clientLeft;427 self.docOffsetY = document.body.scrollTop - document.body.clientTop;428 photo["onload"] = null;429 };430 //设置å¾ççè·¯å¾431 self.setPhoto = function (src) {432 config["photo"] = src;433 };434 //è·åå½åç¶æä¸ç宽é«ãè¾¹è·435 self.getStatus = function () {436 var scale = self.realPhotoWidth / self.photoWidth;437 var fw = self.centerWidth;438 var fh = self.centerHeight;439 var fx = self.parseIntValue(self.center.style.left);440 var fy = self.parseIntValue(self.center.style.top);441 var w = self.parseIntValue(fw * scale);442 var h = self.parseIntValue(fh * scale);443 var x = self.parseIntValue(fx * scale);444 var y = self.parseIntValue(fy * scale);445 return {446 w: w,447 h: h,448 x: x,449 y: y,450 fw: fw,451 fh: fh,452 fx: fx,453 fy: fy,454 rw: self.realPhotoWidth,455 rh: self.realPhotoHeight456 };457 };458 //...
EmulatedDevices.js
Source:EmulatedDevices.js
...71 * @param {*} object72 * @param {string} key73 * @return {number}74 */75 function parseIntValue(object, key) {76 const value = /** @type {number} */ (parseValue(object, key, 'number'));77 if (value !== Math.abs(value)) {78 throw new Error('Emulated device value \'' + key + '\' must be integer');79 }80 return value;81 }82 /**83 * @param {*} json84 * @return {!UI.Geometry.Insets}85 */86 function parseInsets(json) {87 return new UI.Geometry.Insets(88 parseIntValue(json, 'left'), parseIntValue(json, 'top'), parseIntValue(json, 'right'),89 parseIntValue(json, 'bottom'));90 }91 /**92 * @param {*} json93 * @return {!SDK.OverlayModel.HighlightColor}94 */95 function parseRGBA(json) {96 const result = {};97 result.r = parseIntValue(json, 'r');98 if (result.r < 0 || result.r > 255) {99 throw new Error('color has wrong r value: ' + result.r);100 }101 result.g = parseIntValue(json, 'g');102 if (result.g < 0 || result.g > 255) {103 throw new Error('color has wrong g value: ' + result.g);104 }105 result.b = parseIntValue(json, 'b');106 if (result.b < 0 || result.b > 255) {107 throw new Error('color has wrong b value: ' + result.b);108 }109 result.a = /** @type {number} */ (parseValue(json, 'a', 'number'));110 if (result.a < 0 || result.a > 1) {111 throw new Error('color has wrong a value: ' + result.a);112 }113 return /** @type {!SDK.OverlayModel.HighlightColor} */ (result);114 }115 /**116 * @param {*} json117 * @return {!SDK.OverlayModel.Hinge}118 */119 function parseHinge(json) {120 const result = {};121 result.width = parseIntValue(json, 'width');122 if (result.width < 0 || result.width > MaxDeviceSize) {123 throw new Error('Emulated device has wrong hinge width: ' + result.width);124 }125 result.height = parseIntValue(json, 'height');126 if (result.height < 0 || result.height > MaxDeviceSize) {127 throw new Error('Emulated device has wrong hinge height: ' + result.height);128 }129 result.x = parseIntValue(json, 'x');130 if (result.x < 0 || result.x > MaxDeviceSize) {131 throw new Error('Emulated device has wrong x offset: ' + result.height);132 }133 result.y = parseIntValue(json, 'y');134 if (result.x < 0 || result.x > MaxDeviceSize) {135 throw new Error('Emulated device has wrong y offset: ' + result.height);136 }137 if (json['contentColor']) {138 result.contentColor = parseRGBA(json['contentColor']);139 }140 if (json['outlineColor']) {141 result.outlineColor = parseRGBA(json['outlineColor']);142 }143 return /** @type {!SDK.OverlayModel.Hinge} */ (result);144 }145 /**146 * @param {*} json147 * @return {!Orientation}148 */149 function parseOrientation(json) {150 const result = {};151 result.width = parseIntValue(json, 'width');152 if (result.width < 0 || result.width > MaxDeviceSize || result.width < MinDeviceSize) {153 throw new Error('Emulated device has wrong width: ' + result.width);154 }155 result.height = parseIntValue(json, 'height');156 if (result.height < 0 || result.height > MaxDeviceSize || result.height < MinDeviceSize) {157 throw new Error('Emulated device has wrong height: ' + result.height);158 }159 const outlineInsets = parseValue(json['outline'], 'insets', 'object', null);160 if (outlineInsets) {161 result.outlineInsets = parseInsets(outlineInsets);162 if (result.outlineInsets.left < 0 || result.outlineInsets.top < 0) {163 throw new Error('Emulated device has wrong outline insets');164 }165 result.outlineImage = /** @type {string} */ (parseValue(json['outline'], 'image', 'string'));166 }167 if (json['hinge']) {168 result.hinge = parseHinge(parseValue(json, 'hinge', 'object', undefined));169 }...
SummaryItem.js
Source:SummaryItem.js
...14 this.DepositGap = this.getIntValue(msmeData[19]);15 this.CreditGap = this.getIntValue(msmeData[20]);16 this.A2F = this.parseFloatValue(msmeData[10]);17 this.A2F += (this.A2F != "" ? '%' : '');18 this.Checking = this.parseIntValue(msmeData[6]);19 this.Overdratf = this.parseIntValue(msmeData[7]);20 this.Loan = this.parseIntValue(msmeData[8]);21 this.Credit = this.parseIntValue(msmeData[9]);22 this.DoesNotNeedCredit = this.parseIntValue(msmeData[11]);23 this.Unserved = this.parseIntValue(msmeData[12]);24 this.Underserved = this.parseIntValue(msmeData[13]);25 this.Wellserved = this.parseIntValue(msmeData[14]);26 this.SourcePrivate = this.parseIntValue(msmeData[15]);27 this.SourceGov = this.parseIntValue(msmeData[16]);28 this.SourceNonBank = this.parseIntValue(msmeData[17]);29 this.SourceOther = this.parseIntValue(msmeData[18]);30 this.Gdp2005 = this.getIntValue(this.indData[3]);31 this.GdpCurrent = this.getIntValue(this.indData[4]);32 this.Atms = this.parseFloatValue(this.indData[5]);33 this.BankBranches = this.parseFloatValue(this.indData[6]);34 this.PosTerminals = this.parseFloatValue(this.indData[7]);35 this.DomesticCredit = this.parseFloatValue(this.indData[8]);36 this.LendingIr = this.parseFloatValue(this.indData[9]);37 this.Population = this.getIntValue(this.indData[10]);38 this.PopulationAges = this.parseFloatValue(this.indData[29]);39 this.MobileSubscriptions = this.parseFloatValue(this.indData[12]);40 this.LaborForce = this.getIntValue(this.indData[13]);41 this.EmploymentRatio = this.parseFloatValue(this.indData[14]);42 this.PovertyRatio = this.parseFloatValue(this.indData[15]);43 this.LegalRightsStrength = this.parseFloatValue(this.indData[16]);44 this.CreditDepth = this.parseFloatValue(this.indData[17]);45 this.EaseOfBusiness = this.parseFloatValue(this.indData[18]);46 this.LiteracyRate = this.parseFloatValue(this.indData[19]);47 this.DepositIr = this.parseFloatValue(this.indData[20]);48 this.Unemployment = this.parseFloatValue(this.indData[21]);49 this.IrSpread = this.parseFloatValue(this.indData[22]);50 this.PrivateCreditCoverage = this.parseFloatValue(this.indData[23]);51 this.PublicCreditCoverage = this.parseFloatValue(this.indData[24]);52 this.LaborMale = this.parseFloatValue(this.indData[25]);53 this.LaborFemale = this.parseFloatValue(this.indData[26]);54 this.UrbanPopulation = this.parseFloatValue(this.indData[27]);55 break;56 case 'region':57 this.Name = msmeData[0];58 this.EnterprisesCount = this.getIntValue(msmeData[5]);59 this.DepositGap = this.getIntValue(msmeData[25]);60 this.CreditGap = this.getIntValue(msmeData[23]);61 this.A2F = this.parseFloatValue(msmeData[10]);62 this.A2F += (this.A2F != "" ? '%' : '');63 this.Checking = this.parseIntValue(msmeData[6]);64 this.Overdratf = this.parseIntValue(msmeData[7]);65 this.Loan = this.parseIntValue(msmeData[8]);66 this.Credit = this.parseIntValue(msmeData[9]);67 this.DoesNotNeedCredit = this.parseIntValue(msmeData[11]);68 this.Unserved = this.parseIntValue(msmeData[12]);69 this.Underserved = this.parseIntValue(msmeData[13]);70 this.Wellserved = this.parseIntValue(msmeData[14]);71 this.SourcePrivate = this.parseIntValue(msmeData[18]);72 this.SourceGov = this.parseIntValue(msmeData[19]);73 this.SourceNonBank = this.parseIntValue(msmeData[20]);74 this.SourceOther = this.parseIntValue(msmeData[21]);75 this.Gdp2005 = this.getIntValue(this.indData[0]);76 this.GdpCurrent = this.getIntValue(this.indData[1]);77 this.Atms = this.parseFloatValue(this.indData[2]);78 this.BankBranches = this.parseFloatValue(this.indData[3]);79 this.PosTerminals = this.parseFloatValue(this.indData[4]);80 this.DomesticCredit = this.parseFloatValue(this.indData[5]);81 this.LendingIr = this.parseFloatValue(this.indData[6]);82 this.Population = this.getIntValue(this.indData[7]);83 this.PopulationAges = this.parseFloatValue(this.indData[25]);84 this.MobileSubscriptions = this.parseFloatValue(this.indData[9]);85 this.LaborForce = this.getIntValue(this.indData[10]);86 this.EmploymentRatio = this.parseFloatValue(this.indData[11]);87 this.PovertyRatio = this.parseFloatValue(this.indData[12]);88 this.LegalRightsStrength = this.parseFloatValue(this.indData[13]);89 this.CreditDepth = this.parseFloatValue(this.indData[14]);90 this.EaseOfBusiness = this.parseFloatValue(this.indData[15]);91 this.LiteracyRate = this.parseFloatValue(this.indData[16]);92 this.DepositIr = this.parseFloatValue(this.indData[17]);93 this.Unemployment = this.parseFloatValue(this.indData[18]);94 this.IrSpread = this.parseFloatValue(this.indData[19]);95 this.PrivateCreditCoverage = this.parseFloatValue(this.indData[20]);96 this.PublicCreditCoverage = this.parseFloatValue(this.indData[21]);97 this.LaborMale = this.parseFloatValue(this.indData[22]);98 this.LaborFemale = this.parseFloatValue(this.indData[23]);99 this.UrbanPopulation = this.parseFloatValue(this.indData[24]);100 break;101 case 'development':102 this.Name = msmeData[0];103 this.EnterprisesCount = this.getIntValue(msmeData[1]);104 this.DepositGap = this.getIntValue(msmeData[16]);105 this.CreditGap = this.getIntValue(msmeData[15]);106 this.A2F = this.parseFloatValue(msmeData[2]);107 this.A2F += (this.A2F != "" ? '%' : '');108 this.Checking = this.parseIntValue(msmeData[3]);109 this.Overdratf = this.parseIntValue(msmeData[4]);110 this.Loan = this.parseIntValue(msmeData[5]);111 this.Credit = this.parseIntValue(msmeData[6]);112 this.DoesNotNeedCredit = this.parseIntValue(msmeData[7]);113 this.Unserved = this.parseIntValue(msmeData[8]);114 this.Underserved = this.parseIntValue(msmeData[9]);115 this.Wellserved = this.parseIntValue(msmeData[10]);116 this.SourcePrivate = this.parseIntValue(msmeData[11]);117 this.SourceGov = this.parseIntValue(msmeData[12]);118 this.SourceNonBank = this.parseIntValue(msmeData[13]);119 this.SourceOther = this.parseIntValue(msmeData[14]);120 this.Gdp2005 = this.getIntValue(this.indData[3]);121 this.GdpCurrent = this.getIntValue(this.indData[4]);122 this.Atms = this.parseFloatValue(this.indData[5]);123 this.BankBranches = this.parseFloatValue(this.indData[6]);124 this.PosTerminals = this.parseFloatValue(this.indData[7]);125 this.DomesticCredit = this.parseFloatValue(this.indData[8]);126 this.LendingIr = this.parseFloatValue(this.indData[9]);127 this.Population = this.getIntValue(this.indData[10]);128 this.PopulationAges = this.parseFloatValue(this.indData[11]);129 this.MobileSubscriptions = this.parseFloatValue(this.indData[12]);130 this.LaborForce = this.getIntValue(this.indData[13]);131 this.EmploymentRatio = this.parseFloatValue(this.indData[14]);132 this.PovertyRatio = this.parseFloatValue(this.indData[15]);133 this.LegalRightsStrength = this.parseFloatValue(this.indData[16]);...
gprs.js
Source:gprs.js
...40 for (i = 0; i < months.length; i++) {41 if (~s.indexOf(months[i])) {42 console.log('Found: ' + months[i]);43 a = s.split(months[i]);44 day = parseIntValue(a[0]);45 year = parseIntValue(a[1]);46 month = i > 9 ? i : ('0' + i);47 day = day > 9 ? day : ('0' + day);48 var res = parseInt(year) + '-' + month + '-' + parseInt(day);49 console.log(res);50 return res;51 }52 }53 return '';54}55/**56 * @param {String} s ÑÑÑока ÑенÑ, на Ð¼Ð¾Ð¼ÐµÐ½Ñ Ð½Ð°Ð¿Ð¸ÑÐ°Ð½Ð¸Ñ â3 691,19 â½57*/58window.parsePriceValue = function(s)59 {60 var allow = '0123456789-,.â', i, r = '', ch, 61 isPointAlready = 0,62 isMinusAlready = 0;63 s = String(s).trim();64 for (i = 0; i < s.length; i++) {65 ch = s.charAt(i);66 //console.log(ch);67 if (~allow.indexOf(ch)) {68 if (ch == ',') {69 ch = '.';70 }71 if (ch == '.') {72 if (!isPointAlready) {73 isPointAlready = 1;74 } else {75 continue;76 }77 }78 if (ch == 'â') {79 ch = '-';80 }81 if (ch == '-') {82 if (!isMinusAlready) {83 isMinusAlready = 1;84 } else {85 continue;86 }87 }88 r += ch;89 }90 }91 //console.log(r);92 return parseFloat(r);93 }94/**95 * @param {String} s ÑÑÑока даÑÑ, на Ð¼Ð¾Ð¼ÐµÐ½Ñ Ð½Ð°Ð¿Ð¸ÑÐ°Ð½Ð¸Ñ Ð¿ÑÐ¸Ð¼ÐµÑ 21 ноÑб. 2018 г.96*/97window.parseDateValue = function(s) {98 console.log('parseDateValue GOT ' + s);99 if (String(s).indexOf('â') != -1) {100 return '';101 }102 var months = ['nicapius', 'Ñнв.', 'ÑевÑ.', 'маÑ.', 'апÑ.', 'маÑ', 'иÑн.', 'иÑл.', 'авг.', 'ÑенÑ.', 'окÑ.', 'ноÑб.', ''], 103 i, j, a, day, month, year;104 for (i = 0; i < months.length; i++) {105 if (~s.indexOf(months[i])) {106 console.log('Found: ' + months[i]);107 a = s.split(months[i]);108 day = parseIntValue(a[0]);109 if (String(day).length > 2) {110 return '';111 }112 year = parseIntValue(a[1]);113 month = i > 9 ? i : ('0' + i);114 day = day > 9 ? day : ('0' + day);115 var res = parseInt(year) + '-' + month + '-' + parseInt(day);116 console.log(res);117 return res;118 }119 }120 return '';121}122/**123 * @param {String} вÑбиÑÐ°ÐµÑ ÑолÑко ÑелÑе ÑиÑла из ÑÑÑоки124*/125window.parseIntValue = function(s)126 {...
options.js
Source:options.js
...30 options = program31 .description('Download map tile images from OSM tile server')32 .version(pkgInfo.version)33 // Required options34 .option('-s, --start-zoom-level <n>', 'Zoom level start', parseIntValue('-s, --start-zoom-level <n>'))35 .option('-e, --end-zoom-level <n>', 'Zoom level end', parseIntValue('-e, --end-zoom-level <n>'))36 .option('-u, --url <url>', 'Tile server url')37 .option('-o, --output-dir <dir>', 'Output directory')38 // Optional options39 .option('-v, --verbose', 'Verbose mode, default is off')40 .option('-c, --check-tiles', 'Check if the expected tiles exist in output directory instead of downloading them')41 .option('-d, --delay <ms>', 'Delay in ms between downloads, default is 0', parseIntValue('-d, --delay <ms>'))42 .option('-m, --max-retries <num>', 'Maximum number of retries for download, default is 3', parseIntValue('-m, --max-retries <num>'))43 .option('-r, --retry-delay <ms>', 'Delay in ms between download retries, default is 2500', parseIntValue('-r, --retry-delay <ms>'))44 .option('-f, --force-overwrite', 'Force overwriting existing tiles (re-downloads all tiles), default is off')45 .option('-y, --yes', 'Answer yes to prompt confirming downloading of tiles, default is off')46 .parse(process.argv);47 // Set default options unless they were set48 program.verbose = program.verbose === true;49 program.checkTiles = program.checkTiles === true;50 program.forceOverwrite = program.forceOverwrite === true;51 program.yes = program.yes === true;52 program.delay = (_.isFinite(program.delay) && program.delay >= 0) ? program.delay : 0;53 program.maxRetries = (_.isFinite(program.maxRetries) && program.maxRetries >= 0) ? program.maxRetries : 3;54 program.retryDelay = (_.isFinite(program.retryDelay) && program.retryDelay >= 0) ? program.retryDelay : 2500;55 if (program.forceOverwrite && program.checkTiles) {56 showErrorMessageAndExit("Can't use both -f (--force-overwrite) & -c (--check-tiles) options");57 }...
Engine.android.js
Source:Engine.android.js
...44 ponder: parts[3],45 }46 };47 } else if (response.startsWith('info')) {48 const cpScore = parseIntValue(response, 'score cp');49 const mateScore = parseIntValue(response, 'score mate');50 return {51 type: 'info',52 data: {53 multipv: parseIntValue(response, 'multipv'),54 depth: parseIntValue(response, 'depth'),55 seldepth: parseIntValue(response, 'seldepth'),56 nodes: parseIntValue(response, 'nodes'),57 time: parseIntValue(response, 'time'),58 score: cpScore ? ['cp', cpScore] : ['mate', mateScore],59 pv: parsePv(response),60 },61 };62 } else {63 return {64 type: 'unknown',65 data: response,66 };67 }...
apiPaginate.js
Source:apiPaginate.js
...13 return v <= maxLimit ? v : maxLimit;14};15function ApiPaginate() {}16ApiPaginate.parseOptionsForElasticSearch = function(params) {17 const limit = parseIntValue(params.limit, LIMIT_DEFAULT, LIMIT_MAX);18 const offset = parseIntValue(params.offset, OFFSET_DEFAULT);19 // See https://github.com/crowi/crowi/pull/29320 if (limit + offset > DEFAULT_MAX_RESULT_WINDOW) {21 throw new Error(`(limit + offset) must be less than or equal to ${DEFAULT_MAX_RESULT_WINDOW}`);22 }23 return { limit, offset };24};25ApiPaginate.parseOptions = function(params) {26 const limit = parseIntValue(params.limit, LIMIT_DEFAULT, LIMIT_MAX);27 const offset = parseIntValue(params.offset, OFFSET_DEFAULT);28 return { limit, offset };29};...
parseIntValue.js
Source:parseIntValue.js
1import parseIntValue from '../../parseIntValue';2it('parseIntValue', () => {3 expect(parseIntValue(' cp 10', 'cp')).toBe(10);4 expect(parseIntValue(' cp -10', 'cp')).toBe(-10);...
Using AI Code Generation
1const puppeteer = require('puppeteer');2const { parseIntValue } = require('puppeteer-utils');3(async () => {4 const browser = await puppeteer.launch({ headless: false });5 const page = await browser.newPage();6 const searchInput = await page.$('input[name="q"]');7 await searchInput.type('puppeteer');8 const searchButton = await page.$('input[name="btnK"]');9 await searchButton.click();10 await page.waitForNavigation();11 const searchResults = await page.$$('div.g');12 for (const searchResult of searchResults) {13 const searchResultText = await searchResult.$eval('div.rc', el => el.innerText);14 console.log(searchResultText);15 }16 const searchResultsCount = await page.$eval('#result-stats', el => el.innerText);17 const searchResultsCountValue = parseIntValue(searchResultsCount);18 console.log(searchResultsCountValue);19 await browser.close();20})();21MIT © [Sudhanshu Yadav](
Using AI Code Generation
1const puppeteerUtils = require('../puppeteerUtils');2(async () => {3 const browser = await puppeteer.launch();4 const page = await browser.newPage();5 await puppeteerUtils.parseIntValue(page, 'input[name="q"]', 'test');6 await browser.close();7})();8MIT © [Hammad Khan](
Using AI Code Generation
1const Puppeteer = require('./puppeteer');2(async () => {3 const puppeteer = new Puppeteer();4 await puppeteer.init();5 console.log(value);6 await puppeteer.close();7})();8[MIT](
Using AI Code Generation
1const { parseIntValue } = require('puppeteer-utils');2const puppeteer = require('puppeteer');3(async () => {4 const browser = await puppeteer.launch();5 const page = await browser.newPage();6 const value = await parseIntValue(page, '#myId');7 console.log(value);8 await browser.close();9})();10const { parseFloatValue } = require('puppeteer-utils');11const puppeteer = require('puppeteer');12(async () => {13 const browser = await puppeteer.launch();14 const page = await browser.newPage();15 const value = await parseFloatValue(page, '#myId');16 console.log(value);17 await browser.close();18})();19const { parseDateValue } = require('puppeteer-utils');20const puppeteer = require('puppeteer');21(async () => {22 const browser = await puppeteer.launch();23 const page = await browser.newPage();24 const value = await parseDateValue(page, '#myId');25 console.log(value);26 await browser.close();27})();28const { parseBoolValue } = require('puppeteer-utils');29const puppeteer = require('puppeteer');30(async () => {31 const browser = await puppeteer.launch();32 const page = await browser.newPage();33 const value = await parseBoolValue(page, '#myId');34 console.log(value);35 await browser.close();36})();37const { parseArrayValue } = require('puppeteer-utils');38const puppeteer = require('puppeteer');39(async () => {40 const browser = await puppeteer.launch();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!