From 7f00c31d028bc409192bc7d32522d65e64e41deb Mon Sep 17 00:00:00 2001 From: Jaifroid Date: Tue, 2 Apr 2019 12:00:25 +0100 Subject: [PATCH] Provide treePath instead (simpler) Former-commit-id: 633cb3951a69a15a03dcd6aef8c7a5693c6d2d2a [formerly df971366868f296201727f825b63466e31e7ad3b] Former-commit-id: ac8471635bc8c7a68a15e4ede13787a328c3c9e5 --- www/js/lib/uiUtil.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/www/js/lib/uiUtil.js b/www/js/lib/uiUtil.js index e45d4348..bda958a8 100644 --- a/www/js/lib/uiUtil.js +++ b/www/js/lib/uiUtil.js @@ -344,12 +344,14 @@ define(['util'], function(util) { function insertBreakoutLink() { var desc = "Open article in new tab or window"; var iframe = document.getElementById('articleContent').contentDocument; - // Remove the file and any query string from href - var prefix = window.location.href.replace(/^((?!.*\?).*\/|.*\/(?=[^\/]*\?)).*$/, '$1'); + // This code provides an absolute link - keep for reference. Removes the file and any query string from href + // var prefix = window.location.href.replace(/^((?!.*\?).*\/|.*\/(?=[^\/]*\?)).*$/, '$1'); + // But in Kiwix JS Windows, we can easily get the relative path of the current document: + var treePath = decodeURIComponent(params.lastPageVisit).replace(/[^/]+\/(?:[^/]+$)?/g, "../"); var div = document.createElement('div'); div.style.cssText = 'top: 10px; right: 25px; position: relative; z-index: 2; float: right;'; div.id = "openInTab"; - div.innerHTML = ''
+        div.innerHTML = '<a href='
              + desc + ''; iframe.body.insertBefore(div, iframe.body.firstChild); var openInTab = iframe.getElementById('openInTab');