diff --git a/articles/static/copy-code.js b/articles/static/copy-code.js
new file mode 100644
index 0000000..75f5767
--- /dev/null
+++ b/articles/static/copy-code.js
@@ -0,0 +1,28 @@
+"use strict";
+
+function addCopyCode() {
+ const codeBlocks = document.querySelectorAll("pre");
+ codeBlocks.forEach(pre => {
+ pre.addEventListener("click", event => {
+ if (event.detail === 4) {
+ const selection = window.getSelection();
+ selection.setBaseAndExtent(
+ pre.querySelector("code").firstChild,
+ 0,
+ pre.querySelector("code").lastChild,
+ 1
+ );
+ }
+ });
+ pre.setAttribute("title", "Quadruple click to select all");
+ });
+}
+
+
+((readyState) => {
+ if (readyState === "interactive") {
+ addCopyCode();
+ } else if (readyState === "loading") {
+ window.addEventListener("DOMContentLoaded", addCopyCode, false);
+ }
+})(document.readyState);
diff --git a/articles/templates/articles/base.html b/articles/templates/articles/base.html
index 35f214e..0af13ea 100644
--- a/articles/templates/articles/base.html
+++ b/articles/templates/articles/base.html
@@ -63,6 +63,9 @@
{% if user.is_authenticated %}
{% endif %}
+{% if article and article.has_code %}
+
+{% endif %}