diff --git a/www/assets/css/main.css b/www/assets/css/main.css
index a8460e1..7cfd184 100644
--- a/www/assets/css/main.css
+++ b/www/assets/css/main.css
@@ -242,3 +242,72 @@ img, video {
background-color: rgba(255, 255, 255, .95);
}
+/**
+ * Generate links to be copied to anchor targets:
+ *
+ * First, make the target stand out to the left a bit, so that hovering gets activated more easily
+ */
+H1[id],
+H2[id],
+H3[id],
+H4[id],
+H5[id],
+H6[id],
+[id] > H1,
+[id] > H2,
+[id] > H3,
+[id] > H4,
+[id] > H5,
+[id] > H6,
+[id].copy-link,
+[id].copy-link-child > :first-child {
+ z-index: 99;
+ margin-left: -1em;
+ padding-left: 1em;
+ position: relative;
+}
+
+/* Then, on hovering, make it go even further to the left, so there is room for the link icon */
+H1[id]:hover,
+H2[id]:hover,
+H3[id]:hover,
+H4[id]:hover,
+H5[id]:hover,
+H6[id]:hover,
+[id] > H1:hover,
+[id] > H2:hover,
+[id] > H3:hover,
+[id] > H4:hover,
+[id] > H5:hover,
+[id] > H6:hover,
+[id].copy-link:hover,
+[id].copy-link-child > :first-child:hover {
+ z-index: 99;
+ margin-left: -2em;
+ padding-left: 0.3em;
+ position: relative;
+}
+
+/* And last, make the link icon appear to the left. */
+H1[id]:hover::before,
+H2[id]:hover::before,
+H3[id]:hover::before,
+H4[id]:hover::before,
+H5[id]:hover::before,
+H6[id]:hover::before,
+[id] > H1:hover::before,
+[id] > H2:hover::before,
+[id] > H3:hover::before,
+[id] > H4:hover::before,
+[id] > H5:hover::before,
+[id] > H6:hover::before,
+[id].copy-link:hover::before,
+[id].copy-link-child > :first-child:hover::before {
+ content: '\01f517 \a0';
+ cursor: pointer;
+}
+
+/* Make the text in the toast align to the left, as it looks more smoothly. */
+.toast > li {
+ text-align: right;
+}
diff --git a/www/assets/js/main.js b/www/assets/js/main.js
index 906810a..8332e9c 100644
--- a/www/assets/js/main.js
+++ b/www/assets/js/main.js
@@ -62,4 +62,141 @@ $(async => {
}
})();
};
+
+ /**
+ * Function to copy a text to the clipboard
+ **/
+ function copyTextToClipboard(text) {
+ const textarea = document.createElement('textarea');
+ const selection = document.getSelection();
+ const range = document.createRange();
+
+ textarea.textContent = text;
+ document.body.appendChild(textarea);
+
+ range.selectNode(textarea);
+ selection.removeAllRanges();
+ selection.addRange(range);
+
+ const result = document.execCommand('copy');
+
+ document.body.removeChild(textarea);
+
+ return result;
+ }
+
+ /**
+ * Function to dynamically load CSS with a single request.
+ *
+ * @see: https://stackoverflow.com/a/46984311/3102305
+ */
+ $.extend({
+ getCss: function (url, success) {
+
+ if ($("head").children("style[data-url='" + url + "']").length) {
+ console.warn("CSS file already loaded: " + url);
+ }
+
+ var deferred = $.Deferred(function (defer) {
+ $.ajax({
+ url: url
+ , context: {defer: defer, url: url}
+ , dataType: 'text'
+ , cache: (function () {
+ let cache = $.ajaxSetup().cache;
+ if (cache === undefined) {
+ cache = false;
+ }
+ return cache;
+ })()
+ })
+ .then(
+ function (css, textStatus, jqXHR) {
+ css = "\n\n/* CSS dynamically loaded by jQuery */\n\n" + css;
+ $('').appendTo("head");
+ this.defer.resolve(css, textStatus, jqXHR);
+ }
+ , function (jqXHR, textStatus, errorThrown) {
+ this.defer.reject(jqXHR, textStatus, errorThrown);
+ }
+ );
+ });
+ if ($.isFunction(success)) {
+ deferred.done(success);
+ }
+ return deferred;
+ }
+ });
+
+ /**
+ * Append event listener to the elements that shall get the icon to copy the anchored link
+ */
+ document.querySelectorAll(
+ 'h1[id], h2[id], h3[id], h4[id], h5[id], h6[id], ' +
+ '[id]>h1, [id]>h2, [id]>h3, [id]>h4, [id]>h5, [id]>h6, ' +
+ '[id].copy-link-child > :first-child'
+ ).forEach(function (element) {
+ element.addEventListener("click", function (event) {
+
+ const id = event.target.id !== ''
+ ? event.target.id
+ : event.target.parentElement.id
+
+ const page = window.location.href
+ .replace(/#.*$/, '');
+
+ const link = page + '#' + id;
+ const nilesoft = link
+ .replace(/^https?:\/\/[^/]+/, 'https://nilesoft.org');
+
+ const emAsPx = parseFloat(getComputedStyle(event.target).fontSize);
+ const em2 = 2 * emAsPx
+
+ const hitLinkIcon = event.layerX < em2;
+
+ /*console.log({
+ emAsPx: emAsPx,
+ em2: em2,
+ layerX: event.layerX,
+ clientX: event.clientX,
+ doCopy: hitLinkIcon,
+ link: link,
+ offsetLeft: event.target.offsetLeft,
+ parentOffsetLeft: event.target.parentElement.offsetLeft,
+ parentClass: event.target.parentElement.className,
+ event: event
+ })*/
+
+ if (hitLinkIcon) {
+ const result = copyTextToClipboard(nilesoft);
+ if (result) {
+ console.log('copied: ' + nilesoft);
+
+ const toast = function () {
+ $.toast.config.align = 'right';
+ $.toast('' + nilesoft + '
copied to clipboard!', {
+ type: 'info',
+ duration: 3000,
+ });
+ }
+
+ if ($.toast === undefined) {
+ console.log('loading jquery.toast ...')
+ // @see: https://github.com/Soldier-B/jquery.toast
+ $.getCss(
+ "/assets/lib/jquery.toast/jquery.toast.min.css",
+ $.getScript(
+ "/assets/lib/jquery.toast/jquery.toast.min.js"
+ , toast
+ )
+ );
+ } else {
+ toast();
+ }
+
+ window.location.href = link;
+ }
+ }
+ });
+ });
});
\ No newline at end of file
diff --git a/www/assets/lib/jquery.toast/jquery.toast.css b/www/assets/lib/jquery.toast/jquery.toast.css
new file mode 100644
index 0000000..646819d
--- /dev/null
+++ b/www/assets/lib/jquery.toast/jquery.toast.css
@@ -0,0 +1,8 @@
+.toast{ position:fixed; list-style: none; padding: 0; top:0; z-index: 999999; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size:14px; line-height:20px; }
+.toast li{ margin: 10px 0 0 0; display:block; background-color:#fcf8e3; color:#c09853; border:1px solid #fbeed5; padding:5px 10px; border-radius: 4px; -webkit-border-radius: 4px; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); box-shadow: 0 2px 5px rgba(0,0,0,.15); -webkit-box-shadow: 0 2px 5px rgba(0,0,0,.15); }
+.toast li:first-child{ margin-top:0; }
+.toast li.danger{ color: #b94a48; background-color: #f2dede; border-color: #eed3d7; }
+.toast li.info{ color: #3a87ad; background-color: #d9edf7; border-color: #bce8f1; }
+.toast li.success{ color: #468847; background-color: #dff0d8; border-color: #d6e9c6; }
+.toast button.close{ background: none; border: none; font-weight: bold; font-size: 20px; line-height: 20px; float: right; padding: 0; margin: 0 0 0 5px; color: rgba(0,0,0,.25); cursor: pointer; }
+.toast h1, .toast h2, .toast h3, .toast h4 { display: inline; }
\ No newline at end of file
diff --git a/www/assets/lib/jquery.toast/jquery.toast.js b/www/assets/lib/jquery.toast/jquery.toast.js
new file mode 100644
index 0000000..2b4cba5
--- /dev/null
+++ b/www/assets/lib/jquery.toast/jquery.toast.js
@@ -0,0 +1,41 @@
+(function($){
+ var th = null, cf = null, toast = function(m,o){
+ // fix option type
+ o = $.extend({ duration: 5000, sticky: false, 'type': ''}, o);
+ typeof o.duration === 'number' || (o.duration = 5000);
+ typeof o.sticky === 'boolean' || (o.sticky = false);
+ typeof o.type === 'string' || (o.type = '');
+ // create host on first call
+ if(!th){
+ // get/fix config
+ cf = toast.config;
+ th = $('