changed meme publish to use custom claim

This commit is contained in:
bill bittner 2017-06-21 07:43:45 -07:00
parent 2a2dff47e0
commit 9e793467b3
3 changed files with 14 additions and 18 deletions

View file

@ -6,7 +6,7 @@ var fontSize = 28;
var topText = document.getElementById('top-text');
var bottomText = document.getElementById('bottom-text');
var ctx = canvas.getContext('2d');
var fileNameInput = document.getElementById("file-name-input");
var claimNameInput = document.getElementById("file-name-input");
// create the canvas
img.onload = function() {
@ -104,13 +104,16 @@ function dataURItoBlob(dataURI) {
return new Blob([ia], {type:mimeString});
}
var claimName;
// save the meme
function startPublish() {
//download the image
var dataUrl = canvas.toDataURL('image/jpeg');
var blob = dataURItoBlob(dataUrl)
var filename = fileNameInput.value;
var file = new File([blob], filename, {type: 'image/jpeg', lastModified: Date.now()});
claimName = claimNameInput.value;
var fileName = claimNameInput.value + ".jpg";
var file = new File([blob], fileName, {type: 'image/jpeg', lastModified: Date.now()});
console.log(file);
publishMeme(file); // note: this function is in memePublish.js
stageAndPublish(file); // note: this function is in memePublish.js
};

View file

@ -3,7 +3,6 @@
var socket = io();
var uploader = new SocketIOFileUpload(socket);
var stagedFiles = null;
var name = 'meme-fodder-entry';
var license = 'Creative Commons';
var nsfw = false;
@ -27,20 +26,14 @@ function createProgressBar(element, size){
setInterval(addOne, 300);
}
function publishMeme(file) {
// get image data
//var imgData = ctx.getImageData(0, 0, canvasWidth, canvasHeight);
//console.log(imgData);
function stageAndPublish(file) {
// stage files
stagedFiles = [file]; // stores the selected file for upload
//stagedFiles = [selectedFile.getAsFile()]; // stores the selected file for upload
console.log(stagedFiles[0]);
console.log('file staged');
stagedFiles = [file]; // stores the selected file for
// make sure a file was selected
if (stagedFiles) {
// make sure only 1 file was selected
if (stagedFiles.length > 1) {
alert("Only one file allowed at a time");
if (stagedFiles.length < 1) {
alert("A file is needed");
return;
}
// make sure the content type is acceptable
@ -66,7 +59,7 @@ function updatePublishStatus(msg){
/* socketio-file-upload listeners */
uploader.addEventListener('start', function(event){
event.file.meta.name = name;
event.file.meta.name = claimName;
event.file.meta.license = license;
event.file.meta.nsfw = nsfw;
event.file.meta.type = stagedFiles[0].type;

View file

@ -33,8 +33,8 @@
</div>
<div class="row">
<div class="col-md-12">
<label for="meme-name">File Name:</label>
<input id="file-name-input" type="text" value="YourFileName.jpg" />
<label for="meme-name">Claim Name:</label>
<input id="file-name-input" type="text" value="My-Claim-Name" />
</div>
</div>
<div class="row">