Sha256: 2ec3bd3e89af41087d9c4c5eed968be5f60bd554ca2f7a311d0633e953256329

Contents?: true

Size: 660 Bytes

Versions: 80

Compression:

Stored size: 660 Bytes

Contents

import Clipboard from 'clipboard';

export default () => {
  document.querySelectorAll('.code-toolbar button').forEach(function(button) {
    button.addEventListener('click', createRequest, { once: true })
  });
};

function createRequest(event) {
  let dataset = event.target.closest('.code-toolbar').firstChild.dataset;

  let params = {
    "language": dataset.lang,
    "snippet": dataset.block,
    "section": dataset.section,
    "event": "copy"
  };

  fetch(new Request('/usage/code_snippet', {
    method: 'POST',
    credentials: 'same-origin',
    body: JSON.stringify(params),
    headers: {
      'Content-Type': 'application/json'
    }
  }));
}

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
station-0.4.6 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.4.5 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.4.4 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.4.3 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.4.2 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.4.1 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.4.0 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.3.2 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.3.1 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.3.0 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.2.6 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.2.5 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.2.4 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.2.3 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.2.2 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.2.1 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.2.0 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.1.8 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.1.7 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.1.6 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js