function albumPopup(album,name){
     
/*    axios
                    .get('/upload/getFile/'+album)
                    .then((res) => {
                        console.log("data res");
                        console.log(res.data)
                        console.log(res.data.file)

                       
                        $( "#printModal" ).show()
                        $( "#showAlbums" ).empty()
                        for(var i=0;i<res.data.length;i++){
                            if(res.data[i].Type=="image"){
                            $('#showAlbums').append('<img class="selectimg " id="'+res.data[i]._id+'" onclick="select(\''+name+'\',\''+res.data[i]._id+'\',\''+res.data[i].Type+'\')" src="'+res.data[i].Url+'">')
                        }
                        if(res.data[i].Type=="video"){
                            $('#showAlbums').append('<span class="selectimg "  style="display: inline-block;"  onclick="select(\''+name+'\',\''+res.data[i]._id+'\',\''+res.data[i].Type+'\')"><video  style="width: 100%;height: 100%;" controls ><source id="'+res.data[i]._id+'"  src="'+res.data[i].Url+'" type="video/mp4"></video></span>')
                        }
                        if(res.data[i].Type=="font"){
                            $('#showAlbums').append('<span class="selectimg" style="display: inline-block;" id="'+res.data[i]._id+'" name="'+res.data[i].Name+'" onclick="select(\''+name+'\',\''+res.data[i]._id+'\',\''+res.data[i].Type+'\')">'+res.data[i].Name+'</span>')

                        }
                        if(res.data[i].Type=="document"){
                            $('#showAlbums').append('<span class="selectimg" style="display: inline-block;"  id="'+res.data[i]._id+'" name="'+res.data[i].Name+'" onclick="select(\''+name+'\',\''+res.data[i]._id+'\',\''+res.data[i].Type+'\')">'+res.data[i].Name+'</span>')

                        }

                        }
                    
                    })*/
                    $( "#printModal" ).attr("nameinput",name);
                    var socket = io();
var uploader = new SocketIOFileUpload(socket);
uploader.listenOnInput(document.getElementById("imgUploader"));

uploader.addEventListener('start', function (event){
    console.log("firs file")
    console.log(event)
    console.log(event.file.name)
    $('#uploading').empty();
    $('#uploading').append('<div id="'+ event.file.lastModified +'" class="col-lg-4 col-md-6 col-12 "><span class="file-name">'+ event.file.name +'</span><div class="upload-data"><div class="download-percent"></div></div></div>')
})

uploader.addEventListener('progress', function (event){
    var percent = (event.bytesLoaded / event.file.size) * 100;
    console.log("file is ", percent.toFixed(2), " percent loaded");
    selector = '#' + event.file.lastModified + ' > div > .download-percent '
    $(selector).css("width", percent.toFixed(2) + '%')
})
uploader.addEventListener("complete", function (event){
        console.log("finish")
        axios
                    .get('/upload/addFile/'+album+'/' + event.file.name )
                    .then((res) => {
                        console.log("data res");
                        console.log(res.data)
                        console.log(res.data.file)
                        if(res.data.text.Type == 'image') {
                            console.log("data res");
                            var inputname = $( "#printModal" ).attr("nameinput");
                            $('#showAlbums').append('<img  style="width:100px" class="selectimg " id="'+res.data.text._id+'"  onclick="select(\''+inputname+'\',\''+res.data.text._id+'\',\''+res.data.text.Type+'\')" src="'+res.data.text.Url+'">')
                        } 
                        if  (res.data.text.Type == 'video') {
                            console.log("data res");
                            var inputname = $( "#printModal" ).attr("nameinput");
                            $('#showAlbums').append('<div class="selectimg "  style="display: inline-block;"  onclick="select(\''+inputname+'\',\''+res.data.text._id+'\',\''+res.data.text.Type+'\',\''+res.data.text.Type+'\')"><video style="width: 100%;height: 100%;" controls ><source id="'+res.data.text._id+'"  src="'+res.data.text.Url+'" type="video/mp4"></video></div>');

                        } 
                        if(res.data.text.Type=="font"){
                            console.log("data res");
                            var inputname = $( "#printModal" ).attr("nameinput");
                            $('#showAlbums').append('<span class="selectimg" style="display: inline-block;"  id="'+res.data.text._id+'" name="'+res.data.text.Name+'" onclick="select(\''+inputname+'\',\''+res.data.text._id+'\',\''+res.data.text.Type+'\')">'+res.data.text.Name+'</span>');

                        }
                        if(res.data.text.Type=="document"){
                            console.log("data res");
                            var inputname = $( "#printModal" ).attr("nameinput");
                            $('#showAlbums').append('<span class="selectimg" style="display: inline-block;"  id="'+res.data.text._id+'" name="'+res.data.text.Name+'" onclick="select(\''+inputname+'\',\''+res.data.text._id+'\',\''+res.data.text.Type+'\')">'+res.data.text.Name+'</span>');

                        }
                   
                    })
        
        }
    
       
)
uploader.addEventListener("error", function(data){
    console.log("errore")
       console.log(data)
   
});
  }

function select(inputname,fileid,type){
    var input =  document.getElementsByClassName(inputname+'_input')
               $('.'+inputname+'_input')
          $('.selectimg.active').each(function( index ) {
                $(this).removeClass('active')
          });
          $('#'+fileid).addClass('active')
          $('.'+inputname+'_input').empty();
          if(type=="image"){var imgsrc=$('#'+fileid).attr("src");var imgtag='<img src="'+imgsrc+'" style="width:100px">'}
          if(type=="video"){var imgsrc=$('#'+fileid).attr("src");var imgtag='<div style="height:75px"><video style="width: 75px;height: 70px;position: absolute;" controls"><source src="'+imgsrc+'" type="video/mp4"></video></div>'}   
          if(type=="font"){var imgsrc=$('#'+fileid).attr("name");var imgtag='<span  name="'+imgsrc+'">'+imgsrc+'</span>'}
          if(type=="document"){var imgsrc=$('#'+fileid).attr("name");var imgtag='<span  name="'+imgsrc+'">'+imgsrc+'</span>'}

          var text= '<input name="'+inputname+'" value="'+fileid+'" class="d-none" >';
              $('.'+inputname+'_input').append(imgtag)
              $('.'+inputname+'_input').append('<input type="text" name="'+ inputname +'" id="'+ inputname +'" class="d-none" value="' +fileid + '" />')
              $(".btn-close").click();
            
            }