Created
July 23, 2021 18:32
-
-
Save jcroot/6c861463c244eec56a9fc71e73f946f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#capture').on('click', function () { | |
if (confirm("Esta seguro de guardar este Cartel?")){ | |
$(this).prop("disabled", true); | |
let message = $(this).html(); | |
$(this).html('<i class="fa fa-spinner fa-spin" aria-hidden="true"></i> Generando...'); | |
html2canvas(document.querySelector('#content-capture')).then(function (canvas) { | |
let url = "/curate/21/capture"; | |
let name = "228d1aa8f67997062dfa831f4c6f8a59553cd700aced02f5244e6ff4b176b62b"; | |
postCanvas(url, name, canvas, $('#capture'), message); | |
}); | |
} | |
}); | |
function postCanvas(url, name, canvas, object, message) { | |
var dataURL = canvas.toDataURL('image/png', 0.9); | |
var imgData = dataURL.replace(/^data:image\/(png|jpg);base64,/, ""); | |
$.ajaxSetup({ | |
headers: { | |
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') | |
} | |
}); | |
$.ajax({ | |
url: url, | |
type: 'POST', | |
data: { | |
customFile: imgData | |
}, | |
dataType: 'json', | |
}).done(function (data) { | |
object.prop("disabled", false); | |
object.html(message); | |
checkMedia(); | |
alert(data.message); | |
}).fail(function () { | |
alert('Error'); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment