Commit 1e63ab0f authored by Jan Dillenberger's avatar Jan Dillenberger

Fix bug: script loaded multiple times

parent 9ea7a82c
Pipeline #21894 failed with stage
in 142 minutes and 31 seconds
......@@ -22,7 +22,7 @@ class Evaluations extends ShortCodeController
wp_enqueue_style('evaluation_styles', GS_PLUGIN_DIR_URL . "/Public/css/Evaluations/style.css");
$visualizationName = $evaluation->getVisualization()['name'];
$this->templateRenderer->putVariable('EvaluationExists', true);
$this->templateRenderer->putVariable('chart_js', GS_PLUGIN_DIR_URL . "/Public/js/dist/visualizations/" . $visualizationName . ".js");
wp_enqueue_script($visualizationName . 'Script', GS_PLUGIN_DIR_URL . '/Public/js/dist/visualizations/' . $visualizationName . '.js', [], false, true);
$this->templateRenderer->putVariable('EvaluationID', $data["shortCodeAtts"]["visualize"]);
$this->templateRenderer->putVariable('VisualizationName', $visualizationName);
} else {
......
......@@ -101,6 +101,6 @@ let initializeBarChart = (htmlElement, response, params, groupName) => {
}
let filename = document.currentScript.src.split('/').reverse()[0]
let chartName = filename.substring(0, filename.length - 3)
let chartName = filename.replace(/\.js\??.*$/, '')
hookChart(chartName, initializeBarChart, {'hide_buttons': false})
......@@ -142,6 +142,6 @@ let drawNormalDistribution = (htmlElement, response, params, groupName) => {
}
let filename = document.currentScript.src.split('/').reverse()[0]
let chartName = filename.substring(0, filename.length - 3)
let chartName = filename.replace(/\.js\??.*$/, '')
hookChart(chartName, drawNormalDistribution, {'hide_buttons': true})
......@@ -27,5 +27,5 @@ let draw_traffic_light = (htmlElement, response, params, groupName) => {
let filename = document.currentScript.src.split('/').reverse()[0]
let chartName = filename.substring(0, filename.length - 3)
let chartName = filename.replace(/\.js\??.*$/, '')
hookChart(chartName, draw_traffic_light, {'hide_buttons': true})
{% extends '@general/page_base.twig' %}
{% block content %}
{% if EvaluationExists %}
<div class="{{ VisualizationName }}" evaluation_id="{{ EvaluationID }}"></div>
<div class="{{ VisualizationName }}_text_box"></div>
<script src="{{ chart_js }}" charset="utf-8"></script>
{% else %}
The requested Evaluation does not exist. Please inform the Administrator.
{% endif %}
......
<!-- D3.js -->
<script src="https://d3js.org/d3.v5.min.js" charset="utf-8"></script>
{% block content %}{% endblock %}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment