all repos — artbound-go @ 741e68dd3f1c6ff8a04de9ace874dfd986d57e19

The official administration panel for ArtBound, by EarthBound Café.

fix filename when saving
BiRabittoh andronacomarco@gmail.com
Sun, 03 Mar 2024 13:01:47 +0100
commit

741e68dd3f1c6ff8a04de9ace874dfd986d57e19

parent

90a9728820c8f5aa00e6e1243de7fce39e2e9558

2 files changed, 5 insertions(+), 5 deletions(-)

jump to
M static/script.jsstatic/script.js

@@ -68,8 +68,9 @@ index = element.index,

name = element.name, content = element.content, text = `${element.name} → “${element.filename}”`, - disabled = element.enabled == 0 ? " entry-disabled" : ""; - const html_string = Mustache.render("{{={| |}=}}" + fanart_template, { id, index, name, content, text, disabled }); + disabled = element.enabled == 0 ? " entry-disabled" : "", + save_filename = `${('0' + index).slice(-2)} - ${name}.png`; + const html_string = Mustache.render("{{={| |}=}}" + fanart_template, { id, index, name, content, text, disabled, save_filename }); element.div = createElementFromHTML(html_string); element.canvas = element.div.getElementsByTagName("canvas")[0]; const ctx = element.canvas.getContext("2d");

@@ -307,6 +308,5 @@ }

function toClipBoard(id) { const fanart = getFanart(id); - const clipboard_filename = `${('0' + fanart.index).slice(-2)} - ${fanart.name}.png`; - navigator.clipboard.writeText(clipboard_filename); + navigator.clipboard.writeText(fanart.canvas.getAttribute("data-filename")); }
M templates/index.htmltemplates/index.html

@@ -81,7 +81,7 @@ <template id="fanart-template">

<div class="col-lg-4 entry{| disabled |}" id="{| id |}" data-index="{| index |}"> <div class="card mb-4 box-shadow my-card"> <canvas class="card-img-top entry-img" id="{| id |}" data-name="{| name |}" data-content="{| content |}" - data-text="{| text |}"></canvas> + data-text="{| text |}" data-filename="{| save_filename |}"></canvas> <div class="card-body"> <a class="card-text" title="Clicca per copiare." onclick="toClipBoard('{| id |}');">{| text |}</a> <div class="d-flex justify-content-between align-items-center card-controls">