From 9b73819d3b8f1ea068db53f529114c62cc59ae85 Mon Sep 17 00:00:00 2001 From: Emmanuel Viennet Date: Thu, 11 May 2023 18:05:11 +0200 Subject: [PATCH] change link to ref-competences.css --- app/static/js/ref_competences.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/static/js/ref_competences.js b/app/static/js/ref_competences.js index 4850acd4..cf81acd4 100644 --- a/app/static/js/ref_competences.js +++ b/app/static/js/ref_competences.js @@ -1,3 +1,16 @@ +function getCurrentScriptPath() { + // Get all the script elements on the page + var scripts = document.getElementsByTagName('script'); + + // Find the last script element (which is the currently executing script) + var currentScript = scripts[scripts.length - 1]; + + // Retrieve the src attribute of the script element + var scriptPath = currentScript.src; + + return scriptPath; +} + class ref_competences extends HTMLElement { constructor() { super(); @@ -14,11 +27,7 @@ class ref_competences extends HTMLElement { /* Style du module */ const styles = document.createElement('link'); styles.setAttribute('rel', 'stylesheet'); - // if (location.href.split("/")[3] == "ScoDoc") { - styles.setAttribute('href', '/ScoDoc/static/css/ref-competences.css'); - // } else { - // styles.setAttribute('href', 'ref-competences.css'); - // } + styles.setAttribute('href', getCurrentScriptPath() + '../css/ref-competences.css'); this.shadow.appendChild(styles); }