Dereferrering external links

before-bootstrap
Candid Dauth 2015-02-05 22:43:01 +01:00
rodzic 8857e0631a
commit d0e254afb8
2 zmienionych plików z 26 dodań i 0 usunięć

Wyświetl plik

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script>
var url = decodeURIComponent(location.search.replace(/^\?/, ""));
if(url)
location.replace(url);
</script>
</body>
</html>

Wyświetl plik

@ -8,6 +8,19 @@ var FacilPad = {
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|javascript):/);
} ]);
// Dereferrer
$(document).on("click", "a", function(e) {
var el = $(e.target);
var href = el.attr("href");
if(href && href.match(/^\s*(https?:)?\/\//i)) {
el.attr("href", "deref.html?"+encodeURIComponent(href));
setTimeout(function() {
el.attr("href", href);
}, 0);
}
});
fp.app.run([ "$rootScope", "fpUtils", function($rootScope, fpUtils) {
$rootScope.padId = location.pathname.match(/[^\/]*$/)[0];
$rootScope.urlPrefix = location.protocol + "//" + location.host + location.pathname.replace(/[^\/]*$/, "");