Set path for cookies and change window access from iframe,
so access from tutorials don't become a cross-origin access
Change-Id: I49b9c401b3de20cb2ba7fb8c6fc5649d6b105891
diff --git a/Changes b/Changes
index 4dc1198..7bf542e 100644
--- a/Changes
+++ b/Changes
@@ -22,6 +22,7 @@
- Keep plugin state in statemanager (fixes #201; diewald)
- Fix alerts in hint helper (diewald)
- Don't send empty pipes and states via query param (diewald)
+ - Fix access of iframe location in tutorials. (diewald)
0.58 2024-11-15
- Cookie path is settable now (hebasta)
diff --git a/dev/js/src/init.js b/dev/js/src/init.js
index 1796c6a..7f6dce6 100644
--- a/dev/js/src/init.js
+++ b/dev/js/src/init.js
@@ -82,10 +82,13 @@
// Set base URL
KorAP.URL = d.body.getAttribute('data-korap-url') || "";
-
+
+
+
// Create suffix if KorAP is run in a subfolder
KorAP.session = sessionClass.create(
- KorAP.URL.length > 0 ? 'kalamarJS-' + KorAP.URL.slugify() : 'kalamarJS'
+ (KorAP.URL.length > 0 ? 'kalamarJS-' + KorAP.URL.slugify() : 'kalamarJS'),
+ KorAP.URL
);
// Get koralQuery response
diff --git a/dev/js/src/tutorial.js b/dev/js/src/tutorial.js
index ae42bad..9fe132d 100644
--- a/dev/js/src/tutorial.js
+++ b/dev/js/src/tutorial.js
@@ -197,23 +197,22 @@
let page = obj;
if (typeof page != 'string') {
- const l = this._iframe !== null ? window.frames[0].location : window.location;
+ const l = this._iframe !== null ? this._iframe.contentWindow.location : window.location;
- page = l.pathname + l.search;
+ page = l.pathname + l.search;
- for (let i = 1; i < 5; i++) {
- if ((obj.nodeName === 'SECTION' || obj.nodeName === 'PRE') && obj.hasAttribute('id')) {
- page += '#' + obj.getAttribute('id');
- break;
- }
- else {
- obj = obj.parentNode;
+ for (let i = 1; i < 5; i++) {
+ if ((obj.nodeName === 'SECTION' || obj.nodeName === 'PRE') && obj.hasAttribute('id')) {
+ page += '#' + obj.getAttribute('id');
+ break;
+ }
+ else {
+ obj = obj.parentNode;
if (obj === null)
break;
- };
- };
+ };
+ };
};
-
this._session.set('tutpage', page);
},