diff --git a/src/index.html b/src/index.html index 1ab132c64d8aa55dfdfccbf9e055602e52872afb_c3JjL2luZGV4Lmh0bWw=..feb04ebd0174ca125b0293b80413c5356408ec5e_c3JjL2luZGV4Lmh0bWw= 100644 --- a/src/index.html +++ b/src/index.html @@ -92,6 +92,7 @@ </div> </div> <div class="row justify-content-center"> + <button class="btn btn-primary" id="csv-export-button" disabled>Télécharger en CSV</button> <div class="col-md-11"> <div id="yasr"></div> </div> @@ -316,9 +317,15 @@ .replace(/>/g, ">") ); yasqe.setValue(queryString); + if(queryString.length === 0) { + $("#csv-export-button").prop("disabled", true); + } else { + $("#csv-export-button").prop("disabled", false); + } + yasqe.query(); }, }); }); var yasqe = YASQE.fromTextArea(document.getElementById("yasqe"), { @@ -319,9 +326,10 @@ yasqe.query(); }, }); }); var yasqe = YASQE.fromTextArea(document.getElementById("yasqe"), { + persistencyExpire: 0, sparql: { showQueryButton: true, endpoint: $("#endpoint").text(), @@ -339,6 +347,15 @@ // link yasqe and yasr yasqe.options.sparql.callbacks.complete = yasr.setResponse; + + + document.getElementById("csv-export-button").onclick = () => { + const query = yasqe.getValue().replace("LIMIT 5000", ""); + const endpoint = $("#endpoint").text(); + const url = endpoint + "?query=" + encodeURIComponent(query) + "&format=text/csv"; + var win = window.open(url, '_blank'); + win.focus(); + }; </script> </body> </html>