How to use _getOption method in mochawesome

Best JavaScript code snippet using mochawesome

jquery.flipCounter.1.2.js

Source:jquery.flipCounter.1.2.js Github

copy

Full Screen

...164 obj = $(this);165 166 if (!_isInitialized()) $(this).flipCounter();167 168 val = _getOption('number');169 170 return val;171 172 }173 174 );175 176 return val;177 178 },179 // Start animation or resume paused animation180 startAnimation: function (options) {181 return this.each(182 183 function () {184 185 obj = $(this);186 187 if (!_isInitialized()) $(this).flipCounter();188 189 obj.trigger('startAnimation', options);190 191 }192 193 );194 },195 // Stop animation196 stopAnimation: function () {197 198 return this.each(199 200 function () {201 202 obj = $(this);203 204 if (!_isInitialized()) $(this).flipCounter();205 206 obj.trigger('stopAnimation');207 208 }209 210 );211 212 },213 // Pause animation214 pauseAnimation: function () {215 216 return this.each(217 218 function () {219 220 obj = $(this);221 if (!_isInitialized()) $(this).flipCounter();222 223 obj.trigger('pauseAnimation');224 225 }226 227 );228 229 },230 // Resume animation231 resumeAnimation: function () {232 233 return this.each(234 235 function () {236 237 obj = $(this);238 239 if (!_isInitialized()) $(this).flipCounter();240 241 obj.trigger('resumeAnimation');242 243 }244 245 );246 247 }248 };249 // Call public methods250 if (methods[method]) {251 252 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));253 254 } else if (typeof method === 'object' || !method) {255 256 return methods.init.apply(this, arguments);257 258 } else {259 260 $.error('Method ' + method + ' does not exist on jQuery.flipCounter');261 262 }263 // Private Functions264 function _isInitialized() {265 266 var data = obj.data('flipCounter');267 268 if (typeof data == 'undefined') return false269 270 return true;271 272 }273 // Get an option274 function _getOption(option) {275 276 var data = obj.data('flipCounter');277 var value = data[option];278 279 if (typeof value !== 'undefined') {280 281 return value;282 283 }284 285 return false;286 287 }288 // Set an option289 function _setOption(option, value) {290 291 var data = obj.data('flipCounter');292 293 data[option] = value;294 obj.data('flipCounter', data);295 296 }297 // Setup the counter298 function _setupCounter() {299 300 // If object doesn't have a hidden field then create one301 if (obj.children('[name="' + _getOption('counterFieldName') + '"]').length < 1) {302 303 obj.append('<input type="hidden" name="' + _getOption('counterFieldName') + '" value="' + _getOption('number') + '" />');304 305 }306 // Add or remove enough digits to fit number307 var digits_length = _getDigitsLength();308 var num_digits_needed = _getNumberFormatted().length;309 if (num_digits_needed > digits_length) {310 for (i = 0; i < (num_digits_needed - digits_length); i++) {311 var digit_element = $('<span class="' + _getOption('digitClass') + '" style="' + _getDigitStyle('0') + '" />');312 obj.prepend(digit_element);313 }314 } else if (num_digits_needed < digits_length) {315 316 for (i = 0; i < (digits_length - num_digits_needed); i++) {317 318 obj.children('.' + _getOption('digitClass')).first().remove();319 320 }321 322 }323 // Add the invisible span if it doesn't already exist324 obj.find('.' + _getOption('digitClass')).each(325 326 function () {327 328 if (0 == $(this).find('span').length)329 {330 331 $(this).append('<span style="visibility:hidden">0</span>');332 333 }334 335 }336 337 );338 }339 // Render the counter340 function _renderCounter() {341 _setupCounter();342 var number = _getNumberFormatted();343 var digits = _getDigits();344 var pos = 0;345 346 $.each(digits, function (index, value) {347 348 digit = number.toString().charAt(pos);349 $(this).attr('style', _getDigitStyle(digit));350 $(this).find('span').text(digit.replace(' ', '&nbsp;').toString()); // replace empty space with &nbsp; to prevent rendering bug351 pos++352 353 });354 355 _setCounterValue();356 }357 // get a collection of the objects digit DOM elements358 function _getDigits() {359 360 return obj.children('.' + _getOption('digitClass'));361 362 }363 // get the current number of digit DOM elements364 function _getDigitsLength() {365 366 return _getDigits().length;367 368 }369 // get the value stored in the counter field370 function _getCounterValue() {371 372 var val = parseFloat(obj.children('[name="' + _getOption('counterFieldName') + '"]').val());373 374 if (val == val == false) return false; // test for NaN375 376 return val;377 378 }379 // update the counter field with the current number380 function _setCounterValue() {381 382 obj.children('[name="' + _getOption('counterFieldName') + '"]').val(_getOption('number'));383 384 }385 // format number as a string according to given options386 function _getNumberFormatted() {387 388 var number = _getOption('number');389 390 // check is numeric391 if (typeof number !== 'number') {392 393 $.error('Attempting to render non-numeric value.');394 return '0';395 396 } 397 398 var str_number = '';399 400 // Number formatter plugin is being used401 if (_getOption('formatNumberOptions')) 402 {403 404 if ($.formatNumber) {405 406 str_number = $.formatNumber(number, _getOption('formatNumberOptions'));407 408 } else {409 410 $.error('The numberformatter jQuery plugin is not loaded. This plugin is required to use the formatNumberOptions setting.');411 412 }413 414 } else {415 416 // if greater than zero add leading zeros if necessary417 if (number >= 0) { 418 419 var num_integral_digits = _getOption('numIntegralDigits');420 var num_extra_zeros = num_integral_digits - number.toFixed().toString().length;421 422 for (var i = 0; i < num_extra_zeros; i++) {423 424 str_number += '0';425 426 }427 428 str_number += number.toFixed(_getOption('numFractionalDigits'));429 430 // if less than zero remove leading zeros and add minus sign 431 } else { 432 433 str_number = '-' + Math.abs(number.toFixed(_getOption('numFractionalDigits')));434 435 }436 437 }438 return str_number;439 }440 441 // Get CSS background image positiong442 function _getDigitStyle(character)443 {444 445 var style = "height:" + _getOption('digitHeight') + "px; width:" + _getOption('digitWidth') + "px; display:inline-block; background-image:url('" + _getOption('imagePath') + "'); background-repeat:no-repeat; ";446 447 var bg_pos = new Array();448 449 bg_pos['1'] = _getOption('digitWidth') * 0;450 bg_pos['2'] = _getOption('digitWidth') * -1;451 bg_pos['3'] = _getOption('digitWidth') * -2;452 bg_pos['4'] = _getOption('digitWidth') * -3;453 bg_pos['5'] = _getOption('digitWidth') * -4;454 bg_pos['6'] = _getOption('digitWidth') * -5;455 bg_pos['7'] = _getOption('digitWidth') * -6;456 bg_pos['8'] = _getOption('digitWidth') * -7;457 bg_pos['9'] = _getOption('digitWidth') * -8;458 bg_pos['0'] = _getOption('digitWidth') * -9;459 bg_pos['.'] = _getOption('digitWidth') * -10;460 bg_pos['-'] = _getOption('digitWidth') * -11;461 bg_pos[','] = _getOption('digitWidth') * -12;462 bg_pos[' '] = _getOption('digitWidth') * -13;463 464 if( character in bg_pos)465 {466 467 return style + 'background-position: ' + bg_pos[character] + 'px 0px;'468 469 }470 471 return style;472 473 }474 // Start the animation 475 function _startAnimation(options) {476 if (true == _getOption('animating')) _stopAnimation();477 if (typeof options !== 'undefined') {478 479 options = $.extend(obj.data('flipCounter'), options);480 obj.data('flipCounter', options);481 482 } else {483 484 options = obj.data('flipCounter');485 486 }487 if (false == _getOption('start_time')) {488 _setOption('start_time', new Date().getTime());489 }490 if (false == _getOption('time')) {491 _setOption('time', 0);492 }493 if (false == _getOption('elapsed')) {494 _setOption('elapsed', '0.0');495 }496 if (false == _getOption('start_number')) {497 _setOption('start_number', _getOption('number'));498 if (false == _getOption('start_number')) {499 _setOption('start_number', 0);500 }501 }502 _doAnimation();503 504 var onAnimationStarted = _getOption('onAnimationStarted');505 506 if (typeof onAnimationStarted == 'function') onAnimationStarted.call(obj, obj);507 }508 // Do animation step509 function _doAnimation() {510 var start_time = _getOption('start_time');511 var time = _getOption('time');512 var elapsed = _getOption('elapsed');513 var start_number = _getOption('start_number');514 var number_change = _getOption('end_number') - _getOption('start_number');515 if (number_change == 0) return false;516 var duration = _getOption('duration');517 var easing = _getOption('easing');518 _setOption('animating', true);519 function animation_step() {520 time += 10;521 elapsed = Math.floor(time / 10) / 10;522 if (Math.round(elapsed) == elapsed) {523 524 elapsed += '.0';525 526 }527 _setOption('elapsed', elapsed);528 var diff = (new Date().getTime() - start_time) - time;529 530 var new_num = 0;531 532 if(typeof easing == 'function') {533 534 new_num = easing.apply(obj, [false, time, start_number, number_change, duration]);535 }536 else537 {538 539 new_num = _noEasing(false, time, start_number, number_change, duration);540 541 }542 543 _setOption('number', new_num);544 _setOption('time', time);545 _renderCounter();546 if (time < duration) {547 _setOption('interval', window.setTimeout(animation_step, (10 - diff)));548 } else {549 550 _stopAnimation();551 552 }553 }554 window.setTimeout(animation_step, 10);555 }556 // Stop animation557 function _stopAnimation() {558 if (false == _getOption('animating')) return false;559 clearTimeout(_getOption('interval'));560 _setOption('start_time', false);561 _setOption('start_number', false);562 _setOption('end_number', false);563 _setOption('time', 0);564 _setOption('animating', false);565 _setOption('paused', false);566 var onAnimationStopped = _getOption('onAnimationStopped');567 568 if (typeof onAnimationStopped == 'function') onAnimationStopped.call(obj, obj);569 }570 // Pause animation571 function _pauseAnimation() {572 if (false == _getOption('animating') || true == _getOption('paused')) return false;573 clearTimeout(_getOption('interval'));574 _setOption('paused', true);575 var onAnimationPaused = _getOption('onAnimationPaused');576 577 if (typeof onAnimationPaused == 'function') onAnimationPaused.call(obj, obj);578 }579 // Resume animation580 function _resumeAnimation() {581 if (false == _getOption('animating') || false == _getOption('paused')) return false;582 _setOption('paused', false);583 _doAnimation();584 var onAnimationResumed = _getOption('onAnimationResumed');585 586 if (typeof onAnimationResumed == 'function') onAnimationResumed.call(obj, obj);587 }588 // Default linear interpolation589 function _noEasing(x, t, b, c, d) {590 591 return t / d * c + b;592 593 }594 }595})(jQuery);596// Used to remove white space in counter that causes rendering bugs597jQuery.fn.htmlClean = function () {598 this.contents().filter(function () {...

