-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
83 lines (71 loc) · 3.22 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
$(document).ready(function() {
// Sets Cloudinary config
$.cloudinary.config({ cloud_name: 'majincloud', secure: false});
let transformationButton = document.getElementById('transformationButton');
var uploadButton = document.getElementById('uploadImageButton');
//Upload for file upload
if($.fn.cloudinary_fileupload !== undefined) {
$("input.cloudinary-fileupload[type=file]").cloudinary_fileupload();
}
// Delete button onclick();
document.getElementById('deleteImageButton').onclick = function(){
$.cloudinary.delete_by_token(deleteToken);
}
// Begin task 1 code
// uploadButton.onclick = function(){
// let urlvar = document.getElementById('urlInput').value;
// let secondParam = {type: "fetch", transformation: [
// {gravity: "face", height: 300, width: 300, crop: "fill"},
// {radius: "max"},
// {fetch_format: "auto"}
// ]}
// //start cloudinary fetch code
// $.cloudinary.image(urlvar, secondParam);
// let imagePreview = $.cloudinary.imageTag(urlvar, secondParam).toHtml();
// //end cloudinary fetch code
// //renders the uploaded image with effects
// $('.uploadedImage').empty().append(imagePreview);
// }
// End task 1 code
//Prevents redirection when hitting enter in input field
$("#overLayText").keydown(function(event) {
if (event.keyCode == 13) {
event.preventDefault();
}
});
//Applies all selected transformations
transformationButton.onclick = function(){
// let secondParam = {type: "fetch", transformation: [
// {gravity: "face", height: 300, width: 300, crop: "fill"},
// {radius: "max"},
// {fetch_format: "auto"}
// ]}
// Check for any transformation checkmarks before submitting
var checkBoxArray = []
var checkBoxes = document.querySelectorAll('input[type=checkbox]:checked')
for (var i = 0; i < checkBoxes.length; i++) {
checkBoxArray.push("e_" + checkBoxes[i].value+"/");
}
console.log(checkBoxArray);
let inputText = document.getElementById('overLayText').value;
if( inputText ){
let finalInputText = "l_text:Arial_200:" + inputText;
let transformURL = document.getElementById('widgetURL');
let urlToChange = transformURL.getAttribute('src');
let finalUrlOutput = urlToChange.replace("/upload/", "/upload/" + checkBoxArray.join(",") +finalInputText+"/" + "c_crop/g_custom/");
transformURL.setAttribute('src', finalUrlOutput);
// secondParam.transformation.push({overlay: new cloudinary.TextLayer().fontFamily("Arial").fontSize(24).fontWeight("bold").text(inputText)});
}
let urlvar = document.getElementById('urlInput').value;
//start cloudinary fetch code
// $.cloudinary.image(urlvar, secondParam);
// let imagePreview = $.cloudinary.imageTag(urlvar, secondParam).toHtml();
//end cloudinary fetch code
//renders the uploaded image with effects
// console.log(imagePreview);
// $('.uploadedImage').empty().append(imagePreview);
}
});
//
//https://en.wikipedia.org/wiki/Cat#/media/File:Cat_poster_1.jpg
//https://images.unsplash.com/photo-1506755855567-92ff770e8d00?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=3456&q=80