Best JavaScript code snippet using stryker-parent
quickedit.js
Source:quickedit.js
1/**2* DO NOT EDIT THIS FILE.3* See the following change record for more information,4* https://www.drupal.org/node/28150835* @preserve6**/7(function ($, _, Backbone, Drupal, drupalSettings, JSON, storage) {8 var options = $.extend(drupalSettings.quickedit, {9 strings: {10 quickEdit: Drupal.t('Quick edit')11 }12 });13 var fieldsMetadataQueue = [];14 var fieldsAvailableQueue = [];15 var contextualLinksQueue = [];16 var entityInstancesTracker = {};17 function initQuickEdit(bodyElement) {18 Drupal.quickedit.collections.entities = new Drupal.quickedit.EntityCollection();19 Drupal.quickedit.collections.fields = new Drupal.quickedit.FieldCollection();20 Drupal.quickedit.app = new Drupal.quickedit.AppView({21 el: bodyElement,22 model: new Drupal.quickedit.AppModel(),23 entitiesCollection: Drupal.quickedit.collections.entities,24 fieldsCollection: Drupal.quickedit.collections.fields25 });26 }27 function processEntity(entityElement) {28 var entityID = entityElement.getAttribute('data-quickedit-entity-id');29 if (!entityInstancesTracker.hasOwnProperty(entityID)) {30 entityInstancesTracker[entityID] = 0;31 } else {32 entityInstancesTracker[entityID]++;33 }34 var entityInstanceID = entityInstancesTracker[entityID];35 entityElement.setAttribute('data-quickedit-entity-instance-id', entityInstanceID);36 }37 function initializeField(fieldElement, fieldID, entityID, entityInstanceID) {38 var entity = Drupal.quickedit.collections.entities.findWhere({39 entityID: entityID,40 entityInstanceID: entityInstanceID41 });42 $(fieldElement).addClass('quickedit-field');43 var field = new Drupal.quickedit.FieldModel({44 el: fieldElement,45 fieldID: fieldID,46 id: "".concat(fieldID, "[").concat(entity.get('entityInstanceID'), "]"),47 entity: entity,48 metadata: Drupal.quickedit.metadata.get(fieldID),49 acceptStateChange: _.bind(Drupal.quickedit.app.acceptEditorStateChange, Drupal.quickedit.app)50 });51 Drupal.quickedit.collections.fields.add(field);52 }53 function loadMissingEditors(callback) {54 var loadedEditors = _.keys(Drupal.quickedit.editors);55 var missingEditors = [];56 Drupal.quickedit.collections.fields.each(function (fieldModel) {57 var metadata = Drupal.quickedit.metadata.get(fieldModel.get('fieldID'));58 if (metadata.access && _.indexOf(loadedEditors, metadata.editor) === -1) {59 missingEditors.push(metadata.editor);60 Drupal.quickedit.editors[metadata.editor] = false;61 }62 });63 missingEditors = _.uniq(missingEditors);64 if (missingEditors.length === 0) {65 callback();66 return;67 }68 var loadEditorsAjax = Drupal.ajax({69 url: Drupal.url('quickedit/attachments'),70 submit: {71 'editors[]': missingEditors72 }73 });74 var realInsert = Drupal.AjaxCommands.prototype.insert;75 loadEditorsAjax.commands.insert = function (ajax, response, status) {76 _.defer(callback);77 realInsert(ajax, response, status);78 };79 loadEditorsAjax.execute();80 }81 function initializeEntityContextualLink(contextualLink) {82 var metadata = Drupal.quickedit.metadata;83 function hasFieldWithPermission(fieldIDs) {84 for (var i = 0; i < fieldIDs.length; i++) {85 var fieldID = fieldIDs[i];86 if (metadata.get(fieldID, 'access') === true) {87 return true;88 }89 }90 return false;91 }92 function allMetadataExists(fieldIDs) {93 return fieldIDs.length === metadata.intersection(fieldIDs).length;94 }95 var fields = _.where(fieldsAvailableQueue, {96 entityID: contextualLink.entityID,97 entityInstanceID: contextualLink.entityInstanceID98 });99 var fieldIDs = _.pluck(fields, 'fieldID');100 if (fieldIDs.length === 0) {101 return false;102 }103 if (hasFieldWithPermission(fieldIDs)) {104 var entityModel = new Drupal.quickedit.EntityModel({105 el: contextualLink.region,106 entityID: contextualLink.entityID,107 entityInstanceID: contextualLink.entityInstanceID,108 id: "".concat(contextualLink.entityID, "[").concat(contextualLink.entityInstanceID, "]"),109 label: Drupal.quickedit.metadata.get(contextualLink.entityID, 'label')110 });111 Drupal.quickedit.collections.entities.add(entityModel);112 var entityDecorationView = new Drupal.quickedit.EntityDecorationView({113 el: contextualLink.region,114 model: entityModel115 });116 entityModel.set('entityDecorationView', entityDecorationView);117 _.each(fields, function (field) {118 initializeField(field.el, field.fieldID, contextualLink.entityID, contextualLink.entityInstanceID);119 });120 fieldsAvailableQueue = _.difference(fieldsAvailableQueue, fields);121 var initContextualLink = _.once(function () {122 var $links = $(contextualLink.el).find('.contextual-links');123 var contextualLinkView = new Drupal.quickedit.ContextualLinkView($.extend({124 el: $('<li class="quickedit"><a href="" role="button" aria-pressed="false"></a></li>').prependTo($links),125 model: entityModel,126 appModel: Drupal.quickedit.app.model127 }, options));128 entityModel.set('contextualLinkView', contextualLinkView);129 });130 loadMissingEditors(initContextualLink);131 return true;132 }133 if (allMetadataExists(fieldIDs)) {134 return true;135 }136 return false;137 }138 function extractEntityID(fieldID) {139 return fieldID.split('/').slice(0, 2).join('/');140 }141 function processField(fieldElement) {142 var metadata = Drupal.quickedit.metadata;143 var fieldID = fieldElement.getAttribute('data-quickedit-field-id');144 var entityID = extractEntityID(fieldID);145 var entityElementSelector = "[data-quickedit-entity-id=\"".concat(entityID, "\"]");146 var $entityElement = $(entityElementSelector);147 if (!$entityElement.length) {148 throw new Error("Quick Edit could not associate the rendered entity field markup (with [data-quickedit-field-id=\"".concat(fieldID, "\"]) with the corresponding rendered entity markup: no parent DOM node found with [data-quickedit-entity-id=\"").concat(entityID, "\"]. This is typically caused by the theme's template for this entity type forgetting to print the attributes."));149 }150 var entityElement = $(fieldElement).closest($entityElement);151 if (entityElement.length === 0) {152 var $lowestCommonParent = $entityElement.parents().has(fieldElement).first();153 entityElement = $lowestCommonParent.find($entityElement);154 }155 var entityInstanceID = entityElement.get(0).getAttribute('data-quickedit-entity-instance-id');156 if (!metadata.has(fieldID)) {157 fieldsMetadataQueue.push({158 el: fieldElement,159 fieldID: fieldID,160 entityID: entityID,161 entityInstanceID: entityInstanceID162 });163 return;164 }165 if (metadata.get(fieldID, 'access') !== true) {166 return;167 }168 if (Drupal.quickedit.collections.entities.findWhere({169 entityID: entityID,170 entityInstanceID: entityInstanceID171 })) {172 initializeField(fieldElement, fieldID, entityID, entityInstanceID);173 } else {174 fieldsAvailableQueue.push({175 el: fieldElement,176 fieldID: fieldID,177 entityID: entityID,178 entityInstanceID: entityInstanceID179 });180 }181 }182 function deleteContainedModelsAndQueues($context) {183 $context.find('[data-quickedit-entity-id]').addBack('[data-quickedit-entity-id]').each(function (index, entityElement) {184 var entityModel = Drupal.quickedit.collections.entities.findWhere({185 el: entityElement186 });187 if (entityModel) {188 var contextualLinkView = entityModel.get('contextualLinkView');189 contextualLinkView.undelegateEvents();190 contextualLinkView.remove();191 entityModel.get('entityDecorationView').remove();192 entityModel.destroy();193 }194 function hasOtherRegion(contextualLink) {195 return contextualLink.region !== entityElement;196 }197 contextualLinksQueue = _.filter(contextualLinksQueue, hasOtherRegion);198 });199 $context.find('[data-quickedit-field-id]').addBack('[data-quickedit-field-id]').each(function (index, fieldElement) {200 Drupal.quickedit.collections.fields.chain().filter(function (fieldModel) {201 return fieldModel.get('el') === fieldElement;202 }).invoke('destroy');203 function hasOtherFieldElement(field) {204 return field.el !== fieldElement;205 }206 fieldsMetadataQueue = _.filter(fieldsMetadataQueue, hasOtherFieldElement);207 fieldsAvailableQueue = _.filter(fieldsAvailableQueue, hasOtherFieldElement);208 });209 }210 function fetchMissingMetadata(callback) {211 if (fieldsMetadataQueue.length) {212 var fieldIDs = _.pluck(fieldsMetadataQueue, 'fieldID');213 var fieldElementsWithoutMetadata = _.pluck(fieldsMetadataQueue, 'el');214 var entityIDs = _.uniq(_.pluck(fieldsMetadataQueue, 'entityID'), true);215 entityIDs = _.difference(entityIDs, Drupal.quickedit.metadata.intersection(entityIDs));216 fieldsMetadataQueue = [];217 $.ajax({218 url: Drupal.url('quickedit/metadata'),219 type: 'POST',220 data: {221 'fields[]': fieldIDs,222 'entities[]': entityIDs223 },224 dataType: 'json',225 success: function success(results) {226 _.each(results, function (fieldMetadata, fieldID) {227 Drupal.quickedit.metadata.add(fieldID, fieldMetadata);228 });229 callback(fieldElementsWithoutMetadata);230 }231 });232 }233 }234 Drupal.behaviors.quickedit = {235 attach: function attach(context) {236 $('body').once('quickedit-init').each(initQuickEdit);237 var $fields = $(context).find('[data-quickedit-field-id]').once('quickedit');238 if ($fields.length === 0) {239 return;240 }241 $(context).find('[data-quickedit-entity-id]').once('quickedit').each(function (index, entityElement) {242 processEntity(entityElement);243 });244 $fields.each(function (index, fieldElement) {245 processField(fieldElement);246 });247 contextualLinksQueue = _.filter(contextualLinksQueue, function (contextualLink) {248 return !initializeEntityContextualLink(contextualLink);249 });250 fetchMissingMetadata(function (fieldElementsWithFreshMetadata) {251 _.each(fieldElementsWithFreshMetadata, processField);252 contextualLinksQueue = _.filter(contextualLinksQueue, function (contextualLink) {253 return !initializeEntityContextualLink(contextualLink);254 });255 });256 },257 detach: function detach(context, settings, trigger) {258 if (trigger === 'unload') {259 deleteContainedModelsAndQueues($(context));260 }261 }262 };263 Drupal.quickedit = {264 app: null,265 collections: {266 entities: null,267 fields: null268 },269 editors: {},270 metadata: {271 has: function has(fieldID) {272 return storage.getItem(this._prefixFieldID(fieldID)) !== null;273 },274 add: function add(fieldID, metadata) {275 storage.setItem(this._prefixFieldID(fieldID), JSON.stringify(metadata));276 },277 get: function get(fieldID, key) {278 var metadata = JSON.parse(storage.getItem(this._prefixFieldID(fieldID)));279 return typeof key === 'undefined' ? metadata : metadata[key];280 },281 _prefixFieldID: function _prefixFieldID(fieldID) {282 return "Drupal.quickedit.metadata.".concat(fieldID);283 },284 _unprefixFieldID: function _unprefixFieldID(fieldID) {285 return fieldID.substring(26);286 },287 intersection: function intersection(fieldIDs) {288 var prefixedFieldIDs = _.map(fieldIDs, this._prefixFieldID);289 var intersection = _.intersection(prefixedFieldIDs, _.keys(sessionStorage));290 return _.map(intersection, this._unprefixFieldID);291 }292 }293 };294 var permissionsHashKey = Drupal.quickedit.metadata._prefixFieldID('permissionsHash');295 var permissionsHashValue = storage.getItem(permissionsHashKey);296 var permissionsHash = drupalSettings.user.permissionsHash;297 if (permissionsHashValue !== permissionsHash) {298 if (typeof permissionsHash === 'string') {299 _.chain(storage).keys().each(function (key) {300 if (key.substring(0, 26) === 'Drupal.quickedit.metadata.') {301 storage.removeItem(key);302 }303 });304 }305 storage.setItem(permissionsHashKey, permissionsHash);306 }307 $(document).on('drupalContextualLinkAdded', function (event, data) {308 if (data.$region.is('[data-quickedit-entity-id]')) {309 if (!data.$region.is('[data-quickedit-entity-instance-id]')) {310 data.$region.once('quickedit');311 processEntity(data.$region.get(0));312 }313 var contextualLink = {314 entityID: data.$region.attr('data-quickedit-entity-id'),315 entityInstanceID: data.$region.attr('data-quickedit-entity-instance-id'),316 el: data.$el[0],317 region: data.$region[0]318 };319 if (!initializeEntityContextualLink(contextualLink)) {320 contextualLinksQueue.push(contextualLink);321 }322 }323 });...
Server.js
Source:Server.js
1Server = class {2 constructor(id) {3 this.id = id;4 this.entities = {};5 this.clients = {};6 this.dataRecorder = new DataRecorder(this);7 }8 Update(dt) {9 for (var entity_id in this.entities) { this.entities[entity_id].Update(dt); }10 for (var client_id in this.clients) {11 var client = this.clients[client_id];12 client.Update(dt);13 for (var entity_id in this.entities) {14 var entity = this.entities[entity_id];15 if(!client.entity_history[entity_id]) {16 client.entity_history[entity_id] = {};17 }18 client.entity_history[entity_id].position = client.entity_history[entity_id].position || [];19 client.entity_history[entity_id].position.push({t: Date.now() - client.lastUpdated, x: entity.position.x, y: entity.position.y});20 }21 }22 }23 GetEvents(time) {24 var events = {entities: {}};25 for (var entity_id in this.entities) {26 var entity = this.entities[entity_id];27 events.entities[entity_id] = {info: {}};28 for (var k in entity._dataInfo.values) {29 events.entities[entity_id].info[k] = {current: typeof entity[k] == "object" ? Object.assign({}, entity[k]) : entity[k], history: []};30 }31 //console.log(time)32 if(time != null) {33 for (var key in entity._dataInfo.history) {34 for (var h of entity._dataInfo.history[key]) {35 //console.log(`${key}, ${h.t - time}`)36 if(h.t - time >= 0) {37 var frame = Object.assign({}, h);38 frame.t = frame.t - time;39 events.entities[entity_id].info[key].history.push(frame);40 }41 }42 }43 }44 }45 //console.log(events)46 return events;47 }48 HandleConnection(callback) {49 //var id = Utils.AvaliableId(this.clients);50 //var client = new ClientHandle(id);51 //client.playerEntity = this.CreateEntity();52 //this.clients[id] = client;53 //callback({id: id, playerEntity: client.playerEntity.id});54 }55 CreatePlayer(options) {56 return this.CreateBaseEntity(new Entity(), options);57 }58 CreatePlayer(options) {59 return this.CreateBaseEntity(new PlayerEntity(), options);60 }61 CreateBaseEntity(entity, options) {62 options = options || {};63 entity.server = this;64 if(options.id != undefined) {65 entity.id = options.id;66 } else {67 entity.id = Utils.AvaliableId(this.entities);68 }69 if(options.position != undefined) {70 entity.position.x = options.position.x;71 entity.position.y = options.position.y;72 }73 if(options.size != undefined) {74 entity.size = options.size;75 }76 entity.CreateColision();77 this.entities[entity.id] = entity;78 return entity;79 }80 CreateEntity(options) {81 return this.CreateBaseEntity(new Entity(), options);82 }...
Using AI Code Generation
1const strykerParent = require('stryker-parent');2strykerParent.entity();3const strykerParent = require('stryker-parent');4strykerParent.entity();5const strykerParent = require('stryker-parent');6strykerParent.entity();7const strykerParent = require('stryker-parent');8strykerParent.entity();9const strykerParent = require('stryker-parent');10strykerParent.entity();11const strykerParent = require('stryker-parent');12strykerParent.entity();13const strykerParent = require('stryker-parent');14strykerParent.entity();15const strykerParent = require('stryker-parent');16strykerParent.entity();17const strykerParent = require('stryker-parent');18strykerParent.entity();19const strykerParent = require('stryker-parent');20strykerParent.entity();21const strykerParent = require('stryker-parent');22strykerParent.entity();23const strykerParent = require('stryker-parent');24strykerParent.entity();25const strykerParent = require('stryker-parent');26strykerParent.entity();27const strykerParent = require('stryker-parent');28strykerParent.entity();29const strykerParent = require('stry
Using AI Code Generation
1var stryker = require('stryker-parent');2stryker.entity('test');3var stryker = require('stryker-parent');4stryker.entity('test2');5var stryker = require('stryker-parent');6stryker.entity('test3');7var stryker = require('stryker-parent');8stryker.entity('test4');9var stryker = require('stryker-parent');10stryker.entity('test5');11var stryker = require('stryker-parent');12stryker.entity('test6');13var stryker = require('stryker-parent');14stryker.entity('test7');15var stryker = require('stryker-parent');16stryker.entity('test8');17var stryker = require('stryker-parent');18stryker.entity('test9');19var stryker = require('stryker-parent');20stryker.entity('test10');21var stryker = require('stryker-parent');22stryker.entity('test11');23var stryker = require('stryker-parent');24stryker.entity('test12');25var stryker = require('stryker-parent');26stryker.entity('test13');27var stryker = require('stryker-parent');28stryker.entity('test14');
Using AI Code Generation
1const parent = require('stryker-parent');2parent.entity('test');3const parent = require('stryker-parent');4parent.entity('test2');5module.exports = function(config) {6 config.set({7 });8};9module.exports = function(config) {10 config.set({11 });12};13module.exports = function(config) {14 config.set({15 });16};17module.exports = function(config) {18 config.set({19 });20};21module.exports = function(config) {22 config.set({23 });24};25module.exports = function(config) {26 config.set({
Using AI Code Generation
1const entity = require('stryker-parent').entity;2const entity = require('stryker-parent').entity;3const entity = require('stryker-child').entity;4const entity = require('stryker-child').entity;5const entity = require('stryker-parent').entity;6const entity = require('stryker-parent').entity;7const entity = require('stryker-child').entity;8const entity = require('stryker-child').entity;9const entity = require('stryker-parent').entity;10const entity = require('stryker-parent').entity;11const entity = require('stryker-child').entity;12const entity = require('stryker-child').entity;13const entity = require('stryker-parent').entity;14const entity = require('stryker-parent').entity;15const entity = require('stryker-child').entity;16const entity = require('stryker-child').entity;17const entity = require('stryker-parent').entity;18const entity = require('stryker-parent').entity;19const entity = require('stryker-child').entity;20const entity = require('stryker-child').entity;21const entity = require('stryker-parent').entity;22const entity = require('stryker-parent').entity;23const entity = require('stryker-child').entity;24const entity = require('stryker-child').entity;25const entity = require('stryker-parent').entity;26const entity = require('stryker-parent').entity;27const entity = require('stryker-child').entity;28const entity = require('stryker-child').entity
Using AI Code Generation
1const entity = require('stryker-parent').entity;2const entity = require('stryker-parent').entity;3module.exports = {4 entity: function() {5 return 'entity';6 }7};8{9}10{11}12{13}14{15}16{17}18{19}
Using AI Code Generation
1var stryker = require('stryker-parent');2stryker.entity({name: 'test'});3var stryker = require('stryker-parent');4stryker.entity({name: 'test'});5var stryker = require('stryker-parent');6stryker.entity({name: 'test'});7var stryker = require('stryker-parent');8stryker.entity({name: 'test'});9var stryker = require('stryker-parent');10stryker.entity({name: 'test'});11var stryker = require('stryker-parent');12stryker.entity({name: 'test'});13var stryker = require('stryker-parent');14stryker.entity({name: 'test'});15var stryker = require('stryker-parent');16stryker.entity({name: 'test'});17var stryker = require('stryker-parent');18stryker.entity({name: 'test'});19var stryker = require('stryker-parent');20stryker.entity({name: 'test'});21var stryker = require('stryker-parent');22stryker.entity({name: 'test'});23var stryker = require('stryker-parent');24stryker.entity({name: 'test'});25var stryker = require('stryker-parent');26stryker.entity({name: 'test'});27var stryker = require('stryker-parent');28stryker.entity({name: 'test'});29var stryker = require('stryker-parent');30stryker.entity({name: 'test'});31var stryker = require('stryker-parent');32stryker.entity({name: 'test'});
Using AI Code Generation
1const { entity } = require('stryker-parent');2entity();3const { entity } = require('stryker-parent');4entity();5const { entity } = require('stryker-parent');6entity();7const { entity } = require('stryker-parent');8entity();9const { entity } = require('stryker-parent');10entity();11const { entity } = require('stryker-parent');12entity();13const { entity } = require('stryker-parent');14entity();
Using AI Code Generation
1var stryker = require('stryker-parent');2var strykerConfig = stryker.config.load('stryker.conf.js');3var strykerOptions = stryker.config.parseConfig(strykerConfig);4var stryker = new stryker.Stryker(strykerOptions);5stryker.runMutationTest();6stryker.runCoverageAnalysis();7stryker.runUnitTests();8stryker.runInProcess();9stryker.runInChildProcess();10stryker.runInSandbox();11stryker.runInSandboxAsync().then(function(result){12});13stryker.runInSandboxAsync(function(result){14});15stryker.runInSandboxAsync().then(function(result){16});17stryker.runInSandboxAsync().then(function(result){18});19stryker.runInSandboxAsync().then(function(result){20});21stryker.runInSandboxAsync().then(function(result){22});23stryker.runInSandboxAsync().then(function(result){24});25stryker.runInSandboxAsync().then(function(result){26});27stryker.runInSandboxAsync().then(function(result){28});
Using AI Code Generation
1var parent = require('stryker-parent');2var entity = parent.entity;3var stryker = entity('stryker');4var strykerConfig = stryker.config;5var strykerConfigFile = strykerConfig.file;6var strykerConfigFileContent = strykerConfigFile.content;7var strykerConfigFileContent = strykerConfigFile.content;8console.log(strykerConfigFileContent);
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!!