How to use GetOptions method of js Package

Best K6 code snippet using js.GetOptions

deckjs.go

Source:deckjs.go Github

copy

Full Screen

1// Copyright 2014 Andreas Koch. All rights reserved.2// Use of this source code is governed by a BSD-style3// license that can be found in the LICENSE file.4package themefiles5const DeckJs = `6/*!7Deck JS - deck.core8Copyright (c) 2011 Caleb Troughton9Dual licensed under the MIT license and GPL license.10https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt11https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt12*/13/*14The deck.core module provides all the basic functionality for creating and15moving through a deck. It does so by applying classes to indicate the state of16the deck and its slides, allowing CSS to take care of the visual representation17of each state. It also provides methods for navigating the deck and inspecting18its state, as well as basic key bindings for going to the next and previous19slides. More functionality is provided by wholly separate extension modules20that use the API provided by core.21*/22(function($, deck, document, undefined) {23 var slides, // Array of all the uh, slides...24 current, // Array index of the current slide25 $container, // Keeping this cached26 27 events = {28 /*29 This event fires whenever the current slide changes, whether by way of30 next, prev, or go. The callback function is passed two parameters, from31 and to, equal to the indices of the old slide and the new slide32 respectively. If preventDefault is called on the event within this handler33 the slide change does not occur.34 35 $(document).bind('deck.change', function(event, from, to) {36 alert('Moving from slide ' + from + ' to ' + to);37 });38 */39 change: 'deck.change',40 41 /*42 This event fires at the beginning of deck initialization, after the options43 are set but before the slides array is created. This event makes a good hook44 for preprocessing extensions looking to modify the deck.45 */46 beforeInitialize: 'deck.beforeInit',47 48 /*49 This event fires at the end of deck initialization. Extensions should50 implement any code that relies on user extensible options (key bindings,51 element selectors, classes) within a handler for this event. Native52 events associated with Deck JS should be scoped under a .deck event53 namespace, as with the example below:54 55 var $d = $(document);56 $.deck.defaults.keys.myExtensionKeycode = 70; // 'h'57 $d.bind('deck.init', function() {58 $d.bind('keydown.deck', function(event) {59 if (event.which === $.deck.getOptions().keys.myExtensionKeycode) {60 // Rock out61 }62 });63 });64 */65 initialize: 'deck.init' 66 },67 68 options = {},69 $d = $(document),70 71 /*72 Internal function. Updates slide and container classes based on which73 slide is the current slide.74 */75 updateStates = function() {76 var oc = options.classes,77 osc = options.selectors.container,78 old = $container.data('onSlide'),79 $all = $();80 81 // Container state82 $container.removeClass(oc.onPrefix + old)83 .addClass(oc.onPrefix + current)84 .data('onSlide', current);85 86 // Remove and re-add child-current classes for nesting87 $('.' + oc.current).parentsUntil(osc).removeClass(oc.childCurrent);88 slides[current].parentsUntil(osc).addClass(oc.childCurrent);89 90 // Remove previous states91 $.each(slides, function(i, el) {92 $all = $all.add(el);93 });94 $all.removeClass([95 oc.before,96 oc.previous,97 oc.current,98 oc.next,99 oc.after100 ].join(" "));101 102 // Add new states back in103 slides[current].addClass(oc.current);104 if (current > 0) {105 slides[current-1].addClass(oc.previous);106 }107 if (current + 1 < slides.length) {108 slides[current+1].addClass(oc.next);109 }110 if (current > 1) {111 $.each(slides.slice(0, current - 1), function(i, el) {112 el.addClass(oc.before);113 });114 }115 if (current + 2 < slides.length) {116 $.each(slides.slice(current+2), function(i, el) {117 el.addClass(oc.after);118 });119 }120 },121 122 /* Methods exposed in the jQuery.deck namespace */123 methods = {124 125 /*126 jQuery.deck(selector, options)127 128 selector: string | jQuery | array129 options: object, optional130 131 Initializes the deck, using each element matched by selector as a slide.132 May also be passed an array of string selectors or jQuery objects, in133 which case each selector in the array is considered a slide. The second134 parameter is an optional options object which will extend the default135 values.136 137 $.deck('.slide');138 139 or140 141 $.deck([142 '#first-slide',143 '#second-slide',144 '#etc'145 ]);146 */ 147 init: function(elements, opts) {148 var startTouch,149 tolerance,150 esp = function(e) {151 e.stopPropagation();152 };153 154 options = $.extend(true, {}, $[deck].defaults, opts);155 slides = [];156 current = 0;157 $container = $(options.selectors.container);158 tolerance = options.touch.swipeTolerance;159 160 // Pre init event for preprocessing hooks161 $d.trigger(events.beforeInitialize);162 163 // Hide the deck while states are being applied to kill transitions164 $container.addClass(options.classes.loading);165 166 // Fill slides array depending on parameter type167 if ($.isArray(elements)) {168 $.each(elements, function(i, e) {169 slides.push($(e));170 });171 }172 else {173 $(elements).each(function(i, e) {174 slides.push($(e));175 });176 }177 178 /* Remove any previous bindings, and rebind key events */179 $d.unbind('keydown.deck').bind('keydown.deck', function(e) {180 if (e.which === options.keys.next || $.inArray(e.which, options.keys.next) > -1) {181 methods.next();182 e.preventDefault();183 }184 else if (e.which === options.keys.previous || $.inArray(e.which, options.keys.previous) > -1) {185 methods.prev();186 e.preventDefault();187 }188 })189 /* Stop propagation of key events within editable elements */190 .undelegate('input, textarea, select, button, meter, progress, [contentEditable]', 'keydown', esp)191 .delegate('input, textarea, select, button, meter, progress, [contentEditable]', 'keydown', esp);192 193 /* Bind touch events for swiping between slides on touch devices */194 $container.unbind('touchstart.deck').bind('touchstart.deck', function(e) {195 if (!startTouch) {196 startTouch = $.extend({}, e.originalEvent.targetTouches[0]);197 }198 })199 .unbind('touchmove.deck').bind('touchmove.deck', function(e) {200 $.each(e.originalEvent.changedTouches, function(i, t) {201 if (startTouch && t.identifier === startTouch.identifier) {202 if (t.screenX - startTouch.screenX > tolerance || t.screenY - startTouch.screenY > tolerance) {203 $[deck]('prev');204 startTouch = undefined;205 }206 else if (t.screenX - startTouch.screenX < -1 * tolerance || t.screenY - startTouch.screenY < -1 * tolerance) {207 $[deck]('next');208 startTouch = undefined;209 }210 return false;211 }212 });213 e.preventDefault();214 })215 .unbind('touchend.deck').bind('touchend.deck', function(t) {216 $.each(t.originalEvent.changedTouches, function(i, t) {217 if (startTouch && t.identifier === startTouch.identifier) {218 startTouch = undefined;219 }220 });221 })222 .scrollLeft(0).scrollTop(0);223 224 /*225 Kick iframe videos, which dont like to redraw w/ transforms.226 Remove this if Webkit ever fixes it.227 */228 $.each(slides, function(i, $el) {229 $el.unbind('webkitTransitionEnd.deck').bind('webkitTransitionEnd.deck',230 function(event) {231 if ($el.hasClass($[deck]('getOptions').classes.current)) {232 var embeds = $(this).find('iframe').css('opacity', 0);233 window.setTimeout(function() {234 embeds.css('opacity', 1);235 }, 100);236 }237 });238 });239 240 if (slides.length) {241 updateStates();242 }243 244 // Show deck again now that slides are in place245 $container.removeClass(options.classes.loading);246 $d.trigger(events.initialize);247 },248 249 /*250 jQuery.deck('go', index)251 252 index: integer | string253 254 Moves to the slide at the specified index if index is a number. Index is255 0-based, so $.deck('go', 0); will move to the first slide. If index is a256 string this will move to the slide with the specified id. If index is out257 of bounds or doesn't match a slide id the call is ignored.258 */259 go: function(index) {260 var e = $.Event(events.change),261 ndx;262 263 /* Number index, easy. */264 if (typeof index === 'number' && index >= 0 && index < slides.length) {265 ndx = index;266 }267 /* Id string index, search for it and set integer index */268 else if (typeof index === 'string') {269 $.each(slides, function(i, $slide) {270 if ($slide.attr('id') === index) {271 ndx = i;272 return false;273 }274 });275 };276 277 /* Out of bounds, id doesn't exist, illegal input, eject */278 if (typeof ndx === 'undefined') return;279 280 $d.trigger(e, [current, ndx]);281 if (e.isDefaultPrevented()) {282 /* Trigger the event again and undo the damage done by extensions. */283 $d.trigger(events.change, [ndx, current]);284 }285 else {286 current = ndx;287 updateStates();288 }289 },290 291 /*292 jQuery.deck('next')293 294 Moves to the next slide. If the last slide is already active, the call295 is ignored.296 */297 next: function() {298 methods.go(current+1);299 },300 301 /*302 jQuery.deck('prev')303 304 Moves to the previous slide. If the first slide is already active, the305 call is ignored.306 */307 prev: function() {308 methods.go(current-1);309 },310 311 /*312 jQuery.deck('getSlide', index)313 314 index: integer, optional315 316 Returns a jQuery object containing the slide at index. If index is not317 specified, the current slide is returned.318 */319 getSlide: function(index) {320 var i = typeof index !== 'undefined' ? index : current;321 if (typeof i != 'number' || i < 0 || i >= slides.length) return null;322 return slides[i];323 },324 325 /*326 jQuery.deck('getSlides')327 328 Returns all slides as an array of jQuery objects.329 */330 getSlides: function() {331 return slides;332 },333 334 /*335 jQuery.deck('getContainer')336 337 Returns a jQuery object containing the deck container as defined by the338 container option.339 */340 getContainer: function() {341 return $container;342 },343 344 /*345 jQuery.deck('getOptions')346 347 Returns the options object for the deck, including any overrides that348 were defined at initialization.349 */350 getOptions: function() {351 return options;352 },353 354 /*355 jQuery.deck('extend', name, method)356 357 name: string358 method: function359 360 Adds method to the deck namespace with the key of name. This doesn’t361 give access to any private member data — public methods must still be362 used within method — but lets extension authors piggyback on the deck363 namespace rather than pollute jQuery.364 365 $.deck('extend', 'alert', function(msg) {366 alert(msg);367 });368 // Alerts 'boom'369 $.deck('alert', 'boom');370 */371 extend: function(name, method) {372 methods[name] = method;373 }374 };375 376 /* jQuery extension */377 $[deck] = function(method, arg) {378 if (methods[method]) {379 return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));380 }381 else {382 return methods.init(method, arg);383 }384 };385 386 /*387 The default settings object for a deck. All deck extensions should extend388 this object to add defaults for any of their options.389 390 options.classes.after391 This class is added to all slides that appear after the 'next' slide.392 393 options.classes.before394 This class is added to all slides that appear before the 'previous'395 slide.396 397 options.classes.childCurrent398 This class is added to all elements in the DOM tree between the399 'current' slide and the deck container. For standard slides, this is400 mostly seen and used for nested slides.401 402 options.classes.current403 This class is added to the current slide.404 405 options.classes.loading406 This class is applied to the deck container during loading phases and is407 primarily used as a way to short circuit transitions between states408 where such transitions are distracting or unwanted. For example, this409 class is applied during deck initialization and then removed to prevent410 all the slides from appearing stacked and transitioning into place411 on load.412 413 options.classes.next414 This class is added to the slide immediately following the 'current'415 slide.416 417 options.classes.onPrefix418 This prefix, concatenated with the current slide index, is added to the419 deck container as you change slides.420 421 options.classes.previous422 This class is added to the slide immediately preceding the 'current'423 slide.424 425 options.selectors.container426 Elements matched by this CSS selector will be considered the deck427 container. The deck container is used to scope certain states of the428 deck, as with the onPrefix option, or with extensions such as deck.goto429 and deck.menu.430 431 options.keys.next432 The numeric keycode used to go to the next slide.433 434 options.keys.previous435 The numeric keycode used to go to the previous slide.436 437 options.touch.swipeTolerance438 The number of pixels the users finger must travel to produce a swipe439 gesture.440 */441 $[deck].defaults = {442 classes: {443 after: 'deck-after',444 before: 'deck-before',445 childCurrent: 'deck-child-current',446 current: 'deck-current',447 loading: 'deck-loading',448 next: 'deck-next',449 onPrefix: 'on-slide-',450 previous: 'deck-previous'451 },452 453 selectors: {454 container: '.deck-container'455 },456 457 keys: {458 // enter, space, page down, right arrow, down arrow,459 next: [13, 32, 34, 39, 40],460 // backspace, page up, left arrow, up arrow461 previous: [8, 33, 37, 38]462 },463 464 touch: {465 swipeTolerance: 60466 }467 };468 469 $d.ready(function() {470 $('html').addClass('ready');471 });472 473 /*474 FF + Transforms + Flash video don't get along...475 Firefox will reload and start playing certain videos after a476 transform. Blanking the src when a previously shown slide goes out477 of view prevents this.478 */479 $d.bind('deck.change', function(e, from, to) {480 var oldFrames = $[deck]('getSlide', from).find('iframe'),481 newFrames = $[deck]('getSlide', to).find('iframe');482 483 oldFrames.each(function() {484 var $this = $(this),485 curSrc = $this.attr('src');486 487 if(curSrc) {488 $this.data('deck-src', curSrc).attr('src', '');489 }490 });491 492 newFrames.each(function() {493 var $this = $(this),494 originalSrc = $this.data('deck-src');495 496 if (originalSrc) {497 $this.attr('src', originalSrc);498 }499 });500 });501})(jQuery, 'deck', document);502/*!503Deck JS - deck.goto504Copyright (c) 2011 Caleb Troughton505Dual licensed under the MIT license and GPL license.506https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt507https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt508*/509/*510This module adds the necessary methods and key bindings to show and hide a form511for jumping to any slide number/id in the deck (and processes that form512accordingly). The form-showing state is indicated by the presence of a class on513the deck container.514*/515(function($, deck, undefined) {516 var $d = $(document);517 518 /*519 Extends defaults/options.520 521 options.classes.goto522 This class is added to the deck container when showing the Go To Slide523 form.524 525 options.selectors.gotoDatalist526 The element that matches this selector is the datalist element that will527 be populated with options for each of the slide ids. In browsers that528 support the datalist element, this provides a drop list of slide ids to529 aid the user in selecting a slide.530 531 options.selectors.gotoForm532 The element that matches this selector is the form that is submitted533 when a user hits enter after typing a slide number/id in the gotoInput534 element.535 536 options.selectors.gotoInput537 The element that matches this selector is the text input field for538 entering a slide number/id in the Go To Slide form.539 540 options.keys.goto541 The numeric keycode used to show the Go To Slide form.542 543 options.countNested544 If false, only top level slides will be counted when entering a545 slide number.546 */547 $.extend(true, $[deck].defaults, {548 classes: {549 goto: 'deck-goto'550 },551 552 selectors: {553 gotoDatalist: '#goto-datalist',554 gotoForm: '.goto-form',555 gotoInput: '#goto-slide'556 },557 558 keys: {559 goto: 71 // g560 },561 562 countNested: true563 });564 /*565 jQuery.deck('showGoTo')566 567 Shows the Go To Slide form by adding the class specified by the goto class568 option to the deck container.569 */570 $[deck]('extend', 'showGoTo', function() {571 $[deck]('getContainer').addClass($[deck]('getOptions').classes.goto);572 $($[deck]('getOptions').selectors.gotoInput).focus();573 });574 /*575 jQuery.deck('hideGoTo')576 577 Hides the Go To Slide form by removing the class specified by the goto class578 option from the deck container.579 */580 $[deck]('extend', 'hideGoTo', function() {581 $($[deck]('getOptions').selectors.gotoInput).blur();582 $[deck]('getContainer').removeClass($[deck]('getOptions').classes.goto);583 });584 /*585 jQuery.deck('toggleGoTo')586 587 Toggles between showing and hiding the Go To Slide form.588 */589 $[deck]('extend', 'toggleGoTo', function() {590 $[deck]($[deck]('getContainer').hasClass($[deck]('getOptions').classes.goto) ? 'hideGoTo' : 'showGoTo');591 });592 593 $d.bind('deck.init', function() {594 var opts = $[deck]('getOptions'),595 $datalist = $(opts.selectors.gotoDatalist),596 slideTest = $.map([597 opts.classes.before,598 opts.classes.previous,599 opts.classes.current,600 opts.classes.next,601 opts.classes.after602 ], function(el, i) {603 return '.' + el;604 }).join(', '),605 rootCounter = 1;606 607 // Bind key events608 $d.unbind('keydown.deckgoto').bind('keydown.deckgoto', function(e) {609 var key = $[deck]('getOptions').keys.goto;610 611 if (e.which === key || $.inArray(e.which, key) > -1) {612 e.preventDefault();613 $[deck]('toggleGoTo');614 }615 });616 617 /* Populate datalist and work out countNested*/618 $.each($[deck]('getSlides'), function(i, $slide) {619 var id = $slide.attr('id'),620 $parentSlides = $slide.parentsUntil(opts.selectors.container, slideTest);621 622 if (id) {623 $datalist.append('<option value="' + id + '">');624 }625 626 if ($parentSlides.length) {627 $slide.removeData('rootIndex');628 }629 else if (!opts.countNested) {630 $slide.data('rootIndex', rootCounter);631 ++rootCounter;632 }633 });634 635 // Process form submittal, go to the slide entered636 $(opts.selectors.gotoForm)637 .unbind('submit.deckgoto')638 .bind('submit.deckgoto', function(e) {639 var $field = $($[deck]('getOptions').selectors.gotoInput),640 ndx = parseInt($field.val(), 10);641 642 if (!$[deck]('getOptions').countNested) {643 if (ndx >= rootCounter) return false;644 $.each($[deck]('getSlides'), function(i, $slide) {645 if ($slide.data('rootIndex') === ndx) {646 ndx = i + 1;647 return false;648 }649 });650 }651 652 $[deck]('go', isNaN(ndx) ? $field.val() : ndx - 1);653 $[deck]('hideGoTo');654 $field.val('');655 656 e.preventDefault();657 });658 659 // Dont let keys in the input trigger deck actions660 $(opts.selectors.gotoInput)661 .unbind('keydown.deckgoto')662 .bind('keydown.deckgoto', function(e) {663 e.stopPropagation();664 });665 });666})(jQuery, 'deck');667/*!668Deck JS - deck.hash669Copyright (c) 2011 Caleb Troughton670Dual licensed under the MIT license and GPL license.671https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt672https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt673*/674/*675This module adds deep linking to individual slides, enables internal links676to slides within decks, and updates the address bar with the hash as the user677moves through the deck. A permalink anchor is also updated. Standard themes678hide this link in browsers that support the History API, and show it for679those that do not. Slides that do not have an id are assigned one according to680the hashPrefix option. In addition to the on-slide container state class681kept by core, this module adds an on-slide state class that uses the id of each682slide.683*/684(function ($, deck, window, undefined) {685 var $d = $(document),686 $window = $(window),687 688 /* Collection of internal fragment links in the deck */689 $internals,690 691 /*692 Internal only function. Given a string, extracts the id from the hash,693 matches it to the appropriate slide, and navigates there.694 */695 goByHash = function(str) {696 var id = str.substr(str.indexOf("#") + 1),697 slides = $[deck]('getSlides');698 699 $.each(slides, function(i, $el) {700 if ($el.attr('id') === id) {701 $[deck]('go', i);702 return false;703 }704 });705 706 // If we don't set these to 0 the container scrolls due to hashchange707 $[deck]('getContainer').scrollLeft(0).scrollTop(0);708 };709 710 /*711 Extends defaults/options.712 713 options.selectors.hashLink714 The element matching this selector has its href attribute updated to715 the hash of the current slide as the user navigates through the deck.716 717 options.hashPrefix718 Every slide that does not have an id is assigned one at initialization.719 Assigned ids take the form of hashPrefix + slideIndex, e.g., slide-0,720 slide-12, etc.721 options.preventFragmentScroll722 When deep linking to a hash of a nested slide, this scrolls the deck723 container to the top, undoing the natural browser behavior of scrolling724 to the document fragment on load.725 */726 $.extend(true, $[deck].defaults, {727 selectors: {728 hashLink: '.deck-permalink'729 },730 731 hashPrefix: 'slide-',732 preventFragmentScroll: true733 });734 735 736 $d.bind('deck.init', function() {737 var opts = $[deck]('getOptions');738 $internals = $(),739 slides = $[deck]('getSlides');740 741 $.each(slides, function(i, $el) {742 var hash;743 744 /* Hand out ids to the unfortunate slides born without them */745 if (!$el.attr('id') || $el.data('deckAssignedId') === $el.attr('id')) {746 $el.attr('id', opts.hashPrefix + i);747 $el.data('deckAssignedId', opts.hashPrefix + i);748 }749 750 hash ='#' + $el.attr('id');751 752 /* Deep link to slides on init */753 if (hash === window.location.hash) {754 $[deck]('go', i);755 }756 757 /* Add internal links to this slide */758 $internals = $internals.add('a[href="' + hash + '"]');759 });760 761 if (!Modernizr.hashchange) {762 /* Set up internal links using click for the poor browsers763 without a hashchange event. */764 $internals.unbind('click.deckhash').bind('click.deckhash', function(e) {765 goByHash($(this).attr('href'));766 });767 }768 769 /* Set up first id container state class */770 if (slides.length) {771 $[deck]('getContainer').addClass(opts.classes.onPrefix + $[deck]('getSlide').attr('id'));772 };773 })774 /* Update permalink, address bar, and state class on a slide change */775 .bind('deck.change', function(e, from, to) {776 var hash = '#' + $[deck]('getSlide', to).attr('id'),777 hashPath = window.location.href.replace(/#.*/, '') + hash,778 opts = $[deck]('getOptions'),779 osp = opts.classes.onPrefix,780 $c = $[deck]('getContainer');781 782 $c.removeClass(osp + $[deck]('getSlide', from).attr('id'));783 $c.addClass(osp + $[deck]('getSlide', to).attr('id'));784 785 $(opts.selectors.hashLink).attr('href', hashPath);786 if (Modernizr.history) {787 window.history.replaceState({}, "", hashPath);788 }789 });790 791 /* Deals with internal links in modern browsers */792 $window.bind('hashchange.deckhash', function(e) {793 if (e.originalEvent && e.originalEvent.newURL) {794 goByHash(e.originalEvent.newURL);795 }796 else {797 goByHash(window.location.hash);798 }799 })800 /* Prevent scrolling on deep links */801 .bind('load', function() {802 if ($[deck]('getOptions').preventFragmentScroll) {803 $[deck]('getContainer').scrollLeft(0).scrollTop(0);804 }805 });806})(jQuery, 'deck', this);807/*!808Deck JS - deck.menu809Copyright (c) 2011 Caleb Troughton810Dual licensed under the MIT license and GPL license.811https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt812https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt813*/814/*815This module adds the methods and key binding to show and hide a menu of all816slides in the deck. The deck menu state is indicated by the presence of a class817on the deck container.818*/819(function($, deck, undefined) {820 var $d = $(document),821 rootSlides; // Array of top level slides822 823 /*824 Extends defaults/options.825 826 options.classes.menu827 This class is added to the deck container when showing the slide menu.828 829 options.keys.menu830 The numeric keycode used to toggle between showing and hiding the slide831 menu.832 833 options.touch.doubletapWindow834 Two consecutive touch events within this number of milliseconds will835 be considered a double tap, and will toggle the menu on touch devices.836 */837 $.extend(true, $[deck].defaults, {838 classes: {839 menu: 'deck-menu'840 },841 842 keys: {843 menu: 77 // m844 },845 846 touch: {847 doubletapWindow: 400848 }849 });850 /*851 jQuery.deck('showMenu')852 853 Shows the slide menu by adding the class specified by the menu class option854 to the deck container.855 */856 $[deck]('extend', 'showMenu', function() {857 var $c = $[deck]('getContainer'),858 opts = $[deck]('getOptions');859 860 if ($c.hasClass(opts.classes.menu)) return;861 862 // Hide through loading class to short-circuit transitions (perf)863 $c.addClass([opts.classes.loading, opts.classes.menu].join(' '));864 865 /* Forced to do this in JS until CSS learns second-grade math. Save old866 style value for restoration when menu is hidden. */867 if (Modernizr.csstransforms) {868 $.each(rootSlides, function(i, $slide) {869 $slide.data('oldStyle', $slide.attr('style'));870 $slide.css({871 'position': 'absolute',872 'left': ((i % 4) * 25) + '%',873 'top': (Math.floor(i / 4) * 25) + '%'874 });875 });876 }877 878 // Need to ensure the loading class renders first, then remove879 window.setTimeout(function() {880 $c.removeClass(opts.classes.loading)881 .scrollTop($[deck]('getSlide').offset().top);882 }, 0);883 });884 /*885 jQuery.deck('hideMenu')886 887 Hides the slide menu by removing the class specified by the menu class888 option from the deck container.889 */890 $[deck]('extend', 'hideMenu', function() {891 var $c = $[deck]('getContainer'),892 opts = $[deck]('getOptions');893 894 if (!$c.hasClass(opts.classes.menu)) return;895 896 $c.removeClass(opts.classes.menu);897 $c.addClass(opts.classes.loading);898 899 /* Restore old style value */900 if (Modernizr.csstransforms) {901 $.each(rootSlides, function(i, $slide) {902 var oldStyle = $slide.data('oldStyle');903 $slide.attr('style', oldStyle ? oldStyle : '');904 });905 }906 907 window.setTimeout(function() {908 $c.removeClass(opts.classes.loading).scrollTop(0);909 }, 0);910 });911 /*912 jQuery.deck('toggleMenu')913 914 Toggles between showing and hiding the slide menu.915 */916 $[deck]('extend', 'toggleMenu', function() {917 $[deck]('getContainer').hasClass($[deck]('getOptions').classes.menu) ?918 $[deck]('hideMenu') : $[deck]('showMenu');919 });920 $d.bind('deck.init', function() {921 var opts = $[deck]('getOptions'),922 touchEndTime = 0,923 currentSlide,924 slideTest = $.map([925 opts.classes.before,926 opts.classes.previous,927 opts.classes.current,928 opts.classes.next,929 opts.classes.after930 ], function(el, i) {931 return '.' + el;932 }).join(', ');933 934 // Build top level slides array935 rootSlides = [];936 $.each($[deck]('getSlides'), function(i, $el) {937 if (!$el.parentsUntil(opts.selectors.container, slideTest).length) {938 rootSlides.push($el);939 }940 });941 942 // Bind key events943 $d.unbind('keydown.deckmenu').bind('keydown.deckmenu', function(e) {944 if (e.which === opts.keys.menu || $.inArray(e.which, opts.keys.menu) > -1) {945 $[deck]('toggleMenu');946 e.preventDefault();947 }948 });949 950 // Double tap to toggle slide menu for touch devices951 $[deck]('getContainer').unbind('touchstart.deckmenu').bind('touchstart.deckmenu', function(e) {952 currentSlide = $[deck]('getSlide');953 })954 .unbind('touchend.deckmenu').bind('touchend.deckmenu', function(e) {955 var now = Date.now();956 957 // Ignore this touch event if it caused a nav change (swipe)958 if (currentSlide !== $[deck]('getSlide')) return;959 960 if (now - touchEndTime < opts.touch.doubletapWindow) {961 $[deck]('toggleMenu');962 e.preventDefault();963 }964 touchEndTime = now;965 });966 967 // Selecting slides from the menu968 $.each($[deck]('getSlides'), function(i, $s) {969 $s.unbind('click.deckmenu').bind('click.deckmenu', function(e) {970 if (!$[deck]('getContainer').hasClass(opts.classes.menu)) return;971 $[deck]('go', i);972 $[deck]('hideMenu');973 e.stopPropagation();974 e.preventDefault();975 });976 });977 })978 .bind('deck.change', function(e, from, to) {979 var container = $[deck]('getContainer');980 981 if (container.hasClass($[deck]('getOptions').classes.menu)) {982 container.scrollTop($[deck]('getSlide', to).offset().top);983 }984 });985})(jQuery, 'deck');986/*!987Deck JS - deck.navigation988Copyright (c) 2011 Caleb Troughton989Dual licensed under the MIT license and GPL license.990https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt991https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt992*/993/*994This module adds clickable previous and next links to the deck.995*/996(function($, deck, undefined) {997 var $d = $(document),998 999 /* Updates link hrefs, and disabled states if last/first slide */1000 updateButtons = function(e, from, to) {1001 var opts = $[deck]('getOptions'),1002 last = $[deck]('getSlides').length - 1,1003 prevSlide = $[deck]('getSlide', to - 1),1004 nextSlide = $[deck]('getSlide', to + 1),1005 hrefBase = window.location.href.replace(/#.*/, ''),1006 prevId = prevSlide ? prevSlide.attr('id') : undefined,1007 nextId = nextSlide ? nextSlide.attr('id') : undefined;1008 1009 $(opts.selectors.previousLink)1010 .toggleClass(opts.classes.navDisabled, !to)1011 .attr('href', hrefBase + '#' + (prevId ? prevId : ''));1012 $(opts.selectors.nextLink)1013 .toggleClass(opts.classes.navDisabled, to === last)1014 .attr('href', hrefBase + '#' + (nextId ? nextId : ''));1015 };1016 1017 /*1018 Extends defaults/options.1019 1020 options.classes.navDisabled1021 This class is added to a navigation link when that action is disabled.1022 It is added to the previous link when on the first slide, and to the1023 next link when on the last slide.1024 1025 options.selectors.nextLink1026 The elements that match this selector will move the deck to the next1027 slide when clicked.1028 1029 options.selectors.previousLink1030 The elements that match this selector will move to deck to the previous1031 slide when clicked.1032 */1033 $.extend(true, $[deck].defaults, {1034 classes: {1035 navDisabled: 'deck-nav-disabled'1036 },1037 1038 selectors: {1039 nextLink: '.deck-next-link',1040 previousLink: '.deck-prev-link'1041 }1042 });1043 $d.bind('deck.init', function() {1044 var opts = $[deck]('getOptions'),1045 slides = $[deck]('getSlides'),1046 $current = $[deck]('getSlide'),1047 ndx;1048 1049 // Setup prev/next link events1050 $(opts.selectors.previousLink)1051 .unbind('click.decknavigation')1052 .bind('click.decknavigation', function(e) {1053 $[deck]('prev');1054 e.preventDefault();1055 });1056 1057 $(opts.selectors.nextLink)1058 .unbind('click.decknavigation')1059 .bind('click.decknavigation', function(e) {1060 $[deck]('next');1061 e.preventDefault();1062 });1063 1064 // Find where we started in the deck and set initial states1065 $.each(slides, function(i, $slide) {1066 if ($slide === $current) {1067 ndx = i;1068 return false;1069 }1070 });1071 updateButtons(null, ndx, ndx);1072 })1073 .bind('deck.change', updateButtons);1074})(jQuery, 'deck');1075/*!1076Deck JS - deck.status1077Copyright (c) 2011 Caleb Troughton1078Dual licensed under the MIT license and GPL license.1079https://github.com/imakewebthings/deck.js/blob/master/MIT-license.txt1080https://github.com/imakewebthings/deck.js/blob/master/GPL-license.txt1081*/1082/*1083This module adds a (current)/(total) style status indicator to the deck.1084*/1085(function($, deck, undefined) {1086 var $d = $(document),1087 1088 updateCurrent = function(e, from, to) {1089 var opts = $[deck]('getOptions');1090 1091 $(opts.selectors.statusCurrent).text(opts.countNested ?1092 to + 1 :1093 $[deck]('getSlide', to).data('rootSlide')1094 );1095 };1096 1097 /*1098 Extends defaults/options.1099 1100 options.selectors.statusCurrent1101 The element matching this selector displays the current slide number.1102 1103 options.selectors.statusTotal1104 The element matching this selector displays the total number of slides.1105 1106 options.countNested1107 If false, only top level slides will be counted in the current and1108 total numbers.1109 */1110 $.extend(true, $[deck].defaults, {1111 selectors: {1112 statusCurrent: '.deck-status-current',1113 statusTotal: '.deck-status-total'1114 },1115 1116 countNested: true1117 });1118 1119 $d.bind('deck.init', function() {1120 var opts = $[deck]('getOptions'),1121 slides = $[deck]('getSlides'),1122 $current = $[deck]('getSlide'),1123 ndx;1124 1125 // Set total slides once1126 if (opts.countNested) {1127 $(opts.selectors.statusTotal).text(slides.length);1128 }1129 else {1130 /* Determine root slides by checking each slide's ancestor tree for1131 any of the slide classes. */1132 var rootIndex = 1,1133 slideTest = $.map([1134 opts.classes.before,1135 opts.classes.previous,1136 opts.classes.current,1137 opts.classes.next,1138 opts.classes.after1139 ], function(el, i) {1140 return '.' + el;1141 }).join(', ');1142 1143 /* Store the 'real' root slide number for use during slide changes. */1144 $.each(slides, function(i, $el) {1145 var $parentSlides = $el.parentsUntil(opts.selectors.container, slideTest);1146 $el.data('rootSlide', $parentSlides.length ?1147 $parentSlides.last().data('rootSlide') :1148 rootIndex++1149 );1150 });1151 1152 $(opts.selectors.statusTotal).text(rootIndex - 1);1153 }1154 1155 // Find where we started in the deck and set initial state1156 $.each(slides, function(i, $el) {1157 if ($el === $current) {1158 ndx = i;1159 return false;1160 }1161 });1162 updateCurrent(null, ndx, ndx);1163 })1164 /* Update current slide number with each change event */1165 .bind('deck.change', updateCurrent);1166})(jQuery, 'deck');1167`1168const DeckCss = `1169body.deck-container {1170 overflow-y: auto;1171 position: static;1172}1173.deck-container {1174 position: relative;1175 min-height: 100%;1176 margin: 0 auto;1177 padding: 0 48px;1178 font-size: 16px;1179 line-height: 1.25;1180 overflow: hidden;1181 /* Resets and base styles from HTML5 Boilerplate */1182 /* End HTML5 Boilerplate adaptations */1183}1184.js .deck-container {1185 visibility: hidden;1186}1187.ready .deck-container {1188 visibility: visible;1189}1190.touch .deck-container {1191 -webkit-text-size-adjust: none;1192 -moz-text-size-adjust: none;1193}1194.deck-container div, .deck-container span, .deck-container object, .deck-container iframe,1195.deck-container h1, .deck-container h2, .deck-container h3, .deck-container h4, .deck-container h5, .deck-container h6, .deck-container p, .deck-container blockquote, .deck-container pre,1196.deck-container abbr, .deck-container address, .deck-container cite, .deck-container code, .deck-container del, .deck-container dfn, .deck-container em, .deck-container img, .deck-container ins, .deck-container kbd, .deck-container q, .deck-container samp,1197.deck-container small, .deck-container strong, .deck-container sub, .deck-container sup, .deck-container var, .deck-container b, .deck-container i, .deck-container dl, .deck-container dt, .deck-container dd, .deck-container ol, .deck-container ul, .deck-container li,1198.deck-container fieldset, .deck-container form, .deck-container label, .deck-container legend,1199.deck-container table, .deck-container caption, .deck-container tbody, .deck-container tfoot, .deck-container thead, .deck-container tr, .deck-container th, .deck-container td,1200.deck-container article, .deck-container aside, .deck-container canvas, .deck-container details, .deck-container figcaption, .deck-container figure,1201.deck-container footer, .deck-container header, .deck-container hgroup, .deck-container menu, .deck-container nav, .deck-container section, .deck-container summary,1202.deck-container time, .deck-container mark, .deck-container audio, .deck-container video {1203 margin: 0;1204 padding: 0;1205 border: 0;1206 font-size: 100%;1207 font: inherit;1208 vertical-align: baseline;1209}1210.deck-container article, .deck-container aside, .deck-container details, .deck-container figcaption, .deck-container figure,1211.deck-container footer, .deck-container header, .deck-container hgroup, .deck-container menu, .deck-container nav, .deck-container section {1212 display: block;1213}1214.deck-container blockquote, .deck-container q {1215 quotes: none;1216}1217.deck-container blockquote:before, .deck-container blockquote:after, .deck-container q:before, .deck-container q:after {1218 content: "";1219 content: none;1220}1221.deck-container ins {1222 background-color: #ff9;1223 color: #000;1224 text-decoration: none;1225}1226.deck-container mark {1227 background-color: #ff9;1228 color: #000;1229 font-style: italic;1230 font-weight: bold;1231}1232.deck-container del {1233 text-decoration: line-through;1234}1235.deck-container abbr[title], .deck-container dfn[title] {1236 border-bottom: 1px dotted;1237 cursor: help;1238}1239.deck-container table {1240 border-collapse: collapse;1241 border-spacing: 0;1242}1243.deck-container hr {1244 display: block;1245 height: 1px;1246 border: 0;1247 border-top: 1px solid #ccc;1248 margin: 1em 0;1249 padding: 0;1250}1251.deck-container input, .deck-container select {1252 vertical-align: middle;1253}1254.deck-container select, .deck-container input, .deck-container textarea, .deck-container button {1255 font: 99% sans-serif;1256}1257.deck-container pre, .deck-container code, .deck-container kbd, .deck-container samp {1258 font-family: monospace, sans-serif;1259}1260.deck-container a {1261 -webkit-tap-highlight-color: rgba(0, 0, 0, 0);1262}1263.deck-container a:hover, .deck-container a:active {1264 outline: none;1265}1266.deck-container ul, .deck-container ol {1267 margin-left: 2em;1268 vertical-align: top;1269}1270.deck-container ol {1271 list-style-type: decimal;1272}1273.deck-container nav ul, .deck-container nav li {1274 margin: 0;1275 list-style: none;1276 list-style-image: none;1277}1278.deck-container small {1279 font-size: 85%;1280}1281.deck-container strong, .deck-container th {1282 font-weight: bold;1283}1284.deck-container td {1285 vertical-align: top;1286}1287.deck-container sub, .deck-container sup {1288 font-size: 75%;1289 line-height: 0;1290 position: relative;1291}1292.deck-container sup {1293 top: -0.5em;1294}1295.deck-container sub {1296 bottom: -0.25em;1297}1298.deck-container textarea {1299 overflow: auto;1300}1301.ie6 .deck-container legend, .ie7 .deck-container legend {1302 margin-left: -7px;1303}1304.deck-container input[type="radio"] {1305 vertical-align: text-bottom;1306}1307.deck-container input[type="checkbox"] {1308 vertical-align: bottom;1309}1310.ie7 .deck-container input[type="checkbox"] {1311 vertical-align: baseline;1312}1313.ie6 .deck-container input {1314 vertical-align: text-bottom;1315}1316.deck-container label, .deck-container input[type="button"], .deck-container input[type="submit"], .deck-container input[type="image"], .deck-container button {1317 cursor: pointer;1318}1319.deck-container button, .deck-container input, .deck-container select, .deck-container textarea {1320 margin: 0;1321}1322.deck-container input:invalid, .deck-container textarea:invalid {1323 border-radius: 1px;1324 -moz-box-shadow: 0px 0px 5px red;1325 -webkit-box-shadow: 0px 0px 5px red;1326 box-shadow: 0px 0px 5px red;1327}1328.deck-container input:invalid .no-boxshadow, .deck-container textarea:invalid .no-boxshadow {1329 background-color: #f0dddd;1330}1331.deck-container button {1332 width: auto;1333 overflow: visible;1334}1335.ie7 .deck-container img {1336 -ms-interpolation-mode: bicubic;1337}1338.deck-container, .deck-container select, .deck-container input, .deck-container textarea {1339 color: #444;1340}1341.deck-container a {1342 color: #607890;1343}1344.deck-container a:hover, .deck-container a:focus {1345 color: #036;1346}1347.deck-container a:link {1348 -webkit-tap-highlight-color: #fff;1349}1350.deck-container.deck-loading {1351 display: none;1352}1353.slide {1354 width: auto;1355 min-height: 100%;1356 position: relative;1357}1358.slide h1 {1359 font-size: 4.5em;1360}1361.slide h1, .slide .vcenter {1362 font-weight: bold;1363 text-align: center;1364 padding-top: 1em;1365 max-height: 100%;1366}1367.csstransforms .slide h1, .csstransforms .slide .vcenter {1368 padding: 0 48px;1369 position: absolute;1370 left: 0;1371 right: 0;1372 top: 50%;1373 -webkit-transform: translate(0, -50%);1374 -moz-transform: translate(0, -50%);1375 -ms-transform: translate(0, -50%);1376 -o-transform: translate(0, -50%);1377 transform: translate(0, -50%);1378}1379.slide .vcenter h1 {1380 position: relative;1381 top: auto;1382 padding: 0;1383 -webkit-transform: none;1384 -moz-transform: none;1385 -ms-transform: none;1386 -o-transform: none;1387 transform: none;1388}1389.slide h2 {1390 font-size: 2.25em;1391 font-weight: bold;1392 padding-top: .5em;1393 margin: 0 0 .66666em 0;1394 border-bottom: 3px solid #888;1395}1396.slide h3 {1397 font-size: 1.4375em;1398 font-weight: bold;1399 margin-bottom: .30435em;1400}1401.slide h4 {1402 font-size: 1.25em;1403 font-weight: bold;1404 margin-bottom: .25em;1405}1406.slide h5 {1407 font-size: 1.125em;1408 font-weight: bold;1409 margin-bottom: .2222em;1410}1411.slide h6 {1412 font-size: 1em;1413 font-weight: bold;1414}1415.slide img, .slide iframe, .slide video {1416 display: block;1417 max-width: 100%;1418}1419.slide video, .slide iframe, .slide img {1420 display: block;1421 margin: 0 auto;1422}1423.slide p, .slide blockquote, .slide iframe, .slide img, .slide ul, .slide ol, .slide pre, .slide video {1424 margin-bottom: 1em;1425}1426.slide pre {1427 white-space: pre;1428 white-space: pre-wrap;1429 word-wrap: break-word;1430 padding: 1em;1431 border: 1px solid #888;1432}1433.slide em {1434 font-style: italic;1435}1436.slide li {1437 padding: .25em 0;1438 vertical-align: middle;1439}1440.deck-before, .deck-previous, .deck-next, .deck-after {1441 position: absolute;1442 left: -999em;1443 top: -999em;1444}1445.deck-current {1446 z-index: 2;1447}1448.slide .slide {1449 visibility: hidden;1450 position: static;1451 min-height: 0;1452}1453.deck-child-current {1454 position: static;1455 z-index: 2;1456}1457.deck-child-current .slide {1458 visibility: hidden;1459}1460.deck-child-current .deck-previous, .deck-child-current .deck-before, .deck-child-current .deck-current {1461 visibility: visible;1462}1463.deck-container .goto-form {1464 position: absolute;1465 z-index: 3;1466 bottom: 10px;1467 left: 50%;1468 height: 1.75em;1469 margin: 0 0 0 -9.125em;1470 line-height: 1.75em;1471 padding: 0.625em;1472 display: none;1473 background: #ccc;1474 overflow: hidden;1475}1476.borderradius .deck-container .goto-form {1477 -webkit-border-radius: 10px;1478 -moz-border-radius: 10px;1479 border-radius: 10px;1480}1481.deck-container .goto-form label {1482 font-weight: bold;1483}1484.deck-container .goto-form label, .deck-container .goto-form input {1485 display: inline-block;1486 font-family: inherit;1487}1488.deck-goto .goto-form {1489 display: block;1490}1491#goto-slide {1492 width: 8.375em;1493 margin: 0 0.625em;1494 height: 1.4375em;1495}1496.deck-container .deck-permalink {1497 display: none;1498 position: absolute;1499 z-index: 4;1500 bottom: 30px;1501 right: 0;1502 width: 48px;1503 text-align: center;1504}1505.no-history .deck-container:hover .deck-permalink {1506 display: block;1507}1508.deck-menu .slide {1509 background: #eee;1510 position: relative;1511 left: 0;1512 top: 0;1513 visibility: visible;1514 cursor: pointer;1515}1516.no-csstransforms .deck-menu > .slide {1517 float: left;1518 width: 22%;1519 height: 22%;1520 min-height: 0;1521 margin: 1%;1522 font-size: 0.22em;1523 overflow: hidden;1524 padding: 0 0.5%;1525}1526.deck-menu iframe, .deck-menu img, .deck-menu video {1527 max-width: 100%;1528}1529.deck-menu .deck-current, .no-touch .deck-menu .slide:hover {1530 background: #ddf;1531}1532.deck-menu.deck-container:hover .deck-prev-link, .deck-menu.deck-container:hover .deck-next-link {1533 display: none;1534}1535.deck-container .deck-prev-link, .deck-container .deck-next-link {1536 display: none;1537 position: absolute;1538 z-index: 3;1539 top: 50%;1540 width: 32px;1541 height: 32px;1542 margin-top: -16px;1543 font-size: 20px;1544 font-weight: bold;1545 line-height: 32px;1546 vertical-align: middle;1547 text-align: center;1548 text-decoration: none;1549 color: #fff;1550 background: #888;1551}1552.borderradius .deck-container .deck-prev-link, .borderradius .deck-container .deck-next-link {1553 -webkit-border-radius: 16px;1554 -moz-border-radius: 16px;1555 border-radius: 16px;1556}1557.deck-container .deck-prev-link:hover, .deck-container .deck-prev-link:focus, .deck-container .deck-prev-link:active, .deck-container .deck-prev-link:visited, .deck-container .deck-next-link:hover, .deck-container .deck-next-link:focus, .deck-container .deck-next-link:active, .deck-container .deck-next-link:visited {1558 color: #fff;1559}1560.deck-container .deck-prev-link {1561 left: 8px;1562}1563.deck-container .deck-next-link {1564 right: 8px;1565}1566.deck-container:hover .deck-prev-link, .deck-container:hover .deck-next-link {1567 display: block;1568}1569.deck-container:hover .deck-prev-link.deck-nav-disabled, .touch .deck-container:hover .deck-prev-link, .deck-container:hover .deck-next-link.deck-nav-disabled, .touch .deck-container:hover .deck-next-link {1570 display: none;1571}1572.deck-container .deck-status {1573 position: absolute;1574 bottom: 10px;1575 right: 5px;1576 color: #888;1577 z-index: 3;1578 margin: 0;1579}1580body.deck-container .deck-status {1581 position: fixed;1582}1583`...

