23e8524c by Jeff Balicki

d

1 parent 90decfcf
...@@ -138,14 +138,16 @@ try { ...@@ -138,14 +138,16 @@ try {
138 $imagefile = $row->folder . '/' . $row->content; 138 $imagefile = $row->folder . '/' . $row->content;
139 $imgLUp = $row->locationUp; 139 $imgLUp = $row->locationUp;
140 $imgLRight = $row->locationRight; 140 $imgLRight = $row->locationRight;
141 $bw = $row->width;
142 $bh = $row->height;
141 143
142 //Load and insert the images 144 //Load and insert the images
143 145 $buf = "boxsize={" . $bw . " " . $bh . "} position={center} fitmethod=meet";
144 $image = $p->load_image("auto", $storagePath . $imagefile, ""); 146 $image = $p->load_image("auto", $storagePath . $imagefile, "");
145 if ($image == 0) { 147 if ($image == 0) {
146 die("Error: " . $p->get_errmsg()); 148 die("Error: " . $p->get_errmsg());
147 } 149 }
148 $p->fit_image($image, $imgLRight, $imgLUp, ""); 150 $p->fit_image($image, $imgLRight, $imgLUp, $buf);
149 151
150 152
151 } 153 }
......
1
2 var pluginUrl = "http://localhost:8888/Forms/";
3 var pdf_customizer = "http://localhost:8888/pdf-customizer/public/";
4
5
6 function getAuth() {
7
8 jQuery(document).ready(function($) {
9
10
11
12
13 var settings = {
14 "async": true,
15 "crossDomain": true,
16 "url": "" + pdf_customizer + "/api/authenticate",
17 "method": "POST",
18
19 "processData": false,
20 "contentType": false,
21 "mimeType": "multipart/form-data",
22 "data": form,
23 "success": function(data) {
24 getJson(user_id);
25 },
26 error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
27 //alert(xhr.status);
28 document.getElementById('contentArea').innerHTML = xhr.responseText;
29 }
30
31 }
32
33 $.ajax(settings).done(function(response) {
34 console.log(response);
35 token = response;
36
37
38 });
39
40
41
42 });
43
44 }
45
46
47
48
49 function offFocus() {
50 {
51 document.getElementById("select").className = "";
52 document.getElementById("select").className += "entry_edit_menu";
53 document.getElementById("select").className += "first_right"
54
55
56
57 }
58 }
59
60
61
62 function getJson(user_id) {
63
64 jQuery(document).ready(function($) {
65
66 $.getJSON("" + pdf_customizer + "/api/v1/get-list/" + user_id, function(data) {
67 // Get the element with id summary and set the inner text to the result.
68 var json = JSON.stringify(data);
69 pickPdfFromList(json);
70
71 });
72
73
74
75 });
76 }
77
78 function getOneJson(id) {
79
80 jQuery(document).ready(function($) {
81
82 $.getJSON("" + pdf_customizer + "/api/v1/get-pdf-google/" + id, function(data) {
83 // Get the element with id summary and set the inner text to the result.
84 var json = JSON.stringify(data);
85
86 changePdfOptions(json);
87
88 });
89
90
91
92 });
93 }
94
95 function pickPdfFromList(json) {
96 json = JSON.parse(json);
97
98
99
100
101 var strVar = "";
102
103
104 var i;
105 var pdflist = "";
106 for (i = 0; i < json.length; ++i) {
107 pdflist += "<div class=\"column\">";
108 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>';
109 pdflist += " <h5>" + json[i].name + "<\/h5>";
110 pdflist += "<\/div>";
111 }
112
113
114 strVar += " <div class=\"callout primary\"><div class=\"row column\"> <h1>Welcome to Synapsus Online PDF Editor<\/h1>";
115 strVar += " <p class=\"lead\">Please pick a PDF<\/p> <\/div><\/div> <div class=\"row small-up-2 medium-up-3 large-up-4\">";
116 strVar += " <\/div>";
117
118
119
120
121 document.getElementById('contentArea').innerHTML = strVar;
122
123
124
125
126 }
127
128
129 function changePdfOptions(json) {
130 json = JSON.parse(json);
131
132 var strVar2 = "";
133
134
135 var pdflist = "";
136 var pdfChange = "";
137 pdflist += "<div class=\"column\">";
138 pdflist += ' <img src=\"' + pdf_customizer + '/fileentry/getImage/' + json[0].folder + '/' + json[0].image + '\" width=\"300px\">';
139 pdflist += "<\/div><br>";
140 pdfChange += "<form id=\"changes\" name=\"changes\" enctype=\"multipart/form-data\" action=\"#\" METHOD=\"POST\"><h4>" + json[0].name + "</h4>";
141 pdfChange += " <input type=\"hidden\" id=\"id\" name=\"id\" value=\"" + json[0].idPDF + "\">";
142 for (i = 0; i < json.length; ++i) {
143 if (json[i].change_type == "text") {
144 pdfChange += " Text: <input id=\"content\" type=\"text\" name=\"content\" value=\"" + json[i].content + "\">";
145 }
146 if (json[i].change_type == "img") {
147 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\" >";
148 }
149 }
150 pdfChange += " <input type=\"submit\" value=\"Submit\">";
151 pdfChange += "<\/form>";
152
153 strVar2 += " <div class=\"callout primary\"><div class=\"row column\"><h1>Welcome to Synapsus Online PDF Editor<\/h1>";
154 strVar2 += "<p class=\"lead\">Please make your changes or return <a href=\"#\" onclick=\"location.reload();\">back to the list</a><\/p>";
155 strVar2 += " <\/div><\/div><div class=\"row small-up-2 medium-up-3 large-up-3\">";
156 strVar2 += pdflist + "<div class=\"column\">" + pdfChange + "<\/div><\/div>";
157
158
159
160 document.getElementById('contentArea').innerHTML = strVar2;
161 document.getElementById('google_drive').innerHTML = " ";
162
163 jQuery(function($) {
164 var files;
165
166 // Add events
167 $(".fileupload").change(function() {
168 files = event.target.files;
169 console.log(files);
170 });
171
172
173 $("#changes").submit(function(e) {
174 e.preventDefault();
175
176 var form = $("#changes");
177 // var values = {};
178 //form.each(function() {
179 // values[this.name] = $(this).val();
180 //});
181 console.log(form);
182
183 returnfileOptions(files, form);
184 return false;
185 });
186
187
188
189 });
190
191 }
192
193 function returnfileOptions(files, form) {
194 jQuery(function($) {
195
196 var data = new FormData();
197 $.each(files, function(key, value) {
198 data.append(key, value);
199 });
200
201 $.ajax({
202 url: '' + pluginUrl + '/wp-content/plugins/pdf-customizer-plugin/admin/uploadfile.php?files',
203 type: 'POST',
204 data: data,
205 cache: false,
206 dataType: 'json',
207 processData: false, // Don't process the files
208 contentType: false, // Set content type to false as jQuery will tell the server its a query string request
209 success: function(data, textStatus, jqXHR) {
210 if (typeof data.error === 'undefined') {
211 returnOptions(form);
212 } else {
213 // Handle errors here
214
215 console.log('ERRORS: ' + data.error);
216 }
217 },
218 error: function(jqXHR, textStatus, errorThrown) {
219 // Handle errors here
220 console.log('ERRORS: ' + textStatus);
221 // STOP LOADING SPINNER
222 }
223 });
224
225 });
226 }
227
228
229 function returnOptions(form) {
230
231
232 // console.log(form[0][1].value);
233
234
235
236
237 jQuery(function($) {
238
239 $.getJSON("" + pdf_customizer + "/api/v1/get-pdf/" + id.value, function(dataReturnd) {
240 // Get the element with id summary and set the inner text to the result.
241 var json = dataReturnd;
242 //console.log(json);
243
244
245 var jsonReturn = '{"pdf":[{"name":"' + json[0].name + '", "folder":"' + json[0].folder + '", "pdfLocation":"' + json[0].file + '"}],"changes":['
246 var e = 1;
247 for (i = 0; i < json.length; ++i) {
248
249
250
251 var style = JSON.stringify(json[i].style);
252 var content = JSON.stringify(form[0][e].value);
253
254
255
256 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"}';
257
258
259 if (i < json.length - 1) {
260 jsonReturn += ',';
261 }
262 ++e
263 }
264 jsonReturn += ' ]}';
265 // console.log(jsonReturn);
266
267
268
269
270 $.ajax({
271 url: "" + pdf_customizer + "/api/update",
272 type: "POST",
273 dataType: 'json',
274 data: jsonReturn,
275 processData: false,
276
277 contentType: "application/json",
278 CrossDomain: true,
279
280
281
282
283 async: true,
284 success: function(data) {
285 document.getElementById('contentArea').innerHTML = '<a href="' + pdf_customizer + '/fileentry/getPDF/' + json[0].folder + '/new_' + json[0].file + '" download="' + json[0].file + '" >Download Here</a>';
286 },
287 error: function(xhr, ajaxOptions, thrownError) { //Add these parameters to display the required response
288 alert(xhr.status);
289 document.getElementById('contentArea').innerHTML = xhr.responseText;
290 }
291
292 });
293
294
295
296
297 });
298
299
300 });
301
302
303 }
...\ No newline at end of file ...\ No newline at end of file