How to use el.text method in Appium Xcuitest Driver

Best JavaScript code snippet using appium-xcuitest-driver

complete_test.js

Source:complete_test.js Github

copy

Full Screen

1/*global describe it before after beforeEach onload*/2"use client";3 var base = require("plugins/c9.ide.language/test_base");4 base.setup(function(err, imports, helpers) {5 if (err) throw err;6 7 var language = imports.language;8 var chai = require("lib/chai/chai");9 var expect = chai.expect;10 var assert = require("assert");11 var tabs = imports.tabManager;12 var complete = imports["language.complete"];13 var afterNoCompleteOpen = helpers.afterNoCompleteOpen;14 var afterCompleteDocOpen = helpers.afterCompleteDocOpen;15 var afterCompleteOpen = helpers.afterCompleteOpen;16 var isCompleterOpen = helpers.isCompleterOpen;17 var getCompletionCalls = helpers.getCompletionCalls;18 describe("analysis", function() {19 var jsTab;20 var jsSession;21 22 // Setup23 beforeEach(function(done) {24 tabs.getTabs().forEach(function(tab) {25 tab.close(true);26 });27 // tab.close() isn't quite synchronous, wait for it :(28 complete.closeCompletionBox();29 setTimeout(function() {30 tabs.openFile("/language.js", function(err, tab) {31 if (err) return done(err);32 33 jsTab = tab;34 jsSession = jsTab.document.getSession().session;35 expect(jsSession).to.not.equal(null);36 setTimeout(function() {37 complete.closeCompletionBox();38 done();39 });40 });41 }, 0);42 });43 44 it('shows a word completer popup on keypress', function(done) {45 jsSession.setValue("conny; con");46 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});47 jsTab.editor.ace.onTextInput("n");48 afterCompleteOpen(function(el) {49 expect.html(el).text(/conny/);50 done();51 });52 });53 54 it('shows a word completer popup for things in comments', function(done) {55 jsSession.setValue("// conny\nco");56 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});57 jsTab.editor.ace.onTextInput("n");58 afterCompleteOpen(function(el) {59 expect.html(el).text(/conny/);60 done();61 });62 });63 64 it('shows an inference completer popup on keypress', function(done) {65 jsSession.setValue("console.");66 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});67 jsTab.editor.ace.onTextInput("l");68 afterCompleteOpen(function(el) {69 expect.html(el).text(/log\(/);70 done();71 });72 });73 74 it('always does dot completion', function(done) {75 language.setContinuousCompletionEnabled(false);76 jsSession.setValue("console");77 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});78 jsTab.editor.ace.onTextInput(".");79 afterCompleteOpen(function(el) {80 expect.html(el).text(/log\(/);81 language.setContinuousCompletionEnabled(true);82 done();83 });84 });85 86 it('shows a documentation popup in completion', function(done) {87 jsSession.setValue("console.");88 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});89 jsTab.editor.ace.onTextInput("l");90 afterCompleteDocOpen(function(el) {91 expect.html(el).text(/Outputs a message/);92 done();93 });94 });95 96 it('shows a word completer in an immediate tab', function(done) {97 tabs.open(98 {99 active: true,100 editorType: "immediate"101 },102 function(err, tab) {103 if (err) return done(err);104 105 // We get a tab, but it's not done yet, so we wait106 setTimeout(function() {107 expect(!isCompleterOpen());108 tab.editor.ace.onTextInput("conny con");109 expect(!isCompleterOpen());110 tab.editor.ace.onTextInput("n");111 afterCompleteOpen(function(el) {112 expect.html(el).text(/conny/);113 done();114 });115 });116 }117 );118 });119 120 it('shows an immediate completer in an immediate tab', function(done) {121 tabs.open(122 {123 active: true,124 editorType: "immediate"125 },126 function(err, tab) {127 if (err) return done(err);128 129 // We get a tab, but it's not done yet, so we wait130 setTimeout(function() {131 tab.editor.ace.onTextInput("window.a");132 tab.editor.ace.onTextInput("p");133 afterCompleteOpen(function(el) {134 expect.html(el).text(/applicationCache/);135 done();136 });137 });138 }139 );140 });141 142 it("doesn't show a word completer when there are contextual completions", function(done) {143 jsSession.setValue("// logaritm\nconsole.");144 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});145 jsTab.editor.ace.onTextInput("l");146 afterCompleteOpen(function(el) {147 assert(!el.textContent.match(/logarithm/));148 done();149 });150 });151 152 it("completes with parentheses insertion", function(done) {153 jsSession.setValue("// logaritm\nconsole.");154 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});155 jsTab.editor.ace.onTextInput("l");156 afterCompleteOpen(function(el) {157 jsTab.editor.ace.keyBinding.onCommandKey({ preventDefault: function() {} }, 0, 13);158 setTimeout(function() {159 assert(jsSession.getValue().match(/console.log\(\)/));160 done();161 });162 });163 });164 165 it("completes local functions with parentheses insertion", function(done) {166 jsSession.setValue('function foobar() {}\nfoo');167 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});168 jsTab.editor.ace.onTextInput("b");169 afterCompleteOpen(function(el) {170 jsTab.editor.ace.keyBinding.onCommandKey({ preventDefault: function() {} }, 0, 13);171 setTimeout(function() {172 assert(jsSession.getValue().match(/foobar\(\)/));173 done();174 });175 });176 });177 178 it("completes without parentheses insertion in strings", function(done) {179 jsSession.setValue('function foobar() {}\n\"foo');180 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});181 jsTab.editor.ace.onTextInput("b");182 afterCompleteOpen(function(el) {183 jsTab.editor.ace.keyBinding.onCommandKey({ preventDefault: function() {} }, 0, 13);184 setTimeout(function() {185 assert(jsSession.getValue().match(/"foobar/));186 assert(!jsSession.getValue().match(/"foobar\(\)/));187 done();188 });189 });190 });191 192 it("completes following local dependencies", function(done) {193 jsSession.setValue('var test2 = require\("./test2.js");\ntest2.');194 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});195 jsTab.editor.ace.onTextInput("h");196 afterCompleteOpen(function(el) {197 assert(el.textContent.match(/hoi/));198 done();199 });200 });201 202 it("completes following local with absolute paths", function(done) {203 jsSession.setValue('var ext = require\("plugins/c9.dummy/dep");\next.');204 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});205 jsTab.editor.ace.onTextInput("e");206 afterCompleteOpen(function(el) {207 assert(el.textContent.match(/export3/));208 assert(el.textContent.match(/export4/));209 done();210 });211 });212 213 it("completes following local dependencies with absolute paths and common js style exports", function(done) {214 jsSession.setValue('var ext = require\("plugins/c9.dummy/dep-define");\next.');215 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});216 jsTab.editor.ace.onTextInput("e");217 afterCompleteOpen(function(el) {218 assert(el.textContent.match(/export1/));219 assert(el.textContent.match(/export2/));220 done();221 });222 });223 224 it("doesn't show default browser properties like onabort for global completions", function(done) {225 jsSession.setValue('// function onlyShowMe() {}; \no');226 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});227 jsTab.editor.ace.onTextInput("n");228 afterCompleteOpen(function(el) {229 assert(!el.textContent.match(/onabort/));230 done();231 });232 });233 234 it("shows default browser properties like onabort when 3 characters were typed", function(done) {235 jsSession.setValue('// function onlyShowMeAndMore() {};\non');236 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});237 jsTab.editor.ace.onTextInput("a");238 afterCompleteOpen(function(el) {239 assert(el.textContent.match(/onabort/));240 done();241 });242 });243 244 it("shows no self-completion for 'var bre'", function(done) {245 jsSession.setValue('var ');246 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});247 jsTab.editor.ace.onTextInput("bre");248 afterCompleteOpen(function(el) {249 assert(!el.textContent.match(/bre\b/));250 assert(el.textContent.match(/break/));251 done();252 });253 });254 255 it("shows word completion for 'var b'", function(done) {256 jsSession.setValue('// blie\nvar ');257 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});258 jsTab.editor.ace.onTextInput("b");259 afterCompleteOpen(function(el) {260 assert(el.textContent.match(/blie/));261 done();262 });263 });264 265 it("shows word completion for 'var bre'", function(done) {266 jsSession.setValue('// breedbeeld\nvar ');267 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});268 jsTab.editor.ace.onTextInput("bre");269 afterCompleteOpen(function(el) {270 assert(el.textContent.match(/breedbeeld/));271 done();272 });273 });274 275 it("shows no self-completion for 'function blie'", function(done) {276 jsSession.setValue('function bli');277 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});278 jsTab.editor.ace.onTextInput("e");279 afterNoCompleteOpen(done);280 });281 282 it("shows no completion for 'function blie(param'", function(done) {283 jsSession.setValue('function blie(para');284 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});285 jsTab.editor.ace.onTextInput("m");286 afterNoCompleteOpen(done);287 });288 289 it.skip("shows word completion for 'function blie(param'", function(done) {290 jsSession.setValue('function parametric() {}\nfunction blie(para');291 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});292 jsTab.editor.ace.onTextInput("m");293 afterCompleteOpen(function(el) {294 assert(!el.textContent.match(/parapara/));295 assert(el.textContent.match(/parametric/));296 done();297 });298 });299 300 it("shows no self-completion for 'x={ prop'", function(done) {301 jsSession.setValue('x={ pro');302 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});303 jsTab.editor.ace.onTextInput("p");304 afterNoCompleteOpen(done);305 });306 307 it("shows no function completion for 'x={ prop: 2 }'", function(done) {308 jsSession.setValue('function propAccess() {}\nx={ pro: 2 }');309 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 7 }, end: { row: 1, column: 7 }});310 jsTab.editor.ace.onTextInput("p");311 afterCompleteOpen(function(el) {312 assert(!el.textContent.match(/propAccess\(\)/));313 assert(el.textContent.match(/propAccess/));314 done();315 });316 });317 318 it("shows completion for '{ prop: fo'", function(done) {319 jsSession.setValue('function foo() {}\n{ prop: f');320 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 2, column: 0 }, end: { row: 2, column: 0 }});321 jsTab.editor.ace.onTextInput("o");322 afterCompleteOpen(function(el) {323 assert(el.textContent.match(/foo\(\)/));324 done();325 });326 });327 328 it("extracts types from comments", function(done) {329 jsSession.setValue('/**\ndocs be here\n@param {String} text\n*/\nfunction foo(text) {}\nf');330 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 10, column: 0 }, end: { row: 10, column: 0 }});331 jsTab.editor.ace.onTextInput("o");332 afterCompleteOpen(function(el) {333 assert(el.textContent.match(/foo\(text\)/));334 afterCompleteDocOpen(function(el) {335 assert(el.textContent.match(/string/i));336 assert(el.textContent.match(/docs/i));337 done();338 });339 });340 });341 342 it("caches across expression prefixes", function(done) {343 jsSession.setValue("_collin; _c");344 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});345 jsTab.editor.ace.onTextInput("o");346 afterCompleteOpen(function(el) {347 assert.equal(getCompletionCalls(), 1);348 complete.closeCompletionBox();349 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});350 jsTab.editor.ace.onTextInput("rry _co");351 afterCompleteOpen(function(el) {352 assert.equal(getCompletionCalls(), 1);353 // Normally typing "_corry _c" would show "_corry" in the completion,354 // but since JavaScript is supposed to have a getCacheCompletionRegex set,355 // a cached results should be used that doesn't have "_corry" yet356 assert(!el.textContent.match(/_corry/));357 assert(el.textContent.match(/_collin/));358 done();359 });360 });361 });362 363 it("caches across expression prefixes, including 'if(' and 'if ('", function(done) {364 jsSession.setValue("b_collin; b_c");365 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});366 jsTab.editor.ace.onTextInput("o");367 afterCompleteOpen(function(el) {368 assert.equal(getCompletionCalls(), 1);369 complete.closeCompletionBox();370 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});371 jsTab.editor.ace.onTextInput("rry if(if (b_co");372 afterCompleteOpen(function(el) {373 assert.equal(getCompletionCalls(), 1);374 assert(el.textContent.match(/b_corry/)); // local_completer secretly ran a second time375 assert(el.textContent.match(/b_collin/));376 done();377 });378 });379 });380 381 it("doesn't cache across expression prefixes in assigments", function(done) {382 jsSession.setValue("_collin; _c");383 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});384 jsTab.editor.ace.onTextInput("o");385 afterCompleteOpen(function(el) {386 assert.equal(getCompletionCalls(), 1);387 complete.closeCompletionBox();388 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});389 jsTab.editor.ace.onTextInput("rry=_co");390 afterCompleteOpen(function(el) {391 assert.equal(getCompletionCalls(), 2);392 assert(el.textContent.match(/_corry/));393 assert(el.textContent.match(/_collin/));394 done();395 });396 });397 });398 399 it("doesn't cache with expression prefixes based on function names or params", function(done) {400 jsSession.setValue("ffarg; function ");401 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});402 jsTab.editor.ace.onTextInput("ff");403 afterCompleteOpen(function(el) {404 assert.equal(getCompletionCalls(), 1);405 assert(el.textContent.match(/ffarg/));406 complete.closeCompletionBox();407 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});408 jsTab.editor.ace.onTextInput("oo(ff");409 afterCompleteOpen(function(el) {410 assert.equal(getCompletionCalls(), 2);411 // cache got cleared so we have farg here now412 assert(el.textContent.match(/ffoo/));413 assert(el.textContent.match(/ffarg/));414 complete.closeCompletionBox();415 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});416 jsTab.editor.ace.onTextInput("ort) ff");417 afterCompleteOpen(function(el) {418 assert.equal(getCompletionCalls(), 3);419 // cache got cleared so we have fort here now420 assert(el.textContent.match(/ffoo/));421 assert(el.textContent.match(/ffort/));422 assert(el.textContent.match(/ffarg/));423 done();424 });425 });426 });427 });428 429 it("doesn't do prefix-caching outside of a function context", function(done) {430 jsSession.setValue("function foo() { ");431 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});432 jsTab.editor.ace.onTextInput("f");433 afterCompleteOpen(function(el) {434 assert.equal(getCompletionCalls(), 1);435 complete.closeCompletionBox();436 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});437 jsTab.editor.ace.onTextInput("} f");438 afterCompleteOpen(function(el) {439 assert.equal(getCompletionCalls(), 2);440 done();441 });442 });443 });444 445 it("doesn't do prefix-caching after property access", function(done) {446 jsSession.setValue("console.l");447 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});448 jsTab.editor.ace.onTextInput("o");449 afterCompleteOpen(function(el) {450 assert.equal(getCompletionCalls(), 1);451 complete.closeCompletionBox();452 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});453 jsTab.editor.ace.onTextInput("g c");454 afterCompleteOpen(function(el) {455 assert(el.textContent.match(/console/), el.textContent);456 assert.equal(getCompletionCalls(), 2, "Should refetch after property access: " + getCompletionCalls());457 done();458 });459 });460 });461 462 it.skip('predicts console.log() when typing just consol', function(done) {463 jsSession.setValue("conso");464 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});465 jsTab.editor.ace.onTextInput("l");466 imports.worker.once("complete_predict_called", function() {467 assert.equal(getCompletionCalls(), 1);468 afterCompleteOpen(function retry(el) {469 assert.equal(getCompletionCalls(), 1);470 if (!el.textContent.match(/log/))471 return afterCompleteOpen(retry);472 done();473 });474 });475 });476 477 it('shows the current identifier as the top result', function(done) {478 jsSession.setValue("concat; conso; cons");479 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});480 jsTab.editor.ace.onTextInput("o");481 afterCompleteOpen(function(el) {482 assert.equal(getCompletionCalls(), 1);483 assert(el.textContent.match(/conso(?!l).*console/));484 done();485 });486 });487 488 it('shows the current identifier as the top result, and removes it as you keep typing', function(done) {489 jsSession.setValue("2; concat; conso; cons");490 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});491 jsTab.editor.ace.onTextInput("o");492 afterCompleteOpen(function(el) {493 assert.equal(getCompletionCalls(), 1);494 assert(el.textContent.match(/conso(?!l).*console/));495 complete.closeCompletionBox();496 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});497 jsTab.editor.ace.onTextInput("l");498 afterCompleteOpen(function(el) {499 assert.equal(getCompletionCalls(), 1);500 assert(!el.textContent.match(/conso(?!l)/));501 assert(el.textContent.match(/console/));502 done();503 });504 });505 });506 507 it("doesn't assume undeclared vars are functions", function(done) {508 jsSession.setValue('window[imUndefined] = function(json) {};\n\509 var unassigned;\n\510 ');511 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 10, column: 0 }, end: { row: 10, column: 0 }});512 jsTab.editor.ace.onTextInput("u");513 afterCompleteOpen(function(el) {514 assert(el.textContent.match(/unassigned/));515 assert(!el.textContent.match(/unassigned\(/));516 done();517 });518 });519 520 it("doesn't assume arrays are optional", function(done) {521 jsSession.setValue('function myFun(arr){}\nvar a = []\nmyFun(a)\nmyF');522 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 10, column: 0 }, end: { row: 10, column: 0 }});523 jsTab.editor.ace.onTextInput("u");524 afterCompleteDocOpen(function(el) {525 assert(el.textContent.match(/myFun\(arr.*Array/));526 done();527 });528 });529 530 it.skip("completes php variables in short php escapes", function(done) {531 tabs.openFile("/test_broken.php", function(err, _tab) {532 if (err) return done(err);533 var tab = _tab;534 tabs.focusTab(tab);535 var session = tab.document.getSession().session;536 537 session.setValue("<?php $foo = 1; ?>");538 tab.editor.ace.selection.setSelectionRange({ start: { row: 0, column: 16 }, end: { row: 0, column: 16 }});539 tab.editor.ace.onTextInput("$");540 afterCompleteOpen(function(el) {541 complete.closeCompletionBox();542 tab.editor.ace.onTextInput("f");543 afterCompleteOpen(function(el) {544 assert(el.textContent.match(/foo/));545 done();546 });547 });548 });549 });550 551 it.skip("completes php variables in long files", function(done) {552 tabs.openFile("/test_broken.php", function(err, _tab) {553 if (err) return done(err);554 var tab = _tab;555 tabs.focusTab(tab);556 var session = tab.document.getSession().session;557 558 var value = "<?php\n\n";559 for (var i = 0; i < 1000; i++) {560 value += "$foo_" + i + " = 42;\n";561 }562 value = value + "?>";563 session.setValue(value);564 565 tab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});566 tab.editor.ace.onTextInput("$");567 afterCompleteOpen(function(el) {568 complete.closeCompletionBox();569 tab.editor.ace.onTextInput("foo_99");570 afterCompleteOpen(function(el) {571 assert(el.textContent.match(/foo_991/));572 done();573 });574 });575 });576 });577 578 it('starts predicting a completion immediately after an assignment', function(done) {579 // We expect this behavior as infer_completer's predictNextCompletion()580 // tells worker we need completion here.581 jsSession.setValue("foo ");582 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});583 jsTab.editor.ace.onTextInput("=");584 585 imports.testHandler.once("complete_called", function() {586 assert.equal(getCompletionCalls(), 1);587 jsTab.editor.ace.onTextInput(" ");588 // Wait and see if this triggers anything589 setTimeout(function() {590 jsTab.editor.ace.onTextInput("f");591 592 afterCompleteOpen(function(el) {593 assert.equal(getCompletionCalls(), 1);594 assert(el.textContent.match(/foo/));595 done();596 });597 }, 5);598 });599 });600 601 it.skip('just invokes completion once for "v1 + 1 == v2 + v"', function(done) {602 jsSession.setValue("var v1; ");603 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});604 jsTab.editor.ace.onTextInput("v");605 afterCompleteOpen(function(el) {606 complete.closeCompletionBox();607 jsTab.editor.ace.onTextInput("1");608 jsTab.editor.ace.onTextInput(" ");609 jsTab.editor.ace.onTextInput("+");610 jsTab.editor.ace.onTextInput(" ");611 jsTab.editor.ace.onTextInput("1");612 jsTab.editor.ace.onTextInput(" ");613 jsTab.editor.ace.onTextInput("=");614 jsTab.editor.ace.onTextInput("=");615 jsTab.editor.ace.onTextInput(" ");616 jsTab.editor.ace.onTextInput("v");617 afterCompleteOpen(function(el) {618 complete.closeCompletionBox();619 jsTab.editor.ace.onTextInput("2");620 jsTab.editor.ace.onTextInput(" ");621 jsTab.editor.ace.onTextInput("+");622 jsTab.editor.ace.onTextInput(" ");623 jsTab.editor.ace.onTextInput("v");624 afterCompleteOpen(function(el) {625 assert.equal(getCompletionCalls(), 1);626 done();627 });628 });629 });630 });631 632 it.skip('just invokes completion once for "x1 + 1 == x2 + x", with some timeouts', function(done) {633 jsSession.setValue("var x1; ");634 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});635 jsTab.editor.ace.onTextInput("x");636 afterCompleteOpen(function(el) {637 jsTab.editor.ace.onTextInput("1");638 jsTab.editor.ace.onTextInput(" ");639 // Allow prediction to be triggered640 setTimeout(function() {641 jsTab.editor.ace.onTextInput("+");642 // Allow prediction to be triggered643 setTimeout(function() {644 jsTab.editor.ace.onTextInput(" ");645 jsTab.editor.ace.onTextInput("1");646 jsTab.editor.ace.onTextInput(" ");647 jsTab.editor.ace.onTextInput("=");648 jsTab.editor.ace.onTextInput("=");649 // Allow prediction to be triggered650 setTimeout(function() {651 jsTab.editor.ace.onTextInput(" ");652 jsTab.editor.ace.onTextInput("x");653 afterCompleteOpen(function(el) {654 complete.closeCompletionBox();655 jsTab.editor.ace.onTextInput("2");656 jsTab.editor.ace.onTextInput(" ");657 jsTab.editor.ace.onTextInput("+");658 jsTab.editor.ace.onTextInput(" ");659 jsTab.editor.ace.onTextInput("x");660 afterCompleteOpen(function(el) {661 assert.equal(getCompletionCalls(), 1);662 done();663 });664 });665 }, 5);666 }, 5);667 }, 5);668 });669 });670 671 it('calls completion twice for "var y; ...", "var v; ..."', function(done) {672 jsSession.setValue("var y1; ");673 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});674 jsTab.editor.ace.onTextInput("y");675 afterCompleteOpen(function(el) {676 complete.closeCompletionBox();677 jsSession.setValue("var v1; ");678 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});679 jsTab.editor.ace.onTextInput("v");680 afterCompleteOpen(function(el) {681 assert.equal(getCompletionCalls(), 2);682 done();683 });684 });685 });686 687 it("doesn't start predicting completion immediately after a newline", function(done) {688 // We expect this behavior as infer_completer's predictNextCompletion()689 // tells worker we need completion here.690 jsSession.setValue("var foo;");691 jsTab.editor.ace.selection.setSelectionRange({ start: { row: 1, column: 0 }, end: { row: 1, column: 0 }});692 jsTab.editor.ace.onTextInput("\n");693 694 setTimeout(function() {695 jsTab.editor.ace.onTextInput("\nf");696 imports.testHandler.once("complete_called", function() {697 assert.equal(getCompletionCalls(), 1);698 done();699 });700 }, 50);701 });702 703 it("completes python", function(done) {704 tabs.openFile("/python/test_user.py", function(err, _tab) {705 if (err) return done(err);706 var tab = _tab;707 tabs.focusTab(tab);708 var session = tab.document.getSession().session;709 710 session.setValue("import os; os");711 tab.editor.ace.selection.setSelectionRange({ start: { row: 0, column: 16 }, end: { row: 0, column: 16 }});712 imports.worker.once("python_completer_ready", function() {713 tab.editor.ace.onTextInput(".");714 afterCompleteOpen(function(el) {715 complete.closeCompletionBox();716 assert(el.textContent.match(/abort/));717 done();718 });719 });720 });721 });722 }); ...

Full Screen

Full Screen

GitanaConsoleBreadcrumb.js

Source:GitanaConsoleBreadcrumb.js Github

copy

Full Screen

1(function($) {2 Gitana.Console.Breadcrumb = {3 "PATHS" : {4 },5 "findPath": function (child, self, callback) {6 child.listRelatives({7 "type" : "a:child",8 "direction" : "INCOMING"9 }, {10 "skip" : 0,11 "limit" : 112 }).count(function(count) {13 if (count == 1) {14 this.keepOne().then(function() {15 var parentNode = this;16 if (Gitana.Console.Breadcrumb.PATHS[parentNode.getId()]) {17 var childPath = $.merge([], Gitana.Console.Breadcrumb.PATHS[parentNode.getId()]);18 childPath.push({19 "text" : self.friendlyTitle(child),20 "link" : self.folderLink(child)21 });22 Gitana.Console.Breadcrumb.PATHS[child.getId()] = childPath;23 } else {24 Gitana.Console.Breadcrumb.findPath(parentNode, self, function() {25 if (Gitana.Console.Breadcrumb.PATHS[parentNode.getId()]) {26 var childPath = $.merge([], Gitana.Console.Breadcrumb.PATHS[parentNode.getId()]);27 childPath.push({28 "text" : self.friendlyTitle(child),29 "link" : self.folderLink(child)30 });31 Gitana.Console.Breadcrumb.PATHS[child.getId()] = childPath;32 }33 });34 }35 });36 }37 this.then(function() {38 if (callback) {39 callback();40 }41 });42 });43 },44 "Error" : function(self, el) {45 return [46 {47 "text" : "Error",48 "link" : "/error"49 }50 ];51 },52 "MyProfile" : function(self, el) {53 return [54 {55 "text" : "My Profile",56 "link" : "/profile"57 }58 ];59 },60 "Platform" : function(self, el) {61 return [62 {63 "text" : "Platform",64 "link" : self.link(self.platform()),65 "requiredAuthorities" : [66 {67 "permissioned" : self.platform(),68 "permissions" : ["update"]69 }70 ]71 }72 ];73 },74 "PlatformTeams" : function(self, el) {75 return $.merge(this.Platform(self, el), [76 {77 "text" : "Teams",78 "link" : self.LINK().call(self, self.platform(), "teams")79 }80 ]);81 },82 "PlatformTeam" : function(self , el) {83 return $.merge(this.PlatformTeams(self, el), [84 {85 "text" : self.friendlyTitle(self.team()),86 "link" : self.teamLink(self.team(),self.platform())87 }88 ]);89 },90 "PlatformLogs" : function(self, el) {91 return $.merge(this.Platform(self, el), [92 {93 "text" : "Logs",94 "link" : self.link(self.platform()) + "logs"95 }96 ]);97 },98 "PlatformJobs" : function(self, el) {99 return $.merge(this.Platform(self, el), [100 {101 "text" : "Jobs",102 "link" : self.listLink("jobs")103 }104 ]);105 },106 "Domains" : function(self , el) {107 return $.merge(this.Platform(self, el), [108 {109 "text" : "Domains",110 "link" : self.LIST_LINK().call(self,'domains')111 }112 ]);113 },114 "Domain" : function(self , el) {115 return $.merge(this.Domains(self, el), [116 {117 "text" : self.friendlyTitle(self.domain()),118 "link" : self.LINK().call(self,self.domain())119 }120 ]);121 },122 "Vaults" : function(self , el) {123 return $.merge(this.Platform(self, el), [124 {125 "text" : "Vaults",126 "link" : self.LIST_LINK().call(self,'vaults')127 }128 ]);129 },130 "Vault" : function(self , el) {131 return $.merge(this.Vaults(self, el), [132 {133 "text" : self.friendlyTitle(self.vault()),134 "link" : self.LINK().call(self,self.vault())135 }136 ]);137 },138 "VaultTeams" : function(self, el) {139 return $.merge(this.Vault(self, el), [140 {141 "text" : "Teams",142 "link" : self.LINK().call(self, self.vault(), "teams")143 }144 ]);145 },146 "VaultTeam" : function(self , el) {147 return $.merge(this.VaultTeams(self, el), [148 {149 "text" : self.friendlyTitle(self.team()),150 "link" : self.teamLink(self.team(),self.vault())151 }152 ]);153 },154 "Archives" : function(self , el) {155 return $.merge(this.Vault(self, el), [156 {157 "text" : "Archives",158 "link" : self.LIST_LINK().call(self,'archives')159 }160 ]);161 },162 "Archive" : function(self , el) {163 return $.merge(this.Archives(self, el), [164 {165 "text" : self.friendlyTitle(self.archive()),166 "link" : self.LINK().call(self,self.archive())167 }168 ]);169 },170 "Stacks" : function(self , el) {171 return $.merge(this.Platform(self, el), [172 {173 "text" : "Stacks",174 "link" : self.LIST_LINK().call(self,'stacks')175 }176 ]);177 },178 "Stack" : function(self , el) {179 return $.merge(this.Stacks(self, el), [180 {181 "text" : self.friendlyTitle(self.stack()),182 "link" : self.LINK().call(self,self.stack())183 }184 ]);185 },186 "StackAttachments" : function(self, el) {187 return $.merge(this.Stack(self, el), [188 {189 "text" : "Attachments",190 "link" : self.LINK().call(self, self.stack(), "attachments")191 }192 ]);193 },194 "StackLogs" : function(self , el) {195 return $.merge(this.Stack(self, el), [196 {197 "text" : "Logs",198 "link" : self.LINK().call(self, self.stack(),"logs")199 }200 ]);201 },202 "StackTeams" : function(self, el) {203 return $.merge(this.Stack(self, el), [204 {205 "text" : "Teams",206 "link" : self.LINK().call(self, self.stack(), "teams")207 }208 ]);209 },210 "StackTeam" : function(self , el) {211 return $.merge(this.StackTeams(self, el), [212 {213 "text" : self.friendlyTitle(self.team()),214 "link" : self.teamLink(self.team(),self.stack())215 }216 ]);217 },218 "Applications" : function(self , el) {219 return $.merge(this.Platform(self, el), [220 {221 "text" : "Applications",222 "link" : self.LIST_LINK().call(self,'applications')223 }224 ]);225 },226 "Application" : function(self , el) {227 return $.merge(this.Applications(self, el), [228 {229 "text" : self.friendlyTitle(self.application()),230 "link" : self.LINK().call(self,self.application())231 }232 ]);233 },234 "Settings" : function(self , el) {235 return $.merge(this.Application(self, el), [236 {237 "text" : "Settings List",238 "link" : self.LIST_LINK().call(self,'settings')239 }240 ]);241 },242 "Setting" : function(self , el) {243 return $.merge(this.Settings(self, el), [244 {245 "text" : self.friendlyTitle(self.settings()),246 "link" : self.LINK().call(self,self.settings())247 }248 ]);249 },250 "EmailProviders" : function(self , el) {251 return $.merge(this.Application(self, el), [252 {253 "text" : "Email Providers List",254 "link" : self.LIST_LINK().call(self,'emailproviders')255 }256 ]);257 },258 "EmailProvider" : function(self , el) {259 return $.merge(this.EmailProviders(self, el), [260 {261 "text" : self.friendlyTitle(self.emailProvider()),262 "link" : self.LINK().call(self,self.emailProvider())263 }264 ]);265 },266 "Warehouses" : function(self , el) {267 return $.merge(this.Platform(self, el), [268 {269 "text" : "Warehouses",270 "link" : self.LIST_LINK().call(self,'warehouses')271 }272 ]);273 },274 "Warehouse" : function(self , el) {275 return $.merge(this.Warehouses(self, el), [276 {277 "text" : self.friendlyTitle(self.warehouse()),278 "link" : self.LINK().call(self,self.warehouse())279 }280 ]);281 },282 "Sessions" : function(self , el) {283 return $.merge(this.Warehouse(self, el), [284 {285 "text" : "Interaction Sessions",286 "link" : self.LIST_LINK().call(self,'sessions')287 }288 ]);289 },290 "Session" : function(self , el) {291 return $.merge(this.Sessions(self, el), [292 {293 "text" : self.friendlyTitle(self.session()),294 "link" : self.LINK().call(self,self.session())295 }296 ]);297 },298 "InteractionReports" : function(self , el) {299 return $.merge(this.Warehouse(self, el), [300 {301 "text" : "Interaction Reports",302 "link" : self.LIST_LINK().call(self,'interaction-reports')303 }304 ]);305 },306 "InteractionReport" : function(self , el) {307 return $.merge(this.InteractionReports(self, el), [308 {309 "text" : self.friendlyTitle(self.interactionReport()),310 "link" : self.LINK().call(self,self.interactionReport())311 }312 ]);313 },314 "InteractionPages" : function(self , el) {315 return $.merge(this.Warehouse(self, el), [316 {317 "text" : "Interaction Pages",318 "link" : self.LIST_LINK().call(self,'interaction-pages')319 }320 ]);321 },322 "InteractionPage" : function(self , el) {323 return $.merge(this.InteractionPages(self, el), [324 {325 "text" : self.friendlyTitle(self.interactionPage()),326 "link" : self.LINK().call(self,self.interactionPage())327 }328 ]);329 },330 "InteractionUsers" : function(self , el) {331 return $.merge(this.Warehouse(self, el), [332 {333 "text" : "Interaction Users",334 "link" : self.LIST_LINK().call(self,'interaction-users')335 }336 ]);337 },338 "InteractionUser" : function(self , el) {339 return $.merge(this.InteractionUsers(self, el), [340 {341 "text" : self.friendlyTitle(self.interactionUser()),342 "link" : self.LINK().call(self,self.interactionUser())343 }344 ]);345 },346 "InteractionNodes" : function(self , el) {347 return $.merge(this.Warehouse(self, el), [348 {349 "text" : "Interaction Nodes",350 "link" : self.LIST_LINK().call(self,'interaction-nodes')351 }352 ]);353 },354 "InteractionNode" : function(self , el) {355 return $.merge(this.InteractionNodes(self, el), [356 {357 "text" : self.friendlyTitle(self.interactionNode()),358 "link" : self.LINK().call(self,self.interactionNode())359 }360 ]);361 },362 "InteractionApplications" : function(self , el) {363 return $.merge(this.Warehouse(self, el), [364 {365 "text" : "Interaction Applications",366 "link" : self.LIST_LINK().call(self,'interaction-applications')367 }368 ]);369 },370 "InteractionApplication" : function(self , el) {371 return $.merge(this.InteractionApplications(self, el), [372 {373 "text" : self.friendlyTitle(self.interactionApplication()),374 "link" : self.LINK().call(self,self.interactionApplication())375 }376 ]);377 },378 "ApplicationTeams" : function(self, el) {379 return $.merge(this.Application(self, el), [380 {381 "text" : "Teams",382 "link" : self.LINK().call(self, self.application(), "teams")383 }384 ]);385 },386 "ApplicationTeam" : function(self , el) {387 return $.merge(this.ApplicationTeams(self, el), [388 {389 "text" : self.friendlyTitle(self.team()),390 "link" : self.teamLink(self.team(),self.application())391 }392 ]);393 },394 "WarehouseTeams" : function(self, el) {395 return $.merge(this.Warehouse(self, el), [396 {397 "text" : "Teams",398 "link" : self.LINK().call(self, self.warehouse(), "teams")399 }400 ]);401 },402 "WarehouseTeam" : function(self , el) {403 return $.merge(this.WarehouseTeams(self, el), [404 {405 "text" : self.friendlyTitle(self.team()),406 "link" : self.teamLink(self.team(),self.warehouse())407 }408 ]);409 },410 "Registrars" : function(self , el) {411 return $.merge(this.Platform(self, el), [412 {413 "text" : "Registrars",414 "link" : self.LIST_LINK().call(self,'registrars')415 }416 ]);417 },418 "Registrar" : function(self , el) {419 return $.merge(this.Registrars(self, el), [420 {421 "text" : self.friendlyTitle(self.registrar()),422 "link" : self.LINK().call(self,self.registrar())423 }424 ]);425 },426 "Tenants" : function(self , el) {427 return $.merge(this.Registrar(self, el), [428 {429 "text" : "Tenants",430 "link" : self.LIST_LINK().call(self,'tenants')431 }432 ]);433 },434 "Tenant" : function(self , el) {435 return $.merge(this.Tenants(self, el), [436 {437 "text" : self.friendlyTitle(self.tenant()),438 "link" : self.LINK().call(self,self.tenant())439 }440 ]);441 },442 "TenantAttachments" : function(self, el) {443 return $.merge(this.Tenant(self, el), [444 {445 "text" : "Attachments",446 "link" : self.LINK().call(self, self.tenant(), "attachments")447 }448 ]);449 },450 "TenantTeams" : function(self, el) {451 return $.merge(this.Tenant(self, el), [452 {453 "text" : "Teams",454 "link" : self.LINK().call(self, self.tenant(), "teams")455 }456 ]);457 },458 "TenantTeam" : function(self , el) {459 return $.merge(this.TenantTeams(self, el), [460 {461 "text" : self.friendlyTitle(self.team()),462 "link" : self.teamLink(self.team(),self.tenant())463 }464 ]);465 },466 "Plans" : function(self , el) {467 return $.merge(this.Registrar(self, el), [468 {469 "text" : "Plans",470 "link" : self.LIST_LINK().call(self,'plans')471 }472 ]);473 },474 "Plan" : function(self , el) {475 return $.merge(this.Plans(self, el), [476 {477 "text" : self.friendlyTitle(self.plan()),478 "link" : self.LINK().call(self,self.plan())479 }480 ]);481 },482 "Clients" : function(self , el) {483 return $.merge(this.Platform(self, el), [484 {485 "text" : "Clients",486 "link" : self.LIST_LINK().call(self,'clients')487 }488 ]);489 },490 "Client" : function(self , el) {491 return $.merge(this.Clients(self, el), [492 {493 "text" : self.friendlyTitle(self.client()),494 "link" : self.LINK().call(self,self.client())495 }496 ]);497 },498 "AuthenticationGrants" : function(self , el) {499 return $.merge(this.Platform(self, el), [500 {501 "text" : "Authentication Grants",502 "link" : self.LIST_LINK().call(self,'authenticationGrants')503 }504 ]);505 },506 "AuthenticationGrant" : function(self , el) {507 return $.merge(this.AuthenticationGrants(self, el), [508 {509 "text" : self.friendlyTitle(self.authenticationGrant()),510 "link" : self.LINK().call(self,self.authenticationGrant())511 }512 ]);513 },514 "Projects" : function(self , el) {515 return $.merge(this.Platform(self, el), [516 {517 "text" : "Projects",518 "link" : self.LIST_LINK().call(self,'projects')519 }520 ]);521 },522 "Project" : function(self , el) {523 return $.merge(this.Projects(self, el), [524 {525 "text" : self.friendlyTitle(self.project()),526 "link" : self.LINK().call(self,self.project())527 }528 ]);529 },530 "Repositories" : function(self , el) {531 return $.merge(this.Platform(self, el), [532 {533 "text" : "Repositories",534 "link" : self.LIST_LINK().call(self,'repositories')535 }536 ]);537 },538 "RepositoryLogs" : function(self , el) {539 return $.merge(this.Repositories(self, el), [540 {541 "text" : "Logs",542 "link" : self.LINK().call(self,self.repository(),"logs")543 }544 ]);545 },546 "RepositoryChangesets" : function(self , el) {547 return $.merge(this.Repositories(self, el), [548 {549 "text" : "Change Sets",550 "link" : self.LINK().call(self,self.repository(),"changesets")551 }552 ]);553 },554 "DomainGroups" : function(self , el) {555 return $.merge(this.Domain(self, el), [556 {557 "text" : "Groups",558 "link" : self.listLink('groups')559 }560 ]);561 },562 "DomainUsers" : function(self , el) {563 return $.merge(this.Domain(self, el), [564 {565 "text" : "Users",566 "link" : self.listLink('users')567 }568 ]);569 },570 "Repository" : function(self , el) {571 return $.merge(this.Repositories(self, el), [572 {573 "text" : self.friendlyTitle(self.repository()),574 "link" : self.LINK().call(self,self.repository())575 }576 ]);577 },578 "RepositoryTeams" : function(self , el) {579 return $.merge(this.Repository(self, el), [580 {581 "text" : "Teams",582 "link" : self.listLink('repository-teams')583 }584 ]);585 },586 "RepositoryTeam" : function(self , el) {587 return $.merge(this.RepositoryTeams(self, el), [588 {589 "text" : self.friendlyTitle(self.team()),590 "link" : self.teamLink(self.team(),self.repository())591 }592 ]);593 },594 "Changesets" : function(self , el) {595 return $.merge(this.Repository(self, el), [596 {597 "text" : "Changesets",598 "link" : self.LIST_LINK().call(self,'changesets')599 }600 ]);601 },602 "Changeset" : function(self , el) {603 return $.merge(this.Changesets(self, el), [604 {605 "text" : self.friendlyTitle(self.changeset()),606 "link" : self.LINK().call(self,self.changeset())607 }608 ]);609 },610 "DomainGroup" : function(self , el) {611 return $.merge(this.DomainGroups(self, el), [612 {613 "text" : self.friendlyTitle(self.group()),614 "link" : self.link(self.group())615 }616 ]);617 },618 "DomainUser" : function(self , el) {619 return $.merge(this.DomainUsers(self, el), [620 {621 "text" : self.friendlyName(self.principalUser()),622 "link" : self.link(self.principalUser())623 }624 ]);625 },626 "Branches" : function(self , el) {627 return $.merge(this.Repository(self, el), [628 {629 "text" : "Branches",630 "link" : self.LIST_LINK().call(self,"branches")631 }632 ]);633 },634 "Branch" : function(self , el) {635 return $.merge(this.Branches(self, el), [636 {637 "text" : self.friendlyTitle(self.branch()),638 "link" : self.LINK().call(self,self.branch())639 }640 ]);641 },642 "BranchLogs" : function(self , el) {643 return $.merge(this.Branch(self, el), [644 {645 "text" : "Logs",646 "link" : self.LINK().call(self,self.branch(),"logs")647 }648 ]);649 },650 "Nodes" : function(self , el) {651 return $.merge(this.Branch(self, el), [652 {653 "text" : "Nodes",654 "link" : self.LIST_LINK().call(self,"nodes")655 }656 ]);657 },658 "Tags" : function(self , el) {659 return $.merge(this.Branch(self, el), [660 {661 "text" : "Tags",662 "link" : self.LIST_LINK().call(self,"tags")663 }664 ]);665 },666 "Definitions" : function(self , el) {667 return $.merge(this.Branch(self, el), [668 {669 "text" : "Definitions",670 "link" : self.LIST_LINK().call(self,"definitions")671 }672 ]);673 },674 "Definition" : function(self , el) {675 return $.merge(this.Definitions(self, el), [676 {677 "text" : self.definition().getQName(),678 "link" : self.LINK().call(self,self.definition())679 }680 ]);681 },682 "Forms" : function(self , el) {683 return $.merge(this.Definition(self, el), [684 {685 "text" : "Forms",686 "link" : self.LIST_LINK().call(self,'forms')687 }688 ]);689 },690 "Form" : function(self , el) {691 return $.merge(this.Forms(self, el), [692 {693 "text" : self.form()['formKey'],694 "link" : self.LINK().call(self,self.form())695 }696 ]);697 },698 "Features" : function(self , el) {699 return $.merge(this.Definition(self, el), [700 {701 "text" : "Features",702 "link" : self.LIST_LINK().call(self,'features')703 }704 ]);705 },706 "Node" : function(self , el) {707 return $.merge(this.Nodes(self, el), [708 {709 "text" : self.friendlyTitle(self.node()),710 "link" : self.LINK().call(self,self.node())711 }712 ]);713 },714 "Tag" : function(self , el) {715 return $.merge(this.Tags(self, el), [716 {717 "text" : self.friendlyTitle(self.node()),718 "link" : self.LINK().call(self,self.node())719 }720 ]);721 },722 "Attachments" : function(self , el) {723 return $.merge(this.Node(self, el), [724 {725 "text" : "Attachments",726 "link" : self.LIST_LINK().call(self,"attachments")727 }728 ]);729 },730 "Associations" : function(self , el) {731 return $.merge(this.Node(self, el), [732 {733 "text" : "Associations",734 "link" : self.LIST_LINK().call(self,"associations")735 }736 ]);737 },738 "Translations" : function(self , el) {739 return $.merge(this.Node(self, el), [740 {741 "text" : "Translations",742 "link" : self.LIST_LINK().call(self,"translations")743 }744 ]);745 },746 "NodeAuditRecords" : function(self , el) {747 return $.merge(this.Node(self, el), [748 {749 "text" : "Audit Records",750 "link" : self.LINK().call(self,self.node(),"auditrecords")751 }752 ]);753 },754 "NodeFeatures" : function(self , el) {755 return $.merge(this.Node(self, el), [756 {757 "text" : "Features",758 "link" : self.LINK().call(self,self.node(),"features")759 }760 ]);761 },762 "NodeRules" : function(self , el) {763 return $.merge(this.Node(self, el), [764 {765 "text" : "Rules",766 "link" : self.LIST_LINK().call(self,"rules")767 }768 ]);769 },770 "Folder" : function(self, el, extra) {771 if (self.node().get('_is_association')) {772 return self.breadcrumb(Gitana.Console.Breadcrumb.Nodes(self));773 } else {774 var breadcrumb = self.breadcrumb(Gitana.Console.Breadcrumb.Branch(self));775 var nodeId = self.node().getId();776 if (Gitana.Console.Breadcrumb.PATHS[nodeId]) {777 var nodeBreadcrumb = $.merge(breadcrumb, Gitana.Console.Breadcrumb.PATHS[nodeId]);778 if (extra) {779 $.merge(nodeBreadcrumb, extra);780 }781 //return self.breadcrumb(nodeBreadcrumb);782 } else {783 Gitana.Console.Breadcrumb.findPath(self.node(), self, function() {784 if (Gitana.Console.Breadcrumb.PATHS[nodeId]) {785 var nodeBreadcrumb = $.merge(breadcrumb, Gitana.Console.Breadcrumb.PATHS[nodeId]);786 if (extra) {787 $.merge(nodeBreadcrumb, extra);788 }789 self.breadcrumb(nodeBreadcrumb);790 }791 });792 }793 return self.breadcrumb(nodeBreadcrumb);794 }795 },796 "FolderRules" : function(self , el) {797 return $.merge(this.Folder(self, el), [798 {799 "text" : "Rules",800 "link" : self.LIST_LINK().call(self,"rules")801 }802 ]);803 },804 "BillingProviders" : function(self , el) {805 return $.merge(this.Platform(self, el), [806 {807 "text" : "Billing Provider Configs",808 "link" : self.LIST_LINK().call(self,'billing-providers')809 }810 ]);811 },812 "BillingProvider" : function(self , el) {813 return $.merge(this.BillingProviders(self, el), [814 {815 "text" : self.friendlyTitle(self.billingProvider()),816 "link" : self.LINK().call(self,self.billingProvider())817 }818 ]);819 },820 "Directories" : function(self , el) {821 return $.merge(this.Platform(self, el), [822 {823 "text" : "Directories",824 "link" : self.LIST_LINK().call(self,'directories')825 }826 ]);827 },828 "Directory" : function(self , el) {829 return $.merge(this.Directories(self, el), [830 {831 "text" : self.friendlyTitle(self.directory()),832 "link" : self.LINK().call(self,self.directory())833 }834 ]);835 },836 "Identities" : function(self , el) {837 return $.merge(this.Directory(self, el), [838 {839 "text" : "Identities",840 "link" : self.LIST_LINK().call(self,'identities')841 }842 ]);843 },844 "Identity" : function(self , el) {845 return $.merge(this.Identities(self, el), [846 {847 "text" : self.friendlyTitle(self.identity()),848 "link" : self.LINK().call(self,self.identity())849 }850 ]);851 },852 "Connections" : function(self , el) {853 return $.merge(this.Directory(self, el), [854 {855 "text" : "Connections",856 "link" : self.LIST_LINK().call(self,'connections')857 }858 ]);859 },860 "Connection" : function(self , el) {861 return $.merge(this.Connections(self, el), [862 {863 "text" : self.friendlyTitle(self.connection()),864 "link" : self.LINK().call(self,self.connection())865 }866 ]);867 },868 "Webhosts" : function(self , el) {869 return $.merge(this.Platform(self, el), [870 {871 "text" : "Web Hosts",872 "link" : self.LIST_LINK().call(self,'webhosts')873 }874 ]);875 },876 "Webhost" : function(self , el) {877 return $.merge(this.Webhosts(self, el), [878 {879 "text" : self.friendlyTitle(self.webhost()),880 "link" : self.LINK().call(self,self.webhost())881 }882 ]);883 },884 "AutoClientMappings" : function(self , el) {885 return $.merge(this.Webhost(self, el), [886 {887 "text" : "Auto Client Mappings",888 "link" : self.LIST_LINK().call(self,'auto-client-mappings')889 }890 ]);891 },892 "AutoClientMapping" : function(self , el) {893 return $.merge(this.AutoClientMappings(self, el), [894 {895 "text" : self.friendlyTitle(self.autoClientMapping()),896 "link" : self.LINK().call(self,self.autoClientMapping())897 }898 ]);899 },900 "TrustedDomainMappings" : function(self , el) {901 return $.merge(this.Webhost(self, el), [902 {903 "text" : "Trusted Domain Mappings",904 "link" : self.LIST_LINK().call(self,'trusted-domain-mappings')905 }906 ]);907 },908 "TrustedDomainMapping" : function(self , el) {909 return $.merge(this.TrustedDomainMappings(self, el), [910 {911 "text" : self.friendlyTitle(self.trustedDomainMapping()),912 "link" : self.LINK().call(self,self.trustedDomainMapping())913 }914 ]);915 },916 "DeployedApplications" : function(self , el) {917 return $.merge(this.Webhost(self, el), [918 {919 "text" : "Deployed Applications",920 "link" : self.LIST_LINK().call(self,'deployed-applications')921 }922 ]);923 },924 "DeployedApplication" : function(self , el) {925 return $.merge(this.DeployedApplications(self, el), [926 {927 "text" : self.friendlyTitle(self.deployedApplication()),928 "link" : self.LINK().call(self,self.deployedApplication())929 }930 ]);931 },932 "PlatformActivities" : function(self , el) {933 return $.merge(this.Platform(self, el), [934 {935 "text" : "Activities",936 "link" : self.LIST_LINK().call(self,'activities')937 }938 ]);939 }940 };...

Full Screen

Full Screen

copy_as_gfm.js

Source:copy_as_gfm.js Github

copy

Full Screen

1/* eslint-disable class-methods-use-this, object-shorthand, no-unused-vars, no-use-before-define, no-new, max-len, no-restricted-syntax, guard-for-in, no-continue */2import './lib/utils/common_utils';3const gfmRules = {4 // The filters referenced in lib/banzai/pipeline/gfm_pipeline.rb convert5 // GitLab Flavored Markdown (GFM) to HTML.6 // These handlers consequently convert that same HTML to GFM to be copied to the clipboard.7 // Every filter in lib/banzai/pipeline/gfm_pipeline.rb that generates HTML8 // from GFM should have a handler here, in reverse order.9 // The GFM-to-HTML-to-GFM cycle is tested in spec/features/copy_as_gfm_spec.rb.10 InlineDiffFilter: {11 'span.idiff.addition'(el, text) {12 return `{+${text}+}`;13 },14 'span.idiff.deletion'(el, text) {15 return `{-${text}-}`;16 },17 },18 TaskListFilter: {19 'input[type=checkbox].task-list-item-checkbox'(el) {20 return `[${el.checked ? 'x' : ' '}]`;21 },22 },23 ReferenceFilter: {24 '.tooltip'(el) {25 return '';26 },27 'a.gfm:not([data-link=true])'(el, text) {28 return el.dataset.original || text;29 },30 },31 AutolinkFilter: {32 'a'(el, text) {33 // Fallback on the regular MarkdownFilter's `a` handler.34 if (text !== el.getAttribute('href')) return false;35 return text;36 },37 },38 TableOfContentsFilter: {39 'ul.section-nav'(el) {40 return '[[_TOC_]]';41 },42 },43 EmojiFilter: {44 'img.emoji'(el) {45 return el.getAttribute('alt');46 },47 'gl-emoji'(el) {48 return `:${el.getAttribute('data-name')}:`;49 },50 },51 ImageLinkFilter: {52 'a.no-attachment-icon'(el, text) {53 return text;54 },55 },56 VideoLinkFilter: {57 '.video-container'(el) {58 const videoEl = el.querySelector('video');59 if (!videoEl) return false;60 return CopyAsGFM.nodeToGFM(videoEl);61 },62 'video'(el) {63 return `![${el.dataset.title}](${el.getAttribute('src')})`;64 },65 },66 MathFilter: {67 'pre.code.math[data-math-style=display]'(el, text) {68 return `\`\`\`math\n${text.trim()}\n\`\`\``;69 },70 'code.code.math[data-math-style=inline]'(el, text) {71 return `$\`${text}\`$`;72 },73 'span.katex-display span.katex-mathml'(el) {74 const mathAnnotation = el.querySelector('annotation[encoding="application/x-tex"]');75 if (!mathAnnotation) return false;76 return `\`\`\`math\n${CopyAsGFM.nodeToGFM(mathAnnotation)}\n\`\`\``;77 },78 'span.katex-mathml'(el) {79 const mathAnnotation = el.querySelector('annotation[encoding="application/x-tex"]');80 if (!mathAnnotation) return false;81 return `$\`${CopyAsGFM.nodeToGFM(mathAnnotation)}\`$`;82 },83 'span.katex-html'(el) {84 // We don't want to include the content of this element in the copied text.85 return '';86 },87 'annotation[encoding="application/x-tex"]'(el, text) {88 return text.trim();89 },90 },91 SanitizationFilter: {92 'a[name]:not([href]):empty'(el) {93 return el.outerHTML;94 },95 'dl'(el, text) {96 let lines = text.trim().split('\n');97 // Add two spaces to the front of subsequent list items lines,98 // or leave the line entirely blank.99 lines = lines.map((l) => {100 const line = l.trim();101 if (line.length === 0) return '';102 return ` ${line}`;103 });104 return `<dl>\n${lines.join('\n')}\n</dl>`;105 },106 'sub, dt, dd, kbd, q, samp, var, ruby, rt, rp, abbr, summary, details'(el, text) {107 const tag = el.nodeName.toLowerCase();108 return `<${tag}>${text}</${tag}>`;109 },110 },111 SyntaxHighlightFilter: {112 'pre.code.highlight'(el, t) {113 const text = t.trimRight();114 let lang = el.getAttribute('lang');115 if (!lang || lang === 'plaintext') {116 lang = '';117 }118 // Prefixes lines with 4 spaces if the code contains triple backticks119 if (lang === '' && text.match(/^```/gm)) {120 return text.split('\n').map((l) => {121 const line = l.trim();122 if (line.length === 0) return '';123 return ` ${line}`;124 }).join('\n');125 }126 return `\`\`\`${lang}\n${text}\n\`\`\``;127 },128 'pre > code'(el, text) {129 // Don't wrap code blocks in ``130 return text;131 },132 },133 MarkdownFilter: {134 'br'(el) {135 // Two spaces at the end of a line are turned into a BR136 return ' ';137 },138 'code'(el, text) {139 let backtickCount = 1;140 const backtickMatch = text.match(/`+/);141 if (backtickMatch) {142 backtickCount = backtickMatch[0].length + 1;143 }144 const backticks = Array(backtickCount + 1).join('`');145 const spaceOrNoSpace = backtickCount > 1 ? ' ' : '';146 return backticks + spaceOrNoSpace + text.trim() + spaceOrNoSpace + backticks;147 },148 'blockquote'(el, text) {149 return text.trim().split('\n').map(s => `> ${s}`.trim()).join('\n');150 },151 'img'(el) {152 return `![${el.getAttribute('alt')}](${el.getAttribute('src')})`;153 },154 'a.anchor'(el, text) {155 // Don't render a Markdown link for the anchor link inside a heading156 return text;157 },158 'a'(el, text) {159 return `[${text}](${el.getAttribute('href')})`;160 },161 'li'(el, text) {162 const lines = text.trim().split('\n');163 const firstLine = `- ${lines.shift()}`;164 // Add four spaces to the front of subsequent list items lines,165 // or leave the line entirely blank.166 const nextLines = lines.map((s) => {167 if (s.trim().length === 0) return '';168 return ` ${s}`;169 });170 return `${firstLine}\n${nextLines.join('\n')}`;171 },172 'ul'(el, text) {173 return text;174 },175 'ol'(el, text) {176 // LIs get a `- ` prefix by default, which we replace by `1. ` for ordered lists.177 return text.replace(/^- /mg, '1. ');178 },179 'h1'(el, text) {180 return `# ${text.trim()}`;181 },182 'h2'(el, text) {183 return `## ${text.trim()}`;184 },185 'h3'(el, text) {186 return `### ${text.trim()}`;187 },188 'h4'(el, text) {189 return `#### ${text.trim()}`;190 },191 'h5'(el, text) {192 return `##### ${text.trim()}`;193 },194 'h6'(el, text) {195 return `###### ${text.trim()}`;196 },197 'strong'(el, text) {198 return `**${text}**`;199 },200 'em'(el, text) {201 return `_${text}_`;202 },203 'del'(el, text) {204 return `~~${text}~~`;205 },206 'sup'(el, text) {207 return `^${text}`;208 },209 'hr'(el) {210 return '-----';211 },212 'table'(el) {213 const theadEl = el.querySelector('thead');214 const tbodyEl = el.querySelector('tbody');215 if (!theadEl || !tbodyEl) return false;216 const theadText = CopyAsGFM.nodeToGFM(theadEl);217 const tbodyText = CopyAsGFM.nodeToGFM(tbodyEl);218 return [theadText, tbodyText].join('\n');219 },220 'thead'(el, text) {221 const cells = _.map(el.querySelectorAll('th'), (cell) => {222 let chars = CopyAsGFM.nodeToGFM(cell).length + 2;223 let before = '';224 let after = '';225 switch (cell.style.textAlign) {226 case 'center':227 before = ':';228 after = ':';229 chars -= 2;230 break;231 case 'right':232 after = ':';233 chars -= 1;234 break;235 default:236 break;237 }238 chars = Math.max(chars, 3);239 const middle = Array(chars + 1).join('-');240 return before + middle + after;241 });242 const separatorRow = `|${cells.join('|')}|`;243 return [text, separatorRow].join('\n');244 },245 'tr'(el) {246 const cellEls = el.querySelectorAll('td, th');247 if (cellEls.length === 0) return false;248 const cells = _.map(cellEls, cell => CopyAsGFM.nodeToGFM(cell));249 return `| ${cells.join(' | ')} |`;250 },251 },252};253class CopyAsGFM {254 constructor() {255 $(document).on('copy', '.md, .wiki', (e) => { CopyAsGFM.copyAsGFM(e, CopyAsGFM.transformGFMSelection); });256 $(document).on('copy', 'pre.code.highlight, .diff-content .line_content', (e) => { CopyAsGFM.copyAsGFM(e, CopyAsGFM.transformCodeSelection); });257 $(document).on('paste', '.js-gfm-input', CopyAsGFM.pasteGFM);258 }259 static copyAsGFM(e, transformer) {260 const clipboardData = e.originalEvent.clipboardData;261 if (!clipboardData) return;262 const documentFragment = window.gl.utils.getSelectedFragment();263 if (!documentFragment) return;264 const el = transformer(documentFragment.cloneNode(true));265 if (!el) return;266 e.preventDefault();267 e.stopPropagation();268 clipboardData.setData('text/plain', el.textContent);269 clipboardData.setData('text/x-gfm', this.nodeToGFM(el));270 }271 static pasteGFM(e) {272 const clipboardData = e.originalEvent.clipboardData;273 if (!clipboardData) return;274 const text = clipboardData.getData('text/plain');275 const gfm = clipboardData.getData('text/x-gfm');276 if (!gfm) return;277 e.preventDefault();278 window.gl.utils.insertText(e.target, (textBefore, textAfter) => {279 // If the text before the cursor contains an odd number of backticks,280 // we are either inside an inline code span that starts with 1 backtick281 // or a code block that starts with 3 backticks.282 // This logic still holds when there are one or more _closed_ code spans283 // or blocks that will have 2 or 6 backticks.284 // This will break down when the actual code block contains an uneven285 // number of backticks, but this is a rare edge case.286 const backtickMatch = textBefore.match(/`/g);287 const insideCodeBlock = backtickMatch && (backtickMatch.length % 2) === 1;288 if (insideCodeBlock) {289 return text;290 }291 return gfm;292 });293 }294 static transformGFMSelection(documentFragment) {295 const gfmEls = documentFragment.querySelectorAll('.md, .wiki');296 switch (gfmEls.length) {297 case 0: {298 return documentFragment;299 }300 case 1: {301 return gfmEls[0];302 }303 default: {304 const allGfmEl = document.createElement('div');305 for (let i = 0; i < gfmEls.length; i += 1) {306 const lineEl = gfmEls[i];307 allGfmEl.appendChild(lineEl);308 allGfmEl.appendChild(document.createTextNode('\n\n'));309 }310 return allGfmEl;311 }312 }313 }314 static transformCodeSelection(documentFragment) {315 const lineEls = documentFragment.querySelectorAll('.line');316 let codeEl;317 if (lineEls.length > 1) {318 codeEl = document.createElement('pre');319 codeEl.className = 'code highlight';320 const lang = lineEls[0].getAttribute('lang');321 if (lang) {322 codeEl.setAttribute('lang', lang);323 }324 } else {325 codeEl = document.createElement('code');326 }327 if (lineEls.length > 0) {328 for (let i = 0; i < lineEls.length; i += 1) {329 const lineEl = lineEls[i];330 codeEl.appendChild(lineEl);331 codeEl.appendChild(document.createTextNode('\n'));332 }333 } else {334 codeEl.appendChild(documentFragment);335 }336 return codeEl;337 }338 static nodeToGFM(node, respectWhitespaceParam = false) {339 if (node.nodeType === Node.COMMENT_NODE) {340 return '';341 }342 if (node.nodeType === Node.TEXT_NODE) {343 return node.textContent;344 }345 const respectWhitespace = respectWhitespaceParam || (node.nodeName === 'PRE' || node.nodeName === 'CODE');346 const text = this.innerGFM(node, respectWhitespace);347 if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {348 return text;349 }350 for (const filter in gfmRules) {351 const rules = gfmRules[filter];352 for (const selector in rules) {353 const func = rules[selector];354 if (!window.gl.utils.nodeMatchesSelector(node, selector)) continue;355 let result;356 if (func.length === 2) {357 // if `func` takes 2 arguments, it depends on text.358 // if there is no text, we don't need to generate GFM for this node.359 if (text.length === 0) continue;360 result = func(node, text);361 } else {362 result = func(node);363 }364 if (result === false) continue;365 return result;366 }367 }368 return text;369 }370 static innerGFM(parentNode, respectWhitespace = false) {371 const nodes = parentNode.childNodes;372 const clonedParentNode = parentNode.cloneNode(true);373 const clonedNodes = Array.prototype.slice.call(clonedParentNode.childNodes, 0);374 for (let i = 0; i < nodes.length; i += 1) {375 const node = nodes[i];376 const clonedNode = clonedNodes[i];377 const text = this.nodeToGFM(node, respectWhitespace);378 // `clonedNode.replaceWith(text)` is not yet widely supported379 clonedNode.parentNode.replaceChild(document.createTextNode(text), clonedNode);380 }381 let nodeText = clonedParentNode.innerText || clonedParentNode.textContent;382 if (!respectWhitespace) {383 nodeText = nodeText.trim();384 }385 return nodeText;386 }387}388window.gl = window.gl || {};389window.gl.CopyAsGFM = CopyAsGFM;...

Full Screen

Full Screen

copy_as_gfm.js.es6

Source:copy_as_gfm.js.es6 Github

copy

Full Screen

1/* eslint-disable class-methods-use-this, object-shorthand, no-unused-vars, no-use-before-define, no-new, max-len, no-restricted-syntax, guard-for-in, no-continue */2/* jshint esversion: 6 */3require('./lib/utils/common_utils');4(() => {5 const gfmRules = {6 // The filters referenced in lib/banzai/pipeline/gfm_pipeline.rb convert7 // GitLab Flavored Markdown (GFM) to HTML.8 // These handlers consequently convert that same HTML to GFM to be copied to the clipboard.9 // Every filter in lib/banzai/pipeline/gfm_pipeline.rb that generates HTML10 // from GFM should have a handler here, in reverse order.11 // The GFM-to-HTML-to-GFM cycle is tested in spec/features/copy_as_gfm_spec.rb.12 InlineDiffFilter: {13 'span.idiff.addition'(el, text) {14 return `{+${text}+}`;15 },16 'span.idiff.deletion'(el, text) {17 return `{-${text}-}`;18 },19 },20 TaskListFilter: {21 'input[type=checkbox].task-list-item-checkbox'(el, text) {22 return `[${el.checked ? 'x' : ' '}]`;23 },24 },25 ReferenceFilter: {26 'a.gfm:not([data-link=true])'(el, text) {27 return el.dataset.original || text;28 },29 },30 AutolinkFilter: {31 'a'(el, text) {32 // Fallback on the regular MarkdownFilter's `a` handler.33 if (text !== el.getAttribute('href')) return false;34 return text;35 },36 },37 TableOfContentsFilter: {38 'ul.section-nav'(el, text) {39 return '[[_TOC_]]';40 },41 },42 EmojiFilter: {43 'img.emoji'(el, text) {44 return el.getAttribute('alt');45 },46 },47 ImageLinkFilter: {48 'a.no-attachment-icon'(el, text) {49 return text;50 },51 },52 VideoLinkFilter: {53 '.video-container'(el, text) {54 const videoEl = el.querySelector('video');55 if (!videoEl) return false;56 return CopyAsGFM.nodeToGFM(videoEl);57 },58 'video'(el, text) {59 return `![${el.dataset.title}](${el.getAttribute('src')})`;60 },61 },62 MathFilter: {63 'pre.code.math[data-math-style=display]'(el, text) {64 return `\`\`\`math\n${text.trim()}\n\`\`\``;65 },66 'code.code.math[data-math-style=inline]'(el, text) {67 return `$\`${text}\`$`;68 },69 'span.katex-display span.katex-mathml'(el, text) {70 const mathAnnotation = el.querySelector('annotation[encoding="application/x-tex"]');71 if (!mathAnnotation) return false;72 return `\`\`\`math\n${CopyAsGFM.nodeToGFM(mathAnnotation)}\n\`\`\``;73 },74 'span.katex-mathml'(el, text) {75 const mathAnnotation = el.querySelector('annotation[encoding="application/x-tex"]');76 if (!mathAnnotation) return false;77 return `$\`${CopyAsGFM.nodeToGFM(mathAnnotation)}\`$`;78 },79 'span.katex-html'(el, text) {80 // We don't want to include the content of this element in the copied text.81 return '';82 },83 'annotation[encoding="application/x-tex"]'(el, text) {84 return text.trim();85 },86 },87 SanitizationFilter: {88 'a[name]:not([href]):empty'(el, text) {89 return el.outerHTML;90 },91 'dl'(el, text) {92 let lines = text.trim().split('\n');93 // Add two spaces to the front of subsequent list items lines,94 // or leave the line entirely blank.95 lines = lines.map((l) => {96 const line = l.trim();97 if (line.length === 0) return '';98 return ` ${line}`;99 });100 return `<dl>\n${lines.join('\n')}\n</dl>`;101 },102 'sub, dt, dd, kbd, q, samp, var, ruby, rt, rp, abbr'(el, text) {103 const tag = el.nodeName.toLowerCase();104 return `<${tag}>${text}</${tag}>`;105 },106 },107 SyntaxHighlightFilter: {108 'pre.code.highlight'(el, t) {109 const text = t.trim();110 let lang = el.getAttribute('lang');111 if (lang === 'plaintext') {112 lang = '';113 }114 // Prefixes lines with 4 spaces if the code contains triple backticks115 if (lang === '' && text.match(/^```/gm)) {116 return text.split('\n').map((l) => {117 const line = l.trim();118 if (line.length === 0) return '';119 return ` ${line}`;120 }).join('\n');121 }122 return `\`\`\`${lang}\n${text}\n\`\`\``;123 },124 'pre > code'(el, text) {125 // Don't wrap code blocks in ``126 return text;127 },128 },129 MarkdownFilter: {130 'br'(el, text) {131 // Two spaces at the end of a line are turned into a BR132 return ' ';133 },134 'code'(el, text) {135 let backtickCount = 1;136 const backtickMatch = text.match(/`+/);137 if (backtickMatch) {138 backtickCount = backtickMatch[0].length + 1;139 }140 const backticks = Array(backtickCount + 1).join('`');141 const spaceOrNoSpace = backtickCount > 1 ? ' ' : '';142 return backticks + spaceOrNoSpace + text + spaceOrNoSpace + backticks;143 },144 'blockquote'(el, text) {145 return text.trim().split('\n').map(s => `> ${s}`.trim()).join('\n');146 },147 'img'(el, text) {148 return `![${el.getAttribute('alt')}](${el.getAttribute('src')})`;149 },150 'a.anchor'(el, text) {151 // Don't render a Markdown link for the anchor link inside a heading152 return text;153 },154 'a'(el, text) {155 return `[${text}](${el.getAttribute('href')})`;156 },157 'li'(el, text) {158 const lines = text.trim().split('\n');159 const firstLine = `- ${lines.shift()}`;160 // Add four spaces to the front of subsequent list items lines,161 // or leave the line entirely blank.162 const nextLines = lines.map((s) => {163 if (s.trim().length === 0) return '';164 return ` ${s}`;165 });166 return `${firstLine}\n${nextLines.join('\n')}`;167 },168 'ul'(el, text) {169 return text;170 },171 'ol'(el, text) {172 // LIs get a `- ` prefix by default, which we replace by `1. ` for ordered lists.173 return text.replace(/^- /mg, '1. ');174 },175 'h1'(el, text) {176 return `# ${text.trim()}`;177 },178 'h2'(el, text) {179 return `## ${text.trim()}`;180 },181 'h3'(el, text) {182 return `### ${text.trim()}`;183 },184 'h4'(el, text) {185 return `#### ${text.trim()}`;186 },187 'h5'(el, text) {188 return `##### ${text.trim()}`;189 },190 'h6'(el, text) {191 return `###### ${text.trim()}`;192 },193 'strong'(el, text) {194 return `**${text}**`;195 },196 'em'(el, text) {197 return `_${text}_`;198 },199 'del'(el, text) {200 return `~~${text}~~`;201 },202 'sup'(el, text) {203 return `^${text}`;204 },205 'hr'(el, text) {206 return '-----';207 },208 'table'(el, text) {209 const theadEl = el.querySelector('thead');210 const tbodyEl = el.querySelector('tbody');211 if (!theadEl || !tbodyEl) return false;212 const theadText = CopyAsGFM.nodeToGFM(theadEl);213 const tbodyText = CopyAsGFM.nodeToGFM(tbodyEl);214 return theadText + tbodyText;215 },216 'thead'(el, text) {217 const cells = _.map(el.querySelectorAll('th'), (cell) => {218 let chars = CopyAsGFM.nodeToGFM(cell).trim().length + 2;219 let before = '';220 let after = '';221 switch (cell.style.textAlign) {222 case 'center':223 before = ':';224 after = ':';225 chars -= 2;226 break;227 case 'right':228 after = ':';229 chars -= 1;230 break;231 default:232 break;233 }234 chars = Math.max(chars, 3);235 const middle = Array(chars + 1).join('-');236 return before + middle + after;237 });238 return `${text}|${cells.join('|')}|`;239 },240 'tr'(el, text) {241 const cells = _.map(el.querySelectorAll('td, th'), cell => CopyAsGFM.nodeToGFM(cell).trim());242 return `| ${cells.join(' | ')} |`;243 },244 },245 };246 class CopyAsGFM {247 constructor() {248 $(document).on('copy', '.md, .wiki', this.handleCopy);249 $(document).on('paste', '.js-gfm-input', this.handlePaste);250 }251 handleCopy(e) {252 const clipboardData = e.originalEvent.clipboardData;253 if (!clipboardData) return;254 const documentFragment = window.gl.utils.getSelectedFragment();255 if (!documentFragment) return;256 // If the documentFragment contains more than just Markdown, don't copy as GFM.257 if (documentFragment.querySelector('.md, .wiki')) return;258 e.preventDefault();259 clipboardData.setData('text/plain', documentFragment.textContent);260 const gfm = CopyAsGFM.nodeToGFM(documentFragment);261 clipboardData.setData('text/x-gfm', gfm);262 }263 handlePaste(e) {264 const clipboardData = e.originalEvent.clipboardData;265 if (!clipboardData) return;266 const gfm = clipboardData.getData('text/x-gfm');267 if (!gfm) return;268 e.preventDefault();269 window.gl.utils.insertText(e.target, gfm);270 }271 static nodeToGFM(node) {272 if (node.nodeType === Node.TEXT_NODE) {273 return node.textContent;274 }275 const text = this.innerGFM(node);276 if (node.nodeType === Node.DOCUMENT_FRAGMENT_NODE) {277 return text;278 }279 for (const filter in gfmRules) {280 const rules = gfmRules[filter];281 for (const selector in rules) {282 const func = rules[selector];283 if (!window.gl.utils.nodeMatchesSelector(node, selector)) continue;284 const result = func(node, text);285 if (result === false) continue;286 return result;287 }288 }289 return text;290 }291 static innerGFM(parentNode) {292 const nodes = parentNode.childNodes;293 const clonedParentNode = parentNode.cloneNode(true);294 const clonedNodes = Array.prototype.slice.call(clonedParentNode.childNodes, 0);295 for (let i = 0; i < nodes.length; i += 1) {296 const node = nodes[i];297 const clonedNode = clonedNodes[i];298 const text = this.nodeToGFM(node);299 // `clonedNode.replaceWith(text)` is not yet widely supported300 clonedNode.parentNode.replaceChild(document.createTextNode(text), clonedNode);301 }302 return clonedParentNode.innerText || clonedParentNode.textContent;303 }304 }305 window.gl = window.gl || {};306 window.gl.CopyAsGFM = CopyAsGFM;307 new CopyAsGFM();...

Full Screen

Full Screen

text.js

Source:text.js Github

copy

Full Screen

1(function() {2 QUnit.module('fabric.Text');3 function createTextObject() {4 return new fabric.Text('x');5 }6 var CHAR_WIDTH = 20;7 var REFERENCE_TEXT_OBJECT = {8 'type': 'text',9 'originX': 'left',10 'originY': 'top',11 'left': 0,12 'top': 0,13 'width': CHAR_WIDTH,14 'height': 52.43,15 'fill': 'rgb(0,0,0)',16 'stroke': null,17 'strokeWidth': 1,18 'strokeDashArray': null,19 'strokeLineCap': 'butt',20 'strokeLineJoin': 'miter',21 'strokeMiterLimit': 10,22 'scaleX': 1,23 'scaleY': 1,24 'angle': 0,25 'flipX': false,26 'flipY': false,27 'opacity': 1,28 'shadow': null,29 'visible': true,30 'clipTo': null,31 'backgroundColor': '',32 'text': 'x',33 'fontSize': 40,34 'fontWeight': 'normal',35 'fontFamily': 'Times New Roman',36 'fontStyle': '',37 'lineHeight': 1.16,38 'textDecoration': '',39 'textAlign': 'left',40 'textBackgroundColor': '',41 'fillRule': 'nonzero',42 'globalCompositeOperation': 'source-over'43 };44 var TEXT_SVG = '\t<g transform="translate(10 26.22)">\n\t\t<text font-family="Times New Roman" font-size="40" font-weight="normal" style="stroke: none; stroke-width: 1; stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; fill: rgb(0,0,0); fill-rule: nonzero; opacity: 1;" ><tspan x="-10" y="8.984" fill="rgb(0,0,0)">x</tspan></text>\n\t</g>\n';45 test('constructor', function() {46 ok(fabric.Text);47 var text = createTextObject();48 ok(text);49 ok(text instanceof fabric.Text);50 ok(text instanceof fabric.Object);51 equal(text.get('type'), 'text');52 equal(text.get('text'), 'x');53 });54 test('toString', function() {55 var text = createTextObject();56 ok(typeof text.toString == 'function');57 equal(text.toString(), '#<fabric.Text (1): { "text": "x", "fontFamily": "Times New Roman" }>');58 });59 test('toObject', function() {60 var text = createTextObject();61 ok(typeof text.toObject == 'function');62 deepEqual(text.toObject(), REFERENCE_TEXT_OBJECT);63 });64 test('complexity', function(){65 var text = createTextObject();66 ok(typeof text.complexity == 'function');67 equal(text.complexity(), 1);68 });69 test('set', function() {70 var text = createTextObject();71 ok(typeof text.set == 'function');72 equal(text.set('text', 'bar'), text, 'should be chainable');73 text.set({ left: 1234, top: 2345, angle: 55 });74 equal(text.get('left'), 1234);75 equal(text.get('top'), 2345);76 equal(text.get('angle'), 55);77 });78 test('set with "hash"', function() {79 var text = createTextObject();80 text.set({ opacity: 0.123, fill: 'red', fontFamily: 'blah' });81 equal(text.getOpacity(), 0.123);82 equal(text.getFill(), 'red');83 equal(text.get('fontFamily'), 'blah');84 });85 test('setShadow', function(){86 var text = createTextObject();87 ok(typeof text.setShadow == 'function');88 equal(text.setShadow('10px 8px 2px red'), text, 'should be chainable');89 ok(text.shadow instanceof fabric.Shadow, 'should inherit from fabric.Shadow');90 equal(text.shadow.color, 'red');91 equal(text.shadow.offsetX, 10);92 equal(text.shadow.offsetY, 8);93 equal(text.shadow.blur, 2);94 });95 test('setFontSize', function(){96 var text = createTextObject();97 ok(typeof text.setFontSize == 'function');98 equal(text.setFontSize(12), text, 'should be chainable');99 equal(text.get('fontSize'), 12);100 });101 test('getText', function(){102 var text = createTextObject();103 ok(typeof text.getText == 'function');104 equal(text.getText(), 'x');105 equal(text.getText(), text.get('text'));106 });107 test('setText', function(){108 var text = createTextObject();109 ok(typeof text.setText == 'function');110 equal(text.setText('bar'), text, 'should be chainable');111 equal(text.getText(), 'bar');112 });113 test('fabric.Text.fromObject', function(){114 ok(typeof fabric.Text.fromObject == 'function');115 var text = fabric.Text.fromObject(REFERENCE_TEXT_OBJECT);116 deepEqual(text.toObject(), REFERENCE_TEXT_OBJECT);117 });118 test('fabric.Text.fromElement', function() {119 ok(typeof fabric.Text.fromElement == 'function');120 var elText = fabric.document.createElement('text');121 elText.textContent = 'x';122 var text = fabric.Text.fromElement(elText);123 ok(text instanceof fabric.Text);124 // temp workaround for text objects not obtaining width under node125 // text.width = CHAR_WIDTH;126 var expectedObject = fabric.util.object.extend(fabric.util.object.clone(REFERENCE_TEXT_OBJECT), {127 left: 4,128 top: -3.61,129 width: 8,130 height: 20.97,131 fontSize: 16,132 originX: 'left'133 });134 deepEqual(text.toObject(), expectedObject);135 });136 test('fabric.Text.fromElement with custom attributes', function() {137 var elTextWithAttrs = fabric.document.createElement('text');138 elTextWithAttrs.textContent = 'x';139 elTextWithAttrs.setAttribute('x', 10);140 elTextWithAttrs.setAttribute('y', 20);141 elTextWithAttrs.setAttribute('fill', 'rgb(255,255,255)');142 elTextWithAttrs.setAttribute('opacity', 0.45);143 elTextWithAttrs.setAttribute('stroke', 'blue');144 elTextWithAttrs.setAttribute('stroke-width', 3);145 elTextWithAttrs.setAttribute('stroke-dasharray', '5, 2');146 elTextWithAttrs.setAttribute('stroke-linecap', 'round');147 elTextWithAttrs.setAttribute('stroke-linejoin', 'bevil');148 elTextWithAttrs.setAttribute('stroke-miterlimit', 5);149 elTextWithAttrs.setAttribute('font-family', 'Monaco');150 elTextWithAttrs.setAttribute('font-style', 'italic');151 elTextWithAttrs.setAttribute('font-weight', 'bold');152 elTextWithAttrs.setAttribute('font-size', '123');153 elTextWithAttrs.setAttribute('text-decoration', 'underline');154 elTextWithAttrs.setAttribute('text-anchor', 'middle');155 var textWithAttrs = fabric.Text.fromElement(elTextWithAttrs);156 // temp workaround for text objects not obtaining width under node157 textWithAttrs.width = CHAR_WIDTH;158 ok(textWithAttrs instanceof fabric.Text);159 var expectedObject = fabric.util.object.extend(fabric.util.object.clone(REFERENCE_TEXT_OBJECT), {160 /* left varies slightly due to node-canvas rendering */161 left: fabric.util.toFixed(textWithAttrs.left + '', 2),162 top: -7.72,163 width: CHAR_WIDTH,164 height: 161.23,165 fill: 'rgb(255,255,255)',166 opacity: 0.45,167 stroke: 'blue',168 strokeWidth: 3,169 strokeDashArray: [5, 2],170 strokeLineCap: 'round',171 strokeLineJoin: 'bevil',172 strokeMiterLimit: 5,173 fontFamily: 'Monaco',174 fontStyle: 'italic',175 fontWeight: 'bold',176 fontSize: 123,177 textDecoration: 'underline',178 originX: 'center'179 });180 deepEqual(textWithAttrs.toObject(), expectedObject);181 });182 test('empty fromElement', function() {183 ok(fabric.Text.fromElement() === null);184 });185 test('dimensions after text change', function() {186 var text = new fabric.Text('x');187 equal(text.width, CHAR_WIDTH);188 text.setText('xx');189 equal(text.width, CHAR_WIDTH * 2);190 });191 test('setting fontFamily', function() {192 var text = new fabric.Text('x');193 text.path = 'foobar.js';194 text.set('fontFamily', 'foobar');195 equal(text.get('fontFamily'), 'foobar');196 text.set('fontFamily', '"Arial Black", Arial');197 equal(text.get('fontFamily'), '"Arial Black", Arial');198 });199 test('toSVG', function() {200 var text = new fabric.Text('x');201 // temp workaround for text objects not obtaining width under node202 text.width = CHAR_WIDTH;203 equal(text.toSVG(), TEXT_SVG);204 text.setFontFamily('"Arial Black", Arial');205 // temp workaround for text objects not obtaining width under node206 text.width = CHAR_WIDTH;207 equal(text.toSVG(), TEXT_SVG.replace('font-family="Times New Roman"', 'font-family="\'Arial Black\', Arial"'));208 });...

Full Screen

Full Screen

jquery.simple-text-rotator.js

Source:jquery.simple-text-rotator.js Github

copy

Full Screen

...27 28 return this.each(function(){29 var el = $(this)30 var array = [];31 $.each(el.text().split(settings.separator), function(key, value) { 32 array.push(value); 33 });34 el.text(array[0]);35 36 // animation option37 var rotate = function() {38 switch (settings.animation) { 39 case 'dissolve':40 el.animate({41 textShadowBlur:20,42 opacity: 043 }, 500 , function() {44 index = $.inArray(el.text(), array)45 if((index + 1) == array.length) index = -146 el.text(array[index + 1]).animate({47 textShadowBlur:0,48 opacity: 149 }, 500 );50 });51 break;52 53 case 'flip':54 if(el.find(".back").length > 0) {55 el.html(el.find(".back").html())56 }57 58 var initial = el.text()59 var index = $.inArray(initial, array)60 if((index + 1) == array.length) index = -161 62 el.html("");63 $("<span class='front'>" + initial + "</span>").appendTo(el);64 $("<span class='back'>" + array[index + 1] + "</span>").appendTo(el);65 el.wrapInner("<span class='rotating' />").find(".rotating").hide().addClass("flip").show().css({66 "-webkit-transform": " rotateY(-180deg)",67 "-moz-transform": " rotateY(-180deg)",68 "-o-transform": " rotateY(-180deg)",69 "transform": " rotateY(-180deg)"70 })71 72 break;73 74 case 'flipUp':75 if(el.find(".back").length > 0) {76 el.html(el.find(".back").html())77 }78 79 var initial = el.text()80 var index = $.inArray(initial, array)81 if((index + 1) == array.length) index = -182 83 el.html("");84 $("<span class='front'>" + initial + "</span>").appendTo(el);85 $("<span class='back'>" + array[index + 1] + "</span>").appendTo(el);86 el.wrapInner("<span class='rotating' />").find(".rotating").hide().addClass("flip up").show().css({87 "-webkit-transform": " rotateX(-180deg)",88 "-moz-transform": " rotateX(-180deg)",89 "-o-transform": " rotateX(-180deg)",90 "transform": " rotateX(-180deg)"91 })92 93 break;94 95 case 'flipCube':96 if(el.find(".back").length > 0) {97 el.html(el.find(".back").html())98 }99 100 var initial = el.text()101 var index = $.inArray(initial, array)102 if((index + 1) == array.length) index = -1103 104 el.html("");105 $("<span class='front'>" + initial + "</span>").appendTo(el);106 $("<span class='back'>" + array[index + 1] + "</span>").appendTo(el);107 el.wrapInner("<span class='rotating' />").find(".rotating").hide().addClass("flip cube").show().css({108 "-webkit-transform": " rotateY(180deg)",109 "-moz-transform": " rotateY(180deg)",110 "-o-transform": " rotateY(180deg)",111 "transform": " rotateY(180deg)"112 })113 114 break;115 116 case 'flipCubeUp':117 if(el.find(".back").length > 0) {118 el.html(el.find(".back").html())119 }120 121 var initial = el.text()122 var index = $.inArray(initial, array)123 if((index + 1) == array.length) index = -1124 125 el.html("");126 $("<span class='front'>" + initial + "</span>").appendTo(el);127 $("<span class='back'>" + array[index + 1] + "</span>").appendTo(el);128 el.wrapInner("<span class='rotating' />").find(".rotating").hide().addClass("flip cube up").show().css({129 "-webkit-transform": " rotateX(180deg)",130 "-moz-transform": " rotateX(180deg)",131 "-o-transform": " rotateX(180deg)",132 "transform": " rotateX(180deg)"133 })134 135 break;136 137 case 'spin':138 if(el.find(".rotating").length > 0) {139 el.html(el.find(".rotating").html())140 }141 index = $.inArray(el.text(), array)142 if((index + 1) == array.length) index = -1143 144 el.wrapInner("<span class='rotating spin' />").find(".rotating").hide().text(array[index + 1]).show().css({145 "-webkit-transform": " rotate(0) scale(1)",146 "-moz-transform": "rotate(0) scale(1)",147 "-o-transform": "rotate(0) scale(1)",148 "transform": "rotate(0) scale(1)"149 })150 break;151 152 case 'fade':153 el.fadeOut(settings.speed, function() {154 index = $.inArray(el.text(), array)155 if((index + 1) == array.length) index = -1156 el.text(array[index + 1]).fadeIn(settings.speed);157 });158 break;159 }160 };161 setInterval(rotate, settings.speed);162 });163 }164 ...

Full Screen

Full Screen

filter.spec.js

Source:filter.spec.js Github

copy

Full Screen

1import Vue from 'vue'2import { parseFilters } from 'compiler/parser/filter-parser'3describe('Filters', () => {4 it('basic usage', () => {5 const vm = new Vue({6 template: '<div>{{ msg | upper }}</div>',7 data: {8 msg: 'hi'9 },10 filters: {11 upper: v => v.toUpperCase()12 }13 }).$mount()14 expect(vm.$el.textContent).toBe('HI')15 })16 it('chained usage', () => {17 const vm = new Vue({18 template: '<div>{{ msg | upper | reverse }}</div>',19 data: {20 msg: 'hi'21 },22 filters: {23 upper: v => v.toUpperCase(),24 reverse: v => v.split('').reverse().join('')25 }26 }).$mount()27 expect(vm.$el.textContent).toBe('IH')28 })29 it('in v-bind', () => {30 const vm = new Vue({31 template: `32 <div33 v-bind:id="id | upper | reverse"34 :class="cls | reverse"35 :ref="ref | lower">36 </div>37 `,38 filters: {39 upper: v => v.toUpperCase(),40 reverse: v => v.split('').reverse().join(''),41 lower: v => v.toLowerCase()42 },43 data: {44 id: 'abc',45 cls: 'foo',46 ref: 'BAR'47 }48 }).$mount()49 expect(vm.$el.id).toBe('CBA')50 expect(vm.$el.className).toBe('oof')51 expect(vm.$refs.bar).toBe(vm.$el)52 })53 it('handle regex with pipe', () => {54 const vm = new Vue({55 template: `<test ref="test" :pattern="/a|b\\// | identity"></test>`,56 filters: { identity: v => v },57 components: {58 test: {59 props: ['pattern'],60 template: '<div></div>'61 }62 }63 }).$mount()64 expect(vm.$refs.test.pattern instanceof RegExp).toBe(true)65 expect(vm.$refs.test.pattern.toString()).toBe('/a|b\\//')66 })67 it('handle division', () => {68 const vm = new Vue({69 data: { a: 2 },70 template: `<div>{{ 1/a / 4 | double }}</div>`,71 filters: { double: v => v * 2 }72 }).$mount()73 expect(vm.$el.textContent).toBe(String(1 / 4))74 })75 it('handle division with parenthesis', () => {76 const vm = new Vue({77 data: { a: 20 },78 template: `<div>{{ (a*2) / 5 | double }}</div>`,79 filters: { double: v => v * 2 }80 }).$mount()81 expect(vm.$el.textContent).toBe(String(16))82 })83 it('handle division with dot', () => {84 const vm = new Vue({85 template: `<div>{{ 20. / 5 | double }}</div>`,86 filters: { double: v => v * 2 }87 }).$mount()88 expect(vm.$el.textContent).toBe(String(8))89 })90 it('handle division with array values', () => {91 const vm = new Vue({92 data: { a: [20] },93 template: `<div>{{ a[0] / 5 | double }}</div>`,94 filters: { double: v => v * 2 }95 }).$mount()96 expect(vm.$el.textContent).toBe(String(8))97 })98 it('handle division with hash values', () => {99 const vm = new Vue({100 data: { a: { n: 20 }},101 template: `<div>{{ a['n'] / 5 | double }}</div>`,102 filters: { double: v => v * 2 }103 }).$mount()104 expect(vm.$el.textContent).toBe(String(8))105 })106 it('handle division with variable++', () => {107 const vm = new Vue({108 data: { a: 7 },109 template: `<div>{{ a++ / 2 | double }}</div>`,110 filters: { double: v => v * 2 }111 }).$mount()112 expect(vm.$el.textContent).toBe(String(7))113 })114 it('handle division with variable--', () => {115 const vm = new Vue({116 data: { a: 7 },117 template: `<div>{{ a-- / 2 | double }}</div>`,118 filters: { double: v => v * 2 }119 }).$mount()120 expect(vm.$el.textContent).toBe(String(7))121 })122 it('handle division with variable_', () => {123 const vm = new Vue({124 data: { a_: 8 },125 template: `<div>{{ a_ / 2 | double }}</div>`,126 filters: { double: v => v * 2 }127 }).$mount()128 expect(vm.$el.textContent).toBe(String(8))129 })130 it('arguments', () => {131 const vm = new Vue({132 template: `<div>{{ msg | add(a, 3) }}</div>`,133 data: {134 msg: 1,135 a: 2136 },137 filters: {138 add: (v, arg1, arg2) => v + arg1 + arg2139 }140 }).$mount()141 expect(vm.$el.textContent).toBe('6')142 })143 it('quotes', () => {144 const vm = new Vue({145 template: `<div>{{ msg + "b | c" + 'd' | upper }}</div>`,146 data: {147 msg: 'a'148 },149 filters: {150 upper: v => v.toUpperCase()151 }152 }).$mount()153 expect(vm.$el.textContent).toBe('AB | CD')154 })155 it('double pipe', () => {156 const vm = new Vue({157 template: `<div>{{ b || msg | upper }}</div>`,158 data: {159 b: false,160 msg: 'a'161 },162 filters: {163 upper: v => v.toUpperCase()164 }165 }).$mount()166 expect(vm.$el.textContent).toBe('A')167 })168 it('object literal', () => {169 const vm = new Vue({170 template: `<div>{{ { a: 123 } | pick('a') }}</div>`,171 filters: {172 pick: (v, key) => v[key]173 }174 }).$mount()175 expect(vm.$el.textContent).toBe('123')176 })177 it('array literal', () => {178 const vm = new Vue({179 template: `<div>{{ [1, 2, 3] | reverse }}</div>`,180 filters: {181 reverse: arr => arr.reverse().join(',')182 }183 }).$mount()184 expect(vm.$el.textContent).toBe('3,2,1')185 })186 it('warn non-existent', () => {187 new Vue({188 template: '<div>{{ msg | upper }}</div>',189 data: { msg: 'foo' }190 }).$mount()191 expect('Failed to resolve filter: upper').toHaveBeenWarned()192 })193 it('support template string', () => {194 expect(parseFilters('`a | ${b}c` | d')).toBe('_f("d")(`a | ${b}c`)')195 })...

Full Screen

Full Screen

script-2.js

Source:script-2.js Github

copy

Full Screen

...41 zitate.forEach(function(zitat, i){42 var $el = $('<span class="zitat">' + zitat + '&nbsp;</span>')43 container.append($el)44 $el.data('width', $el.outerWidth())45 var elText = $el.text()46 $el.text(elText + elText + elText + elText + elText + elText + elText + elText + elText + elText + elText)47 $el.css('display', 'block')48 $el.css('width', '49000px')49 $el.hover(50 function () {51 $(this).addClass('active')52 },53 function () {54 $(this).removeClass('active')55 })56 $el.click( //Video-Background57 function () {58 var youTubeId = allDescriptions[i].fields.context_event_service_id59 setYTVideo(youTubeId)60 })...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1el.text();2el.getText();3el.text();4el.getText();5el.text();6el.getText();7el.text();8el.getText();9el.text();10el.getText();11el.text();12el.getText();13el.text();14el.getText();15el.text();16el.getText();17el.text();18el.getText();19el.text();20el.getText();21el.text();22el.getText();23el.text();

Full Screen

Using AI Code Generation

copy

Full Screen

1const el = await driver.$('XCUIElementTypeStaticText');2const text = await el.getText();3console.log(text);4const el = await driver.$('XCUIElementTypeStaticText');5const text = await el.text();6console.log(text);7const el = await driver.$('XCUIElementTypeStaticText');8const text = await el.getAttribute('text');9console.log(text);10const el = await driver.$('XCUIElementTypeStaticText');11const text = await el.getAttribute('value');12console.log(text);13const el = await driver.$('XCUIElementTypeStaticText');14const text = await el.getAttribute('label');15console.log(text);16const el = await driver.$('XCUIElementTypeStaticText');17const text = await el.getAttribute('name');18console.log(text);19const el = await driver.$('XCUIElementTypeStaticText');20const text = await el.getAttribute('value');21console.log(text);22const el = await driver.$('XCUIElementTypeStaticText');23const text = await el.getAttribute('value');24console.log(text);25const el = await driver.$('XCUIElementTypeStaticText');26const text = await el.getAttribute('value');27console.log(text);28const el = await driver.$('XCUIElementTypeStaticText');29const text = await el.getAttribute('value');30console.log(text);31const el = await driver.$('XCUIElementTypeStaticText');32const text = await el.getAttribute('value');33console.log(text);34const el = await driver.$('XCUIElementTypeStaticText');35const text = await el.getAttribute('value');36console.log(text);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var assert = require('assert');3var chai = require('chai');4var chaiAsPromised = require('chai-as-promised');5chai.use(chaiAsPromised);6chai.should();7chaiAsPromised.transferPromiseness = wd.transferPromiseness;8var desiredCaps = {9};10var driver = wd.promiseChainRemote('localhost', 4723);11 .init(desiredCaps)12 .elementByAccessibilityId('URL')13 .then(function(el) {14 el.text().should.eventually.equal('URL');15 })16 .fin(function() { return driver.quit(); })17 .done();18info: [debug] [JSONWP Proxy] Got response with status 200: {"value":{"sessionId":"E8D4A7E4-1D4C-4B4B-8C1E-9E4D4A8F6C3B","capabilities":{"device":"iphone","browserName":"Safari","sdkVersion":"10.3","CFBundleIdentifier":"com.apple.mobilesafari"}},"sessionId":"E8D4A7E4-1D4C-4B4B-8C1E-9E4D4A8F6C3B","status":0}

Full Screen

Using AI Code Generation

copy

Full Screen

1var el = driver.findElementByAccessibilityId('test-Label');2el.getText().then(function(text) {3 console.log(text);4});5el = self.driver.find_element_by_accessibility_id("test-Label")6print(el.text)7* Appium version (or git revision) that exhibits the issue: 1.6.48* Last Appium version that did not exhibit the issue (if applicable):9* Node.js version (unless using Appium.app|exe): 6.9.1

Full Screen

Using AI Code Generation

copy

Full Screen

1describe('Test', () => {2 it('should have the right title', async () => {3 console.log(await el.getText());4 console.log(await el.getText());5 });6});

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 Appium Xcuitest Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Sign up Free
_

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful