Skip to content
Snippets Groups Projects

F fix linkify preview

Merged Florian Spreckelsen requested to merge f-fix-linkify-preview into dev
All threads resolved!
2 files
+ 13
15
Compare changes
  • Side-by-side
  • Inline
Files
2
/*
* This file is a part of the CaosDB Project.
*
* Copyright (C) 2021 IndiScale GmbH <info@indiscale.com>
* Copyright (C) 2021-2023 IndiScale GmbH <info@indiscale.com>
* Copyright (C) 2021 Timm Fitschen <t.fitschen@indiscale.com>
* Copyright (C) 2023 Florian Spreckelsen <f.spreckelsen@indiscale.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -37,7 +38,7 @@ var cosmetics = new function () {
var _linkify = function () {
$('.caosdb-f-property-text-value').each(function (index) {
if (/https?:\/\//.test(this.innerText)) {
if (!($(this).hasClass("caosdb-v-property-linkified")) && (/https?:\/\//.test(this.innerText))) {
var result = this.innerText.replace(/https?:\/\/[^\s]*/g, function (href, index) {
var link_text = href;
if (_link_cut_off_length > 4 && link_text.length > _link_cut_off_length) {
@@ -47,6 +48,9 @@ var cosmetics = new function () {
return `<a title="Open ${href} in a new tab." target="_blank" class="caosdb-v-property-href-value" href="${href}">${link_text} <i class="bi bi-box-arrow-up-right"></i></a>`;
});
// add class to highlight that this has been linkified already
// (see https://gitlab.com/caosdb/caosdb-webui/-/issues/199).
$(this).addClass("caosdb-v-property-linkified")
$(this).hide();
$(this).after(result);
}
@@ -80,4 +84,4 @@ var cosmetics = new function () {
$(document).ready(function () {
caosdb_modules.register(cosmetics);
});
\ No newline at end of file
});
Loading