Full Screen

Full Screen

file.go

Source:file.go Github

copy

Full Screen

...51func (f *file) Extensions() []Field {52 return f.extensions53}54func (f *file) CsharpNamespace() string {55 return f.fileDescriptor.GetOptions().GetCsharpNamespace()56}57func (f *file) GoPackage() string {58 return f.fileDescriptor.GetOptions().GetGoPackage()59}60func (f *file) JavaMultipleFiles() bool {61 return f.fileDescriptor.GetOptions().GetJavaMultipleFiles()62}63func (f *file) JavaOuterClassname() string {64 return f.fileDescriptor.GetOptions().GetJavaOuterClassname()65}66func (f *file) JavaPackage() string {67 return f.fileDescriptor.GetOptions().GetJavaPackage()68}69func (f *file) JavaStringCheckUtf8() bool {70 return f.fileDescriptor.GetOptions().GetJavaStringCheckUtf8()71}72func (f *file) ObjcClassPrefix() string {73 return f.fileDescriptor.GetOptions().GetObjcClassPrefix()74}75func (f *file) PhpClassPrefix() string {76 return f.fileDescriptor.GetOptions().GetPhpClassPrefix()77}78func (f *file) PhpNamespace() string {79 return f.fileDescriptor.GetOptions().GetPhpNamespace()80}81func (f *file) PhpMetadataNamespace() string {82 return f.fileDescriptor.GetOptions().GetPhpMetadataNamespace()83}84func (f *file) RubyPackage() string {85 return f.fileDescriptor.GetOptions().GetRubyPackage()86}87func (f *file) SwiftPrefix() string {88 return f.fileDescriptor.GetOptions().GetSwiftPrefix()89}90func (f *file) OptimizeFor() FileOptionsOptimizeMode {91 return f.optimizeMode92}93func (f *file) CcGenericServices() bool {94 return f.fileDescriptor.GetOptions().GetCcGenericServices()95}96func (f *file) JavaGenericServices() bool {97 return f.fileDescriptor.GetOptions().GetJavaGenericServices()98}99func (f *file) PyGenericServices() bool {100 return f.fileDescriptor.GetOptions().GetPyGenericServices()101}102func (f *file) PhpGenericServices() bool {103 return f.fileDescriptor.GetOptions().GetPhpGenericServices()104}105func (f *file) CcEnableArenas() bool {106 return f.fileDescriptor.GetOptions().GetCcEnableArenas()107}108func (f *file) PackageLocation() Location {109 return f.getLocationByPathKey(packagePathKey)110}111func (f *file) CsharpNamespaceLocation() Location {112 return f.getLocationByPathKey(csharpNamespacePathKey)113}114func (f *file) GoPackageLocation() Location {115 return f.getLocationByPathKey(goPackagePathKey)116}117func (f *file) JavaMultipleFilesLocation() Location {118 return f.getLocationByPathKey(javaMultipleFilesPathKey)119}120func (f *file) JavaOuterClassnameLocation() Location {121 return f.getLocationByPathKey(javaOuterClassnamePathKey)122}123func (f *file) JavaPackageLocation() Location {124 return f.getLocationByPathKey(javaPackagePathKey)125}126func (f *file) JavaStringCheckUtf8Location() Location {127 return f.getLocationByPathKey(javaStringCheckUtf8PathKey)128}129func (f *file) ObjcClassPrefixLocation() Location {130 return f.getLocationByPathKey(objcClassPrefixPathKey)131}132func (f *file) PhpClassPrefixLocation() Location {133 return f.getLocationByPathKey(phpClassPrefixPathKey)134}135func (f *file) PhpNamespaceLocation() Location {136 return f.getLocationByPathKey(phpNamespacePathKey)137}138func (f *file) PhpMetadataNamespaceLocation() Location {139 return f.getLocationByPathKey(phpMetadataNamespacePathKey)140}141func (f *file) RubyPackageLocation() Location {142 return f.getLocationByPathKey(rubyPackagePathKey)143}144func (f *file) SwiftPrefixLocation() Location {145 return f.getLocationByPathKey(swiftPrefixPathKey)146}147func (f *file) OptimizeForLocation() Location {148 return f.getLocationByPathKey(optimizeForPathKey)149}150func (f *file) CcGenericServicesLocation() Location {151 return f.getLocationByPathKey(ccGenericServicesPathKey)152}153func (f *file) JavaGenericServicesLocation() Location {154 return f.getLocationByPathKey(javaGenericServicesPathKey)155}156func (f *file) PyGenericServicesLocation() Location {157 return f.getLocationByPathKey(pyGenericServicesPathKey)158}159func (f *file) PhpGenericServicesLocation() Location {160 return f.getLocationByPathKey(phpGenericServicesPathKey)161}162func (f *file) CcEnableArenasLocation() Location {163 return f.getLocationByPathKey(ccEnableArenasPathKey)164}165func (f *file) SyntaxLocation() Location {166 return f.getLocationByPathKey(syntaxPathKey)167}168// does not validation of the fileDescriptorProto - this is assumed to be done elsewhere169// does no duplicate checking by name - could just have maps ie importToFileImport, enumNameToEnum, etc170func newFile(inputFile InputFile) (*file, error) {171 f := &file{172 FileInfo: inputFile,173 fileDescriptor: inputFile.FileDescriptor(),174 optionExtensionDescriptor: newOptionExtensionDescriptor(175 inputFile.FileDescriptor().GetOptions(),176 ),177 }178 descriptor := newDescriptor(179 f,180 newLocationStore(f.fileDescriptor.GetSourceCodeInfo().GetLocation()),181 )182 f.descriptor = descriptor183 if inputFile.IsSyntaxUnspecified() {184 f.syntax = SyntaxUnspecified185 } else {186 switch syntaxString := f.fileDescriptor.GetSyntax(); syntaxString {187 // if the syntax is "proto2", protoc and buf will not set the syntax188 // field even if it was explicitly set, this is why we have189 // IsSyntaxUnspecified190 case "", "proto2":191 f.syntax = SyntaxProto2192 case "proto3":193 f.syntax = SyntaxProto3194 default:195 return nil, fmt.Errorf("unknown syntax: %q", syntaxString)196 }197 }198 for dependencyIndex, dependency := range f.fileDescriptor.GetDependency() {199 fileImport, err := newFileImport(200 f.descriptor,201 dependency,202 getDependencyPath(dependencyIndex),203 )204 if err != nil {205 return nil, err206 }207 f.fileImports = append(f.fileImports, fileImport)208 }209 for _, dependencyIndex := range f.fileDescriptor.GetPublicDependency() {210 if int(dependencyIndex) < 0 || len(f.fileImports) <= int(dependencyIndex) {211 return nil, fmt.Errorf("got dependency index of %d but length of imports is %d", dependencyIndex, len(f.fileImports))212 }213 fileImport, ok := f.fileImports[dependencyIndex].(*fileImport)214 if !ok {215 return nil, fmt.Errorf("could not cast %T to a *fileImport", f.fileImports[dependencyIndex])216 }217 fileImport.setIsPublic()218 }219 for _, dependencyIndex := range f.fileDescriptor.GetWeakDependency() {220 if int(dependencyIndex) < 0 || len(f.fileImports) <= int(dependencyIndex) {221 return nil, fmt.Errorf("got dependency index of %d but length of imports is %d", dependencyIndex, len(f.fileImports))222 }223 fileImport, ok := f.fileImports[dependencyIndex].(*fileImport)224 if !ok {225 return nil, fmt.Errorf("could not cast %T to a *fileImport", f.fileImports[dependencyIndex])226 }227 fileImport.setIsWeak()228 }229 for _, dependencyIndex := range inputFile.UnusedDependencyIndexes() {230 if int(dependencyIndex) < 0 || len(f.fileImports) <= int(dependencyIndex) {231 return nil, fmt.Errorf("got dependency index of %d but length of imports is %d", dependencyIndex, len(f.fileImports))232 }233 fileImport, ok := f.fileImports[dependencyIndex].(*fileImport)234 if !ok {235 return nil, fmt.Errorf("could not cast %T to a *fileImport", f.fileImports[dependencyIndex])236 }237 fileImport.setIsUnused()238 }239 for enumIndex, enumDescriptorProto := range f.fileDescriptor.GetEnumType() {240 enum, err := f.populateEnum(241 enumDescriptorProto,242 enumIndex,243 nil,244 nil,245 )246 if err != nil {247 return nil, err248 }249 f.enums = append(f.enums, enum)250 }251 for messageIndex, descriptorProto := range f.fileDescriptor.GetMessageType() {252 message, err := f.populateMessage(253 descriptorProto,254 messageIndex,255 nil,256 nil,257 nil,258 )259 if err != nil {260 return nil, err261 }262 f.messages = append(f.messages, message)263 }264 for serviceIndex, serviceDescriptorProto := range f.fileDescriptor.GetService() {265 service, err := f.populateService(266 serviceDescriptorProto,267 serviceIndex,268 )269 if err != nil {270 return nil, err271 }272 f.services = append(f.services, service)273 }274 for extensionIndex, extensionDescriptorProto := range f.fileDescriptor.GetExtension() {275 extension, err := f.populateExtension(276 extensionDescriptorProto,277 extensionIndex,278 )279 if err != nil {280 return nil, err281 }282 f.extensions = append(f.extensions, extension)283 }284 optimizeMode, err := getFileOptionsOptimizeMode(f.fileDescriptor.GetOptions().GetOptimizeFor())285 if err != nil {286 return nil, err287 }288 f.optimizeMode = optimizeMode289 return f, nil290}291func (f *file) populateEnum(292 enumDescriptorProto *descriptorpb.EnumDescriptorProto,293 enumIndex int,294 // all message indexes leading to this enum295 nestedMessageIndexes []int,296 // all message names leading to this enum297 nestedMessageNames []string,298) (Enum, error) {299 enumNamedDescriptor, err := newNamedDescriptor(300 newLocationDescriptor(301 f.descriptor,302 getEnumPath(enumIndex, nestedMessageIndexes...),303 ),304 enumDescriptorProto.GetName(),305 getEnumNamePath(enumIndex, nestedMessageIndexes...),306 nestedMessageNames,307 )308 if err != nil {309 return nil, err310 }311 enum := newEnum(312 enumNamedDescriptor,313 newOptionExtensionDescriptor(314 enumDescriptorProto.GetOptions(),315 ),316 enumDescriptorProto.GetOptions().GetAllowAlias(),317 getEnumAllowAliasPath(enumIndex, nestedMessageIndexes...),318 )319 for enumValueIndex, enumValueDescriptorProto := range enumDescriptorProto.GetValue() {320 enumValueNamedDescriptor, err := newNamedDescriptor(321 newLocationDescriptor(322 f.descriptor,323 getEnumValuePath(enumIndex, enumValueIndex, nestedMessageIndexes...),324 ),325 enumValueDescriptorProto.GetName(),326 getEnumValueNamePath(enumIndex, enumValueIndex, nestedMessageIndexes...),327 append(nestedMessageNames, enum.Name()),328 )329 if err != nil {330 return nil, err331 }332 enumValue := newEnumValue(333 enumValueNamedDescriptor,334 newOptionExtensionDescriptor(335 enumValueDescriptorProto.GetOptions(),336 ),337 enum,338 int(enumValueDescriptorProto.GetNumber()),339 getEnumValueNumberPath(enumIndex, enumValueIndex, nestedMessageIndexes...),340 )341 enum.addValue(enumValue)342 }343 for reservedRangeIndex, reservedRangeDescriptorProto := range enumDescriptorProto.GetReservedRange() {344 reservedRangeLocationDescriptor := newLocationDescriptor(345 f.descriptor,346 getEnumReservedRangePath(enumIndex, reservedRangeIndex, nestedMessageIndexes...),347 )348 reservedEnumRange := newEnumRange(349 reservedRangeLocationDescriptor,350 enum,351 int(reservedRangeDescriptorProto.GetStart()),352 int(reservedRangeDescriptorProto.GetEnd()),353 )354 enum.addReservedEnumRange(reservedEnumRange)355 }356 for reservedNameIndex, reservedNameValue := range enumDescriptorProto.GetReservedName() {357 reservedNameLocationDescriptor := newLocationDescriptor(358 f.descriptor,359 getEnumReservedNamePath(enumIndex, reservedNameIndex, nestedMessageIndexes...),360 )361 reservedName, err := newReservedName(362 reservedNameLocationDescriptor,363 reservedNameValue,364 )365 if err != nil {366 return nil, err367 }368 enum.addReservedName(reservedName)369 }370 return enum, nil371}372func (f *file) populateMessage(373 descriptorProto *descriptorpb.DescriptorProto,374 // always stays the same on every recursive call375 topLevelMessageIndex int,376 // includes descriptorProto index377 nestedMessageIndexes []int,378 // does NOT include descriptorProto.GetName()379 nestedMessageNames []string,380 parent Message,381) (Message, error) {382 messageNamedDescriptor, err := newNamedDescriptor(383 newLocationDescriptor(384 f.descriptor,385 getMessagePath(topLevelMessageIndex, nestedMessageIndexes...),386 ),387 descriptorProto.GetName(),388 getMessageNamePath(topLevelMessageIndex, nestedMessageIndexes...),389 nestedMessageNames,390 )391 if err != nil {392 return nil, err393 }394 message := newMessage(395 messageNamedDescriptor,396 newOptionExtensionDescriptor(397 descriptorProto.GetOptions(),398 ),399 parent,400 descriptorProto.GetOptions().GetMapEntry(),401 descriptorProto.GetOptions().GetMessageSetWireFormat(),402 descriptorProto.GetOptions().GetNoStandardDescriptorAccessor(),403 getMessageMessageSetWireFormatPath(topLevelMessageIndex, nestedMessageIndexes...),404 getMessageNoStandardDescriptorAccessorPath(topLevelMessageIndex, nestedMessageIndexes...),405 )406 oneofIndexToOneof := make(map[int]*oneof)407 for oneofIndex, oneofDescriptorProto := range descriptorProto.GetOneofDecl() {408 oneofNamedDescriptor, err := newNamedDescriptor(409 newLocationDescriptor(410 f.descriptor,411 getMessageOneofPath(oneofIndex, topLevelMessageIndex, nestedMessageIndexes...),412 ),413 oneofDescriptorProto.GetName(),414 getMessageOneofNamePath(oneofIndex, topLevelMessageIndex, nestedMessageIndexes...),415 append(nestedMessageNames, message.Name()),416 )417 if err != nil {418 return nil, err419 }420 oneof := newOneof(421 oneofNamedDescriptor,422 newOptionExtensionDescriptor(423 oneofDescriptorProto.GetOptions(),424 ),425 message,426 )427 message.addOneof(oneof)428 oneofIndexToOneof[oneofIndex] = oneof429 }430 for fieldIndex, fieldDescriptorProto := range descriptorProto.GetField() {431 // TODO: not working for map entries432 fieldNamedDescriptor, err := newNamedDescriptor(433 newLocationDescriptor(434 f.descriptor,435 getMessageFieldPath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),436 ),437 fieldDescriptorProto.GetName(),438 getMessageFieldNamePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),439 append(nestedMessageNames, message.Name()),440 )441 if err != nil {442 return nil, err443 }444 var packed *bool445 if fieldDescriptorProto.Options != nil {446 packed = fieldDescriptorProto.GetOptions().Packed447 }448 label, err := getFieldDescriptorProtoLabel(fieldDescriptorProto.GetLabel())449 if err != nil {450 return nil, err451 }452 typ, err := getFieldDescriptorProtoType(fieldDescriptorProto.GetType())453 if err != nil {454 return nil, err455 }456 jsType, err := getFieldOptionsJSType(fieldDescriptorProto.GetOptions().GetJstype())457 if err != nil {458 return nil, err459 }460 cType, err := getFieldOptionsCType(fieldDescriptorProto.GetOptions().GetCtype())461 if err != nil {462 return nil, err463 }464 var oneof *oneof465 var ok bool466 if fieldDescriptorProto.OneofIndex != nil {467 oneofIndex := int(*fieldDescriptorProto.OneofIndex)468 oneof, ok = oneofIndexToOneof[oneofIndex]469 if !ok {470 return nil, fmt.Errorf("no oneof for index %d", oneofIndex)471 }472 }473 field := newField(474 fieldNamedDescriptor,475 newOptionExtensionDescriptor(476 fieldDescriptorProto.GetOptions(),477 ),478 message,479 int(fieldDescriptorProto.GetNumber()),480 label,481 typ,482 fieldDescriptorProto.GetTypeName(),483 fieldDescriptorProto.GetExtendee(),484 oneof,485 fieldDescriptorProto.GetProto3Optional(),486 fieldDescriptorProto.GetJsonName(),487 jsType,488 cType,489 packed,490 getMessageFieldNumberPath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),491 getMessageFieldTypePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),492 getMessageFieldTypeNamePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),493 getMessageFieldJSONNamePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),494 getMessageFieldJSTypePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),495 getMessageFieldCTypePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),496 getMessageFieldPackedPath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),497 getMessageFieldExtendeePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),498 )499 message.addField(field)500 if oneof != nil {501 oneof.addField(field)502 }503 }504 for fieldIndex, fieldDescriptorProto := range descriptorProto.GetExtension() {505 fieldNamedDescriptor, err := newNamedDescriptor(506 newLocationDescriptor(507 f.descriptor,508 getMessageExtensionPath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),509 ),510 fieldDescriptorProto.GetName(),511 getMessageExtensionNamePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),512 append(nestedMessageNames, message.Name()),513 )514 if err != nil {515 return nil, err516 }517 var packed *bool518 if fieldDescriptorProto.Options != nil {519 packed = fieldDescriptorProto.GetOptions().Packed520 }521 label, err := getFieldDescriptorProtoLabel(fieldDescriptorProto.GetLabel())522 if err != nil {523 return nil, err524 }525 typ, err := getFieldDescriptorProtoType(fieldDescriptorProto.GetType())526 if err != nil {527 return nil, err528 }529 jsType, err := getFieldOptionsJSType(fieldDescriptorProto.GetOptions().GetJstype())530 if err != nil {531 return nil, err532 }533 cType, err := getFieldOptionsCType(fieldDescriptorProto.GetOptions().GetCtype())534 if err != nil {535 return nil, err536 }537 var oneof *oneof538 var ok bool539 if fieldDescriptorProto.OneofIndex != nil {540 oneofIndex := int(*fieldDescriptorProto.OneofIndex)541 oneof, ok = oneofIndexToOneof[oneofIndex]542 if !ok {543 return nil, fmt.Errorf("no oneof for index %d", oneofIndex)544 }545 }546 field := newField(547 fieldNamedDescriptor,548 newOptionExtensionDescriptor(549 fieldDescriptorProto.GetOptions(),550 ),551 message,552 int(fieldDescriptorProto.GetNumber()),553 label,554 typ,555 fieldDescriptorProto.GetTypeName(),556 fieldDescriptorProto.GetExtendee(),557 oneof,558 fieldDescriptorProto.GetProto3Optional(),559 fieldDescriptorProto.GetJsonName(),560 jsType,561 cType,562 packed,563 getMessageExtensionNumberPath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),564 getMessageExtensionTypePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),565 getMessageExtensionTypeNamePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),566 getMessageExtensionJSONNamePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),567 getMessageExtensionJSTypePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),568 getMessageExtensionCTypePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),569 getMessageExtensionPackedPath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),570 getMessageExtensionExtendeePath(fieldIndex, topLevelMessageIndex, nestedMessageIndexes...),571 )572 if err != nil {573 return nil, err574 }575 message.addExtension(field)576 if oneof != nil {577 oneof.addField(field)578 }579 }580 for reservedRangeIndex, reservedRangeDescriptorProto := range descriptorProto.GetReservedRange() {581 reservedRangeLocationDescriptor := newLocationDescriptor(582 f.descriptor,583 getMessageReservedRangePath(reservedRangeIndex, topLevelMessageIndex, nestedMessageIndexes...),584 )585 reservedMessageRange := newMessageRange(586 reservedRangeLocationDescriptor,587 message,588 int(reservedRangeDescriptorProto.GetStart()),589 int(reservedRangeDescriptorProto.GetEnd()),590 )591 message.addReservedMessageRange(reservedMessageRange)592 }593 for reservedNameIndex, reservedNameValue := range descriptorProto.GetReservedName() {594 reservedNameLocationDescriptor := newLocationDescriptor(595 f.descriptor,596 getMessageReservedNamePath(reservedNameIndex, topLevelMessageIndex, nestedMessageIndexes...),597 )598 reservedName, err := newReservedName(599 reservedNameLocationDescriptor,600 reservedNameValue,601 )602 if err != nil {603 return nil, err604 }605 message.addReservedName(reservedName)606 }607 for extensionRangeIndex, extensionRangeDescriptorProto := range descriptorProto.GetExtensionRange() {608 extensionRangeLocationDescriptor := newLocationDescriptor(609 f.descriptor,610 getMessageExtensionRangePath(extensionRangeIndex, topLevelMessageIndex, nestedMessageIndexes...),611 )612 extensionMessageRange := newMessageRange(613 extensionRangeLocationDescriptor,614 message,615 int(extensionRangeDescriptorProto.GetStart()),616 int(extensionRangeDescriptorProto.GetEnd()),617 )618 message.addExtensionMessageRange(extensionMessageRange)619 }620 for enumIndex, enumDescriptorProto := range descriptorProto.GetEnumType() {621 nestedEnum, err := f.populateEnum(622 enumDescriptorProto,623 enumIndex,624 // this is all of the message indexes including this one625 // TODO we should refactor get.*Path messages to be more consistent626 append([]int{topLevelMessageIndex}, nestedMessageIndexes...),627 append(nestedMessageNames, message.Name()),628 )629 if err != nil {630 return nil, err631 }632 message.addNestedEnum(nestedEnum)633 }634 for nestedMessageIndex, nestedMessageDescriptorProto := range descriptorProto.GetNestedType() {635 nestedMessage, err := f.populateMessage(636 nestedMessageDescriptorProto,637 topLevelMessageIndex,638 append(nestedMessageIndexes, nestedMessageIndex),639 append(nestedMessageNames, message.Name()),640 message,641 )642 if err != nil {643 return nil, err644 }645 message.addNestedMessage(nestedMessage)646 }647 return message, nil648}649func (f *file) populateService(650 serviceDescriptorProto *descriptorpb.ServiceDescriptorProto,651 serviceIndex int,652) (Service, error) {653 serviceNamedDescriptor, err := newNamedDescriptor(654 newLocationDescriptor(655 f.descriptor,656 getServicePath(serviceIndex),657 ),658 serviceDescriptorProto.GetName(),659 getServiceNamePath(serviceIndex),660 nil,661 )662 if err != nil {663 return nil, err664 }665 service := newService(666 serviceNamedDescriptor,667 newOptionExtensionDescriptor(668 serviceDescriptorProto.GetOptions(),669 ),670 )671 for methodIndex, methodDescriptorProto := range serviceDescriptorProto.GetMethod() {672 methodNamedDescriptor, err := newNamedDescriptor(673 newLocationDescriptor(674 f.descriptor,675 getMethodPath(serviceIndex, methodIndex),676 ),677 methodDescriptorProto.GetName(),678 getMethodNamePath(serviceIndex, methodIndex),679 []string{service.Name()},680 )681 if err != nil {682 return nil, err683 }684 idempotencyLevel, err := getMethodOptionsIdempotencyLevel(methodDescriptorProto.GetOptions().GetIdempotencyLevel())685 if err != nil {686 return nil, err687 }688 method, err := newMethod(689 methodNamedDescriptor,690 newOptionExtensionDescriptor(691 methodDescriptorProto.GetOptions(),692 ),693 service,694 methodDescriptorProto.GetInputType(),695 methodDescriptorProto.GetOutputType(),696 methodDescriptorProto.GetClientStreaming(),697 methodDescriptorProto.GetServerStreaming(),698 getMethodInputTypePath(serviceIndex, methodIndex),699 getMethodOutputTypePath(serviceIndex, methodIndex),700 idempotencyLevel,701 getMethodIdempotencyLevelPath(serviceIndex, methodIndex),702 )703 if err != nil {704 return nil, err705 }706 service.addMethod(method)707 }708 return service, nil709}710func (f *file) populateExtension(711 fieldDescriptorProto *descriptorpb.FieldDescriptorProto,712 fieldIndex int,713) (Field, error) {714 fieldNamedDescriptor, err := newNamedDescriptor(715 newLocationDescriptor(716 f.descriptor,717 getFileExtensionPath(fieldIndex),718 ),719 fieldDescriptorProto.GetName(),720 getFileExtensionNamePath(fieldIndex),721 nil,722 )723 if err != nil {724 return nil, err725 }726 var packed *bool727 if fieldDescriptorProto.Options != nil {728 packed = fieldDescriptorProto.GetOptions().Packed729 }730 label, err := getFieldDescriptorProtoLabel(fieldDescriptorProto.GetLabel())731 if err != nil {732 return nil, err733 }734 typ, err := getFieldDescriptorProtoType(fieldDescriptorProto.GetType())735 if err != nil {736 return nil, err737 }738 jsType, err := getFieldOptionsJSType(fieldDescriptorProto.GetOptions().GetJstype())739 if err != nil {740 return nil, err741 }742 cType, err := getFieldOptionsCType(fieldDescriptorProto.GetOptions().GetCtype())743 if err != nil {744 return nil, err745 }746 return newField(747 fieldNamedDescriptor,748 newOptionExtensionDescriptor(749 fieldDescriptorProto.GetOptions(),750 ),751 nil,752 int(fieldDescriptorProto.GetNumber()),753 label,754 typ,755 fieldDescriptorProto.GetTypeName(),756 fieldDescriptorProto.GetExtendee(),757 nil,758 fieldDescriptorProto.GetProto3Optional(),759 fieldDescriptorProto.GetJsonName(),760 jsType,761 cType,762 packed,763 getFileExtensionNumberPath(fieldIndex),...

