How to use jquery - 10 common examples

To help you get started, we’ve selected a few jquery examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mediachain / cccoin / node / frontend / src / auth.js View on Github external
request1.done(function( hh ) {
      console.log('login.request1.done()');

      console.log('got_challenge', JSON.stringify(hh));

      const dd = hh['challenge'];

      const sig = ethUtils.ecsign(ethUtils.sha256(new Buffer(dd)), new Buffer(posting_priv, 'hex'));

      // Send challenge response:
      const request2 = $.ajax({
        dataType: "json",
        url: "/login_2",
        method: "POST",
        data: JSON.stringify({
          the_pub: posting_pub,
          challenge: dd,
          requested_username: requested_username,
          sig: {
            sig_v: sig.v,
            sig_r: sig.r.toString('hex'),
            sig_s: sig.s.toString('hex'),
          },
        })
      });

      request2.done(function( msg2 ) {
github talos / no.js / js / src / main.js View on Github external
.done(function (resp, status, doc) {
                    if (doc.responseText) {
                        var context = json.parse(doc.responseText);
                        $.each(templates, function (id, template) {
                            $app.find('#' + id).html(mustache.render(template, context));
                        });

                        // This is hacky, but have to make sure that
                        // chat is only updated if it is empty.
                        if ($chat.children().length === 0) {
                            $chat.html(mustache.render(chat, context));
                        }
                        id = context.id;
                    }
                    setTimeout(function () {
                        update(id);
                    }, 100);
                }).fail(function (resp) {
                    //console.log(resp);
github apache / incubator-echarts-doc / public / en / js / docTool / schemaHelper.js View on Github external
schemaHelper.parseOptionPath = function (optionPath, options) {
        options = options || {};
        var errorInfo = 'Path is illegal: \'' + optionPath + '\'';
        dtLib.assert(
            optionPath && (optionPath = $.trim(optionPath)), errorInfo
        );
        // 因为mark down的url中不支持小括号(marked实现太简单了),所以小括号改用减号,数组不再用减号。
        // URL中的数组,不写[i]。
        // optionPath = optionPath.replace(/\-i/g, '-i]'); // 兼容 series-i表示数组的情况。
        var pathArr = optionPath.split(/\.|\[/);
        var retArr = [];

        for (var i = 0, len = pathArr.length; i < len; i++) {
            var itemStr = $.trim(pathArr[i]);
            if (options.ignoreEmptyItem && itemStr === '') {
                continue;
            }
            // 因为mark down的url中不支持小括号(marked实现太简单了),所以不用小括号,改用减号表示type。
            // match: 'asdf-bb' 'asdf-' 'i]-bb' 'i]-' 'asdf' 'i]'
            var regResult = itemStr.match(PATH_ITEM_REG) || [];
github OpenBazaar / openbazaar-desktop / js / views / transactions / Transactions.js View on Github external
const orderDetail = new OrderDetail({
      model,
      removeOnClose: true,
      returnText: app.polyglot.t(`transactions.${type}s.returnToFromOrder`),
      ...opts.modalOptions,
    });

    orderDetail.render().open();

    if (opts.addToRoute) {
      // add the order / case id to the url
      const params = deparam(location.hash.split('?')[1] || '');
      delete params.orderId;
      delete params.caseId;
      params[type === 'case' ? 'caseId' : 'orderId'] = id;
      app.router.navigate(`${location.hash.split('?')[0]}?${$.param(params)}`);
    }

    // remove it from the url on close of the modal
    const onClose = () => {
      const params = deparam(location.hash.split('?')[1] || '');
      delete params.orderId;
      delete params.caseId;
      app.router.navigate(`${location.hash.split('?')[0]}?${$.param(params)}`);
    };

    this.listenTo(orderDetail, 'close', onClose);

    // Do not alter the url if the user is routing to a new route. The
    // user has already altered the url.
    this.listenTo(app.router, 'will-route', () => {
      this.stopListening(orderDetail, 'close', onClose);
github epam / miew / demo / scripts / ui / Menu.js View on Github external
Menu.prototype._updateInfo = function (dataSource) {
  if (dataSource && dataSource.id !== 'Complex') {
    return;
  }
  const complex = dataSource;

  const body = $('.panel-menu[data-panel-type=miew-menu-panel-info]').children('.panel-body')[0];

  // remove all existing text
  const parent = body;
  while (parent.firstChild) {
    parent.removeChild(parent.firstChild);
  }

  const frag = document.createDocumentFragment();
  if (!complex) {
    frag.appendChild(createElement('p', null, 'No data loaded yet.'));
    body.appendChild(frag);
    return;
  }

  const { metadata } = complex;
  const h1 = createElement('h1', null, `${metadata.id || complex.name || 'Unknown data'} `);
github Esshahn / spritemate / src / js / List.js View on Github external
<div id="spritelist"></div>
    `;

    $("#window-"+this.window).append(template);

    
    $("#spritelist").sortable({
      cursor:"move",
      tolerance: "pointer",
      revert: '100'
    });

    // this line is ridiculous, but apparently it is needed for the sprite sorting to not screw up
    $("<style type="text/css"> .list-sprite-size{ width:"+this.width+"px; height:"+this.height+"px;} </style>").appendTo("head");

    $("#spritelist").disableSelection();
  }
github TYPO3 / TYPO3.CMS / Build / Sources / TypeScript / backend / Resources / Public / TypeScript / ModuleMenu.ts View on Github external
private initialize(): void {
    const me = this;
    let deferred = $.Deferred();
    deferred.resolve();

    // load the start module
    if (top.startInModule && top.startInModule[0] && $('#' + top.startInModule[0]).length > 0) {
      deferred = this.showModule(
        top.startInModule[0],
        top.startInModule[1],
      );
    } else {
      // fetch first module
      const $firstModule = $('.t3js-modulemenu-action[data-link]:first');
      if ($firstModule.attr('id')) {
        deferred = this.showModule(
          $firstModule.attr('id'),
        );
      }
      // else case: the main module has no entries, this is probably a backend
      // user with very little access rights, maybe only the logout button and
      // a user settings module in topbar.
    }

    deferred.then((): void => {
      me.initializeEvents();
    });
  }
github domino14 / Webolith / djAerolith / wordwalls / static / js / wordwalls / newtable / play_button.jsx View on Github external
const $ul = $(this).children('.dropdown-menu');
      const $button = $(this).children('.dropdown-toggle');
      // Ugh, the position of the , plus the offset of the UL relative
      // to the dropdown toggle button.
      const ulOffsetTop = $ul.parents('.list-table-row').position().top +
        $ul.position().top;
      // how much space would be left on the top if the dropdown opened that
      // direction
      const spaceUp = ulOffsetTop - $button.height() - $ul.height();
      // how much space is left at the bottom
      const spaceDown = $tableScroller.height() - (ulOffsetTop + $ul.height());
      // switch to dropup only if there is no space at the bottom
      // AND there is space at the top, or there isn't either but it
      // would be still better fit
      if (spaceDown &lt; 0 &amp;&amp; (spaceUp &gt;= 0 || spaceUp &gt; spaceDown)) {
        $(this).addClass('dropup');
      }
    }).on('hidden.bs.dropdown', '.dropdown', function hhidden() {
      // always reset after close
github enketo / enketo-core / src / widget / select-autocomplete / jquery.relevant-dropdown.js View on Github external
RelevantDropdown.prototype._init = function() {
    const $input = $( this.element );
    this.listId = $input.attr( 'list' );

    // Insert home for new fake datalist
    this.$fakeDatalist = $( '<ul>', {
        'class': 'datalist widget',
        'id': this.listId
    } ).appendTo( $input.parent() );

    this._updateFakeDatalist();
    this._setEventListeners();
};
</ul>
github openworm / org.geppetto.frontend / src / main / webapp / js / widgets / form / Form.js View on Github external
setData: function (state, options, dataset) {
                // If no options specify by user, use default options
                if (options != null) {
                    $.extend(this.options, options);
                }
            	form.setValue(state);
            	return this;
            },