Full Screen

Full Screen

jquery.flipCounter.js

Source:jquery.flipCounter.js Github

copy

Full Screen

...164 obj = $(this);165 166 if (!_isInitialized()) $(this).flipCounter();167 168 val = _getOption('number');169 170 return val;171 172 }173 174 );175 176 return val;177 178 },179 // Start animation or resume paused animation180 startAnimation: function (options) {181 return this.each(182 183 function () {184 185 obj = $(this);186 187 if (!_isInitialized()) $(this).flipCounter();188 189 obj.trigger('startAnimation', options);190 191 }192 193 );194 },195 // Stop animation196 stopAnimation: function () {197 198 return this.each(199 200 function () {201 202 obj = $(this);203 204 if (!_isInitialized()) $(this).flipCounter();205 206 obj.trigger('stopAnimation');207 208 }209 210 );211 212 },213 // Pause animation214 pauseAnimation: function () {215 216 return this.each(217 218 function () {219 220 obj = $(this);221 if (!_isInitialized()) $(this).flipCounter();222 223 obj.trigger('pauseAnimation');224 225 }226 227 );228 229 },230 // Resume animation231 resumeAnimation: function () {232 233 return this.each(234 235 function () {236 237 obj = $(this);238 239 if (!_isInitialized()) $(this).flipCounter();240 241 obj.trigger('resumeAnimation');242 243 }244 245 );246 247 }248 };249 // Call public methods250 if (methods[method]) {251 252 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));253 254 } else if (typeof method === 'object' || !method) {255 256 return methods.init.apply(this, arguments);257 258 } else {259 260 $.error('Method ' + method + ' does not exist on jQuery.flipCounter');261 262 }263 // Private Functions264 function _isInitialized() {265 266 var data = obj.data('flipCounter');267 268 if (typeof data == 'undefined') return false269 270 return true;271 272 }273 // Get an option274 function _getOption(option) {275 276 var data = obj.data('flipCounter');277 var value = data[option];278 279 if (typeof value !== 'undefined') {280 281 return value;282 283 }284 285 return false;286 287 }288 // Set an option289 function _setOption(option, value) {290 291 var data = obj.data('flipCounter');292 293 data[option] = value;294 obj.data('flipCounter', data);295 296 }297 // Setup the counter298 function _setupCounter() {299 300 // If object doesn't have a hidden field then create one301 if (obj.children('[name="' + _getOption('counterFieldName') + '"]').length < 1) {302 303 obj.append('<input type="hidden" name="' + _getOption('counterFieldName') + '" value="' + _getOption('number') + '" />');304 305 }306 // Add or remove enough digits to fit number307 var digits_length = _getDigitsLength();308 var num_digits_needed = _getNumberFormatted().length;309 if (num_digits_needed > digits_length) {310 for (i = 0; i < (num_digits_needed - digits_length); i++) {311 var digit_element = $('<span class="' + _getOption('digitClass') + '" style="' + _getDigitStyle('0') + '" />');312 obj.prepend(digit_element);313 }314 } else if (num_digits_needed < digits_length) {315 316 for (i = 0; i < (digits_length - num_digits_needed); i++) {317 318 obj.children('.' + _getOption('digitClass')).first().remove();319 320 }321 322 }323 // Add the invisible span if it doesn't already exist324 obj.find('.' + _getOption('digitClass')).each(325 326 function () {327 328 if (0 == $(this).find('span').length)329 {330 331 $(this).append('<span style="visibility:hidden">0</span>');332 333 }334 335 }336 337 );338 }339 // Render the counter340 function _renderCounter() {341 _setupCounter();342 var number = _getNumberFormatted();343 var digits = _getDigits();344 var pos = 0;345 346 $.each(digits, function (index, value) {347 348 digit = number.toString().charAt(pos);349 $(this).attr('style', _getDigitStyle(digit));350 $(this).find('span').text(digit.replace(' ', '&nbsp;').toString()); // replace empty space with &nbsp; to prevent rendering bug351 pos++352 353 });354 355 _setCounterValue();356 }357 // get a collection of the objects digit DOM elements358 function _getDigits() {359 360 return obj.children('.' + _getOption('digitClass'));361 362 }363 // get the current number of digit DOM elements364 function _getDigitsLength() {365 366 return _getDigits().length;367 368 }369 // get the value stored in the counter field370 function _getCounterValue() {371 372 var val = parseFloat(obj.children('[name="' + _getOption('counterFieldName') + '"]').val());373 374 if (val == val == false) return false; // test for NaN375 376 return val;377 378 }379 // update the counter field with the current number380 function _setCounterValue() {381 382 obj.children('[name="' + _getOption('counterFieldName') + '"]').val(_getOption('number'));383 384 }385 // format number as a string according to given options386 function _getNumberFormatted() {387 388 var number = _getOption('number');389 390 // check is numeric391 if (typeof number !== 'number') {392 393 $.error('Attempting to render non-numeric value.');394 return '0';395 396 } 397 398 var str_number = '';399 400 // Number formatter plugin is being used401 if (_getOption('formatNumberOptions')) 402 {403 404 if ($.formatNumber) {405 406 str_number = $.formatNumber(number, _getOption('formatNumberOptions'));407 408 } else {409 410 $.error('The numberformatter jQuery plugin is not loaded. This plugin is required to use the formatNumberOptions setting.');411 412 }413 414 } else {415 416 // if greater than zero add leading zeros if necessary417 if (number >= 0) { 418 419 var num_integral_digits = _getOption('numIntegralDigits');420 var num_extra_zeros = num_integral_digits - number.toFixed().toString().length;421 422 for (var i = 0; i < num_extra_zeros; i++) {423 424 str_number += '0';425 426 }427 428 str_number += number.toFixed(_getOption('numFractionalDigits'));429 430 // if less than zero remove leading zeros and add minus sign 431 } else { 432 433 str_number = '-' + Math.abs(number.toFixed(_getOption('numFractionalDigits')));434 435 }436 437 }438 return str_number;439 }440 441 // Get CSS background image positiong442 function _getDigitStyle(character)443 {444 445 var style = "height:" + _getOption('digitHeight') + "px; width:" + _getOption('digitWidth') + "px; display:inline-block; background-image:url('" + _getOption('imagePath') + "'); background-repeat:no-repeat; ";446 447 var bg_pos = new Array();448 449 bg_pos['1'] = _getOption('digitWidth') * 0;450 bg_pos['2'] = _getOption('digitWidth') * -1;451 bg_pos['3'] = _getOption('digitWidth') * -2;452 bg_pos['4'] = _getOption('digitWidth') * -3;453 bg_pos['5'] = _getOption('digitWidth') * -4;454 bg_pos['6'] = _getOption('digitWidth') * -5;455 bg_pos['7'] = _getOption('digitWidth') * -6;456 bg_pos['8'] = _getOption('digitWidth') * -7;457 bg_pos['9'] = _getOption('digitWidth') * -8;458 bg_pos['0'] = _getOption('digitWidth') * -9;459 bg_pos['.'] = _getOption('digitWidth') * -10;460 bg_pos['-'] = _getOption('digitWidth') * -11;461 bg_pos[','] = _getOption('digitWidth') * -12;462 bg_pos[' '] = _getOption('digitWidth') * -13;463 464 if( character in bg_pos)465 {466 467 return style + 'background-position: ' + bg_pos[character] + 'px 0px;'468 469 }470 471 return style;472 473 }474 // Start the animation 475 function _startAnimation(options) {476 if (true == _getOption('animating')) _stopAnimation();477 if (typeof options !== 'undefined') {478 479 options = $.extend(obj.data('flipCounter'), options);480 obj.data('flipCounter', options);481 482 } else {483 484 options = obj.data('flipCounter');485 486 }487 if (false == _getOption('start_time')) {488 _setOption('start_time', new Date().getTime());489 }490 if (false == _getOption('time')) {491 _setOption('time', 0);492 }493 if (false == _getOption('elapsed')) {494 _setOption('elapsed', '0.0');495 }496 if (false == _getOption('start_number')) {497 _setOption('start_number', _getOption('number'));498 if (false == _getOption('start_number')) {499 _setOption('start_number', 0);500 }501 }502 _doAnimation();503 504 var onAnimationStarted = _getOption('onAnimationStarted');505 506 if (typeof onAnimationStarted == 'function') onAnimationStarted.call(obj, obj);507 }508 // Do animation step509 function _doAnimation() {510 var start_time = _getOption('start_time');511 var time = _getOption('time');512 var elapsed = _getOption('elapsed');513 var start_number = _getOption('start_number');514 var number_change = _getOption('end_number') - _getOption('start_number');515 if (number_change == 0) return false;516 var duration = _getOption('duration');517 var easing = _getOption('easing');518 _setOption('animating', true);519 function animation_step() {520 time += 10;521 elapsed = Math.floor(time / 10) / 10;522 if (Math.round(elapsed) == elapsed) {523 524 elapsed += '.0';525 526 }527 _setOption('elapsed', elapsed);528 var diff = (new Date().getTime() - start_time) - time;529 530 var new_num = 0;531 532 if(typeof easing == 'function') {533 534 new_num = easing.apply(obj, [false, time, start_number, number_change, duration]);535 }536 else537 {538 539 new_num = _noEasing(false, time, start_number, number_change, duration);540 541 }542 543 _setOption('number', new_num);544 _setOption('time', time);545 _renderCounter();546 if (time < duration) {547 _setOption('interval', window.setTimeout(animation_step, (10 - diff)));548 } else {549 550 _stopAnimation();551 552 }553 }554 window.setTimeout(animation_step, 10);555 }556 // Stop animation557 function _stopAnimation() {558 if (false == _getOption('animating')) return false;559 clearTimeout(_getOption('interval'));560 _setOption('start_time', false);561 _setOption('start_number', false);562 _setOption('end_number', false);563 _setOption('time', 0);564 _setOption('animating', false);565 _setOption('paused', false);566 var onAnimationStopped = _getOption('onAnimationStopped');567 568 if (typeof onAnimationStopped == 'function') onAnimationStopped.call(obj, obj);569 }570 // Pause animation571 function _pauseAnimation() {572 if (false == _getOption('animating') || true == _getOption('paused')) return false;573 clearTimeout(_getOption('interval'));574 _setOption('paused', true);575 var onAnimationPaused = _getOption('onAnimationPaused');576 577 if (typeof onAnimationPaused == 'function') onAnimationPaused.call(obj, obj);578 }579 // Resume animation580 function _resumeAnimation() {581 if (false == _getOption('animating') || false == _getOption('paused')) return false;582 _setOption('paused', false);583 _doAnimation();584 var onAnimationResumed = _getOption('onAnimationResumed');585 586 if (typeof onAnimationResumed == 'function') onAnimationResumed.call(obj, obj);587 }588 // Default linear interpolation589 function _noEasing(x, t, b, c, d) {590 591 return t / d * c + b;592 593 }594 }595})(jQuery);596// Used to remove white space in counter that causes rendering bugs597jQuery.fn.htmlClean = function () {598 this.contents().filter(function () {...

Full Screen

Full Screen

jquery.flipCounter.1.1.pack.js

Source:jquery.flipCounter.1.1.pack.js Github

copy

Full Screen

...90 var val = false;91 this.each(function()92 {93 obj = $(this);94 val = _getOption('number');95 });96 return val;97 },98 99 // Start animation or resume paused animation100 startAnimation: function(options) {101 102 return this.each(function()103 {104 obj = $(this);105 obj.trigger('startAnimation', options);106 });107 108 },109 110 // Stop animation111 stopAnimation: function() {112 return this.each(function()113 {114 obj = $(this);115 obj.trigger('stopAnimation');116 });117 },118 119 // Pause animation120 pauseAnimation: function() {121 return this.each(function()122 {123 obj = $(this);124 obj.trigger('pauseAnimation');125 });126 }127 128 }; 129130 // Call public methods131 if ( methods[method] ) {132 return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));133 } else if ( typeof method === 'object' || ! method ) {134 return methods.init.apply( this, arguments );135 } else {136 $.error( 'Method ' + method + ' does not exist on jQuery.flipCounter' );137 }138 139 // Private Functions140 141 // Get an option142 function _getOption(option) {143 var data = obj.data('flipCounter');144 var value = data[option];145 if(typeof value !== 'undefined')146 {147 return value;148 }149 return false;150 }151 152 // Set an option153 function _setOption(option, value) {154 var data = obj.data('flipCounter');155 data[option] = value;156 obj.data('flipCounter', data);157 }158 159 // Setup the counter160 function _setupCounter() {161 162 // If object doesn't have a hidden field then create one163 if(obj.children('[name="'+_getOption('counterFieldName')+'"]').length < 1)164 {165 obj.append('<input type="hidden" name="'+_getOption('counterFieldName')+'" value="'+_getOption('number')+'" />');166 }167 168 // Add or remove enough digits to fit number169 var digits_length = _getDigitsLength();170 var num_digits_needed = _getNumberFormatted().length;171 172 while(num_digits_needed != digits_length)173 {174 if(num_digits_needed > digits_length)175 {176 obj.prepend('<span class="'+_getOption('digitClass')+'" style="'+style_digit+style_character['0']+'">0</span>');177 }178 else if(num_digits_needed < digits_length)179 {180 obj.children('.'+_getOption('digitClass')+':nth-child(1)').remove();181 }182 digits_length = _getDigitsLength();183 }184 185 }186 187 // Render the counter188 function _renderCounter()189 {190 _setupCounter();191 var number = _getNumberFormatted();192 var digits = _getDigits();193 var pos = 0;194195 $.each(digits, function(index, value) {196 digit = number.toString().charAt(pos);197 $(this).attr('style',style_digit+style_character[digit]);198 $(this).text(digit.replace(' ','&nbsp;').toString()); // replace empty space with &nbsp; to prevent rendering bug199 pos++200 });201 _setCounterValue();202 }203 204 // Setup the CSS styles205 function _setupStyles()206 {207 style_digit = "height:"+_getOption('digitHeight')+"px;width:"+_getOption('digitWidth')+"px;background-image:url('"+_getOption('imagePath')+"');background-repeat:no-repeat;text-indent: -999em;display:inline-block;";208 style_character = {209 '1': 'background-position: '+_getOption('digitWidth')*0+'px 0px;',210 '2': 'background-position: -'+_getOption('digitWidth')*1+'px 0px;',211 '3': 'background-position: -'+_getOption('digitWidth')*2+'px 0px;',212 '4': 'background-position: -'+_getOption('digitWidth')*3+'px 0px;',213 '5': 'background-position: -'+_getOption('digitWidth')*4+'px 0px;',214 '6': 'background-position: -'+_getOption('digitWidth')*5+'px 0px;',215 '7': 'background-position: -'+_getOption('digitWidth')*6+'px 0px;',216 '8': 'background-position: -'+_getOption('digitWidth')*7+'px 0px;',217 '9': 'background-position: -'+_getOption('digitWidth')*8+'px 0px;',218 '0': 'background-position: -'+_getOption('digitWidth')*9+'px 0px;',219 '.': 'background-position: -'+_getOption('digitWidth')*10+'px 0px;',220 '-': 'background-position: -'+_getOption('digitWidth')*11+'px 0px;',221 ',': 'background-position: -'+_getOption('digitWidth')*12+'px 0px;',222 ' ': 'background-position: -'+_getOption('digitWidth')*13+'px 0px;'223 };224 }225 226 // get a collection of the objects digit DOM elements227 function _getDigits()228 {229 return obj.children('.'+_getOption('digitClass'));230 }231 232 // get the current number of digit DOM elements233 function _getDigitsLength()234 {235 return _getDigits().length;236 }237 238 function str_pad (input, pad_length, pad_string, pad_type) {239 // Returns input string padded on the left or right to specified length with pad_string 240 // 241 // version: 1107.2516242 // discuss at: http://phpjs.org/functions/str_pad // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)243 // + namespaced by: Michael White (http://getsprink.com)244 // + input by: Marco van Oort245 // + bugfixed by: Brett Zamir (http://brett-zamir.me)246 // * example 1: str_pad('Kevin van Zonneveld', 30, '-=', 'STR_PAD_LEFT'); // * returns 1: '-=-=-=-=-=-Kevin van Zonneveld'247 // * example 2: str_pad('Kevin van Zonneveld', 30, '-', 'STR_PAD_BOTH');248 // * returns 2: '------Kevin van Zonneveld-----'249 var half = '',250 pad_to_go; 251 var str_pad_repeater = function (s, len) {252 var collect = '',253 i;254 while (collect.length < len) {255 collect += s;256 }257 collect = collect.substr(0, len);258 return collect;259 };260 261 input += '';262 pad_string = pad_string !== undefined ? pad_string : ' '; 263 if (pad_type != 'STR_PAD_LEFT' && pad_type != 'STR_PAD_RIGHT' && pad_type != 'STR_PAD_BOTH') {264 pad_type = 'STR_PAD_RIGHT';265 }266 if ((pad_to_go = pad_length - input.length) > 0) { if (pad_type == 'STR_PAD_LEFT') {267 input = str_pad_repeater(pad_string, pad_to_go) + input;268 } else if (pad_type == 'STR_PAD_RIGHT') {269 input = input + str_pad_repeater(pad_string, pad_to_go);270 } else if (pad_type == 'STR_PAD_BOTH') { half = str_pad_repeater(pad_string, Math.ceil(pad_to_go / 2));271 input = half + input + half;272 input = input.substr(0, pad_length);273 }274 } 275 return input;276}277278 // get the value stored in the counter field279 function _getCounterValue()280 {281 var val = parseFloat(obj.children('[name="'+_getOption('counterFieldName')+'"]').val());282 if(val == val == false) return false; // test for NaN283 var x = str_pad(val,4,0,'STR_PAD_LEFT');284 //alert(x);285 return val;286 }287 288 // update the counter field with the current number289 function _setCounterValue()290 {291 obj.children('[name="'+_getOption('counterFieldName')+'"]').val(_getOption('number'));292 }293 294 // format number as a string according to given options295 function _getNumberFormatted()296 {297 var number = _getOption('number');298 if(typeof number !== 'number') { $.error('Attempting to render non-numeric value.'); return '0'; } // check is numeric299 var str_number = '';300 301 if(_getOption('formatNumberOptions')) // Number formatter plugin is being used302 {303 if($.formatNumber)304 {305 str_number = $.formatNumber(number, _getOption('formatNumberOptions'));306 }307 else308 {309 $.error( 'The numberformatter jQuery plugin is not loaded. This plugin is required to use the formatNumberOptions setting.' );310 }311 }312 else313 { 314 if(number >= 0){ // if greater than zero add leading zeros if necessary315 var num_integral_digits = _getOption('numIntegralDigits');316 var num_extra_zeros = num_integral_digits - number.toFixed().toString().length;317 for(var i = 0; i < num_extra_zeros; i++)318 {319 str_number += '0';320 }321 str_number += number.toFixed(_getOption('numFractionalDigits')); 322 }323 else { // if less than zero remove leading zeros and add minus sign324 str_number = '-'+Math.abs(number.toFixed(_getOption('numFractionalDigits')));325 }326 }327 328 329 return str_number;330331 }332 333 // Start the animation 334 function _startAnimation(options) {335 336 if(typeof options == 'undefined' && false == _getOption('animating')) return false; // if trying to resume from pause without first starting return false337 338 if(typeof options !== 'undefined')339 {340 if (typeof options.easing == 'function') _setOption('easing', options.easing);341 if (typeof options.onAnimationStarted == 'function') _setOption('onAnimationStarted', options.onAnimationStarted);342 if (typeof options.onAnimationStopped == 'function') _setOption('onAnimationStopped', options.onAnimationStopped);343 if (typeof options.onAnimationPaused == 'function') _setOption('onAnimationPaused', options.onAnimationPaused);344 if (typeof options.duration == 'number') _setOption('duration', options.duration);345 }346 347 // if its been paused then simply restart the timer348 if(_getOption('paused') === true) {349 _setOption('paused', false);350 _setOption('animating', true);351 _setOption('interval', setInterval(_doAnimation, 1));352 353 }354 else // it is being started new, initialize the animation355 {356 357 _setOption('start_number', _getOption('number'));358 _setOption('end_number', options.number);359 _setOption('time', 0);360 _setOption('duration', _getOption('duration') / 10); // divide by 10 so 1000 duration = 1 sec361 _setOption('animating', true);362 _setOption('interval', setInterval(_doAnimation, 1));363 364 }365 366 // Callback for animation started367 var onAnimationStarted = _getOption('onAnimationStarted');368 if(typeof onAnimationStarted == 'function') onAnimationStarted.call(obj, obj);369 370 }371 372 // Do animation step373 function _doAnimation() {374 375 var time = _getOption('time');376 var start_number = _getOption('start_number');377 var number_change = _getOption('end_number') - start_number;378 var duration = _getOption('duration');379 var easing = _getOption('easing');380 381 // apply easing function382 var new_num = easing.apply(obj, [false, time,start_number,number_change,duration]);383 384 _setOption('number', new_num);385 _renderCounter();386 387 if(time >= duration) {388 _stopAnimation(); // if animation has expired, stop it389 }390 391 _setOption('time',time+1); // increase time step392 393 }394 395 // Stop animation396 function _stopAnimation() {397 398 if(true !== _getOption('animating')) return false;399 400 clearInterval(_getOption('interval'));401 _setOption('number', _getOption('end_number'));402 _setOption('start_number', null);403 _setOption('end_number', null);404 _setOption('timer', 0);405 _setOption('animating',false);406 407 var onAnimationStopped = _getOption('onAnimationStopped');408 if(typeof onAnimationStopped == 'function') onAnimationStopped.call(obj, obj);409 410 }411 412 // Pause animation413 function _pauseAnimation() {414 415 if(true !== _getOption('animating')) return false;416 417 _setOption('paused', true);418 clearInterval(_getOption('interval'));419 420 var onAnimationPaused = _getOption('onAnimationPaused');421 if(typeof onAnimationPaused == 'function') onAnimationPaused.call(obj, obj);422 }423 424 // Default linear interpolation, override this function in options to replace it with jQuery.easing or custom function425 function _noEasing(x, t, b, c, d)426 {427 return t /d * c + b;428 }429 430 }431 ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { _getOption } = require('mochawesome-screenshots');2const { _setOption } = require('mochawesome-screenshots');3const { _resetOptions } = require('mochawesome-screenshots');4const { _setOptions } = require('mochawesome-screenshots');5_setOptions({6 beforeScreenshot: () => {},7 afterScreenshot: () => {},8 beforeHook: () => {},9 afterHook: () => {},10 beforeAll: () => {},11 afterAll: () => {},12 beforeTest: () => {},13 afterTest: () => {},14 beforeSuite: () => {},15 afterSuite: () => {},16 beforeHook: () => {},17 afterHook: () => {},18 beforeTest: () => {},19 afterTest: () => {},20 before: () => {},21 after: () => {},22 onTestFail: () => {},23 onTestPass: () => {},24 onTestSkip: () => {},25 onTestRetry: () => {},26 onSuiteStart: () => {},27 onSuiteEnd: () => {},28 onHookStart: () => {},29 onHookEnd: () => {},30 onRunnerStart: () => {},31 onRunnerEnd: () => {},32 onInstanceStart: () => {},33 onInstanceEnd: () => {},34 onInstanceReady: () => {},35});36_setOption('screenshotOnRunFailure', false);37_getOption('screenshotOnRunFailure');

