forked from ScoDoc/ScoDoc
Fix JS access to css
This commit is contained in:
parent
59a25c4cc3
commit
d5a6ba7448
@ -1,27 +1,4 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
function removeLastTwoComponents(path) {
|
|
||||||
// Split the path into individual components
|
|
||||||
var components = path.split('/');
|
|
||||||
|
|
||||||
// Remove the last two components (filename and enclosing directory)
|
|
||||||
components.splice(-2);
|
|
||||||
|
|
||||||
// Join the remaining components back into a path
|
|
||||||
var newPath = components.join('/');
|
|
||||||
|
|
||||||
return newPath;
|
|
||||||
}
|
|
||||||
class ref_competences extends HTMLElement {
|
class ref_competences extends HTMLElement {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
@ -15,8 +15,8 @@ class releveBUT extends HTMLElement {
|
|||||||
/* Style du module */
|
/* Style du module */
|
||||||
const styles = document.createElement('link');
|
const styles = document.createElement('link');
|
||||||
styles.setAttribute('rel', 'stylesheet');
|
styles.setAttribute('rel', 'stylesheet');
|
||||||
if (location.href.split("/")[3] == "ScoDoc") {
|
if (location.href.includes("ScoDoc")) {
|
||||||
styles.setAttribute('href', '/ScoDoc/static/css/releve-but.css'); // Scodoc
|
styles.setAttribute('href', removeLastTwoComponents(getCurrentScriptPath()) + '/css/releve-but.css'); // Scodoc
|
||||||
} else {
|
} else {
|
||||||
styles.setAttribute('href', '/assets/styles/releve-but.css'); // Passerelle
|
styles.setAttribute('href', '/assets/styles/releve-but.css'); // Passerelle
|
||||||
}
|
}
|
||||||
|
@ -256,3 +256,27 @@ class ScoFieldEditor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
function removeLastTwoComponents(path) {
|
||||||
|
// Split the path into individual components
|
||||||
|
var components = path.split('/');
|
||||||
|
|
||||||
|
// Remove the last two components (filename and enclosing directory)
|
||||||
|
components.splice(-2);
|
||||||
|
|
||||||
|
// Join the remaining components back into a path
|
||||||
|
var newPath = components.join('/');
|
||||||
|
|
||||||
|
return newPath;
|
||||||
|
}
|
||||||
|
@ -10,10 +10,16 @@
|
|||||||
{% include 'bul_head.j2' %}
|
{% include 'bul_head.j2' %}
|
||||||
|
|
||||||
<releve-but></releve-but>
|
<releve-but></releve-but>
|
||||||
<script src="{{scu.STATIC_DIR}}/js/releve-but.js"></script>
|
|
||||||
|
|
||||||
{% include 'bul_foot.j2' %}
|
{% include 'bul_foot.j2' %}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block scripts %}
|
||||||
|
{{super()}}
|
||||||
|
|
||||||
|
<script src="{{scu.STATIC_DIR}}/js/releve-but.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let dataSrc = "{{bul_url|safe}}";
|
let dataSrc = "{{bul_url|safe}}";
|
||||||
fetch(dataSrc)
|
fetch(dataSrc)
|
||||||
@ -46,4 +52,5 @@
|
|||||||
// });
|
// });
|
||||||
document.querySelector("html").style.scrollBehavior = "smooth";
|
document.querySelector("html").style.scrollBehavior = "smooth";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -19,8 +19,6 @@
|
|||||||
<ref-competences></ref-competences>
|
<ref-competences></ref-competences>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="{{scu.STATIC_DIR}}/js/ref_competences.js"></script>
|
|
||||||
|
|
||||||
{% include "but/refcomp_parcours_niveaux.j2" %}
|
{% include "but/refcomp_parcours_niveaux.j2" %}
|
||||||
|
|
||||||
|
|
||||||
@ -49,6 +47,8 @@
|
|||||||
{% block scripts %}
|
{% block scripts %}
|
||||||
{{super()}}
|
{{super()}}
|
||||||
|
|
||||||
|
<script src="{{scu.STATIC_DIR}}/js/ref_competences.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
$(function () {
|
$(function () {
|
||||||
let data_url = "{{data_source}}";
|
let data_url = "{{data_source}}";
|
||||||
|
Loading…
Reference in New Issue
Block a user