2018-03-03 06:41:19 +00:00
|
|
|
export default () => {
|
|
|
|
const { protocol, host, pathname } = location;
|
2018-03-07 13:06:16 +00:00
|
|
|
const shareBtn = document.querySelector('.js-share-btn');
|
|
|
|
const embedBtn = document.querySelector('.js-embed-btn');
|
|
|
|
const snippetUrlArea = document.querySelector('.js-snippet-url-area');
|
|
|
|
const embedAction = document.querySelector('.js-embed-action');
|
2018-03-06 18:44:57 +00:00
|
|
|
const url = `${protocol}//${host + pathname}`;
|
2018-02-06 13:33:18 +00:00
|
|
|
|
2018-03-03 08:00:08 +00:00
|
|
|
shareBtn.addEventListener('click', () => {
|
2018-03-03 06:41:19 +00:00
|
|
|
shareBtn.classList.add('is-active');
|
|
|
|
embedBtn.classList.remove('is-active');
|
2018-03-06 18:44:57 +00:00
|
|
|
snippetUrlArea.value = url;
|
|
|
|
embedAction.innerText = 'Share';
|
2018-03-03 06:41:19 +00:00
|
|
|
});
|
2018-02-06 13:33:18 +00:00
|
|
|
|
2018-03-03 08:00:08 +00:00
|
|
|
embedBtn.addEventListener('click', () => {
|
2018-03-03 06:41:19 +00:00
|
|
|
embedBtn.classList.add('is-active');
|
|
|
|
shareBtn.classList.remove('is-active');
|
2018-03-06 18:44:57 +00:00
|
|
|
const scriptTag = `<script src="${url}.js"></script>`;
|
2018-03-03 06:41:19 +00:00
|
|
|
snippetUrlArea.value = scriptTag;
|
2018-03-06 18:44:57 +00:00
|
|
|
embedAction.innerText = 'Embed';
|
2018-02-06 13:33:18 +00:00
|
|
|
});
|
2018-03-03 06:41:19 +00:00
|
|
|
};
|