Sha256: d8459d77e68d7cd80d018aa85c21ddc2897f110eecef6d948ea78d9b0a67643f
Contents?: true
Size: 1004 Bytes
Versions: 1
Compression:
Stored size: 1004 Bytes
Contents
--- --- // https://stackoverflow.com/a/7090123 const searchToObject = () => { var pairs = window.location.search.substring(1).split("&"), obj = {}, pair, i; for (i in pairs) { if (pairs[i] === "") continue; pair = pairs[i].split("="); obj[decodeURIComponent(pair[0])] = decodeURIComponent(pair[1]); } return obj; } document.addEventListener('{%- if site.turbolinks.enabled -%}turbolinks:load{%- else -%}DOMContentLoaded{%- endif -%}', () => { const urlShared = searchToObject(); document.querySelectorAll('a[lang]').forEach(a => a.href += window.location.search); ['t','d','u'].forEach(field => { if (urlShared[field] === undefined) return; document.querySelector(`#${field}`).innerText = urlShared[field]; }); document.querySelector('#text').value = Object.values(urlShared).join("\n\n"); document.querySelector('form').addEventListener('submit', e => { e.target.action = document.querySelector('#instance').value + '/share'; }); });
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
share-to-fediverse-jekyll-theme-0.1.3 | assets/js/script.js |