Commit 6b48e2eb authored by jonnybradley's avatar jonnybradley

[REF] files: Reformat disturbingly badly formatted JavaScript

parent 33e77ea8
Pipeline #50337913 failed with stages
in 29 minutes and 15 seconds
......@@ -188,60 +188,59 @@
sendData.data.append('image_max_size_x', image_max_size_x);
sendData.data.append('image_max_size_y', image_max_size_y);
sendData.data.append('ticket', ticket);
sendData.data.append('name',file.name);
var waiting=false;
//checking if image is uploaded to call resize function and resizing options are set by tracker field creator
if(file.type.substring(0,6) == 'image/' && (image_max_size_x!='' || image_max_size_y!='')) {
waiting=true;
sendData.data.append('name', file.name);
var waiting = false;
//checking if image is uploaded to call resize function and resizing options are set by tracker
// field creator
if (file.type.substring(0, 6) == 'image/' && (image_max_size_x || image_max_size_y)) {
waiting = true;
var imageData;
var picFile = e.target;
imageData = picFile.result;
var img = new Image();
var blobImage=null;
img.src=imageData;
img.onload = function(){
var width = parseInt(image_max_size_x);
var height = parseInt(image_max_size_y);
var image_x = parseInt(image_max_size_x);
var image_y = parseInt(image_max_size_y);
var ratio;
if (img.width > image_x || img.height > image_y) {
if (img.width > image_x) {
width = image_x;
ratio = image_x / img.width;
height = Math.round(img.height * ratio);
}
if (height >image_y) {
height =image_y;
ratio = image_y / img.height;
width = Math.round(img.width * ratio);
}
}
else
{
width=img.width;
height=img.height;
}
var canvas = $("<canvas/>").get(0);
canvas.width = width;
canvas.height = height;
var context = canvas.getContext('2d');
context.drawImage(img, 0, 0, width, height);
var resizedImage = restoreExif(imageData, canvas.toDataURL('image/jpeg'));
blobImage = dataURItoBlob(resizedImage);
sendData.data.append('data',blobImage,file.name);
$.ajax(sendData);
}
var picFile = e.target;
imageData = picFile.result;
var img = new Image();
var blobImage = null;
img.src = imageData;
img.onload = function () {
var width = parseInt(image_max_size_x);
var height = parseInt(image_max_size_y);
var image_x = parseInt(image_max_size_x);
var image_y = parseInt(image_max_size_y);
var ratio;
if (img.width > image_x || img.height > image_y) {
if (img.width > image_x) {
width = image_x;
ratio = image_x / img.width;
height = Math.round(img.height * ratio);
}
if (height > image_y) {
height = image_y;
ratio = image_y / img.height;
width = Math.round(img.width * ratio);
}
} else {
width = img.width;
height = img.height;
}
var canvas = $("<canvas/>").get(0);
canvas.width = width;
canvas.height = height;
var context = canvas.getContext('2d');
context.drawImage(img, 0, 0, width, height);
var resizedImage = restoreExif(imageData, canvas.toDataURL('image/jpeg'));
blobImage = dataURItoBlob(resizedImage);
sendData.data.append('data', blobImage, file.name);
$.ajax(sendData);
}
} else {
sendData.data.append('data', file);
}
else
sendData.data.append('data', file);
} else {
data = e.target.result;
sendData.data = {
......@@ -250,19 +249,21 @@
type: file.type,
data: data.substr(data.indexOf('base64') + 7),
galleryId: galleryId,
image_max_size_x:image_max_size_x,
image_max_size_y:image_max_size_y
image_max_size_x: image_max_size_x,
image_max_size_y: image_max_size_y
};
}
if (accept) {
valid = file.type.match(new RegExp( ".?(" + accept.replace('*', '.*') + ")$", "i"));
valid = file.type.match(new RegExp(".?(" + accept.replace('*', '.*') + ")$", "i"));
}
if (valid && !waiting) {
$.ajax(sendData);
} else if(!valid) {
sendData.error(null);
} else {
if (!valid) {
sendData.error(null);
}
}
};
reader.readAsDataURL(file);
......
Markdown is supported
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