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