From 366777b048c9d287f9a1dbc5a007aa494ff95fe8 Mon Sep 17 00:00:00 2001
From: Anton Sarukhanov <code@ant.sr>
Date: Sat, 23 Mar 2019 15:46:41 -0400
Subject: [PATCH] Open external links in new tab.

---
 theme/static/js/script.js | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/theme/static/js/script.js b/theme/static/js/script.js
index 7506110..b5670f4 100644
--- a/theme/static/js/script.js
+++ b/theme/static/js/script.js
@@ -76,4 +76,18 @@
             }
         }).change();
     }
-})("form")
+})("form");
+
+
+
+
+/* Make all external links open in new tab.
+ * Adapted from http://mitchbarry.com/handling-external-links/
+ */
+(function() {
+    for (var links = document.links, i = 0, link; link = links[i]; i++) {
+        if (link.hostname !== window.location.host.split('.').slice(-2).join('.')) {
+            link.target = '_blank';
+        }
+    }
+})();
-- 
GitLab