Full Screen

Full Screen

class.go

Source:class.go Github

copy

Full Screen

1package class2import (3 "io"4 "strings"5)6const classjs string=`/*!7* @author Angelo Dini8* @version 1.09* @copyright Distributed under the BSD License.10*/11(function(){var d="1.0";var c=window.Class;var b=window.Class=function(n){n=n||{};var m=function(){return(this.initialize)?this.initialize.apply(this,arguments):j};if(n.implement){var j=window===this?g(m.prototype):this;var l=n.implement;a(n,"implement");n=f(n,e(l))}m.prototype=g(n);m.constructor=m;m._parent=g(n);for(var k=0,h=["extend","implement","getOptions","setOptions"];k<h.length;k++){m[h[k]]=b[h[k]]}return m};b.extend=function(j){var h=this;if(j.implement){this.prototype=f(this.prototype,e(j.implement));a(j,"implement")}for(var i in j){j[i]=typeof j[i]==="function"&&/parent/.test(j[i].toString())?(function(l,k){return function(){this.parent=h._parent[k];return l.apply(this,arguments)}})(j[i],i):j[i]}this._parent=f(this._parent,j,true);this.prototype=f(this.prototype,j);return this};b.implement=function(h){return this.prototype=f(this.prototype,e(h))};b.getOptions=function(){return this.prototype.options||{}};b.setOptions=function(h){return this.prototype.options=f(this.prototype.options,h)};b.noConflict=function(){window.Class=c;return b};b.version=d;function g(i){var h=function(){};h.prototype=i.prototype||i;return new h()}function a(l,i,k){if(k){var h={};for(var j in l){if(j!==i){h[j]=l[j]}}}else{delete l[i]}return h||l}function f(h,i,k){if(!h||!i){return h||i||{}}h=g(h);i=g(i);for(var j in i){if(Object.prototype.toString.call(i[j])==="[object Object]"){f(h[j],i[j])}else{h[j]=(k&&h[j])?h[j]:i[j]}}return h}function e(l){var k={};for(var h=0;h<l.length;h++){if(typeof(l[h])==="function"){l[h]=l[h].prototype}var j=a(l[h],"initialize",true);if(j.implement){k=e(j.implement)}else{k=f(k,j)}}return k}})();`12func ClassJS() io.Reader {13 return strings.NewReader(classjs);14}15func ClassFindJS(findclassjs string) io.Reader {16 if strings.LastIndex(findclassjs,"/")>-1 {17 findclassjs=findclassjs[strings.LastIndex(findclassjs,"/")+1:]18 }19 if findclassjs=="class.js" {20 return ClassJS()21 }22 return nil23}...

