[chronojump-server] Player image display when checkbox change



commit 688639659425e7d0b29f4006aa068fac038c2f69
Author: Max Ros i Morejon <mros33 gmail com>
Date:   Fri Apr 12 12:13:29 2019 +0200

    Player image display when checkbox change

 .../templates/organizations/players/players_list.html    | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/chronojumpserver-django/chronojump_networks/templates/organizations/players/players_list.html 
b/chronojumpserver-django/chronojump_networks/templates/organizations/players/players_list.html
index a42d1a0..0175a66 100644
--- a/chronojumpserver-django/chronojump_networks/templates/organizations/players/players_list.html
+++ b/chronojumpserver-django/chronojump_networks/templates/organizations/players/players_list.html
@@ -54,6 +54,7 @@
 <script>
   var csrftoken = jQuery("[name=csrfmiddlewaretoken]").val();
   var image_changed = "False";
+  var image_pl;
   
   $(document).ready(function() {
     /* Datatable for players in groups */
@@ -230,6 +231,7 @@
       $('#id_image').val(null);
       $('#imgView').prop("src", 'http://localhost:8000/static/images/default_player.png');
       $('#chkId').prop("checked", false);
+      image_pl = 'http://localhost:8000/static/images/default_player.png';
     }
     
     $('#btn_read_rfid').click(function() {
@@ -266,15 +268,28 @@
     
     $('#id_image').on('change', function() {
         //$("#imgView").prop("src", $('#id_image')[0].files[0]);
+        /*var new_img
+        jQuery.each($('#id_image')[0].files, function(i, file) {
+            //formdata.append('image', file);
+            new_img = file;
+            console.log(new_img);
+        });
+        $("#imgView").prop("src", new_img.path);*/
+        $('#chkId').prop("checked",false);
         image_changed = "True";
     })
     
     $('#chkId').on('change', function() {
         if(this.checked) {
             $('#id_image').val(null);
+            $('#imgView').prop("src", "http://localhost:8000/static/images/default_player.png";);
             image_changed = "True";
             console.log("canvi checked");
         }
+        else {
+            $('#imgView').prop("src", image_pl);
+            image_changed = "False";
+        }
     })
     
      // Get all the values in the form into json object 
@@ -314,6 +329,7 @@
       console.log(player.image);      
       $('#imgView').prop("src", player.image);
       $('#id_image').val(player.image.name);
+      image_pl = player.image;
       $('#chkId').prop("checked", false);
     }
     


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]