Full Screen

Using AI Code Generation

copy

Full Screen

1var mocha = require('mocha');2var mochawesome = require('mochawesome');3var Mocha = mocha.Mocha;4var mochaInstance = new Mocha();5var mochawesomeInstance = new mochawesome();6var mochaOptions = mochaInstance._options;7var mochawesomeOptions = mochawesomeInstance._options;8console.log(mochaOptions);9console.log(mochawesomeOptions);10var mocha = require('mocha');11var mochawesome = require('mochawesome');12var Mocha = mocha.Mocha;13var mochaInstance = new Mocha();14var mochawesomeInstance = new mochawesome();15var mochaOptions = mochaInstance._options;16var mochawesomeOptions = mochawesomeInstance._options;17console.log(mochaOptions);18console.log(mochawesomeOptions);

Full Screen

Using AI Code Generation

copy

Full Screen

1const mochawesome = require('mochawesome-report-generator');2const options = {3};4const report = mochawesome.create(options);5report.then(console.log).catch(console.error);6const mochawesome = require('mochawesome-report-generator');7const options = {8};9const report = mochawesome.create(options);10report.then(console.log).catch(console.error);11const mochawesome = require('mochawesome-report-generator');12const options = {13};14const report = mochawesome.create(options);15report.then(console.log).catch(console.error);16const mochawesome = require('mochawesome-report-generator');17const options = {

Full Screen

Using AI Code Generation

copy

Full Screen

1const Reporter = require('mochawesome/reporter');2const reporter = new Reporter();3const option = reporter._getOption('reportDir');4const Reporter = require('mochawesome/reporter');5const reporter = new Reporter();6const option = reporter._merge({foo: 'bar'}, {bar: 'foo'});7const Reporter = require('mochawesome/reporter');8const reporter = new Reporter();9const option = reporter._getSuite('foo');10const Reporter = require('mochawesome/reporter');11const reporter = new Reporter();12const option = reporter._getTest('foo');13const Reporter = require('mochawesome/reporter');14const reporter = new Reporter();15const option = reporter._getTestResult('foo');16const Reporter = require('mochawesome/reporter');17const reporter = new Reporter();18const option = reporter._getHookResult('foo');19const Reporter = require('mochawesome/reporter');20const reporter = new Reporter();21const option = reporter._getTestOrHook('foo');22const Reporter = require('mochawesome/reporter');23const reporter = new Reporter();24const option = reporter._getTestOrHookResult('foo');25const Reporter = require('mochawesome/reporter');26const reporter = new Reporter();27const option = reporter._getTestOrHookTitle('foo');28const Reporter = require('mochawesome/reporter');29const reporter = new Reporter();30const option = reporter._getTestOrHookDuration('foo');

Full Screen

Using AI Code Generation

copy

Full Screen

1const mochawesome = require('mochawesome');2const reporter = new mochawesome('reporterOptions');3const options = reporter._getOptions();4console.log(options);5{ 6 chartsOptions: { 7 chartjs: { 8 } 9 },10 chartsOptions: { chartjs: { type: 'bar', options: [Object] } },11 chartsOptions: { chartjs: { type: 'bar', options: [Object] } },12}

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run mochawesome 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