Full Screen

Full Screen

GetOptions

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 c := make(chan struct{}, 0)4 js.Global().Set("getOptions", js.FuncOf(getOptions))5}6func getOptions(this js.Value, args []js.Value) interface{} {7 fmt.Println("getOptions called")8 return js.Null()9}10 function getOptions() {11 let result = window.wasm.getOptions();12 console.log(result);13 }14 <button onclick="getOptions()">Get Options</button>

Full Screen

Full Screen

GetOptions

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 jsObj := js.Global.Get("Object").New()4 fmt.Println(jsObj)5 jsArray := js.Global.Get("Array").New()6 fmt.Println(jsArray)7 jsFunc := js.Global.Get("Function").New()8 fmt.Println(jsFunc)9 jsDate := js.Global.Get("Date").New()10 fmt.Println(jsDate)11 jsRegexp := js.Global.Get("RegExp").New()12 fmt.Println(jsRegexp)13}14{Object}15function (){}16{Date}17{RegExp}

Full Screen

Full Screen

GetOptions

Using AI Code Generation

copy

Full Screen

1jsObj = new jsObject();2jsObj.GetOptions();3jsObj = new jsObject();4jsObj.GetOptions();5jsObj = new jsObject();6jsObj.GetOptions();7jsObj = new jsObject();8jsObj.GetOptions();9jsObj = new jsObject();10jsObj.GetOptions();11jsObj = new jsObject();12jsObj.GetOptions();13jsObj = new jsObject();14jsObj.GetOptions();15jsObj = new jsObject();16jsObj.GetOptions();17jsObj = new jsObject();18jsObj.GetOptions();19jsObj = new jsObject();20jsObj.GetOptions();

