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.5.16 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.15 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.14 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.13 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.12 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.11 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.10 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.9 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.8 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.7 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.6 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.5 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.4 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.3 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.2 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.1 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.5.0 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.4.9 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.4.8 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js
station-0.4.7 lib/nexmo_developer/app/webpacker/javascript/code_snippet_events/index.js