-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,43 +12,5 @@ <h1 class="site__title">{{ site.title | xml_escape }}</h1> | |
</div> | ||
</div> | ||
</body> | ||
|
||
<!-- <script src="js/script.js"></script> --> | ||
<script> | ||
|
||
// highlight text in code blocks when clicked | ||
var codeBlocks = document.querySelectorAll('.highlighter-rouge code'); | ||
var codeBlocksLength = codeBlocks.length; | ||
var i; | ||
|
||
for (i = 0; i < codeBlocksLength; i++) { | ||
codeBlocks[i].addEventListener('click', function() { | ||
clip(this); | ||
}, false); | ||
} | ||
|
||
var clip = function(el) { | ||
var range = document.createRange(); | ||
var sel = window.getSelection(); | ||
|
||
range.selectNodeContents(el); | ||
|
||
sel.removeAllRanges(); | ||
sel.addRange(range); | ||
}; | ||
|
||
// open external links in new tab | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
scottaohara
Collaborator
|
||
var links = document.links; | ||
var linksLength = links.length; | ||
var i; | ||
|
||
for (i = 0; i < linksLength; i++) { | ||
if (links[i].hostname != window.location.hostname) { | ||
links[i].rel = 'noopener noreferrer'; | ||
links[i].target = '_blank'; | ||
} | ||
} | ||
|
||
</script> | ||
{% include analytics.html %} | ||
</html> |
3 comments
on commit 4cd6e5c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha go me π Yeah that was an accident. @scottaohara I respect your opinion on opening links in new tabs, and I agree for internal links. However, personally, I prefer all external links to open in a new tab. Can't stand it when I assume a link will be opened in a new tab/window and instead it hijacks my tab/window and potentially loses the state of the page/app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joshbuchea Don't assume, use the appropriate modifier key to open as new tab.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hope would have been a more appropriate word than assume, but point taken @dodekeract π
@joshbuchea You also removed this section, which opens all external links in a new tab