Full Screen

Full Screen

GetOptions

Using AI Code Generation

copy

Full Screen

1var opt = new GetOptions();2opt.set("key", "value");3var p = new Promise(function(resolve, reject){4 myObject.GetOptions(opt, function(err, res){5 if(err) reject(err);6 else resolve(res);7 });8});9p.then(function(res){10 console.log(res);11}).catch(function(err){12 console.log(err);13});14var opt = new GetOptions();15opt.set("key", "value");16var p = new Promise(function(resolve, reject){17 myObject.GetOptions(opt, function(err, res){18 if(err) reject(err);19 else resolve(res);20 });21});22p.then(function(res){23 console.log(res);24}).catch(function(err){25 console.log(err);26});27var opt = new GetOptions();28opt.set("key", "value");29var p = new Promise(function(resolve, reject){30 myObject.GetOptions(opt, function(err, res){31 if(err) reject(err);32 else resolve(res);33 });34});35p.then(function(res){36 console.log(res);37}).catch(function(err){38 console.log(err);39});40var opt = new GetOptions();41opt.set("key", "value");42var p = new Promise(function(resolve, reject){43 myObject.GetOptions(opt, function(err, res){44 if(err) reject(err);45 else resolve(res);46 });47});48p.then(function(res){49 console.log(res);50}).catch(function(err){51 console.log(err);52});53var opt = new GetOptions();54opt.set("key", "value");55var p = new Promise(function(resolve, reject){56 myObject.GetOptions(opt, function(err, res){57 if(err) reject(err);58 else resolve(res);59 });60});61p.then(function(res){62 console.log(res);63}).catch(function(err){64 console.log(err);65});66var opt = new GetOptions();67opt.set("key", "value");68var p = new Promise(function(resolve, reject){69 myObject.GetOptions(opt, function(err, res){70 if(err) reject(err

Full Screen

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 K6 automation tests on LambdaTest cloud grid

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

Most used method in

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful