23e8524c by Jeff Balicki

d

1 parent 90decfcf
......@@ -138,14 +138,16 @@ try {
$imagefile = $row->folder . '/' . $row->content;
$imgLUp = $row->locationUp;
$imgLRight = $row->locationRight;
$bw = $row->width;
$bh = $row->height;
//Load and insert the images
$image = $p->load_image("auto", $storagePath . $imagefile, "");
$buf = "boxsize={" . $bw . " " . $bh . "} position={center} fitmethod=meet";
$image = $p->load_image("auto", $storagePath . $imagefile, "");
if ($image == 0) {
die("Error: " . $p->get_errmsg());
}
$p->fit_image($image, $imgLRight, $imgLUp, "");
$p->fit_image($image, $imgLRight, $imgLUp, $buf);
}
......
var pluginUrl = "http://localhost:8888/Forms/";
var pdf_customizer = "http://localhost:8888/pdf-customizer/public/";
function getAuth() {
jQuery(document).ready(function($) {
var settings = {
"async": true,
"crossDomain": true,
"url": "" + pdf_customizer + "/api/authenticate",
"method": "POST",
"processData": false,
"contentType": false,
"mimeType": "multipart/form-data",
"data": form,
"success": function(data) {
getJson(user_id);
},
error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
//alert(xhr.status);
document.getElementById('contentArea').innerHTML = xhr.responseText;
}
}
$.ajax(settings).done(function(response) {
console.log(response);
token = response;
});
});
}
function offFocus() {
{
document.getElementById("select").className = "";
document.getElementById("select").className += "entry_edit_menu";
document.getElementById("select").className += "first_right"
}
}
function getJson(user_id) {
jQuery(document).ready(function($) {
$.getJSON("" + pdf_customizer + "/api/v1/get-list/" + user_id, function(data) {
// Get the element with id summary and set the inner text to the result.
var json = JSON.stringify(data);
pickPdfFromList(json);
});
});
}
function getOneJson(id) {
jQuery(document).ready(function($) {
$.getJSON("" + pdf_customizer + "/api/v1/get-pdf-google/" + id, function(data) {
// Get the element with id summary and set the inner text to the result.
var json = JSON.stringify(data);
changePdfOptions(json);
});
});
}
function pickPdfFromList(json) {
json = JSON.parse(json);
var strVar = "";
var i;
var pdflist = "";
for (i = 0; i < json.length; ++i) {
pdflist += "<div class=\"column\">";
pdflist += '<a href=\"#\" onclick=\"getOneJson(' + json[i].idPDF + ');\"> <img class=\"thumbnail\" src="' + pdf_customizer + '/fileentry/getImage/' + json[i].folder + '/' + json[i].image + '" height=\"270px\"></a>';
pdflist += " <h5>" + json[i].name + "<\/h5>";
pdflist += "<\/div>";
}
strVar += " <div class=\"callout primary\"><div class=\"row column\"> <h1>Welcome to Synapsus Online PDF Editor<\/h1>";
strVar += " <p class=\"lead\">Please pick a PDF<\/p> <\/div><\/div> <div class=\"row small-up-2 medium-up-3 large-up-4\">";
strVar += " <\/div>";
document.getElementById('contentArea').innerHTML = strVar;
}
function changePdfOptions(json) {
json = JSON.parse(json);
var strVar2 = "";
var pdflist = "";
var pdfChange = "";
pdflist += "<div class=\"column\">";
pdflist += ' <img src=\"' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].image + '\" width=\"300px\">';
pdflist += "<\/div><br>";
pdfChange += "<form id=\"changes\" name=\"changes\" enctype=\"multipart/form-data\" action=\"#\" METHOD=\"POST\"><h4>" + json[0].name + "</h4>";
pdfChange += " <input type=\"hidden\" id=\"id\" name=\"id\" value=\"" + json[0].idPDF + "\">";
for (i = 0; i < json.length; ++i) {
if (json[i].change_type == "text") {
pdfChange += " Text: <input id=\"content\" type=\"text\" name=\"content\" value=\"" + json[i].content + "\">";
}
if (json[i].change_type == "img") {
pdfChange += "Image: <input class=\"fileupload\" id=\"content\" style=\"display: block; box-sizing: border-box; width: 100%; height: 2.4375rem; padding: .5rem; border: 1px solid #cacaca; margin: 0 0 1rem; font-family: inherit; font-size: 1rem; color: #8a8a8a; background-color: #fefefe; box-shadow: inset 0 1px 2px rgba(10,10,10,.1); border-radius: 0; transition: box-shadow .5s,border-color .25s ease-in-out; -webkit-appearance: none; -moz-appearance: none;\" type=\"file\" name=\"content\" >";
}
}
pdfChange += " <input type=\"submit\" value=\"Submit\">";
pdfChange += "<\/form>";
strVar2 += " <div class=\"callout primary\"><div class=\"row column\"><h1>Welcome to Synapsus Online PDF Editor<\/h1>";
strVar2 += "<p class=\"lead\">Please make your changes or return <a href=\"#\" onclick=\"location.reload();\">back to the list</a><\/p>";
strVar2 += " <\/div><\/div><div class=\"row small-up-2 medium-up-3 large-up-3\">";
strVar2 += pdflist + "<div class=\"column\">" + pdfChange + "<\/div><\/div>";
document.getElementById('contentArea').innerHTML = strVar2;
document.getElementById('google_drive').innerHTML = " ";
jQuery(function($) {
var files;
// Add events
$(".fileupload").change(function() {
files = event.target.files;
console.log(files);
});
$("#changes").submit(function(e) {
e.preventDefault();
var form = $("#changes");
// var values = {};
//form.each(function() {
// values[this.name] = $(this).val();
//});
console.log(form);
returnfileOptions(files, form);
return false;
});
});
}
function returnfileOptions(files, form) {
jQuery(function($) {
var data = new FormData();
$.each(files, function(key, value) {
data.append(key, value);
});
$.ajax({
url: '' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files',
type: 'POST',
data: data,
cache: false,
dataType: 'json',
processData: false, // Don't process the files
contentType: false, // Set content type to false as jQuery will tell the server its a query string request
success: function(data, textStatus, jqXHR) {
if (typeof data.error === 'undefined') {
returnOptions(form);
} else {
// Handle errors here
console.log('ERRORS: ' + data.error);
}
},
error: function(jqXHR, textStatus, errorThrown) {
// Handle errors here
console.log('ERRORS: ' + textStatus);
// STOP LOADING SPINNER
}
});
});
}
function returnOptions(form) {
// console.log(form[0][1].value);
jQuery(function($) {
$.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) {
// Get the element with id summary and set the inner text to the result.
var json = dataReturnd;
//console.log(json);
var jsonReturn = '{"pdf":[{"name":"' + json[0].name + '", "folder":"' + json[0].folder + '", "pdfLocation":"' + json[0].file + '"}],"changes":['
var e = 1;
for (i = 0; i < json.length; ++i) {
var style = JSON.stringify(json[i].style);
var content = JSON.stringify(form[0][e].value);
jsonReturn += '{"label":"' + json[i].label + '", "locationUp":"' + json[i].locationUp + '", "locationRight":"' + json[i].locationRight + '","width":"' + json[i].width + '","height":"' + json[i].height + '", "pages":"' + json[i].pages + '", "content":' + content + ', "z-index":null, "idstylesPDF":"' + json[i].idstylesPDF + '", "style":' + style + ', "order":"' + json[i].order + '", "idchange_typePDF":"' + json[i].idchange_typePDF + '", "change_type":"' + json[i].change_type + '", "fileLocation":"' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/images"}';
if (i < json.length - 1) {
jsonReturn += ',';
}
++e
}
jsonReturn += ' ]}';
// console.log(jsonReturn);
$.ajax({
url: "" + pdf_customizer + "/api/update",
type: "POST",
dataType: 'json',
data: jsonReturn,
processData: false,
contentType: "application/json",
CrossDomain: true,
async: true,
success: function(data) {
document.getElementById('contentArea').innerHTML = '<a href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" >Download Here</a>';
},
error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
alert(xhr.status);
document.getElementById('contentArea').innerHTML = xhr.responseText;
}
});
});
});
}
\ No newline at end of file
var pluginUrl = "http://contact.gotenzing.com/";
var pdf_customizer = "pdf-customizer.synapsus.co";
function getAuth(){
var host = '';
if(host = 'local'){
var pluginUrl = "http://localhost:8888/Forms/";
var pdf_customizer = "http://localhost:8888/pdf-customizer/public/";
}else{
var pluginUrl = "http://contact.gotenzing.com";
var pdf_customizer = "http://pdf-customizer.synapsus.co";
}
function getAuth() {
jQuery(document).ready(function($) {
var settings = {
"async": true,
"crossDomain": true,
"url": "http://"+pdf_customizer+"/api/authenticate",
"method": "POST",
"processData": false,
"contentType": false,
"mimeType": "multipart/form-data",
"data": form,
"success": function (data) {
getJson(user_id);
},
error: function (xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
//alert(xhr.status);
document.getElementById('contentArea').innerHTML =xhr.responseText;
}
}
$.ajax(settings).done(function (response) {
console.log(response);
token = response;
});
var settings = {
"async": true,
"crossDomain": true,
"url": "" + pdf_customizer + "/api/authenticate",
"method": "POST",
});
"processData": false,
"contentType": false,
"mimeType": "multipart/form-data",
"data": form,
"success": function(data) {
getJson(user_id);
},
error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
//alert(xhr.status);
document.getElementById('contentArea').innerHTML = xhr.responseText;
}
}
$.ajax(settings).done(function(response) {
console.log(response);
token = response;
});
});
}
function getJson(user_id){
jQuery(document).ready(function($) {
$.getJSON("http://"+pdf_customizer+"/api/v1/get-list/"+user_id, function (data) {
// Get the element with id summary and set the inner text to the result.
var json = JSON.stringify(data);
pickPdfFromList(json);
function offFocus() {
jQuery(document).ready(function($) {
$("#select").removeClass("focus");
$(".entry_block").mouseleave(function() {
$("#select").addClass("focus");
});
});
}
function getJson(user_id) {
jQuery(document).ready(function($) {
$.getJSON("" + pdf_customizer + "/api/v1/get-list/" + user_id, function(data) {
// Get the element with id summary and set the inner text to the result.
var json = JSON.stringify(data);
pickPdfFromList(json);
});
});
}
function getOneJson(id){
function getOneJson(id) {
jQuery(document).ready(function($) {
$.getJSON("http://"+pdf_customizer+"/api/v1/get-pdf-google/"+id, function (data) {
$.getJSON("" + pdf_customizer + "/api/v1/get-pdf-google/" + id, function(data) {
// Get the element with id summary and set the inner text to the result.
var json = JSON.stringify(data);
......@@ -76,20 +105,20 @@ $.ajax(settings).done(function (response) {
});
}
function pickPdfFromList(json){
json = JSON.parse(json);
var strVar="";
function pickPdfFromList(json) {
json = JSON.parse(json);
var strVar = "";
var i;
var pdflist = "";
for (i = 0; i < json.length; ++i) {
pdflist += "<div class=\"column\">";
pdflist += '<a href=\"#\" onclick=\"getOneJson(' +json[i].idPDF+');\"> <img class=\"thumbnail\" src="http://'+pdf_customizer+'/fileentry/getImage/' + json[i].folder + '/' + json[i].image + '" height=\"270px\"></a>';
pdflist += '<a href=\"#\" onclick=\"getOneJson(' + json[i].idPDF + ');\"> <img class=\"thumbnail\" src="' + pdf_customizer + '/fileentry/getImage/' + json[i].folder + '/' + json[i].image + '" height=\"270px\"></a>';
pdflist += " <h5>" + json[i].name + "<\/h5>";
pdflist += "<\/div>";
}
......@@ -98,134 +127,129 @@ $.ajax(settings).done(function (response) {
strVar += " <div class=\"callout primary\"><div class=\"row column\"> <h1>Welcome to Synapsus Online PDF Editor<\/h1>";
strVar += " <p class=\"lead\">Please pick a PDF<\/p> <\/div><\/div> <div class=\"row small-up-2 medium-up-3 large-up-4\">";
strVar += " <\/div>";
document.getElementById('contentArea').innerHTML = strVar;
}
}
function changePdfOptions(json) {
json = JSON.parse(json);
function changePdfOptions(json){
json = JSON.parse(json);
var strVar2 = "";
var strVar2="";
var pdflist ="";
var pdfChange ="";
pdflist += "<div class=\"column\">";
pdflist += ' <img src=\"http://'+pdf_customizer+'/fileentry/getImage/' + json[0].folder + '/' + json[0].image + '\" width=\"300px\">';
pdflist += "<\/div><br>";
pdfChange += "<form id=\"changes\" name=\"changes\" enctype=\"multipart/form-data\" action=\"#\" METHOD=\"POST\"><h4>" + json[0].name+"</h4>";
pdfChange += " <input type=\"hidden\" id=\"id\" name=\"id\" value=\""+json[0].idPDF+"\">";
for (i = 0; i < json.length; ++i) {
if(json[i].change_type == "text"){
pdfChange += " Text: <input id=\"content\" type=\"text\" name=\"content\" value=\""+json[i].content+"\">";
}if(json[i].change_type == "img"){
pdfChange += "Image: <input class=\"fileupload\" id=\"content\" style=\"display: block; box-sizing: border-box; width: 100%; height: 2.4375rem; padding: .5rem; border: 1px solid #cacaca; margin: 0 0 1rem; font-family: inherit; font-size: 1rem; color: #8a8a8a; background-color: #fefefe; box-shadow: inset 0 1px 2px rgba(10,10,10,.1); border-radius: 0; transition: box-shadow .5s,border-color .25s ease-in-out; -webkit-appearance: none; -moz-appearance: none;\" type=\"file\" name=\"content\" >";
}
}
pdfChange += " <input type=\"submit\" value=\"Submit\">";
pdfChange += "<\/form>";
var pdflist = "";
var pdfChange = "";
pdflist += "<div class=\"column\">";
pdflist += ' <img src=\"' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].image + '\" width=\"300px\">';
pdflist += "<\/div><br>";
pdfChange += "<form id=\"changes\" name=\"changes\" enctype=\"multipart/form-data\" action=\"#\" METHOD=\"POST\"><h4>" + json[0].name + "</h4>";
pdfChange += " <input type=\"hidden\" id=\"id\" name=\"id\" value=\"" + json[0].idPDF + "\">";
for (i = 0; i < json.length; ++i) {
if (json[i].change_type == "text") {
pdfChange += " Text: <input id=\"content\" type=\"text\" name=\"content\" value=\"" + json[i].content + "\">";
}
if (json[i].change_type == "img") {
pdfChange += "Image: <input class=\"fileupload\" id=\"content\" style=\"display: block; box-sizing: border-box; width: 100%; height: 2.4375rem; padding: .5rem; border: 1px solid #cacaca; margin: 0 0 1rem; font-family: inherit; font-size: 1rem; color: #8a8a8a; background-color: #fefefe; box-shadow: inset 0 1px 2px rgba(10,10,10,.1); border-radius: 0; transition: box-shadow .5s,border-color .25s ease-in-out; -webkit-appearance: none; -moz-appearance: none;\" type=\"file\" name=\"content\" >";
}
}
pdfChange += " <input type=\"submit\" value=\"Submit\">";
pdfChange += "<\/form>";
strVar2 += " <div class=\"callout primary\"><div class=\"row column\"><h1>Welcome to Synapsus Online PDF Editor<\/h1>";
strVar2 += "<p class=\"lead\">Please make your changes or return <a href=\"#\" onclick=\"location.reload();\">back to the list</a><\/p>";
strVar2 += " <\/div><\/div><div class=\"row small-up-2 medium-up-3 large-up-3\">";
strVar2 += pdflist+"<div class=\"column\">"+pdfChange+"<\/div><\/div>";
strVar2 += " <div class=\"callout primary\"><div class=\"row column\"><h1>Welcome to Synapsus Online PDF Editor<\/h1>";
strVar2 += "<p class=\"lead\">Please make your changes or return <a href=\"#\" onclick=\"location.reload();\">back to the list</a><\/p>";
strVar2 += " <\/div><\/div><div class=\"row small-up-2 medium-up-3 large-up-3\">";
strVar2 += pdflist + "<div class=\"column\">" + pdfChange + "<\/div><\/div>";
document.getElementById('contentArea').innerHTML =strVar2;
document.getElementById('google_drive').innerHTML = " ";
document.getElementById('contentArea').innerHTML = strVar2;
document.getElementById('google_drive').innerHTML = " ";
jQuery(function ($) {
var files;
jQuery(function($) {
var files;
// Add events
$(".fileupload").change(function() { files = event.target.files; console.log(files); });
// Add events
$(".fileupload").change(function() {
files = event.target.files;
console.log(files);
});
$("#changes").submit(function(e) {
e.preventDefault();
$("#changes").submit(function(e) {
e.preventDefault();
var form = $("#changes");
// var values = {};
//form.each(function() {
// values[this.name] = $(this).val();
//});
console.log(form);
var form = $("#changes");
// var values = {};
//form.each(function() {
// values[this.name] = $(this).val();
//});
console.log(form);
returnfileOptions(files, form);
return false;});
returnfileOptions(files, form);
return false;
});
});
});
}
}
function returnfileOptions(files,form) {
jQuery(function ($) {
function returnfileOptions(files, form) {
jQuery(function($) {
var data = new FormData();
$.each(files, function(key, value)
{
data.append(key, value);
});
var data = new FormData();
$.each(files, function(key, value) {
data.append(key, value);
});
$.ajax({
url: 'http://contact.gotenzing.com/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files',
type: 'POST',
data: data,
cache: false,
dataType: 'json',
processData: false, // Don't process the files
contentType: false, // Set content type to false as jQuery will tell the server its a query string request
success: function(data, textStatus, jqXHR)
{
if(typeof data.error === 'undefined')
{
returnOptions(form);
}
else
{
$.ajax({
url: '' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files',
type: 'POST',
data: data,
cache: false,
dataType: 'json',
processData: false, // Don't process the files
contentType: false, // Set content type to false as jQuery will tell the server its a query string request
success: function(data, textStatus, jqXHR) {
if (typeof data.error === 'undefined') {
returnOptions(form);
} else {
// Handle errors here
console.log('ERRORS: ' + data.error);
}
},
error: function(jqXHR, textStatus, errorThrown) {
// Handle errors here
console.log('ERRORS: ' + data.error);
console.log('ERRORS: ' + textStatus);
// STOP LOADING SPINNER
}
},
error: function(jqXHR, textStatus, errorThrown)
{
// Handle errors here
console.log('ERRORS: ' + textStatus);
// STOP LOADING SPINNER
}
});
});
});
});
}
function returnOptions(form) {
// console.log(form[0][1].value);
// console.log(form[0][1].value);
jQuery(function($) {
jQuery(function ($) {
$.getJSON("http://"+pdf_customizer+"/api/v1/get-pdf/" + id.value, function (dataReturnd) {
$.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) {
// Get the element with id summary and set the inner text to the result.
var json = dataReturnd;
//console.log(json);
......@@ -237,53 +261,48 @@ strVar2 += pdflist+"<div class=\"column\">"+pdfChange+"<\/div><\/div>";
var style = JSON.stringify(json[i].style);
var content = JSON.stringify(form[0][e].value);
var style = JSON.stringify(json[i].style);
var content = JSON.stringify(form[0][e].value);
jsonReturn += '{"label":"' + json[i].label + '", "locationUp":"' + json[i].locationUp + '", "locationRight":"' + json[i].locationRight + '","width":"' + json[i].width + '","height":"' + json[i].height + '", "pages":"' + json[i].pages + '", "content":' + content + ', "z-index":null, "idstylesPDF":"' + json[i].idstylesPDF + '", "style":' + style + ', "order":"' + json[i].order + '", "idchange_typePDF":"' + json[i].idchange_typePDF + '", "change_type":"' + json[i].change_type + '", "fileLocation":"http://contact.gotenzing.com/wp-content/plugins/pdf-customizer-plugin/admin/images"}';
jsonReturn += '{"label":"' + json[i].label + '", "locationUp":"' + json[i].locationUp + '", "locationRight":"' + json[i].locationRight + '","width":"' + json[i].width + '","height":"' + json[i].height + '", "pages":"' + json[i].pages + '", "content":' + content + ', "z-index":null, "idstylesPDF":"' + json[i].idstylesPDF + '", "style":' + style + ', "order":"' + json[i].order + '", "idchange_typePDF":"' + json[i].idchange_typePDF + '", "change_type":"' + json[i].change_type + '", "fileLocation":"' + pluginUrl + '/wp-content/uploads/"}';
if (i < json.length - 1){
jsonReturn += ',';
if (i < json.length - 1) {
jsonReturn += ',';
}
++e
++e
}
jsonReturn += ' ]}';
// console.log(jsonReturn);
// console.log(jsonReturn);
$.ajax({
url: "http://"+pdf_customizer+"/api/update",
url: "" + pdf_customizer + "/api/update",
type: "POST",
dataType: 'json',
data: jsonReturn,
processData: false,
contentType: "application/json",
CrossDomain:true,
contentType: "application/json",
CrossDomain: true,
async: true,
success: function (data) {
document.getElementById('contentArea').innerHTML ='<a href="http://'+pdf_customizer+'/fileentry/getPDF/'+json[0].folder+'/new_'+json[0].file+'" download="'+json[0].file+'" >Download Here</a>';
success: function(data) {
document.getElementById('contentArea').innerHTML = '<a href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" >Download Here</a>';
},
error: function (xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
alert(xhr.status);
document.getElementById('contentArea').innerHTML =xhr.responseText;
document.getElementById('contentArea').innerHTML = xhr.responseText;
}
});
});
......@@ -291,11 +310,7 @@ strVar2 += pdflist+"<div class=\"column\">"+pdfChange+"<\/div><\/div>";
});
});
}
});
}
\ No newline at end of file
......