How to use eventString method in storybook-root

Best JavaScript code snippet using storybook-root

minibus.js

Source:minibus.js Github

copy

Full Screen

1/*! minibus - v3.1.0 - 2014-11-222 * https://github.com/axelpale/minibus3 *4 * Copyright (c) 2014 Akseli Palen <akseli.palen@gmail.com>;5 * Licensed under the MIT license */6(function (root, factory) {7 'use strict';8 // UMD pattern commonjsStrict.js9 // https://github.com/umdjs/umd10 if (typeof define === 'function' && define.amd) {11 // AMD. Register as an anonymous module.12 define(['exports'], factory);13 } else if (typeof exports === 'object') {14 // CommonJS & Node15 factory(exports);16 } else {17 // Browser globals18 factory((root.Minibus = {}));19 }20}(this, function (exports) {21 'use strict';22// Minibus23//**************24// Constructor *25//**************26var Bus = function () {27 // event string -> sub route map28 this.eventMap = {};29 // route string -> route object30 this.routeMap = {};31 // free namespace shared between the event handlers on the bus.32 this.busContext = {};33};34exports.create = function () {35 return new Bus();36};37// For extendability.38// Usage: Minibus.extension.myFunction = function (...) {...};39exports.extension = Bus.prototype;40//*******************41// Helper functions *42//*******************43var isArray = function (v) {44 return Object.prototype.toString.call(v) === '[object Array]';45};46var isEmpty = function (obj) {47 for (var prop in obj) {48 if (obj.hasOwnProperty(prop)) {49 return false;50 }51 }52 return true;53};54//*************55// Exceptions *56//*************57var InvalidEventStringError = function (eventString) {58 // Usage59 // throw new InvalidEventStringError(eventString)60 this.name = 'InvalidEventStringError';61 this.message = 'Invalid event string given: ' + eventString;62};63var InvalidRouteStringError = function (routeString) {64 // Usage65 // throw new InvalidRouteStringError(routeString)66 this.name = 'InvalidRouteStringError';67 this.message = 'Invalid route string given: ' + routeString;68};69var InvalidEventHandlerError = function (eventHandler) {70 // Usage71 // throw new InvalidEventHandlerError(eventHandler)72 this.name = 'InvalidEventHandlerError';73 this.message = 'Invalid event handler function given: ' + eventHandler;74};75//*******************************************76// Member functions. They all are mutators. *77//*******************************************78var _emit = function (eventString) {79 // Emit an event to execute the bound event handler functions.80 // The event handlers are executed immediately.81 //82 // Parameter83 // eventString84 // Event string or array of event strings.85 // arg1 (optional)86 // Argument to be passed to the handler functions.87 // arg2 (optional)88 // ...89 //90 // Return91 // nothing92 //93 // Throw94 // InvalidEventStringError95 // if given event string is not a string or array of strings.96 //97 var emitArgs, i, subRouteMap, routeString, eventHandlers, busContext;98 // Turn to array for more general code.99 if (!isArray(eventString)) {100 eventString = [eventString];101 }102 // Validate all eventStrings before mutating anything.103 // This makes the on call more atomic.104 for (i = 0; i < eventString.length; i += 1) {105 if (typeof eventString[i] !== 'string') {106 throw new InvalidEventStringError(eventString[i]);107 }108 }109 // Collect passed arguments after the eventString argument.110 emitArgs = [];111 for (i = 1; i < arguments.length; i += 1) {112 emitArgs.push(arguments[i]);113 }114 // Collect all the event handlers bound to the given eventString115 eventHandlers = [];116 for (i = 0; i < eventString.length; i += 1) {117 if (this.eventMap.hasOwnProperty(eventString[i])) {118 subRouteMap = this.eventMap[eventString[i]];119 for (routeString in subRouteMap) {120 if (subRouteMap.hasOwnProperty(routeString)) {121 eventHandlers.push(subRouteMap[routeString].eventHandler);122 }123 }124 }125 }126 // Apply the event handlers.127 // All event handlers on the bus share a same bus context.128 busContext = this.busContext;129 for (i = 0; i < eventHandlers.length; i += 1) {130 eventHandlers[i].apply(busContext, emitArgs);131 }132};133// See Node.js events.EventEmitter.emit134Bus.prototype.emit = _emit;135// See Backbone.js Events.trigger136Bus.prototype.trigger = _emit;137// See Mozilla Web API EventTarget.dispatchEvent138// See http://stackoverflow.com/a/10085161/638546139// Uncomment to enable. Too lengthy to be included by default.140//Bus.prototype.dispatchEvent = _emit;141// See http://stackoverflow.com/a/9672223/638546142// Uncomment to enable. Too rare to be included by default.143//Bus.prototype.fireEvent = _emit;144var _on = function (eventString, eventHandler) {145 // Bind an event string(s) to an event handler function.146 //147 // Parameter148 // eventString149 // Event string or array of event strings.150 // Empty array is ok but does nothing.151 // eventHandler152 // Event handler function to be executed when the event is emitted.153 //154 // Throw155 // InvalidEventStringError156 // InvalidEventHandlerError157 //158 // Return159 // a route string or an array of route strings160 //161 var wasArray, i, routeObject, routeString, routeStringArray;162 // Turn to array for more general code.163 // Store whether parameter was array to return right type of value.164 wasArray = isArray(eventString);165 if (!wasArray) {166 eventString = [eventString];167 }168 // Validate all eventStrings before mutating anything.169 // This makes the on call more atomic.170 for (i = 0; i < eventString.length; i += 1) {171 if (typeof eventString[i] !== 'string') {172 throw new InvalidEventStringError(eventString[i]);173 }174 }175 // Validate the eventHandler176 if (typeof eventHandler !== 'function') {177 throw new InvalidEventHandlerError(eventHandler);178 }179 routeStringArray = [];180 for (i = 0; i < eventString.length; i += 1) {181 routeObject = {182 eventString: eventString[i],183 eventHandler: eventHandler184 };185 routeString = Identity.create();186 routeStringArray.push(routeString);187 if (!this.eventMap.hasOwnProperty(eventString[i])) {188 this.eventMap[eventString[i]] = {};189 }190 this.eventMap[eventString[i]][routeString] = routeObject;191 this.routeMap[routeString] = routeObject;192 }193 if (wasArray) {194 return routeStringArray;195 } // else196 return routeStringArray[0];197};198// See Backbone.js Events.on199// See Node.js events.EventEmitter.on200Bus.prototype.on = _on;201// See http://stackoverflow.com/a/9672223/638546202Bus.prototype.listen = _on;203// See Node.js events.EventEmitter.addListener204// Uncomment to enable. Too lengthy to be included by default.205//Bus.prototype.addListener = _on;206// See Mozilla Web API EventTarget.addEventListener207// See http://stackoverflow.com/a/11237657/638546208// Uncomment to enable. Too lengthy to be included by default.209//Bus.prototype.addEventListener = _on;210var _once = function (eventString, eventHandler) {211 // Like _on but reacts to emit only once.212 //213 // Parameter214 // See _on215 //216 // Return217 // See _on218 //219 // Throw220 // InvalidEventStringError221 // InvalidEventHandlerError222 //223 var that, routeString, called;224 // Validate the eventHandler. On does the validation also.225 // Duplicate validation is required because a wrapper function226 // is feed into on instead the given eventHandler.227 if (typeof eventHandler !== 'function') {228 throw new InvalidEventHandlerError(eventHandler);229 }230 that = this;231 called = false;232 routeString = this.on(eventString, function () {233 if (!called) {234 called = true; // Required to prevent duplicate sync calls235 that.off(routeString);236 // Apply. Use the context given by emit to embrace code dryness.237 eventHandler.apply(this, arguments);238 }239 });240 return routeString;241};242// See Node.js events.EventEmitter.once243// See Backbone.js Events.once244Bus.prototype.once = _once;245var _off = function (routeString) {246 // Unbind one or many event handlers.247 //248 // Parameter249 // routeString250 // A route string or an array of route strings or251 // an array of arrays of route strings.252 // The route to be shut down.253 //254 // Parameter (Alternative)255 // eventString256 // An event string or an array of event strings or257 // an array of arrays of event strings.258 // Shut down all the routes with this event string.259 //260 // Parameter (Alternative)261 // (nothing)262 // Shut down all the routes i.e. unbind all the event handlers.263 //264 // Throws265 // InvalidRouteStringError266 //267 // Return268 // nothing269 //270 var noArgs, i, routeObject, eventString, subRouteMap, rs;271 noArgs = (typeof routeString === 'undefined');272 if (noArgs) {273 this.routeMap = {};274 this.eventMap = {};275 return;276 }277 // Turn to array for more general code.278 if (!isArray(routeString)) {279 routeString = [routeString];280 }281 // Flatten arrays to allow arrays of arrays of route strings.282 // This is needed if user wants to off an array of routes. Some routes283 // might be arrays or route strings because 'on' interface.284 // http://stackoverflow.com/a/10865042/638546285 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/286 // Reference/Global_Objects/Array/concat287 var flat = [];288 flat = flat.concat.apply(flat, routeString);289 routeString = flat;290 // Validate all routeStrings before mutating anything.291 // This makes the off call more atomic.292 for (i = 0; i < routeString.length; i += 1) {293 if (typeof routeString[i] !== 'string') {294 throw new InvalidRouteStringError(routeString[i]);295 }296 }297 for (i = 0; i < routeString.length; i += 1) {298 if (this.routeMap.hasOwnProperty(routeString[i])) {299 routeObject = this.routeMap[routeString[i]];300 delete this.routeMap[routeString[i]];301 delete this.eventMap[routeObject.eventString][routeString[i]];302 // Remove sub route map from the event map if it is empty.303 // This prevents outdated eventStrings piling up on the eventMap.304 if (isEmpty(this.eventMap[routeObject.eventString])) {305 delete this.eventMap[routeObject.eventString];306 }307 } else {308 // As eventString309 eventString = routeString[i];310 if (this.eventMap.hasOwnProperty(eventString)) {311 subRouteMap = this.eventMap[eventString];312 for (rs in subRouteMap) {313 if (subRouteMap.hasOwnProperty(rs)) {314 delete this.routeMap[rs];315 }316 }317 delete this.eventMap[eventString];318 }319 }320 }321 // Assert: event handlers and their routes removed.322};323// Backbone.js Events.off324Bus.prototype.off = _off;325// Node.js events.EventEmitter.removeListener326Bus.prototype.removeListener = _off;327// See Mozilla Web API EventTarget.removeEventListener328// Uncomment to enable. Too lengthy to be included by default.329//Bus.prototype.removeEventListener = _off;330var Identity = (function () {331 // A utility for creating unique strings for identification.332 // Abstracts how uniqueness is archieved.333 //334 // Usages335 // >>> Identity.create();336 // '532402059994638'337 // >>> Identity.create();338 // '544258285779506'339 //340 var exports = {};341 /////////////////342 exports.create = function () {343 return Math.random().toString().substring(2);344 };345 ///////////////346 return exports;347}());348 // Version349 exports.version = '3.1.0';350// End of intro...

Full Screen

Full Screen

medals.js

Source:medals.js Github

copy

Full Screen

1var fadeTime = 800;2var animTime = 18;3var removeTime = 4500;4var medalsPath = 'medals://';5var playQueue = [];6var eventJSONCache;7var playVol;8var suppressRepeat = false;9var medalWidth = '3.5vw';10var leftPos = '6.78vw';11var bottomPos = '32vh';12var transform = 'skew(0,-2.75deg)'; 13var juggleEvent = 0;14var juggleDelay = 3000;15var settingsArray = { 'Game.CefMedals': '1', 'Game.MedalPack': 'default', 'Game.SuppressJuggling': '0', 'Settings.MasterVolume': '50', 'Settings.SfxVolume': '100' };16dew.on("mpevent", function (event) {17 if(settingsArray['Game.CefMedals'] == 1){18 medalsPath = "medals://" + settingsArray['Game.MedalPack'] + "/";19 if(!eventJSONCache){20 $.getJSON(medalsPath+'events.json', function(json) {21 eventJSONCache = json;22 parseEvent(event);23 });24 }else{25 parseEvent(event);26 }27 }28});29function parseEvent(event){30 if(settingsArray['Game.SuppressJuggling'] == 1){31 suppressRepeat = true;32 } else {33 suppressRepeat = false;34 }35 var sfxVol = settingsArray['Settings.MasterVolume']/100;36 var mstrVol = settingsArray['Settings.SfxVolume']/100;37 playVol = sfxVol * mstrVol * 0.3;38 var medal = event.data.name;39 if(suppressRepeat && ( medal.startsWith('ctf_event_flag_') || medal.startsWith('assault_event_bomb_') || medal.startsWith('oddball_event_ball') || medal.startsWith('king_event_hill_c'))){40 juggleEvent++;41 setTimeout(function(){42 if(juggleEvent > 0){ juggleEvent--; }43 }, juggleDelay);44 } 45 if(juggleEvent > 2 && ((medal.startsWith('oddball_event_ball') && (medal != 'oddball_event_ball_spawned' && medal != 'oddball_event_ball_reset')) || (medal.startsWith('ctf_event_flag_') && medal != 'ctf_event_flag_captured')||(medal.startsWith('assault_event_bomb_') && medal != 'assault_event_bomb_placed_on_enemy_post') || medal.startsWith('king_event_hill_c'))){46 return47 }48 doMedal(event.data.name, event.data.audience); 49}50$.fn.pulse = function() { 51 var i = 0.5, x = 0, medal = this.selector;52 function pulseLoop(medal) { 53 setTimeout(function () { 54 $(medal).css({'transform': 'scale('+ i +','+ i +')', 'opacity': x });55 i+=0.1, x+=0.4;56 if (i < 1.5) { 57 pulseLoop(medal);58 } else if (i = 1.5) {59 $(medal).css({'transform' : 'scale(1.2,1.2)'}); 60 setTimeout(function () { 61 $(medal).css({'transform' : 'scale(1,1)'}); 62 }, animTime)63 } 64 }, animTime)65 }66 pulseLoop(medal);67};68function queue_audio(audio){69 playQueue.push(medalsPath + 'audio/' + audio);70 playQueue.splice(4, Infinity);71 if(!isPlaying){72 play(playQueue[0]); 73 }74}75var isPlaying = false;76function play(audio){77 isPlaying = true;78 var audioElement = new Audio(audio);79 audioElement.play();80 audioElement.volume = playVol;81 audioElement.onended = function(){82 advanceQueue();83 }84 audioElement.onerror = function(){ 85 advanceQueue();86 }; 87 function advanceQueue(){88 isPlaying = false;89 playQueue.splice(0, 1);90 if(playQueue.length > 0){91 play(playQueue[0]); 92 }93 }94}95var medalNum = 0;96function display_medal(medal){97 dew.show();98 $('#medalBox').css({99 left:leftPos,100 bottom: bottomPos, 101 transform: transform102 });103 var currentMedalNum = medalNum;104 $('<img />', { 105 id: currentMedalNum,106 src: medalsPath + 'images/' + medal,107 css: {108 width: medalWidth109 }110 }).prependTo($('#medalBox'));111 $("#"+currentMedalNum).pulse();112 setTimeout(function(){113 $("#"+currentMedalNum).fadeOut(fadeTime, function() { 114 $("#"+currentMedalNum).remove(); 115 if(!$('#medalBox img').length){116 dew.hide(); 117 }118 });119 }, removeTime);120 medalNum++;121}122function doMedal(eventString, audience){123 //console.log(eventString+', '+audience);124 if(eventJSONCache[eventString]){125 switch(audience){126 case 0:127 if(eventJSONCache[eventString].hasOwnProperty('cause_player')){128 if(eventJSONCache[eventString].cause_player.hasOwnProperty('image')){129 if(typeof eventJSONCache[eventString].cause_player.image === 'string'){130 display_medal(eventJSONCache[eventString].cause_player.image);131 }132 else{133 var items = eventJSONCache[eventString].cause_player.image;134 display_medal(items[Math.floor(Math.random()*items.length)]);135 }136 }137 if(eventJSONCache[eventString].cause_player.hasOwnProperty('sound')){138 if(typeof eventJSONCache[eventString].cause_player.sound === 'string'){139 queue_audio(eventJSONCache[eventString].cause_player.sound); 140 }141 else{142 var items = eventJSONCache[eventString].cause_player.sound;143 queue_audio(items[Math.floor(Math.random()*items.length)]);144 }145 }146 }147 break;148 case 1:149 if(eventJSONCache[eventString].hasOwnProperty('cause_team')){150 if(eventJSONCache[eventString].cause_team.hasOwnProperty('image')){151 if(typeof eventJSONCache[eventString].cause_team.image === 'string'){152 display_medal(eventJSONCache[eventString].cause_team.image);153 }154 else{155 var items = eventJSONCache[eventString].cause_team.image;156 display_medal(items[Math.floor(Math.random()*items.length)]);157 }158 }159 if(eventJSONCache[eventString].cause_team.hasOwnProperty('sound')){160 if(typeof eventJSONCache[eventString].cause_team.sound === 'string'){161 queue_audio(eventJSONCache[eventString].cause_team.sound); 162 }163 else{164 var items = eventJSONCache[eventString].cause_team.sound;165 queue_audio(items[Math.floor(Math.random()*items.length)]);166 }167 }168 }169 break;170 case 2:171 if(eventJSONCache[eventString].hasOwnProperty('effect_player')){172 if(eventJSONCache[eventString].effect_player.hasOwnProperty('image')){173 if(typeof eventJSONCache[eventString].effect_player.image === 'string'){174 display_medal(eventJSONCache[eventString].effect_player.image);175 }176 else{177 var items = eventJSONCache[eventString].effect_player.image;178 display_medal(items[Math.floor(Math.random()*items.length)]);179 }180 }181 if(eventJSONCache[eventString].effect_player.hasOwnProperty('sound')){182 if(typeof eventJSONCache[eventString].effect_player.sound === 'string'){183 queue_audio(eventJSONCache[eventString].effect_player.sound); 184 }185 else{186 var items = eventJSONCache[eventString].effect_player.sound;187 queue_audio(items[Math.floor(Math.random()*items.length)]);188 }189 }190 }191 break;192 case 3:193 if(eventJSONCache[eventString].hasOwnProperty('effect_team')){194 if(eventJSONCache[eventString].effect_team.hasOwnProperty('image')){195 if(typeof eventJSONCache[eventString].effect_team.image === 'string'){196 display_medal(eventJSONCache[eventString].effect_team.image);197 }198 else{199 var items = eventJSONCache[eventString].effect_team.image;200 display_medal(items[Math.floor(Math.random()*items.length)]);201 }202 }203 if(eventJSONCache[eventString].effect_team.hasOwnProperty('sound')){204 if(typeof eventJSONCache[eventString].effect_team.sound === 'string'){205 queue_audio(eventJSONCache[eventString].effect_team.sound); 206 }207 else{208 var items = eventJSONCache[eventString].effect_team.sound;209 queue_audio(items[Math.floor(Math.random()*items.length)]);210 }211 }212 }213 break;214 case 4:215 if(eventJSONCache[eventString].hasOwnProperty('image')){216 if(typeof eventJSONCache[eventString].image === 'string'){217 display_medal(eventJSONCache[eventString].image);218 }219 else{220 var items = eventJSONCache[eventString].image;221 display_medal(items[Math.floor(Math.random()*items.length)]);222 }223 }224 if(eventJSONCache[eventString].hasOwnProperty('sound')){225 if(typeof eventJSONCache[eventString].sound === 'string'){226 queue_audio(eventJSONCache[eventString].sound); 227 }228 else{229 var items = eventJSONCache[eventString].sound;230 queue_audio(items[Math.floor(Math.random()*items.length)]);231 }232 }233 break;234 }235 }236}237dew.on("variable_update", function(e){238 for(i = 0; i < e.data.length; i++){239 if(e.data[i].name in settingsArray){240 settingsArray[e.data[i].name] = e.data[i].value;241 if(e.data[i].name == "Game.MedalPack"){242 eventJSONCache = null;243 }244 }245 }246});247$(document).ready(function(){248 loadSettings(0);249})250function loadSettings(i){251 if (i != Object.keys(settingsArray).length) {252 dew.command(Object.keys(settingsArray)[i], {}).then(function(response) {253 settingsArray[Object.keys(settingsArray)[i]] = response;254 i++;255 loadSettings(i);256 });257 }...

Full Screen

Full Screen

event-text.js

Source:event-text.js Github

copy

Full Screen

1// For simplicity this calendar has no backend.2// An event is displayed as a sentence below the event creation dialogue3// with the details of the event in readable English.4/////////////////////////////////////////////////////////////////////////////5// New Event Creation6/////////////////////////////////////////////////////////////////////////////7$(function() {8 $('#create-event-button').click(function() {9 if (checkInputs()) {10 $('#create-event-button').trigger('log', ['event created', {}]);11 writeEventToScreen(getEventText());12 }13 });14});15// End time must come after start time16function isValidEndTime() {17 var startTime = $('#event-start-date').datetimepicker('getValue');18 var endTime = $('#event-end-date').datetimepicker('getValue');19 return !(endTime < startTime);20}21function checkInputs() {22 if (!isValidEndTime()) {23 writeEventToScreen('End date must come after start date.');24 return false;25 }26 var frequency = $('#' + $('input[name=recurrent-event-time-selector]:checked').val() + '-recurrent-freq').val();27 console.log(frequency);28 if (!$.isNumeric(frequency)) {29 writeEventToScreen('Frequency must be a numeric value.');30 return false;31 }32 return true;33}34// Functions for building the event string35function getWeeklyRepeatingDays() {36 var days = [];37 var weekdayIds = ['#weekday-sun', '#weekday-mon', '#weekday-tue', '#weekday-wed', '#weekday-thu', '#weekday-fri', 38 '#weekday-sat'];39 var weekdays = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];40 for (i = 0; i < weekdayIds.length; i++) {41 if ($(weekdayIds[i]).is(':checked')) {42 days.push(weekdays[i]);43 }44 }45 return days;46}47function getMonthlyRepeatingDays() {48 var days = [];49 var monthdayIds = ['#month-1', '#month-2', '#month-3', '#month-4', '#month-5', '#month-6', '#month-7', '#month-8',50 '#month-9', '#month-10', '#month-11', '#month-12', '#month-13', '#month-14', '#month-15', '#month-16',51 '#month-17', '#month-18', '#month-19', '#month-20', '#month-21', '#month-22', '#month-23', '#month-24',52 '#month-25', '#month-26', '#month-27', '#month-28', '#month-29', '#month-30', '#month-31'];53 for (i = 0; i < monthdayIds.length; i++) {54 if ($(monthdayIds[i]).is(':checked')) {55 days.push(i+1);56 }57 }58 return days;59}60function getYearlyRepeatingMonths() {61 var months = [];62 var monthIds = ['#year-jan', '#year-feb', '#year-mar', '#year-apr', '#year-may', '#year-jun', '#year-jul', 63 '#year-aug', '#year-sept', '#year-oct', '#year-nov', '#year-dec'];64 var monthsNames = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];65 for (i = 0; i < monthIds.length; i++) {66 if ($(monthIds[i]).is(':checked')) {67 months.push(monthsNames[i]);68 }69 }70 return months;71}72function getWeeklyRepeatingString(arr) {73 var eventString = 'on every ';74 for (i = 0; i < arr.length-1; i++) {75 eventString += arr[i] + ', ';76 }77 if (arr.length > 1) {78 eventString += 'and ';79 }80 eventString += arr[arr.length-1] + ' of the week ';81 return eventString;82}83function getMonthlyRepeatingString(arr) {84 var eventString = 'on the ';85 for (i = 0; i < arr.length-1; i++) {86 eventString += arr[i] + ', ';87 }88 if (arr.length > 1) {89 eventString += 'and ';90 }91 eventString += arr[arr.length-1] + ' of the month ';92 return eventString;93}94function getYearlyRepeatingString(arr) {95 var eventString = 'in ';96 for (i = 0; i < arr.length-1; i++) {97 eventString += arr[i] + ', ';98 }99 if (arr.length > 1) {100 eventString += 'and ';101 }102 eventString += arr[arr.length-1] + ' on the corresponding day of the month(s) ';103 return eventString;104}105function getEventText() {106 var a=document.getElementById('event-location').value;107 var b=document.getElementById('event-name').value;108 var c=document.getElementById('event-start-date').value;109 var d=document.getElementById('event-end-date').value;110 var e=document.getElementById('all-day-event-date').value;111 var f=document.getElementById('recurrent-event-end-date').value;112 113 if(a=='' || b==''){114 var eventstring='Please Enter all the required fields';115 return eventstring;116 117 }118 else if(a!='' && b!='' && e!=''){119 var eventName = $('#event-name').val();120 var eventLocation = $('#event-location').val();121 122 var eventString = 'Event created: ' + eventName + ' at ' + eventLocation + ', ';123 var allDayEvent = $('#all-day-event-checkbox').is(':checked');124 if (allDayEvent) {125 var eventDate = $('#all-day-event-date').datetimepicker('getValue');126 eventString += 'an all day event on ' + eventDate;127 } else {128 var startTime = $('#event-start-date').datetimepicker('getValue');129 var endTime = $('#event-end-date').datetimepicker('getValue');130 eventString += 'starting at ' + startTime + ' and ending at ' + endTime;131 }132 var repeatOption = $('input[name=r]:checked').val();133 if (repeatOption == 'none') {134 eventString += '.';135 return eventString;136 } else if (repeatOption == 'day') {137 eventString += ', repeating every day ';138 } else if (repeatOption == 'week') {139 eventString += ', repeating every week ';140 } else if (repeatOption == 'month') {141 eventString += ', repeating every month ';142 } else if (repeatOption == 'year') {143 eventString += ', repeating every year ';144 } else { // custom145 var frequencyOption =$('input[name=recurrent-event-time-selector]:checked').val();146 var frequency = 1;147 var repeatingUnits = [];148 if (frequencyOption == 'daily') {149 frequency = $('#daily-recurrent-freq').val();150 eventString += ', ' + 'repeating every ' + frequency + ' day(s) ';151 } else if (frequencyOption == 'weekly') {152 frequency = $('#weekly-recurrent-freq').val();153 repeatingUnits = getWeeklyRepeatingDays();154 eventString += ', ' + 'repeating every ' + frequency + ' week(s) ' + getWeeklyRepeatingString(repeatingUnits);155 } else if (frequencyOption == 'monthly') {156 frequency = $('#monthly-recurrent-freq').val();157 repeatingUnits = getMonthlyRepeatingDays();158 eventString += ', ' + 'repeating every ' + frequency + ' month(s) ' + getMonthlyRepeatingString(repeatingUnits);159 } else { // yearly160 frequency = $('#yearly-recurrent-freq').val();161 repeatingUnits = getYearlyRepeatingMonths();162 eventString += ', ' + 'repeating every ' + frequency + ' year(s) ' + getYearlyRepeatingString(repeatingUnits);163 }164 }165 var endDate = $('#recurrent-event-end-date').datetimepicker('getValue');166 eventString += 'until ' + endDate + '.';167 return eventString;168}169if(c=='' || d==''){170 var eventstring='Please Enter all the required fields';171 return eventstring;172}173else if( c!='' && d!='' && a!='' && b!='')174{175 var eventName = $('#event-name').val();176 var eventLocation = $('#event-location').val();177 178 var eventString = 'Event created: ' + eventName + ' at ' + eventLocation + ', ';179 var allDayEvent = $('#all-day-event-checkbox').is(':checked');180 if (allDayEvent) {181 var eventDate = $('#all-day-event-date').datetimepicker('getValue');182 eventString += 'an all day event on ' + eventDate;183 } else {184 var startTime = $('#event-start-date').datetimepicker('getValue');185 var endTime = $('#event-end-date').datetimepicker('getValue');186 eventString += 'starting at ' + startTime + ' and ending at ' + endTime;187 }188 var repeatOption = $('input[name=r]:checked').val();189 if (repeatOption == 'none') {190 eventString += '.';191 return eventString;192 } else if (repeatOption == 'day') {193 eventString += ', repeating every day ';194 } else if (repeatOption == 'week') {195 eventString += ', repeating every week ';196 } else if (repeatOption == 'month') {197 eventString += ', repeating every month ';198 } else if (repeatOption == 'year') {199 eventString += ', repeating every year ';200 } else { // custom201 var frequencyOption = $('input[name=recurrent-event-time-selector]:checked').val();202 var frequency = 1;203 var repeatingUnits = [];204 if (frequencyOption == 'daily') {205 frequency = $('#daily-recurrent-freq').val();206 eventString += ', ' + 'repeating every ' + frequency + ' day(s) ';207 } else if (frequencyOption == 'weekly') {208 frequency = $('#weekly-recurrent-freq').val();209 repeatingUnits = getWeeklyRepeatingDays();210 eventString += ', ' + 'repeating every ' + frequency + ' week(s) ' + getWeeklyRepeatingString(repeatingUnits);211 } else if (frequencyOption == 'monthly') {212 frequency = $('#monthly-recurrent-freq').val();213 repeatingUnits = getMonthlyRepeatingDays();214 eventString += ', ' + 'repeating every ' + frequency + ' month(s) ' + getMonthlyRepeatingString(repeatingUnits);215 } else { // yearly216 frequency = $('#yearly-recurrent-freq').val();217 repeatingUnits = getYearlyRepeatingMonths();218 eventString += ', ' + 'repeating every ' + frequency + ' year(s) ' + getYearlyRepeatingString(repeatingUnits);219 }220 }221 var endDate = $('#recurrent-event-end-date').datetimepicker('getValue');222 eventString += 'until ' + endDate + '.';223 return eventString;224}225if(e=='' || a=='' || b==''){226 var eventstring='Please Enter all the required fields';227 return eventstring;228 }229}230function writeEventToScreen(eventString) {231 $('#new-event-text').text(eventString);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from 'react';2import { storiesOf } from '@storybook/react';3import { action } from '@storybook/addon-actions';4import { linkTo } from '@storybook/addon-links';5import { withInfo } from '@storybook/addon-info';6import { Button, Welcome } from '@storybook/react/demo';7import { withEventString } from 'storybook-root';8const eventString = withEventString();9storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);10storiesOf('Button', module)11 .add(12 withInfo()(() => (13 <Button onClick={eventString(action('clicked'))}>Hello Button</Button>14 .add(15 withInfo()(() => (16 <Button onClick={eventString(action('clicked'))}>17 );

Full Screen

Using AI Code Generation

copy

Full Screen

1import React from 'react';2import { storiesOf } from '@storybook/react';3import { linkTo } from '@storybook/addon-links';4import { Welcome } from '@storybook/react/demo';5import { withKnobs, text, boolean, number } from '@storybook/addon-knobs';6import { withInfo } from '@storybook/addon-info';7import { action } from '@storybook/addon-actions';8import { withNotes } from '@storybook/addon-notes';9storiesOf('Welcome', module).add('to Storybook', () => <Welcome showApp={linkTo('Button')} />);10storiesOf('Button', module)11 .addDecorator(withKnobs)12 .addDecorator(withInfo)13 .addDecorator(withNotes)14 .add('with text', () => (15 <button onClick={action('clicked')}>{text('Label', 'Hello Button')}</button>16 .add('with some emoji', () => (17 <button onClick={action('clicked')}>{text('Label', 'πŸ˜€ 😎 πŸ‘ πŸ’―')}</button>18 .add('with some emoji and action', () => (19 <button onClick={action('clicked')}>{text('Label', 'πŸ˜€ 😎 πŸ‘ πŸ’―')}</button>20 .add('with some emoji and action', () => (21 <button onClick={action('clicked')}>{text('Label', 'πŸ˜€ 😎 πŸ‘ πŸ’―')}</button>22 .add('with some emoji and action', () => (23 <button onClick={action('clicked')}>{text('Label', 'πŸ˜€ 😎 πŸ‘ πŸ’―')}</button>24 .add('with some emoji and action', () => (25 <button onClick={action('clicked')}>{text('Label', 'πŸ˜€ 😎 πŸ‘ πŸ’―')}</button>26 .add('with some emoji and action', () => (27 <button onClick={action('clicked')}>{text('Label', 'πŸ˜€ 😎 πŸ‘ πŸ’―')}</button>28 .add('with some emoji and action', () => (29 <button onClick={action('clicked')}>{text('Label', 'πŸ˜€ 😎 πŸ‘ πŸ’―')}</button>30 .add('with some emoji and action', () => (31 <button onClick={action('clicked')}>{text('Label', 'πŸ˜€ 😎

Full Screen

Using AI Code Generation

copy

Full Screen

1import { eventString } from 'storybook-root';2console.log(eventString);3import { eventString } from 'storybook-root';4console.log(eventString);5import { eventString } from 'storybook-root';6console.log(eventString);7import { eventString } from 'storybook-root';8console.log(eventString);9import { eventString } from 'storybook-root';10console.log(eventString);11import { eventString } from 'storybook-root';12console.log(eventString);

Full Screen

Using AI Code Generation

copy

Full Screen

1import { eventString } from 'storybook-root'2import { storiesOf } from '@storybook/react'3storiesOf('Test', module).add('test', () => {4 return <div>{eventString}</div>5})6import { configure } from '@storybook/react'7import { addParameters } from '@storybook/react'8import { addDecorator } from '@storybook/react'9import { withA11y } from '@storybook/addon-a11y'10import { withInfo } from '@storybook/addon-info'11import { withKnobs } from '@storybook/addon-knobs'12import { withTests } from '@storybook/addon-jest'13import { withConsole } from '@storybook/addon-console'14import { withOptions } from '@storybook/addon-options'15import { withViewport } from '@storybook/addon-viewport'16import { withBackgrounds } from '@storybook/addon-backgrounds'17import { withStorysource } from '@storybook/addon-storysource'18import { withActions } from '@storybook/addon-actions'19import { withLinks } from '@storybook/addon-links'20import { withNotes } from '@storybook/addon-notes'21import { withOptions } from '@storybook/addon-options'22import { setOptions } from '@storybook/addon-options'23import { setDefaults } from '@storybook/addon-info'24import { setDefaults } from '@storybook/addon-knobs'25import { setConsoleOptions } from '@storybook/addon-console'26import { setDefaults } from '@storybook/addon-backgrounds'27import { setDefaults } from '@storybook/addon-viewport'28import { setDefaults } from '@storybook/addon-storysource'29import { setDefaults } from '@storybook/addon-notes'30import { setDefaults } from '@storybook/addon-options'31import { themes } from '@storybook/components'32import { setOptions } from '@storybook/addon-options'33import { setDefaults } from '@storybook/addon-info'34import { setDefaults } from '@storybook/addon-knobs'35import { setConsoleOptions } from '@storybook/addon-console'36import { setDefaults } from '@storybook/addon-backgrounds'37import { setDefaults } from '@storybook/addon-viewport'38import { setDefaults } from '@storybook/addon-storysource'39import { setDefaults } from '@storybook/addon-notes'40import { setDefaults } from '@storybook/addon-options

Full Screen

Using AI Code Generation

copy

Full Screen

1var storybook = require('storybook-root');2var story = storybook.story('My Story');3story.eventString();4var storybook = require('storybook-root');5var story = storybook.story('My Story');6story.eventString();7var storybook = require('storybook-root');8var story = storybook.story('My Story');9story.eventString();10var storybook = require('storybook-root');11var story = storybook.story('My Story');12story.eventString();13var storybook = require('storybook-root');14var story = storybook.story('My Story');15story.eventString();16var storybook = require('storybook-root');17var story = storybook.story('My Story');18story.eventString();19var storybook = require('storybook-root');20var story = storybook.story('My Story');21story.eventString();22var storybook = require('storybook-root');23var story = storybook.story('My Story');24story.eventString();25var storybook = require('storybook-root');26var story = storybook.story('My Story');27story.eventString();28var storybook = require('storybook-root');29var story = storybook.story('My Story');30story.eventString();31var storybook = require('storybook-root');32var story = storybook.story('My Story');33story.eventString();34var storybook = require('storybook-root');35var story = storybook.story('My Story');36story.eventString();37var storybook = require('storybook

Full Screen

Using AI Code Generation

copy

Full Screen

1import { eventString } from 'storybook-root';2import { eventString } from 'storybook-root';3import { eventString } from 'storybook-root';4import { eventString } from 'storybook-root';5import { eventString } from 'storybook-root';6import { eventString } from 'storybook-root';7import { eventString } from 'storybook-root';8import { eventString } from 'storybook-root';9import { eventString } from 'storybook-root';10import { eventString } from 'storybook-root';11import { eventString } from 'storybook-root';12import { eventString } from 'storybook-root';13import { eventString } from 'storybook-root';14import { eventString } from 'storybook-root';15import { eventString } from 'storybook-root';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { eventString } from 'storybook-root';2const log = eventString('test', 'test');3log('test');4export * from './src';5export const eventString = (event, message) => {6 return (value) => {7 console.log(event, message, value);8 };9};10export const eventString = (event, message) => {11 return (value) => {12 console.log(event, message, value);13 };14};15export const eventString = (event, message) => {16 return (value) => {17 console.log(event, message, value);18 };19};20export const eventString = (event, message) => {21 return (value) => {22 console.log(event, message, value);23 };24};25export const eventString = (event, message) => {26 return (value) => {27 console.log(event, message, value);28 };29};30export const eventString = (event, message) => {31 return (value) => {32 console.log(event, message, value);33 };34};35export const eventString = (event, message) => {36 return (value) => {37 console.log(event, message, value);38 };39};40export const eventString = (event, message) => {41 return (value) => {42 console.log(event, message, value);43 };44};45export const eventString = (event, message) => {46 return (value) => {47 console.log(event, message, value);48 };49};

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 storybook-root 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