function previewdocuments_set_link() { $('#id-right a[href]:not(.relative_div_)').each(function() { var url = $(this).attr('href'); var mime = $(this).attr('mime'); if (url.indexOf('document.php?') != -1 && url.indexOf('action=delete') == -1 && url.indexOf('action=edit') == -1 && url.indexOf('image/png') == -1 && !mime) { // url.toLowerCase().indexOf('.pdf')!=-1 || if( url.toLowerCase().indexOf('.docx')!=-1 || url.toLowerCase().indexOf('.dotx')!=-1 || url.toLowerCase().indexOf('.dotm')!=-1 || url.toLowerCase().indexOf('.doc')!=-1 || url.toLowerCase().indexOf('.docm')!=-1 || url.toLowerCase().indexOf('.xls')!=-1 || url.toLowerCase().indexOf('.xlsx')!=-1 || url.toLowerCase().indexOf('.xlsb')!=-1 || url.toLowerCase().indexOf('.xlsm')!=-1 || url.toLowerCase().indexOf('.pptx')!=-1 || url.toLowerCase().indexOf('.ppt')!=-1 ) { filename = $(this).text(); if(filename == '') filename = $(this).find('img').attr('alt'); if(filename) filename = filename.replace(/'/g, "\\'"); url = url.replace("&", "&"); console.log(url.indexOf("full_path_nc")); if(url.indexOf("full_path_nc") != -1 && url.indexOf("full_name_nc") != -1){ name_file = url.split("full_name_nc="); name_file = name_file[1].split("&data_nc"); name_new = name_file[0]; big_url = url.split("full_path_nc="); big_url = big_url[1].split("&full_name_nc"); big_url = big_url[0].split("/"); big = big_url.pop(); big_url = big_url.toString(); big_url = big_url.replace(/\,/g,'/'); var urldoc = big_url; }else{ module = url.split('modulepart='); module = module[1].split('&'); module = module[0]; if(module == 'project'){ module = 'projet'; }else if(module == 'facture_fournisseur'){ module = 'fournisseur/facture'; }else if(module == 'propal'){ module = 'propale'; }else if(module == 'commande_fournisseur'){ module = 'fournisseur/commande'; } url_root = "https://cf-doli.computerfee-server.de/backup1"; url_documents = "/home/compute1/dateiablage/cf-doli_data/backup1"; big_url = url.split("file="); big_url = big_url[1].split("/"); big = big_url.pop(); big_url = big_url.toString(); big_url = big_url.replace(/\,/g,'/'); var urldoc = url_documents+"/"+module+"/"+big_url; name_file = url.split("file="); name_file = name_file[1]; name_file = url.split("/"); name_new = name_file[name_file.length-1]; if(name_file.indexOf('$entity=')){ name_file = url.split("$entity="); name_file = name_file[0]; } } var extention = name_new.split("."); extention = extention[1]; url = "javascript:previewdocuments_pop('"+name_new+"', '"+extention+"','"+urldoc+"')"; // url = "javascript:previewdocuments_pop('https://view.officeapps.live.com/op/embed.aspx?src="+last_url_nc+"', '"+name_new+"', '"+last_url_nc+"','"+extention+"','"+urldoc+"')"; if( url.toLowerCase().indexOf('.pdf')!=-1 ) { url = "javascript:previewdocuments_pop_pdf('"+name_new+"', '"+extention+"','"+urldoc+"')"; } // else { // url = "javascript:previewdocuments_pop('https://view.officeapps.live.com/op/embed.aspx?src="+last_url_nc+"', '"+name_new+"')"; // } link = ' '; $(this).after(link); } // if( url.toLowerCase().indexOf('.png')!=-1 || url.toLowerCase().indexOf('.jpg')!=-1 || url.toLowerCase().indexOf('.jpeg')!=-1 ) { // src_file = window.location.origin+url; // link = '  '; // $(this).after(link); // } } $(this).addClass("relative_div_"); $(".added_nc").addClass("relative_div_"); }); } function previewdocuments_pop_pdf(filename, extention=null, urldoc=null) { // console.log("urlfile : "+urlfile); $('#previewdocuments').remove(); // $('#previewdocuments iframe').attr('src', '
https://cf-doli.computerfee-server.de/backup1/custom/previewdocuments/img/loading.gif
'); // $('div#previewdocuments').css({"background":"url(https://cf-doli.computerfee-server.de/backup1/custom/previewdocuments/img/loading.gif) center center no-repeat"}); var data = { // 'urlfile' : urlfile, 'filename' : filename, 'extention' : extention, 'urldoc' : urldoc, 'action' : "readThisFile" }; $.ajax({ type: "POST", url: "https://cf-doli.computerfee-server.de/backup1/custom/previewdocuments/check.php", data: data, dataType: 'json', success: function(found){ if (found != "") { if($('#previewdocuments').length==0) { $('body').append('
'); } // $('div#previewdocuments').css({"background":"url(https://cf-doli.computerfee-server.de/backup1/ /previewdocuments/img/loading.gif) center center no-repeat"}); // console.log("new link : "+found); $('#previewdocuments').dialog({ title: "Preview of " + filename ,width:'80%' ,height:600 ,modal:true ,resizable: true ,close:function() { $('#previewdocuments iframe').attr('src', '#'); } }); var result = found; // console.log("result :"+result); $('#previewdocuments iframe').attr('src', result); setTimeout(function() { $("#previewdocuments iframe").show(); }, 500); } } }); // $('#previewdocuments').dialog({ // title: "Preview of " + filename // ,width:'80%' // ,height:600 // ,modal:true // ,resizable: false // ,close:function() { // $('#previewdocuments iframe').attr('src', '#'); // } // }); // $('#previewdocuments iframe').attr('src', url); } function previewdocuments_pop(filename, extention=null, urldoc=null) { // console.log("urlfile : "+urlfile); $('#previewdocuments').remove(); // $('#previewdocuments iframe').attr('src', '
https://cf-doli.computerfee-server.de/backup1/previewdocuments/img/loading.gif
'); // $('div#previewdocuments').css({"background":"url(https://cf-doli.computerfee-server.de/backup1/previewdocuments/img/loading.gif) center center no-repeat"}); var data = { // 'urlfile' : urlfile, 'filename' : filename, 'extention' : extention, 'urldoc' : urldoc, 'action' : "readThisFile" }; $.ajax({ type: "POST", url: "https://cf-doli.computerfee-server.de/backup1/custom/previewdocuments/check.php", data: data, success: function(found){ console.log(found); if (found != "") { if($('#previewdocuments').length==0) { $('body').append('
'); } // $('div#previewdocuments').css({"background":"url(https://cf-doli.computerfee-server.de/backup1/previewdocuments/img/loading.gif) center center no-repeat"}); // console.log("new link : "+found); $('#previewdocuments').dialog({ title: "Preview of " + filename ,width:'80%' ,height:600 ,modal:true ,resizable: true ,close:function() { $('#previewdocuments iframe').attr('src', '#'); } }); var result = 'https://view.officeapps.live.com/op/embed.aspx?src='+found; // console.log("result :"+result); $('#previewdocuments iframe').attr('src', result); setTimeout(function() { $("#previewdocuments iframe").show(); }, 500); } } }); // $('#previewdocuments').dialog({ // title: "Preview of " + filename // ,width:'80%' // ,height:600 // ,modal:true // ,resizable: false // ,close:function() { // $('#previewdocuments iframe').attr('src', '#'); // } // }); // $('#previewdocuments iframe').attr('src', url); } function preview_images_pop() { $('.lightbox_trigger_nc_').click(function(e) { e.preventDefault(); var image_href = $(this).attr("href"); $('.lightbox_nc .content_img').html(''); $('.lightbox_nc').show(); }); } $(window).on('load', function() { $('body').append(''); var top_menu = ($('#tmenu_tooltip').height() + 10); $('.lightbox_nc p').css({"margin-top":top_menu+"px","margin-right":top_menu+"px","padding-right":"30px"}); $('.lightbox_nc,.lightbox_nc p').click(function() {$('.lightbox_nc').hide();}); previewdocuments_set_link(); preview_images_pop(); });