Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: It's now possible to navigate between pages\!
- Loading branch information
1 parent
fa20942
commit a6f41f2
Showing
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
window.addEventListener('click', function (ev) { | ||
if (ev.altKey || ev.ctrlKey || ev.metaKey || ev.shiftKey || ev.defaultPrevented || self.location == top.location) { | ||
console.log('avoided'); | ||
return true; | ||
} | ||
|
||
var anchor = null; | ||
for (var n = ev.target; n.parentNode; n = n.parentNode) { | ||
if (n.nodeName === 'A') { | ||
anchor = n; | ||
break; | ||
} | ||
} | ||
if (!anchor) return true; | ||
|
||
var link = document.createElement('a'); | ||
link.setAttribute('href', anchor.getAttribute('href')); | ||
|
||
if (link.host && link.host !== location.host) return true; | ||
|
||
ev.preventDefault(); | ||
|
||
var gotoUrl = location.protocol + '//' + location.host + '/abe/editor' + link.pathname + (link.search || '') + (link.hash || '') ; | ||
link = null; | ||
top.location.href = gotoUrl | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters