Changeset 327fd70 in prototipo_portal_2018
- Timestamp:
- Oct 26, 2017, 9:45:51 AM (7 years ago)
- Branches:
- master
- Children:
- ad582d7
- Parents:
- 8d37379
- Location:
- prototipo
- Files:
-
- 6 added
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
prototipo/index.html
r445bdb4 r327fd70 35 35 <script src="static/js/ie10-viewport-bug-workaround.js"></script> 36 36 37 <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> 38 <script src="static/js/cropper.js"></script> 39 37 <!--========== Plugins para el pdf =========--> 40 38 <script src="static/js/pdf.js"></script> 41 39 <script src="static/js/pdf.worker.js"></script> 40 41 <!-- ========== Plugins hwcrypto ========= --> 42 <script type="text/javascript" src="static/js/gitversion.js"></script> 43 <script type="text/javascript" src="static/js/hwcrypto-legacy.js"></script> 44 <script type="text/javascript" src="static/js/hwcrypto.js"></script> 45 <script type="text/javascript" src="static/js/hex2base.js"></script> 42 46 43 47 </head> … … 114 118 </li> 115 119 <ul class="nav collapse" id="Formato_Visible" role="menu" aria-labelledby="btn-1"> 116 <form id =" form" enctype='multipart/form-data' >120 <form id ="Form-Format-Visible" enctype='multipart/form-data' > 117 121 <div class="btn-group" id="Formato_Visible"> 118 122 <button type="button" id="upload-button2" class="btn btn-success btn-sm"> … … 124 128 <input type="hidden" class="form-control" id="dataX" placeholder="x"> 125 129 <input type="hidden" class="form-control" id="dataY" placeholder="y"> 126 <input type="file" id="file-to-upload2" accept="application/pdf" /> 130 <input type="hidden" class="form-control" id="pagepdf" placeholder="Page of pdf"> 131 <input type="file" id="file-sign-ft_Vble" accept="application/pdf" /> 127 132 </div> 128 129 133 </form> 134 <div class="text imagen" id="texto"></div> 130 135 </ul> 131 136 <li><a href="#" id="firm_no_v" class="list-group-item list-group-item-link" data-toggle="collapse" data-target="#Formato_Normal">Firma No visible <span class="glyphicon glyphicon-chevron-down"></span></a> … … 159 164 <span class="glyphicon glyphicon-open"></span>Cargar 160 165 </button> 161 <input type="file" id="file-to-uploa d2" accept="application/pdf" />166 <input type="file" id="file-to-uploa" accept="application/pdf" /> 162 167 <div id="etiquet"> 163 168 <div class="text imagen" id="texto"></div> … … 230 235 <!--<div class="ball blue">sdsa</div>--> 231 236 </div> 237 <br> 238 <br> 239 <div id="respuesta"> </div> 232 240 </div> 233 241 </div> … … 288 296 <script src="static/js/jqBootstrapValidation.js"></script> 289 297 <!-- Theme JavaScript --> 290 291 298 <script src="static/js/clean-blog.min.js"></script> 292 <script src="static/js/docs.js"></script>293 299 <script src="static/js/draggable.js"></script> 294 300 <script src="static/js/bounded.js"></script> 295 301 <script src="static/js/jquery/jquery-ui.js"></script> 296 <script src="static/js/docsDraggable.js"></script> 302 <script src="static/js/variables.js"></script> 303 297 304 <script src="static/js/docFirmaNormal.js"></script> 298 305 <script src="static/js/menu.js"></script> 306 307 <!-- Coordenadas--> 299 308 <script src="static/js/functions/DraggableSortable.js"></script> 309 <script src="static/js/docsDraggable.js"></script> 310 <!-- sign--> 311 <script src="static/js/functions/manejoJsonPDF.js"></script> 300 312 <script src="static/js/functions/firmarDocumentoPdf.js"></script> 301 313 302 314 303 304 315 </body> 305 316 </html> -
prototipo/static/css/style.css
r0500480 r327fd70 17 17 border: 1px solid #eee; 18 18 z-index: 2; 19 margin-bottom: 4px;19 /*margin-bottom: 4px;*/ 20 20 display: none; 21 21 … … 54 54 55 55 56 #file-to-upload, #file- to-upload2, #file-to-normal{56 #file-to-upload, #file-sign-ft_Vble, #file-to-normal{ 57 57 display: none; 58 58 } -
prototipo/static/js/docsDraggable.js
r0500480 r327fd70 49 49 // Update current page in HTML 50 50 $("#pdf-current-page2").text(page_no); 51 $("#pagepdf").val(page_no); 51 52 VALOR_PAGE = page_no; 52 53 53 54 // Fetch the page … … 84 85 __id = __CANVAS.toDataURL() 85 86 86 var viewdimen = page.getViewport(1); 87 console.log( "Width: " + viewdimen.width + ", Height: " + viewdimen.height); 87 var viewdimen = page.getViewport(1); 88 88 89 89 $("#container1").attr("style", "background-image: url('"+__id+"');background-size: cover; background-repeat: no-repeat; height:"+viewdimen.height+"px; width:"+viewdimen.width+"px"); … … 105 105 $("#pdf-main-container").show(); 106 106 107 $("#file- to-upload2").trigger('click');107 $("#file-sign-ft_Vble").trigger('click'); 108 108 109 109 }); 110 110 111 111 // When user chooses a PDF file 112 $("#file- to-upload2").on('change', function() {112 $("#file-sign-ft_Vble").on('change', function() { 113 113 114 114 // Validate whether PDF 115 if(['application/pdf'].indexOf($("#file- to-upload2").get(0).files[0].type) == -1) {115 if(['application/pdf'].indexOf($("#file-sign-ft_Vble").get(0).files[0].type) == -1) { 116 116 alert('Error : Not a PDF'); 117 117 return; … … 119 119 120 120 // Send the object url of the pdf 121 showPDF2(URL.createObjectURL($("#file- to-upload2").get(0).files[0]));121 showPDF2(URL.createObjectURL($("#file-sign-ft_Vble").get(0).files[0])); 122 122 123 123 if (__CLICK == 0){ -
prototipo/static/js/functions/DraggableSortable.js
r0500480 r327fd70 28 28 if (num == 1){ 29 29 $("#firma_visible #Formato_Visible .text").hide(); 30 $('#dataX').val(0);31 $('#dataY').val(0);30 VALOR_X = 0; 31 VALOR_Y = 0; 32 32 }else{ 33 $('#dataX').val(ui.position['left']);34 $('#dataY').val(ui.position['top']);33 VALOR_X = parseInt(ui.position['left']); 34 VALOR_Y = parseInt(ui.position['top']); 35 35 } 36 36 -
prototipo/static/js/functions/firmarDocumentoPdf.js
r8d37379 r327fd70 1 2 $("#form").on('submit', function() { 3 1 $("#Form-Format-Visible").on('submit', function() { 4 2 //var formData = new FormData(document.getElementById("form")); 5 3 var formData = new FormData(); 6 7 8 formData.append("upload", $("#file-to-upload2")[0].files[0] ); 9 10 console.log(formData); 11 console.log($(this)); 4 5 formData.append("upload", $("#file-sign-ft_Vble")[0].files[0]); 12 6 13 7 $.ajax({ … … 22 16 headers: {"Authorization":"Basic YWRtaW46YWRtaW4="}, 23 17 success: function(response) { 24 //alert(JSON.stringify(response)); 25 var html = manejoJsonPDF(JSON.stringify(response)); 26 //alert(html); 27 //alert("ver respuesta") 28 document.getElementById("respuesta").innerHTML = html; 18 //alert(JSON.stringify(response)); 19 var html = manejoJsonPDF(JSON.stringify(response)); 20 document.getElementById("respuesta").innerHTML = html; 21 22 // identificador del archivo en el servidor 23 var fileId = response.fileId.toString(); 24 var cert; 25 26 window.hwcrypto.getCertificate({lang: "en"}).then(function(response) { 27 var cert = response; 29 28 30 // identificador del archivo en el servidor 31 var fileId = response.fileId.toString(); 29 var parameters = JSON.stringify({ 30 "fileId":fileId, 31 "certificate":cert.hex, 32 "reason":"Certificado", 33 "location":"CENDITEL", 34 "contact":"582746574336", 35 "signatureVisible":"true", 36 "page": VALOR_PAGE, 37 "coord_x": VALOR_X, 38 "coord_y": VALOR_Y 39 }); 40 41 // ahora llamar al ajax de obtener la resena del pdf 42 $.ajax({ 43 type: 'POST', 44 contentType: 'application/json', 45 //url:"https://192.168.12.125:8443/Murachi/0.1/archivos/pdfs", 46 url:"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs", 47 dataType: "json", 48 data: parameters, 49 headers: {"Authorization":"Basic YWRtaW46YWRtaW4="}, 50 success: function(data, textStatus, jqXHR){ 51 var json_x = data; 52 var hash = json_x['hash']; 53 //alert("hash recibido del servidor "+hash); 54 55 var hashtype = "SHA-256"; 56 var lang = "eng"; 57 58 window.hwcrypto.sign(cert, {type: hashtype, hex: hash}, {lang: lang}).then(function(signature) { 59 60 $.ajax({ 61 type: 'POST', 62 contentType: 'application/json', 63 //url:"https://192.168.12.125:8443/Murachi/0.1/archivos/pdfs/resenas", 64 url:"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs/resenas", 65 dataType: 'json', 66 data: JSON.stringify({"signature":signature.hex}), 67 headers: {"Authorization":"Basic YWRtaW46YWRtaW4="}, 68 success: function(data, textStatus, jqXHR){ 32 69 70 alert('Archivo firmado correctamente: ' + data['signedFileId']); 71 72 var linkToDownload = "<a href=\"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/descargas/" + data['signedFileId'] +"\">descargar archivo firmado</a>"; 73 //alert(linkToDownload); 74 document.getElementById("respuesta").innerHTML = linkToDownload; 75 76 }, 77 error: function(jqXHR, textStatus, errorThrown){ 78 alert('error en pdfs/resenas: ' + textStatus); 79 $("#respuesta").html("error en pdfs/resenas: " + textStatus); 80 } 81 }); 82 83 }, function(err) { 84 log_text("sign() failed: " + err); 33 85 34 var cert; 35 window.hwcrypto.getCertificate({lang: "en"}).then(function(response) { 36 var cert = response; 86 var error; 87 log_text("sign() failed: " + err); 88 if(err == "Error: user_cancel") { 89 alert("sign() failed: El usuario cancelo la operación"); 90 error = "El usuario cancelo la operación"; 91 } 92 else if(err == "Error: no_certificates") { 93 alert("sign() failed: No hay certificado disponible"); 94 error = "No hay certificado disponible"; 95 } 96 else if(err == "Error: no_implementation") { 97 alert("sign() failed: No hay soporte para el manejo del certificado"); 98 error = "No hay soporte para el manejo del certificado"; 99 } 37 100 101 //alert("sign() failed: " + err); 102 $("#respuesta").html("sign() failed: " + error); 103 }); 104 105 }, 106 error: function(jqXHR, textStatus, errorThrown){ 107 //alert('error: ' + textStatus); 108 //var responseText = jQuery.parseJSON(jqXHR.responseText); 109 alert('ajax error function: ' + jqXHR.responseText); 110 $("#respuesta").html("error function: " + jqXHR.responseText); 111 } 112 113 }); 114 115 }, function(err) { 116 log_text("getCertificate() failed: " + err); 117 var error; 118 if(err == "Error: user_cancel") { 119 alert("getCertificate() failed: El usuario cancelo la operación" ); 120 error = "El usuario cancelo la operación"; 121 } 122 else if(err == "Error: no_certificates") { 123 alert("getCertificate() failed: No hay certificado disponible") ; 124 error = "No hay certificado disponible"; 125 } 126 else if(err == "Error: no_implementation") { 127 alert("getCertificate() failed: No hay soporte para el manejo del certificado"); 128 error = "No hay soporte para el manejo del certificado"; 129 } 130 //alert("getCertificate() failed: " + err); 131 $("#respuesta").html("getCertificate() failed: " + error); 132 }); 38 133 39 40 var parameters = JSON.stringify({41 "fileId":fileId,42 "certificate":cert.hex,43 "reason":"Certificado",44 "location":"CENDITEL",45 "contact":"582746574336",46 "signatureVisible":"true"47 // agregar aqui los parametros x,y,pagina48 });49 50 // ahora llamar al ajax de obtener la resena del pdf51 $.ajax({52 type: 'POST',53 contentType: 'application/json',54 //url:"https://192.168.12.125:8443/Murachi/0.1/archivos/pdfs",55 url:"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs",56 dataType: "json",57 data: parameters,58 headers: {"Authorization":"Basic YWRtaW46YWRtaW4="},59 success: function(data, textStatus, jqXHR){60 var json_x = data;61 var hash = json_x['hash'];62 //alert("hash recibido del servidor "+hash);63 64 var hashtype = "SHA-256";65 var lang = "eng";66 67 window.hwcrypto.sign(cert, {type: hashtype, hex: hash}, {lang: lang}).then(function(signature) {68 69 70 71 72 $.ajax({73 type: 'POST',74 contentType: 'application/json',75 //url:"https://192.168.12.125:8443/Murachi/0.1/archivos/pdfs/resenas",76 url:"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/pdfs/resenas",77 dataType: 'json',78 data: JSON.stringify({"signature":signature.hex}),79 headers: {"Authorization":"Basic YWRtaW46YWRtaW4="},80 success: function(data, textStatus, jqXHR){81 82 alert('Archivo firmado correctamente: ' + data['signedFileId']);83 84 85 var linkToDownload = "<a href=\"https://murachi.cenditel.gob.ve/Murachi/0.1/archivos/descargas/" + data['signedFileId'] +"\">descargar archivo firmado</a>";86 //alert(linkToDownload);87 document.getElementById("respuesta").innerHTML = linkToDownload;88 89 90 91 92 },93 error: function(jqXHR, textStatus, errorThrown){94 alert('error en pdfs/resenas: ' + textStatus);95 $("#respuesta").html("error en pdfs/resenas: " + textStatus);96 }97 });98 99 }, function(err) {100 log_text("sign() failed: " + err);101 102 var error;103 log_text("sign() failed: " + err);104 if(err == "Error: user_cancel") {105 alert("sign() failed: El usuario cancelo la operación");106 error = "El usuario cancelo la operación";107 }108 else if(err == "Error: no_certificates") {109 alert("sign() failed: No hay certificado disponible");110 error = "No hay certificado disponible";111 }112 else if(err == "Error: no_implementation") {113 alert("sign() failed: No hay soporte para el manejo del certificado");114 error = "No hay soporte para el manejo del certificado";115 }116 117 //alert("sign() failed: " + err);118 $("#respuesta").html("sign() failed: " + error);119 });120 121 },122 error: function(jqXHR, textStatus, errorThrown){123 //alert('error: ' + textStatus);124 //var responseText = jQuery.parseJSON(jqXHR.responseText);125 alert('ajax error function: ' + jqXHR.responseText);126 $("#respuesta").html("error function: " + jqXHR.responseText);127 }128 129 130 });131 132 133 134 }, function(err) {135 log_text("getCertificate() failed: " + err);136 var error;137 if(err == "Error: user_cancel") {138 alert("getCertificate() failed: El usuario cancelo la operación" );139 error = "El usuario cancelo la operación";140 }141 else if(err == "Error: no_certificates") {142 alert("getCertificate() failed: No hay certificado disponible") ;143 error = "No hay certificado disponible";144 }145 else if(err == "Error: no_implementation") {146 alert("getCertificate() failed: No hay soporte para el manejo del certificado");147 error = "No hay soporte para el manejo del certificado";148 }149 //alert("getCertificate() failed: " + err);150 $("#respuesta").html("getCertificate() failed: " + error);151 });152 153 154 134 }, 155 135 error: function(response) { … … 159 139 } 160 140 }); 161 162 163 164 165 166 141 167 142 });
Note: See TracChangeset
for help on using the changeset viewer.