Skip to content

Commit c4f858f

Browse files
committed
2 parents d7b30d6 + f062f57 commit c4f858f

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

ESSArch_TA/frontend/static/frontend/scripts/controllers/VersionCtrl.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,9 @@ angular.module('myApp').controller('VersionCtrl', function($scope, myService, $w
3030
$window.open('http://www.essolutions.se', '_blank');
3131
};
3232
$scope.scrollToLink = function(link) {
33-
if(!isURL(link)) {
34-
$location.hash(link);
35-
$anchorScroll();
36-
} else {
37-
$window.open(link, '_blank');
38-
return true;
39-
}
40-
}
41-
function isURL(str) {
42-
var urlRegex = '^(?!mailto:)(?:(?:http|https|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$';
43-
var url = new RegExp(urlRegex, 'i');
44-
return str.length < 2083 && url.test(str);
33+
$location.hash(link);
34+
$anchorScroll();
35+
4536
}
4637
$scope.docs = $translate.instant('DOCS');
4738
$scope.sysInfo = $translate.instant('SYSTEMINFORMATION');

ESSArch_TA/frontend/static/frontend/scripts/myApp.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,22 @@ angular.module('myApp', ['ngRoute', 'treeControl', 'ui.bootstrap', 'formly', 'fo
148148
$httpProvider.defaults.xsrfHeaderName = 'X-CSRFToken';
149149
}])
150150
.config(['markedProvider', function (markedProvider) {
151+
function isURL(str) {
152+
var urlRegex = '^(?!mailto:)(?:(?:http|https|ftp)://)(?:\\S+(?::\\S*)?@)?(?:(?:(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}(?:\\.(?:[0-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))|(?:(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)(?:\\.(?:[a-z\\u00a1-\\uffff0-9]+-?)*[a-z\\u00a1-\\uffff0-9]+)*(?:\\.(?:[a-z\\u00a1-\\uffff]{2,})))|localhost)(?::\\d{2,5})?(?:(/|\\?|#)[^\\s]*)?$';
153+
var url = new RegExp(urlRegex, 'i');
154+
return str.length < 2083 && url.test(str);
155+
}
151156
markedProvider.setOptions({
152157
gfm: true,
153158
tables: true,
154159
});
155160
markedProvider.setRenderer({
156-
link: function(href, title, text) {
157-
return "<a ng-click='scrollToLink(\"" + href + "\")'" + ">" + text + "</a>";
161+
link: function(href, title, text) {
162+
if(!isURL(href)) {
163+
return "<a ng-click='scrollToLink(\"" + href + "\")'" + ">" + text + "</a>";
164+
} else {
165+
return "<a href='" + href + "'" + (title ? " title='" + title + "'" : '') + " target='_blank'>" + text + "</a>";
166+
}
158167
}
159168
});
160169
}])

0 commit comments

Comments
 (0)