diff --git a/assets/scripts/snippets.js b/assets/scripts/snippets.js new file mode 100644 index 0000000..e460c9d --- /dev/null +++ b/assets/scripts/snippets.js @@ -0,0 +1,17 @@ +(function() { + 'use strict'; + + var identifier = 0; + var snippets = Array.prototype.slice.call(document.querySelectorAll('pre.snippet')); + + snippets.forEach(function(snippet) { + snippet.id = 'snip' + identifier; + + var copyBtn = document.createElement('span'); + + copyBtn.className = 'btn clip'; + copyBtn.setAttribute('data-clipboard-target', '#snip' + identifier++); + + snippet.parentElement.insertBefore(copyBtn, snippet); + }); +})();