download_link #12

Merged
pstorch merged 2 commits from download_link into main 1 year ago
  1. 28
      index.html

28
index.html

@ -57,15 +57,19 @@
<button class="update-btn" id="button">Update Badge</button>
</div>
<h2>SVG:</h2>
<object id="svg-object" data="get-it-on-blue-on-white.svg" type="image/svg+xml"></object>
<h2>SVG: <a id="svglink">download</a></h2>
<object id="svg-object" data="get-it-on-blue-on-white.svg" type="image/svg+xml" onload="updateBadge();"></object>
<h2>PNG:</h2>
<h2>PNG: <a href="javascript:downloadPng();">download</a></h2>
<canvas id="canvas" width="564" height="168"></canvas>
<h2>Original Artwork from</h2>
<p><a href="https://codeberg.org/Codeberg/Design/wiki/Branding#user-content-logo">https://codeberg.org/Codeberg/Design/wiki/Branding#user-content-logo</a></p>
<p><a href="https://codeberg.org/Codeberg/Design/wiki/Branding#user-content-logo">https://codeberg.org/Codeberg/Design/wiki/Branding#user-content-logo</a></br>
© COPYRIGHT</br>
</br>
Logo material is licensed under CC-BY <a href="http://creativecommons.org/licenses/by/4.0/">http://creativecommons.org/licenses/by/4.0/</a></br>
Codeberg and the Codeberg Logo are trademarks of Codeberg e.V</br>
</p>
<script type="text/javascript">
var btn = document.querySelector('button');
@ -114,6 +118,10 @@
};
img.src = url;
var svgUrl = URL.createObjectURL(svgBlob);
//set url value to a element's href attribute.
document.getElementById("svglink").href = svgUrl;
}
btn.addEventListener('click', function () {
@ -131,5 +139,15 @@
const context = canvas.getContext('2d');
context.clearRect(0, 0, canvas.width, canvas.height);
})
function downloadPng() {
var img = canvas.toDataURL("image/png");
document.write('<img src="'+img+'"/>');
}
function downloadSvg() {
var svgDoc = svgObject.contentDocument;
var svgBadge = svgDoc.getElementById('svg-badge');
document.write(svgBadge);
}
</script>
</body>
Loading…
Cancel
Save