Commit 476cb955 authored by Luc Didry's avatar Luc Didry
Browse files

Fix #10

parent 37a10fcd
Pipeline #24006 passed with stage
in 18 seconds
.container {
.container,
#filename {
text-align:center;
}
#wemake {
......
......@@ -76,6 +76,10 @@
<input id="porn-size" type="number" min="1" value="220">
</div>
</div>
<div>
<label for="filename">First line</label>
<input id="filename" placeholder="WE_MAKE_PORN.png" type="text" value="WE_MAKE_PORN.png" class="u-full-width">
</div>
</div>
<div>
<a class="button" href="#" id="download">Download</a>
......
......@@ -29,9 +29,11 @@ var domIsReady = (function(domIsReady) {
document.querySelectorAll('input[type="text"]').forEach(function(e) {
e.addEventListener('keyup', function() {
refreshText();
refreshFilename();
});
e.addEventListener('paste', function() {
refreshText();
refreshFilename();
});
});
document.querySelectorAll('input[type="radio"]').forEach(function(e) {
......@@ -45,7 +47,8 @@ var domIsReady = (function(domIsReady) {
});
});
document.querySelector('#download').addEventListener('click', function() {
this.download = 'WeMake.png';
var f = document.getElementById('filename');
this.download = f.value;
this.href = document.getElementById('canvas').toDataURL().replace("image/png", "image/octet-stream");
});
document.querySelector('#reset').addEventListener('click', function() {
......@@ -102,7 +105,11 @@ var domIsReady = (function(domIsReady) {
if (url.searchParams.get('rc') !== null) {
document.getElementById('rect-color').value = url.searchParams.get('rc');
}
if (url.searchParams.get('f') !== null) {
document.getElementById('filename').value = url.searchParams.get('f');
}
refreshFilename();
refreshText();
});
})(document, window, domIsReady);
......@@ -132,6 +139,15 @@ function reset() {
refreshText();
}
function refreshFilename() {
var w = document.getElementById('wemake');
var p = document.getElementById('porn');
var f = document.getElementById('filename');
var name = w.value+' '+p.value+'.png';
f.value = name.replace(/ /g, '_');
}
function refreshText() {
var w = document.getElementById('wemake');
var wx = document.getElementById('wemake-x');
......
Supports Markdown
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