How to use msA method in wpt

Best JavaScript code snippet using wpt

app.js

Source:app.js Github

copy

Full Screen

1/*globals Ember, SCUtil, InitialMySystemData*/2var MSA = Ember.Application.create();3MSA.PositionControls = Ember.Mixin.create({4 moveItemUp: function(item) {5 var c = this.get('content');6 var i = c.indexOf(item);7 if (i > 0) {8 var itemBefore = this.objectAt(i-1);9 this.replaceContent(i-1, 2, [item, itemBefore]);10 }11 },12 moveItemDown: function(item) {13 var c = this.get('content');14 var i = c.indexOf(item);15 if (i < (c.length-1)) {16 var itemAfter = this.objectAt(i+1);17 this.replaceContent(i, 2, [itemAfter, item]);18 }19 }20});21MSA.setPreviewApp = function(mysystem) {22 mysystem.setAuthoringDataController(MSA.dataController);23 mysystem.reloadAuthoringData();24 mysystem.saveInitialDiagramAsSaveFunction();25 // set maximum update rate...26 var maxUpdateInterval = 1000;27 var lastUpdateTime = 0;28 var timeOutJob = null;29 var _update_function = function() {30 if(timeOutJob !== null) {31 window.clearTimeout(timeOutJob);32 }33 var _actualyUpdate = function() {34 var data = MSA.dataController.get('data');35 mysystem.updateRuntime(data);36 };37 timeOutJob = window.setTimeout(_actualyUpdate,maxUpdateInterval);38 };39 MSA.dataController.addObserver('data', MSA.dataController, _update_function);40 MSA.rubricCategoriesController.set('scoreFunction',mysystem.scoreDiagram);41};42MSA.setupParentIFrame = function(dataHash, updateObject, mysystem) {43 if (typeof dataHash === "undefined" || dataHash === null){44 dataHash = MSA.dataController.get('data');45 }46 // migration from old content format47 if (!dataHash.diagram_rules) {48 dataHash.diagram_rules = [];49 }50 if (!dataHash.rubric_categories) {51 dataHash.rubric_categories = [];52 }53 if (!dataHash.rubricExpression) {54 dataHash.rubricExpression = "score(1);";55 }56 if (!dataHash.feedbackRules) {57 dataHash.feedbackRules = "none_f(allIconsUsed(), 'you must use every icon in your diagram.');";58 }59 if (typeof dataHash.correctFeedback === "undefined" || dataHash.correctFeedback === null){60 dataHash.correctFeedback = "";61 }62 if (typeof dataHash.enableNodeLabelDisplay === "undefined" || dataHash.enableNodeLabelDisplay === null){63 dataHash.enableNodeLabelDisplay = true;64 }65 if (typeof dataHash.enableNodeLabelEditing === "undefined" || dataHash.enableNodeLabelEditing === null){66 dataHash.enableNodeLabelEditing = false;67 }68 if (typeof dataHash.enableNodeDescriptionEditing === "undefined" || dataHash.enableNodeDescriptionEditing === null){69 dataHash.enableNodeDescriptionEditing = false;70 }71 if (typeof dataHash.enableLinkDescriptionEditing === "undefined" || dataHash.enableLinkDescriptionEditing === null){72 dataHash.enableLinkDescriptionEditing = false;73 }74 if (typeof dataHash.enableLinkLabelEditing === "undefined" || dataHash.enableLinkLabelEditing === null){75 dataHash.enableLinkLabelEditing = false;76 }77 if (typeof dataHash.enableCustomRuleEvaluator === "undefined" || dataHash.enableCustomRuleEvaluator === null){78 dataHash.enableCustomRuleEvaluator = false;79 }80 if (typeof dataHash.customRuleEvaluator === "undefined" || dataHash.customRuleEvaluator === null){81 dataHash.customRuleEvaluator = "";82 }83 if (typeof dataHash.maxSubmissionClicks === "undefined" || dataHash.maxSubmissionClicks === null){84 dataHash.maxSubmissionClicks = 0;85 }86 if (typeof dataHash.maxSubmissionFeedback === "undefined" || dataHash.maxSubmissionFeedback === null){87 dataHash.maxSubmissionFeedback = "You have clicked 'submit' too many times. Please continue working without hints.";88 }89 if (typeof dataHash.feedbackPanelHeight === "undefined" || dataHash.feedbackPanelHeight === null){90 dataHash.feedbackPanelHeight = 250;91 }92 if (typeof dataHash.feedbackPanelWidth === "undefined" || dataHash.feedbackPanelWidth === null){93 dataHash.feedbackPanelWidth = 500;94 }95 if (typeof dataHash.terminalRadius === "undefined" || dataHash.terminalRadius === null){96 dataHash.terminalRadius = 14;97 }98 if (typeof dataHash.nodeWidth === "undefined" || dataHash.nodeWidth === null){99 dataHash.nodeWidth = 100;100 }101 if (typeof dataHash.nodeHeight === "undefined" || dataHash.nodeHeight === null){102 dataHash.nodeHeight = 110;103 }104 if (typeof dataHash.backgroundImage === "undefined" || dataHash.backgroundImage === null){105 dataHash.backgroundImage = null;106 }107 if (typeof dataHash.backgroundImageScaling === "undefined" || dataHash.backgroundImageScaling === null){108 dataHash.backgroundImageScaling = false;109 }110 // TODO: migrate objects to have uuids that don't already have them111 MSA.dataController.loadData(dataHash);112 if(mysystem) {113 MSA.setPreviewApp(mysystem);114 }115};116MSA.ActivityModel = SCUtil.ModelObject.extend({117 prompt: SCUtil.dataHashProperty,118 correctFeedback: SCUtil.dataHashProperty,119 maxFeedbackItems: SCUtil.dataHashProperty,120 enableNodeLabelDisplay: SCUtil.dataHashProperty,121 enableNodeLabelEditing: SCUtil.dataHashProperty,122 enableNodeDescriptionEditing: SCUtil.dataHashProperty,123 enableLinkDescriptionEditing: SCUtil.dataHashProperty,124 enableLinkLabelEditing: SCUtil.dataHashProperty,125 enableCustomRuleEvaluator: SCUtil.dataHashProperty,126 customRuleEvaluator: SCUtil.dataHashProperty,127 maxSubmissionClicks: SCUtil.dataHashProperty,128 maxSubmissionFeedback: SCUtil.dataHashProperty,129 feedbackPanelWidth: SCUtil.dataHashProperty,130 feedbackPanelHeight: SCUtil.dataHashProperty,131 terminalRadius: SCUtil.dataHashProperty,132 nodeWidth: SCUtil.dataHashProperty,133 nodeHeight: SCUtil.dataHashProperty,134 backgroundImage: SCUtil.dataHashProperty,135 backgroundImageScaling: SCUtil.dataHashProperty,136 rubricExpression: SCUtil.dataHashProperty,137 feedbackRules: SCUtil.dataHashProperty,138 initialDiagramJson: SCUtil.dataHashProperty139});140MSA.Module = SCUtil.ModelObject.extend( SCUtil.UUIDModel, {141 name: SCUtil.dataHashProperty,142 image: SCUtil.dataHashProperty,143 defaultDataHash: {144 "xtype": "MySystemContainer",145 "etype": "source",146 "fields": {147 "efficiency": "1"148 }149 }150});151MSA.EnergyType = SCUtil.ModelObject.extend( SCUtil.UUIDModel, {152 label: SCUtil.dataHashProperty,153 color: SCUtil.dataHashProperty154});155// it would be useful to support polymorphic156// so there are different types of rule157MSA.DiagramRule = SCUtil.ModelObject.extend({158 suggestion: SCUtil.dataHashProperty,159 name: SCUtil.dataHashProperty,160 category: SCUtil.dataHashProperty,161 comparison: SCUtil.dataHashProperty,162 number: SCUtil.dataHashProperty,163 type: SCUtil.dataHashProperty,164 hasLink: SCUtil.dataHashProperty,165 linkDirection: SCUtil.dataHashProperty,166 otherNodeType: SCUtil.dataHashProperty,167 energyType: SCUtil.dataHashProperty,168 javascriptExpression: SCUtil.dataHashProperty,169 isJavascript: SCUtil.dataHashProperty,170 not: SCUtil.dataHashProperty,171 defaultDataHash: {172 "javascriptExpression": "",173 "isJavascript": false174 },175 shouldOption: function(key, value) {176 if (value){177 this.set("not", value !== "should");178 }179 return this.get("not") ? "should not" : "should";180 }.property('not'),181 toggleHasLink: function(){182 this.set('hasLink', !this.get('hasLink'));183 }184});185MSA.RubricCategory = SCUtil.ModelObject.extend({186 name: SCUtil.dataHashProperty187});188MSA.RubricCategoriesController = SCUtil.ModelArray.extend(MSA.PositionControls, {189 modelType: MSA.RubricCategory,190 scoreFunction: null,191 showScore: function() {192 var scoreFunction = this.get('scoreFunction');193 if (scoreFunction) {194 scoreFunction();195 }196 }197});198MSA.RulesController = SCUtil.ModelArray.extend(MSA.PositionControls, {199 modelType: MSA.DiagramRule,200 nodesBinding: 'MSA.modulesController.content',201 nodeTypes: function (){202 return MSA.modulesController.mapProperty('name').insertAt(0, 'node');203 }.property('MSA.modulesController.@each.name').cacheable(),204 energyTypes: function() {205 return MSA.energyTypesController.mapProperty('label').insertAt(0, 'any');206 }.property('MSA.energyTypesController.[]', 'MSA.energyTypesController.@each.label').cacheable(),207 categories: function (){208 return MSA.rubricCategoriesController.mapProperty('name').insertAt(0, 'none');209 }.property('MSA.rubricCategoriesController.[]', 'MSA.rubricCategoriesController.@each.name').cacheable(),210 comparisons: ['more than', 'less than', 'exactly'],211 shouldOptions: ['should', 'should not'],212 linkDirections: ['-->', '<--', '---'],213});214MSA.rubricCategoriesController = MSA.RubricCategoriesController.create({});215MSA.ModuleController = SCUtil.ModelArray.extend(MSA.PositionControls, {216 modelType: MSA.Module217});218MSA.modulesController = MSA.ModuleController.create();219MSA.EnergyTypesController = SCUtil.ModelArray.extend(MSA.PositionControls, {220 modelType: MSA.EnergyType221});222MSA.energyTypesController = MSA.EnergyTypesController.create();223MSA.diagramRulesController = MSA.RulesController.create({});224MSA.DataController = Ember.Object.extend({225 modulesBinding: 'MSA.modulesController.content',226 energyTypesBinding: 'MSA.energyTypesController.content',227 diagramRulesBinding: 'MSA.diagramRulesController.content',228 rubricCategoriesBinding: 'MSA.rubricCategoriesController.content',229 defaultDataHash: function() {230 var defaults = {231 "modules" : [],232 "energy_types" : [],233 "diagram_rules" : [],234 "rubric_categories" : [],235 "rubricExpression" : "score(1);",236 "feedbackRules" : "none_f(allIconsUsed(), 'you must use every icon in your diagram.');",237 "correctFeedback" : "Your diagram has no obvious problems.",238 "maxFeedbackItems" : 0,239 "enableNodeLabelDisplay" : true,240 "enableNodeLabelEditing" : false,241 "enableNodeDescriptionEditing" : false,242 "enableLinkDescriptionEditing" : false,243 "enableLinkLabelEditing" : false,244 "enableCustomRuleEvaluator" : false,245 "customRuleEvaluator" : "",246 "maxSubmissionClicks" : 0,247 "maxSubmissionFeedback" : "You have clicked 'submit' too many times. Please continue working without hints.",248 "feedbackPanelWidth" : 500,249 "feedbackPanelHeight" : 250,250 "terminalRadius" : 14,251 "nodeHeight" : 110,252 "nodeWidth" : 110,253 "backgroundImage" : null,254 "backgroundImageScaling" : false,255 "initialDiagramJson" : ""256 };257 if (top === self) {258 // TODO: (test this, is it still needed?)259 // we are not in iframe so load in some fake data260 defaults = InitialMySystemData;261 }262 return defaults;263 }.property().cacheable(),264 // update the dataHash we originated from.265 updateParentHash: function(data) {266 if (this.parentHash && typeof (this.parentHash === 'object')) {267 for (var attr in data) {268 if (data.hasOwnProperty(attr)){269 this.parentHash[attr] = data[attr];270 }271 }272 }273 },274 data: function() {275 var activity = this.get('activity');276 var data;277 if(Ember.isNone(activity)) {278 data = this.get('defaultDataHash');279 }280 else {281 data = activity.get('dataHash');282 }283 data.modules = this.get('modules').mapProperty('dataHash');284 data.energy_types = this.get('energyTypes').mapProperty('dataHash');285 data.diagram_rules = this.get('diagramRules').mapProperty('dataHash');286 data.rubric_categories = this.get('rubricCategories').mapProperty('dataHash');287 data.type = "mysystem2";288 this.updateParentHash(data);289 return data;290 }.property( 'activity.rev',291 'energyTypes.@each.rev',292 'modules.@each.rev',293 'diagramRules.@each.rev',294 'rubricCategories.@each.rev'295 ).cacheable(),296 dataJson: function() {297 return JSON.stringify(this.get('data'),null,2);298 }.property('data').cacheable(),299 saveInitialDiagramJson: function(initialDiagram) {300 this.setPath('activity.initialDiagramJson', initialDiagram);301 },302 loadData: function(dataHash) {303 var data = dataHash;304 this.parentHash = dataHash;305 if (typeof data === 'string') {306 data = JSON.parse(data);307 }308 // old authored data hasn't specified this.309 // authoring interface incorrectly checks a box310 data.diagram_rules.forEach(function(rule) {311 if ((typeof rule.isJavascript === 'undefined')) {312 rule.isJavascript = false;313 }314 });315 MSA.modulesController.contentFromHashArray(data.modules);316 MSA.energyTypesController.contentFromHashArray(data.energy_types);317 MSA.diagramRulesController.contentFromHashArray(data.diagram_rules);318 MSA.rubricCategoriesController.contentFromHashArray(data.rubric_categories);319 var activity = MSA.ActivityModel.create();320 var item;321 for (item in data) {322 activity.set(item,data[item]);323 }324 this.set('activity',activity);325 }326});327MSA.dataController = MSA.DataController.create({});328MSA.NodeTypesView = Ember.CollectionView.extend({329 tagName: 'ul',330 contentBinding: "MSA.diagramRulesController.nodes"331});332// add missing textarea tag attributes333MSA.TextArea = Ember.TextArea.extend({334 attributeBindings: ['rows', 'cols', 'wrap'],335 // reasonable defaults?336 cols: 50,337 rows: 4,338 wrap: "off"339});340// add size, no live_update341MSA.TextField = Ember.View.extend({342 classNames: ['ember-text-field'],343 tagName: "input",344 attributeBindings: ['type', 'value', 'size', 'placeholder'],345 type: "text",346 value: "",347 size: null,348 // unlike Ember.TextSupport, we dont trigger349 // on key-up, paste, copy, &etc. Why?350 // because updated 20 or so lists of nodes (in the rules)351 // was causing CPU spin.352 init: function() {353 this._super();354 this.on("focusOut", this, this._elementValueDidChange);355 this.on("change", this, this._elementValueDidChange);356 },357 _elementValueDidChange: function() {358 Ember.set(this, 'value', this.$().val());359 }360});361MSA.editorController = Ember.Object.create({362 owner: null,363 editorWindow: null,364 value: '',365 callback: function() {},366 editCustomRule: function(owner,value,callback) {367 this.registerWindowCallbacks();368 this.save();// save the previous data back to whomever.369 this.set('owner',owner);370 this.set('value',value);371 this.set('callback',callback);372 var editorWindow = this.get('editorWindow');373 var features = "menubar=false,location=false,titlebar=false,toolbar=false,resizable=yes,scrollbars=yes,status=false,width=750,height=650";374 // reuse existing window:375 if (editorWindow) {376 editorWindow.postMessage(JSON.stringify(value),"*");377 editorWindow.focus();378 }379 // or create a new one:380 else {381 editorWindow = window.open("codemirror.html", 'editorwindow', features);382 this.set('editorWindow', editorWindow);383 editorWindow.originParent = window;384 }385 },386 registerWindowCallbacks: function() {387 if(this.hasregisteredCallbacks) {388 return;389 }390 var self = this;391 var updateMessage = function(event) {392 var message = JSON.parse(event.data);393 var value = self.get('value');394 if (message.javascript) {395 value.code = message.javascript;396 self.set('value', value);397 self.save();398 }399 if (message.windowClosed) {400 self.set('editorWindow',null);401 }402 if (message.ready) {403 self.set('editorWindow', event.source);404 event.source.postMessage(JSON.stringify(self.get('value')), "*");405 event.source.focus();406 }407 }.bind(self);408 window.addEventListener("message", updateMessage, false);409 this.hasregisteredCallbacks = true;410 },411 save: function() {412 var value = this.get('value');413 var callback = this.get("callback");414 if (callback) {415 callback(value.code);416 }417 else {418 console.log("false callback defined");419 }420 }421});422MSA.promptController = Ember.Object.create({423 showPrompt: false424});425MSA.customRuleController = Ember.Object.create({426 helpDiv: '#evalHelp',427 editCustomRule: function() {428 var code = MSA.dataController.activity.get('customRuleEvaluator');429 var mode = 'curomRule';430 var value = {'code': code, 'mode': mode};431 var callback = function(value) {432 MSA.dataController.activity.set('customRuleEvaluator',value);433 }.bind(this);434 MSA.editorController.editCustomRule(this,value,callback);435 }436});437MSA.rubricController = Ember.Object.create({438 helpDiv: '#evalHelp',439 editRubric: function() {440 var code = MSA.dataController.activity.get('rubricExpression');441 var mode = 'rubric';442 var value = {'code': code, 'mode': mode};443 var callback = function(value) {444 MSA.dataController.activity.set('rubricExpression',value);445 }.bind(this);446 MSA.editorController.editCustomRule(this,value,callback);447 }448});449MSA.feedbackRulesController = Ember.Object.create({450 helpDiv: '#evalHelp',451 editFeedback: function() {452 var code = MSA.dataController.activity.get('feedbackRules');453 var mode = "feedback";454 var value = {'code': code, 'mode': mode};455 var callback = function(value) {456 MSA.dataController.activity.set('feedbackRules',value);457 }.bind(this);458 MSA.editorController.editCustomRule(this,value,callback);459 }460});461MSA.NodeView = Ember.View.extend({462 templateName: 'node-template',463 remove: function() {464 MSA.modulesController.removeObject(this.get('node'));465 return true;466 },467 moveItemUp: function() {468 MSA.modulesController.moveItemUp(this.get('node'));469 return true;470 },471 moveItemDown: function() {472 MSA.modulesController.moveItemDown(this.get('node'));473 return true;474 }475});476MSA.LinkView = Ember.View.extend({477 templateName: 'link-template',478 remove: function() {479 MSA.energyTypesController.removeObject(this.get('link'));480 return true;481 }482});483MSA.CategoryView = Ember.View.extend({484 templateName: 'category-template',485 remove: function() {486 MSA.rubricCategoriesController.removeObject(this.get('category'));487 return true;488 }489});490MSA.RuleView = Ember.View.extend({491 templateName: 'rule-template',492 showName: true,493 ruleType: "Diagram Rule",494 javascriptExpressionBinding: "rule.javascriptExpression",495 remove: function() {496 MSA.diagramRulesController.removeObject(this.get('rule'));497 },498 moveItemUp: function() {499 MSA.diagramRulesController.moveItemUp(this.get('rule'));500 },501 moveItemDown: function() {502 MSA.diagramRulesController.moveItemDown(this.get('rule'));503 },504 toggleHasLink: function() {505 var rule = this.get('rule');506 rule.toggleHasLink();507 },508 editorWindow: null,509 editJSRule: function() {510 var self = this;511 var code = this.get('javascriptExpression');512 var mode = 'JSRule';513 var value = {'code': code, 'mode': mode};514 var myCallback = function(newValue) {515 self.set('javascriptExpression',newValue);516 }.bind(this);517 MSA.editorController.editCustomRule(this, value, myCallback);518 }519});520MSA.RubricExpressionView = Ember.View.extend({521 templateName: 'rubricExpression-template',522 showScore: function() {523 MSA.rubricCategoriesController.showScore();524 },525 edit: function() {526 MSA.rubricController.editRubric();527 }528});529MSA.FeedbackRulesView = Ember.View.extend({530 templateName: 'feedbackRules-template',531 edit: function() {532 MSA.feedbackRulesController.editFeedback();533 }534});535MSA.PromptView = Ember.View.extend({536 templateName: 'prompt-template',537 isVisibleBinding: 'MSA.promptController.showPrompt'...

Full Screen

Full Screen

msa.js

Source:msa.js Github

copy

Full Screen

1import {inject, bindable, observable, BindingEngine} from 'aurelia-framework';2import {Api} from 'api';3import {App} from 'app';4let $ = jQuery;5@inject(App, Api, BindingEngine)6export class Msa {7 MAX_HEIGHT = 175;8 DIALOG_WIDTH = 650;9 MSA_LABEL_WIDTH = 150;10 MSA_LABEL_FONT_SIZE = 9;11 MSA_ZOOMER_WIDTH = 475;12 13 @bindable familyName;14 @bindable showDialog; // two-way databinding for toggling dialog in app.js15 @bindable treeEl;16 17 @observable selectedFeatureNames = {};18 @observable selectedFeatureNum = 0; // count of selected features19 20 menu = false;21 _msa = null; // msa viewer component22 msaDirty = false; // flag for whether the msa component should be reloaded23 dialog = null;24 tree = null; // tree view-model25 seqs = [];26 index = {}27 _dim = null; // crossfilter dimension28 constructor(app, api, be) {29 this.app = app; // app.js singleton30 this.api = api; // web api31 this.be = be; // binding engine32 }33 attached() {34 // aurelia bound the <tree> element to a variable, but we need the35 // tree's view-model (tree.js)36 this.tree = this.treeEl.au.controller.viewModel;37 // the dom is ready, so use jquery to get reference to dialog div.38 this.dialog = $("#msa-dialog");39 this.subscribe();40 }41 showDialogChanged(newValue, oldValue) {42 this.showDialog = newValue;43 if(this.showDialog && ! this._msa) {44 // lazily create the msa component45 this.init();46 this.updateMsa();47 }48 if(this.dialog) {49 // hide or show the dialog as necessary50 this.updateDialog(); 51 }52 }53 // initialize the msa component54 init(size) {55 let w = size ? size.width - this.MSA_LABEL_WIDTH -25 : this.MSA_ZOOMER_WIDTH;56 this.seqs = this.api.msaSeqs;57 let opts = {58 el: this.msaElement,59 bootstrapMenu: true,60 vis: {61 overviewbox: false,62 labelId: false,63 },64 zoomer: {65 labelNameLength: this.MSA_LABEL_WIDTH,66 labelFontsize: this.MSA_LABEL_FONT_SIZE,67 alignmentWidth: w,68 autoResize: true69 }70 };71 this._msa = msa(opts);72 let callbacks = {73 reset: this.onMsaSelectionReset,74 add: this.onMsaSelectionAdd,75 // all: function (a, b, c) {}76 };77 this._msa.g.selcol.on(callbacks, this);78 // workaround for biojs-msa menu divs possibly being effected by79 // leaking CSS rules in this context80 $('.smenubar_alink').live('click', evt => {81 setTimeout( () => {82 let el = $('.smenu-dropdown');83 el.css('top', '');84 el.css('left', '');85 });86 });87 }88 updateDialog() {89 if(this.showDialog && this.msaDirty) {90 // lazy update the msa component91 this.updateMsa();92 }93 let opts = {94 title: 'Multiple Sequence Alignment - ' + this.familyName,95 closeOnEscape: true,96 modal: false,97 width: this.DIALOG_WIDTH + 'px',98 position: {99 my: 'right', at: 'bottom'100 },101 close: (event, ui) => this.onDialogClosed(),102 resizeStop: (event, ui) => this.onDialogResized(ui.size)103 };104 if(this.dialogWasOpened) {105 delete opts.position; // allow dialog to re-open in previous location106 }107 this.dialog.dialog(opts);108 let action = this.showDialog ? 'open' : 'close';109 this.dialog.dialog(action);110 this.dialogWasOpened = true;111 }112 /*113 * callback for jquery.ui.dialog resize event. the msa component114 * does not support resizing very well, but we can at least drive115 * the attribute value for the zoomer width. Unknown how to adjust116 * the height of the msa component.117 */118 onDialogResized(newSize) {119 let w = newSize.width - this.MSA_LABEL_WIDTH - 25;120 this._msa.g.zoomer.attributes.alignmentWidth = w;121 this._msa.render();122 }123 124 // callback for jquery.ui.dialog close event125 onDialogClosed() {126 this.onClearSelection();127 this.showDialog = false;128 }129 // setup observers for crossfilter data130 subscribe() {131 this.be.propertyObserver(this.api, 'cf')132 .subscribe( o => this.onCfCreated(o));133 this.be.propertyObserver(this.api, 'cfUpdated')134 .subscribe( o => this.onCfUpdated(o));135 }136 137 onCfCreated(cf) {138 this._cf = cf;139 // create a dimension by name (keep our own instance of this dimension)140 this._dim = cf.dimension(d => d.name);141 }142 143 onCfUpdated(msg) {144 if(msg.sender != this) {145 if(this.showDialog) {146 this.updateMsa();147 }148 else {149 this.msaDirty = true;150 }151 }152 }153 154 updateMsa() {155 let data = this._dim.top(Infinity);156 let seqs = _.map(data, d => d.msa);157 let order = this.tree.getSortOrder();158 seqs = _.sortBy(seqs, d => order.indexOf(d.name));159 seqs.unshift(this.api.getConsensusSeq());160 this.display(seqs);161 this.msaDirty = false;162 }163 display(seqs) {164 this._msa.seqs.reset(seqs);165 this._msa.render();166 let x = seqs.length * 15;167 let height = (x > this.MAX_HEIGHT) ? this.MAX_HEIGHT : x;168 this._msa.g.zoomer.set('alignmentHeight', height);169 if(this.menu) {170 $('div.smenubar').show();// msa component does not clean up menu bar171 }172 else {173 $('div.smenubar').hide();174 }175 }176 onToggleMenu() {177 this.menu = ! this.menu;178 if(this.menu) {179 $('div.smenubar').show();// msa component does not clean up menu bar180 }181 else {182 $('div.smenubar').hide();183 }184 }185 // onMsaSelectionAdd() : add means there is more than 1 feature selected186 onMsaSelectionAdd(newModel, prevModel) {187 // must translate from the msa's "seqId" which is an integer,188 // into the actual fasta subject189 let seqIds = _.map(newModel.collection.models, d => d.attributes.seqId);190 let res = this._msa.seqs.filter(el => seqIds.indexOf(el.id) !== -1);191 let names = _.map(res, d => d.attributes.name);192 this.selectedFeatureNames = {};193 _.each(names, n => this.selectedFeatureNames[n] = true);194 this.selectedFeatureNum = _.size(this.selectedFeatureNames);195 }196 // onMsaSelectionReset() : reset means there is a single feature selected197 onMsaSelectionReset(newModel, prevModel) {198 if(newModel.models.length) {199 let seqId = newModel.models[0].attributes.seqId;200 let res = this._msa.seqs.filter(el => el.id === seqId);201 if(res.length) {202 let n = res[0].attributes.name;203 this.selectedFeatureNames = {};204 this.selectedFeatureNames[n] = true;205 }206 }207 this.selectedFeatureNum = _.size(this.selectedFeatureNames);208 }209 onClearSelection() {210 this._msa.g.selcol.reset([]); 211 this.selectedFeatureNum = 0;212 this.selectedFeatureNames = {};213 }...

Full Screen

Full Screen

news_uu_counting_090611.js

Source:news_uu_counting_090611.js Github

copy

Full Screen

1//<![CDATA[2msa_tracking=new Array(null,null,null,null,null,null);3try {4msa_cp="uu_news_";5msa_dn="msn.com";6msa_dt=new Date();7msa_v=msa_dt.getDay();8msa_v=(msa_v==0)?6:(msa_v-1);9msa_cp=msa_cp+(Math.floor((msa_dt.getTime()+32400000)/86400000)-msa_v);10msa_rand=Math.floor(Math.random()*1000000000);11msa_array=new Array(2000,1000,500,250,125);12msa_cleargif=new Array(13 'http://g.msn.com/0AD00006/1593569.11?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 14 'http://g.msn.com/0AD00006/1593569.12?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 15 'http://g.msn.com/0AD00006/1593569.13?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 16 'http://g.msn.com/0AD00006/1593569.21?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 17 'http://g.msn.com/0AD00006/1593569.22?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 18 'http://g.msn.com/0AD00006/1593569.23?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 19 'http://g.msn.com/0AD00006/1593569.31?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 20 'http://g.msn.com/0AD00006/1593569.32?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 21 'http://g.msn.com/0AD00006/1593569.33?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 22 'http://g.msn.com/0AD00006/1593569.41?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 23 'http://g.msn.com/0AD00006/1593569.42?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 24 'http://g.msn.com/0AD00006/1593569.43?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 25 'http://g.msn.com/0AD00006/1593569.51?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K', 26 'http://g.msn.com/0AD00006/1593569.52?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K',27 'http://g.msn.com/0AD00006/1593569.53?!&amp;&amp;PID=6096902&amp;UIT=M&amp;TargetID=8085829&amp;AN='+msa_rand+'&amp;PG=JXXX0K' 28 );29 rnd=Math.random();30 for (i=0;i<msa_array.length;i++){31 if(msa_array[i]/msa_array[0]>rnd){32 _verify(msa_cp +"_"+i,msa_cleargif[i*3+1],msa_cleargif[i*3],msa_cleargif[i*3+2],i);33 }34 }35}36catch(e){}373839function _verify(adid,cleargif,cleargif2,cleargif3,i) {40var dt=new Date();41dt.setTime(dt.getTime()+3600000*24*7);42if (getCookie(adid)!="yes")43 {44 document.cookie=adid+"=yes;expires="+dt.toGMTString()+";domain="+msa_dn+";path=/";45 if (getCookie(adid)!="yes") {46 msa_tracking[i]=new Image(); msa_tracking[i].src=cleargif3.replace(/[&]amp[;]/g,"&");4748 }49 else {50 msa_tracking[i]=new Image(); msa_tracking[i].src=cleargif.replace(/[&]amp[;]/g,"&");5152}5354 }55 else {56 msa_tracking[i]=new Image(); msa_tracking[i].src=cleargif2.replace(/[&]amp[;]/g,"&");57 }58}596061function getCookie(key){62 tmp=document.cookie+";";63 tmp1=tmp.indexOf(key,0);64 if (tmp1!=-1){65 tmp=tmp.substring(tmp1,tmp.length);66 start=tmp.indexOf("=",0)+1;67 end=tmp.indexOf(";",start);68 return(unescape(tmp.substring(start,end)));69 }70} ...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptoolkit = require('wptoolkit');2var msA = wptoolkit.msA;3var wptoolkit = require('wptoolkit');4var msA = wptoolkit.msA;5var wptoolkit = require('wptoolkit');6var msA = wptoolkit.msA;7var wptoolkit = require('wptoolkit');8var msA = wptoolkit.msA;9var wptoolkit = require('wptoolkit');10var msA = wptoolkit.msA;11var wptoolkit = require('wptoolkit');12var msA = wptoolkit.msA;

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./lib/webpagetest.js');2var wpt = new wpt('www.webpagetest.org');3var options = {4};5wpt.runTest(url, options, function(err, data) {6 if (err) return console.error(err);7 console.log(data);8});9var wpt = require('./lib/webpagetest.js');10var wpt = new wpt('www.webpagetest.org');11var options = {12};13wpt.runTest(url, options, function(err, data) {14 if (err) return console.error(err);15 console.log(data);16});17var wpt = require('./lib/webpagetest.js');18var wpt = new wpt('www.webpagetest.org');19var options = {20};21wpt.runTest(url, options, function(err, data) {22 if (err) return console.error(err);23 console.log(data);24});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var wiki = wptools.page('Barack Obama').get();3wiki.then(function(page) {4 console.log(page.data);5});6var wptools = require('wptools');7var wiki = wptools.page('Barack Obama').get();8wiki.then(function(page) {9 console.log(page.data);10});11var wptools = require('wptools');12var wiki = wptools.page('Barack Obama').get();13wiki.then(function(page) {14 console.log(page.data);15});16var wptools = require('wptools');17var wiki = wptools.page('Barack Obama').get();18wiki.then(function(page) {19 console.log(page.data);20});21var wptools = require('wptools');22var wiki = wptools.page('Barack Obama').get();23wiki.then(function(page) {24 console.log(page.data);25});26var wptools = require('wptools');27var wiki = wptools.page('Barack Obama').get();28wiki.then(function(page) {29 console.log(page.data);30});31var wptools = require('wptools');32var wiki = wptools.page('Barack Obama').get();33wiki.then(function(page) {34 console.log(page.data);35});36var wptools = require('wpt

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptools = require('wptools');2var fs = require('fs');3var file = 'data.json';4var data = require('./data.json');5var data2 = require('./data2.json');6var data3 = require('./data3.json');7var data4 = require('./data4.json');8var data5 = require('./data5.json');9var data6 = require('./data6.json');10var data7 = require('./data7.json');11var data8 = require('./data8.json');12var data9 = require('./data9.json');13var data10 = require('./data10.json');14var data11 = require('./data11.json');15var data12 = require('./data12.json');16var data13 = require('./data13.json');17var data14 = require('./data14.json');18var data15 = require('./data15.json');19var data16 = require('./data16.json');20var data17 = require('./data17.json');21var data18 = require('./data18.json');22var data19 = require('./data19.json');23var data20 = require('./data20.json');24var data21 = require('./data21.json');25var data22 = require('./data22.json');26var data23 = require('./data23.json');27var data24 = require('./data24.json');28var data25 = require('./data25.json');29var data26 = require('./data26.json');30var data27 = require('./data27.json');31var data28 = require('./data28.json');32var data29 = require('./data29.json');33var data30 = require('./data30.json');34var data31 = require('./data31.json');35var data32 = require('./data32.json');36var data33 = require('./data33.json');37var data34 = require('./data34.json');38var data35 = require('./data35.json');39var data36 = require('./data36.json');40var data37 = require('./data37.json');41var data38 = require('./data38.json');42var data39 = require('./data39.json');43var data40 = require('./data40.json');44var data41 = require('./data41.json');45var data42 = require('./data42.json');46var data43 = require('./data43.json');47var data44 = require('./data44.json');48var data45 = require('./data45.json');49var data46 = require('./data46.json');50var data47 = require('./data47.json');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('../wptoolkit');2var msA = wpt.msA;3var ms = new msA();4ms.runTest(function(err, data) {5 if (err) {6 console.log(err);7 } else {8 console.log(data);9 }10});11var wpt = require('../wptoolkit');12var msB = wpt.msB;13var ms = new msB();14ms.runTest(function(err, data) {15 if (err) {16 console.log(err);17 } else {18 console.log(data);19 }20});21var wpt = require('../wptoolkit');22var msC = wpt.msC;23var ms = new msC();24ms.runTest(function(err, data) {25 if (err) {26 console.log(err);27 } else {28 console.log(data);29 }30});31var wpt = require('../wptoolkit');32var msD = wpt.msD;33var ms = new msD();34ms.runTest(function(err, data) {35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var wpt = require('../wptoolkit');42var msE = wpt.msE;43var ms = new msE();44ms.runTest(function(err, data) {45 if (err) {46 console.log(err);47 } else {48 console.log(data);49 }50});51var wpt = require('../wptoolkit');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.3b3c0e3b9e9e3a8a2f2c2b7b1b1b1b1b1');3var options = {4};5wpt.runTest(url, options, function(err, data) {6 if (err) return console.error(err);7 console.log(data);8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var options = {3};4var wpt = new WebPageTest('www.webpagetest.org', options.key);5wpt.runTest('www.google.com', options, function(err, data) {6 if (err) return console.error(err);7 console.log('Test submitted to WebPagetest for %s', data.data.summary);8 console.log('Test ID: %s', data.data.testId);9 console.log('Poll results every %s ms', options.pollResults * 1000);10 wpt.getTestResults(data.data.testId, function(err, data) {11 if (err) return console.error(err);12 console.log('Speed Index: %s', data.data.average.firstView.SpeedIndex);13 console.log('Fully Loaded Time: %s', data.data.average.firstView.fullyLoaded);14 console.log('Title: %s', data.data.average.firstView.title);15 console.log('Visual Complete: %s', data.data.average.firstView.visualComplete);16 });17});

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 wpt 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