From f193ce97d624a9cf5772fd84e93859fbfc79f8a2 Mon Sep 17 00:00:00 2001
From: Patricio Kumagae <pkumagae@boletinoficial.gov.ar>
Date: Wed, 12 Sep 2018 15:33:59 -0300
Subject: [PATCH] =?UTF-8?q?Cambios=20en=20la=20extensi=C3=B3n=20del=20arch?=
 =?UTF-8?q?ivo?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 lib/js/index.js | 86 +++++++++++++++++--------------------------------
 1 file changed, 30 insertions(+), 56 deletions(-)

diff --git a/lib/js/index.js b/lib/js/index.js
index 053b1f1..d68afa7 100644
--- a/lib/js/index.js
+++ b/lib/js/index.js
@@ -22,10 +22,7 @@ function allowDrop(e) {
 }
 
 function stamp(e){
-    e.preventDefault();      
-
-    /*$('#ots_div').html('<img src="' + loader_gif + '">');
-    $('#ots_div').show();*/
+    e.preventDefault();
 
     var file = e.dataTransfer.items[0].getAsFile();    
       
@@ -48,7 +45,7 @@ function stamp(e){
             success: function(response){            
                 
 
-                var ots = ' {"file_hash": "' + file_hash + '", "ots": "' + response.temporay_ots + '"}';
+                var ots = ' {"file_hash": "' + file_hash + '", "rd": "' + response.temporay_ots + '"}';
 
 
                 var saveData = (function () {
@@ -66,8 +63,8 @@ function stamp(e){
                     };
                 }());
 
-                var data = response.temporay_ots
-                fileName = file.name + ".ots.temp";
+                var data = response.temporay_rd
+                fileName = file.name + ".rd.temp";
 
                 saveData(data, fileName);    
 
@@ -76,32 +73,6 @@ function stamp(e){
     }    
 }
 
-
-
-function verify(json_ots){    
-    
-
-    try{
-        var ots = JSON.parse(json_ots);
-    }
-    catch(err){
-        $('#response').html('<span class="glyphicon glyphicon-remove text-danger"></span> Parámetros inválidos');
-        return;
-    }
-
-    
-
-    if(deadline_date<current_date){
-        verify_bfa(ots);
-    }
-    else{
-        a=2;
-    }
-        
-        
-
-}
-
 function verify_bfa(ots){
 
     var pending = false;
@@ -110,7 +81,7 @@ function verify_bfa(ots){
     $.ajax({
         url: tsa_api + "verify/",
         type: "POST",
-        data: {"file_hash" : ots.file_hash, "ots": ots.ots},
+        data: {"file_hash" : ots.file_hash, "rd": ots.rd},
         dataType: "json",
         success: function(response){
 
@@ -130,27 +101,30 @@ function verify_bfa(ots){
                 
             $('#response').html(message);
 
-            var saveData = (function () {
-                var a = document.createElement("a");
-                document.body.appendChild(a);
-                a.style = "display: none";
-                return function (data, fileName) {
-                    var json = JSON.stringify(data),
-                        blob = new Blob([json], {type: "octet/stream"}),
-                        url = window.URL.createObjectURL(blob);
-                    a.href = url;
-                    a.download = fileName;
-                    a.click();
-                    window.URL.revokeObjectURL(url);
-                    };
-                }());
-
-                var data = response.permanent_ots;
-                fileName = $('#hidden_original_file_name').val() + ".ots";
-
-            if($('#ots_info').html().includes('.temp')){
-                saveData(data, fileName);    
-            }    
+            if(!pending){
+                var saveData = (function () {
+                    var a = document.createElement("a");
+                    document.body.appendChild(a);
+                    a.style = "display: none";
+                    return function (data, fileName) {
+                        var json = JSON.stringify(data),
+                            blob = new Blob([json], {type: "octet/stream"}),
+                            url = window.URL.createObjectURL(blob);
+                        a.href = url;
+                        a.download = fileName;
+                        a.click();
+                        window.URL.revokeObjectURL(url);
+                        };
+                    }());
+
+                    var data = response.permanent_rd;
+                    fileName = $('#hidden_original_file_name').val() + ".rd";
+
+                if($('#ots_info').html().includes('.temp')){
+                    saveData(data, fileName);    
+                }
+            }
+                
             
         },
         error:function(jqXHR, textStatus, errorThrown){
@@ -210,7 +184,7 @@ function drop_ots(e){
 
         $('#ots_info').html(file.name);
 
-        var ots = {"file_hash": file_hash, "ots": file_contents}
+        var ots = {"file_hash": file_hash, "rd": file_contents}
 
         verify_bfa(ots);
     };
-- 
GitLab