Sindbad~EG File Manager

Current Path : /home/escuelai/www/it/js/
Upload File :
Current File : /home/escuelai/www/it/js/fileupload.min.js

/**
 * ---------------------------------------------------------------------
 *
 * GLPI - Gestionnaire Libre de Parc Informatique
 *
 * http://glpi-project.org
 *
 * @copyright 2015-2022 Teclib' and contributors.
 * @copyright 2003-2014 by the INDEPNET Development Team.
 * @licence   https://www.gnu.org/licenses/gpl-3.0.html
 *
 * ---------------------------------------------------------------------
 *
 * LICENSE
 *
 * This file is part of GLPI.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 *
 * ---------------------------------------------------------------------
 */
var insertIntoEditor=[];var uploaded_images=[];function uploadFile(e,t){insertIntoEditor[e.name]=isImage(e);var a=$(t.getElement()).siblings(".fileupload");if(a.length===0){a=$(t.getElement()).closest("form").find(".fileupload")}a.find('[type="file"]').fileupload("add",{files:[e]})}var handleUploadedFile=function(e,t,a,n,i){$.ajax({type:"POST",url:CFG_GLPI.root_doc+"/ajax/getFileTag.php",data:{data:t},dataType:"JSON",success:function(r){$.each(e,(function(e,o){if(t[e].error!==undefined){n.parent().find(".uploadbar").text(t[e].error).css("width","100%");return}var d=r[e];var l=null;if(i){l=tinyMCE.get(i);const e=uploaded_images.find((function(e){return e.filename===o.name}));const t=e!==undefined?l.dom.select('img[data-upload_id="'+e.upload_id+'"]'):[];if(t.length>0){l.dom.setAttribs(t,{id:d.tag.replace(/#/g,""),src:URL.createObjectURL(o)})}else if(Object.prototype.hasOwnProperty.call(insertIntoEditor,o.name)&&insertIntoEditor[o.name]){insertImgFromFile(l,o,d.tag);a=l.targetElm.name}}displayUploadedFile(t[e],d,l,a,n);n.parent().find(".uploadbar").text(__("Upload successful")).css("width","100%").delay(2e3).fadeOut("slow")}))},error:function(e){console.warn(e.responseText)},complete:function(){$.each(e,(function(e,t){delete insertIntoEditor[t.name]}))}})};var fileindex=0;var displayUploadedFile=function(e,t,a,n,i){var r=e.name.split(".").pop();var o=$("<p></p>").attr("id",e.id).html(getExtIcon(r)+"&nbsp;"+"<b>"+e.display+"</b>"+"&nbsp;("+getSize(e.size)+")&nbsp;").appendTo(i);$("<input/>").attr("type","hidden").attr("name","_"+n+"["+fileindex+"]").attr("value",e.name).appendTo(o);$("<input/>").attr("type","hidden").attr("name","_prefix_"+n+"["+fileindex+"]").attr("value",e.prefix).appendTo(o);$("<input/>").attr("type","hidden").attr("name","_tag_"+n+"["+fileindex+"]").attr("value",t.name).appendTo(o);var d={0:e.id,1:e.id+"2"};$('<span class="ti ti-circle-x pointer"></span>').click((function(){deleteImagePasted(d,t.tag,a)})).appendTo(o);fileindex++};var deleteImagePasted=function(e,t,a){$.each(e,(function(e,t){$("#"+t).remove()}));if(typeof a!=="undefined"&&typeof a.dom!=="undefined"){var n=new RegExp("#","g");a.dom.remove(t.replace(n,""))}};var insertImgFromFile=function(e,t,a){var n=window.URL||window.webkitURL;var i=n.createObjectURL(t);var r=new RegExp("#","g");var o=$(tinyMCE.activeEditor.getContainer()).height()-60;var d=$(tinyMCE.activeEditor.getContainer()).width()-120;if(window.FileReader&&window.File&&window.FileList&&window.Blob){e.setProgressState(true);var l=new FileReader;l.onload=function(t){var n=new Image;n.src=t.target.result;n.onload=function(){var t=this.width;var n=this.height;var l=0;if(t>d){l=d/t;n=n*l;t=t*l}if(n>o){l=o/n;t=t*l;n=n*l}e.execCommand("mceInsertContent",false,"<img width='"+t+"' height='"+n+"' id='"+a.replace(r,"")+"' src='"+i+"'>");e.setProgressState(false)}};l.readAsDataURL(t)}else{console.warn("thanks to update your browser to get preview of image")}};var dataURItoBlob=function(e){var t;if(e.split(",")[0].indexOf("base64")>=0){t=atob(e.split(",")[1])}else{t=unescape(e.split(",")[1])}var a=e.split(",")[0].split(":")[1].split(";")[0];var n=a.split("/")[1];var i=new Uint8Array(t.length);for(var r=0;r<t.length;r++){i[r]=t.charCodeAt(r)}var o=new Blob([i],{type:a});o.name="image_paste"+Math.floor(Math.random()*1e7+1)+"."+n;return o};var isImageFromPaste=function(e){return e.match(new RegExp("<img.*data:image/"))!==null};var isImageBlobFromPaste=function(e){return e.match(new RegExp("<img.*src=['\"]blob:"))!==null};var extractSrcFromImgTag=function(e){var t=$("<div></div>").append(e).find("img");if(t.length>0){return t.attr("src")}return""};var insertImageInTinyMCE=function(e,t){uploadFile(t,e)};if(typeof tinyMCE!="undefined"){tinyMCE.PluginManager.add("glpi_upload_doc",(function(e){e.on("PastePreProcess",(function(t){var a=$("<div></div>");a.append(t.content);a.find("img").each((function(){const t=$(this);const a=t.attr("src");if(a.match(new RegExp("^(data|blob):"))!==null){const n=Math.random().toString();t.attr("data-upload_id",n);fetch(a).then((function(e){return e.blob()})).then((function(t){if(/^image\/.+/.test(t.type)===false){return}const a=t.type.replace("image/","");t.name="image_paste"+Math.floor(Math.random()*1e7+1)+"."+a;uploaded_images.push({upload_id:n,filename:t.name});uploadFile(t,e)}))}}));t.content=a.html()}))}))}$((function(){$(document).bind("dragover",(function(e){e.preventDefault();var t=$(".dropzone");var a;var n=window.dropZoneTimeout;if(!n){t.addClass("dragin")}else{clearTimeout(n)}var i=false;var r=e.target;do{if($(r).hasClass("draghoverable")){i=true;a=$(r);break}r=r.parentNode}while(r!==null);t.removeClass("dragin draghover");if(i){a.addClass("draghover")}}));$(document).bind("drop",(function(e){e.preventDefault();$(".draghoverable").removeClass("draghover")}))}));

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists