all repos — artbound-python @ 28ba21f6c7910ba167040c393f92b6166b3b9ee3

A client-server reimplementation of the administration panel for ArtBound.

add saveAll()
BiRabittoh birabittoh@tilde.team
Fri, 04 Aug 2023 22:05:42 +0200
commit

28ba21f6c7910ba167040c393f92b6166b3b9ee3

parent

46af02e02321e5eeae46e8af264d3098299ade87

2 files changed, 20 insertions(+), 8 deletions(-)

jump to
M artbound_python/static/script.jsartbound_python/static/script.js

@@ -77,7 +77,7 @@ button4.innerText = "💾";

button1.addEventListener("click", function() { moveUpDown(element.id, -1); }, false); button2.addEventListener("click", function() { toggleEntry(element.id); }, false); button3.addEventListener("click", function() { reloadEntry(element.id); }, false); - button4.addEventListener("click", function() { saveCanvas(element.id); }, false); + button4.addEventListener("click", function() { saveEntry(element.id); }, false); button5.addEventListener("click", function() { moveUpDown(element.id, 1); }, false); div4.appendChild(button1);

@@ -141,14 +141,16 @@ entry.enabled = !entry.enabled;

updateFanartList() } -function saveCanvas(id) { +function saveCanvas(canvas) { + canvas_link.href = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"); + canvas_link.setAttribute("download", canvas.getAttribute("data-filename")); + canvas_link.click() +} + +function saveEntry(id) { entry = getFanart(id); if (!entry) return; - - const image = entry.canvas.toDataURL("image/png").replace("image/png", "image/octet-stream"); - canvas_link.href = image; - canvas_link.setAttribute("download", entry.canvas.getAttribute("data-filename")); - canvas_link.click() + saveCanvas(entry.canvas) } function reloadEntry(id){

@@ -242,4 +244,13 @@ updateFanartList();

}); } - +function saveAll() { + const response = confirm("Vuoi davvero scaricare tutte le fanart?"); + if(response == false) return; + + fanarts.forEach((fanart) => { + if(fanart.enabled) { + saveCanvas(fanart.canvas) + } + }) +}
M artbound_python/templates/index.htmlartbound_python/templates/index.html

@@ -41,6 +41,7 @@ <a href="#" class="btn btn-secondary my-2" onclick="toggleColor()" id="togglecolor_button">⚪</a>

<input type="range" class="form-range" id="opacity_range" min="0" max="1" step="0.01" oninput="updateOpacity()" value="0.4"> <label for="opacity_range" class="form-label" id="opacity_label"></label> + <a href="#" class="btn btn-secondary my-2" onclick="saveAll()" id="saveall_button">💾</a> </div> </div> </section>