function DeleteImage(AccountID, UID, ID, IsConfirm, ComponentName, ElemID, IsDragging, FileName) { var result; if (ID > 0){confmsg = 'هل بالتأكيد تريد حذف هذه الصورة؟'}else{confmsg = 'هل بالتأكيد تريد حذف جميع الصور؟'} if ((IsConfirm != 'true') && (IsConfirm != 'false')) {IsConfirm = true}; if (IsConfirm == 'true') {result = confirm(confmsg)}else{result = true}; if (result) { var imgloc = "//galileosm.galileosolutions.net/galileosm/scripts/photos/delete_image.asp?t=" + AccountID + "&UID=" + UID + "&ID=" + ID + "&CompName=" + ComponentName + "&FileName=" + FileName //alert(imgloc); //return false; delimg = new Image(); delimg.src=imgloc; var d = document.getElementById(ElemID); //td.innerHTML = ''; if(ID > 0){d.style.display = 'none'}else{d.innerHTML = '';d.style.height = 0;document.getElementById("mainimghint").style.display = 'none';document.getElementById('delAllimgButton').style.display = 'none'} //d.style.display = 'none'; if (IsDragging == 'true') { d.parentNode.removeChild(d); //d.style.visibility = "hidden"; //d = null; //alert(d.id); DeleteImageAction = document.getElementById('DeleteImageAction'); //Detect Form Changes if (DeleteImageAction != null){DeleteImageAction.value='true';}; $('.container').shapeshift(); //ReArrange Images after upload MainImageTitle(); //grid.show(true); //grid.hide([d], {instant: false}); //grid.remove([d], {removeElements: true}); //grid.getItems().forEach(function (item, i) { // item.getElement().setAttribute('data-id', i + 1); //item.getElement().querySelector('.card-id').innerHTML = i + 1; //}); //grid.refreshItems(); //grid.refreshSortData().layout(); //grid.synchronize(); //grid.layout(true); //grid = new Muuri('.drag'); //alert(item.isVisible(d)); } } } function RotateImage(AccountID, AdUID, AdPhotoID, ComponentName, FileName) { var http = new XMLHttpRequest(); http.open("POST", "//galileosm.galileosolutions.net/galileosm/scripts/photos/rotate_image.asp", true); http.setRequestHeader("Content-type","application/x-www-form-urlencoded"); var params = "t="+AccountID+"&AdUID="+AdUID+"&AdPhotoID="+AdPhotoID+"&CompName="+ComponentName+"&FileName="+FileName; //console.log(params); http.send(params); http.onload = function() { var container = document.getElementById("PhotoID_"+AdPhotoID); var content = container.src+'?'+Date.now(); container.src= content; } } function ArrangeImage(AccountID,ListingUID,ComponentName){ if (document.getElementById('ThumbContainer') != null) { PhotosOrder = getPhotoOrder(document.getElementById("ThumbContainer"), true); //console.log(PhotosOrder); PostArrangeImage(AccountID, ListingUID, ComponentName, PhotosOrder); } } function getPhotoOrder(parent, getChildrensChildren){ var PhotosOrder = ""; var children = parent.childNodes.length; for(var i=0; i < children; i++){ if(parent.childNodes[i].nodeType != 3){ PhotoFileName = parent.childNodes[i].getAttribute('data-src'); if(PhotoFileName != null && PhotoFileName != ''){ PhotosOrder = PhotosOrder + PhotoFileName+',' } } } return PhotosOrder; } function PostArrangeImage(AccountID, ListingUID, ComponentName, PhotosFileName) { var http = new XMLHttpRequest(); http.open("POST", "//galileosm.galileosolutions.net/galileosm/scripts/photos/arrange_image.asp", true); http.setRequestHeader("Content-type","application/x-www-form-urlencoded"); var params = "t="+AccountID+"&ListingUID="+ListingUID+"&CompName="+ComponentName+"&FileName="+PhotosFileName; //console.log(params); http.send(params); //http.onload = function() { //var container = document.getElementById("PhotoID_"+AdPhotoID); //var content = container.src+'?'+Date.now(); //container.src= content; //} } function MainImage(AccountID, AdUID, AdPhotoID) { var imgloc = "//galileosm.galileosolutions.net/galileosm/realestate/photo_make_main.asp?t=" + AccountID + "&AdUID=" + AdUID + "&AdPhotoID=" + AdPhotoID delimg = new Image(); delimg.src=imgloc; var d = document.getElementById("ThumbID_"+AdPhotoID); //td.innerHTML = ''; d.style.borderColor = 'red'; } function MainImageTitle() { var ThumbContainer = document.getElementById("ThumbContainer") var delAllimgButton = document.getElementById('delAllimgButton'); var mainimghint = document.getElementById("mainimghint"); if (ThumbContainer.childNodes.length != 0 && mainimghint != null){ var MainImg = ThumbContainer.childNodes[0]; mainimghint.style.display = ""; mainimghint.style.left = MainImg.offsetLeft + 7 + "px"; if (delAllimgButton != null){delAllimgButton.style.display = ''}; //alert(MainImg.offsetLeft); //console.log(MainImg.offsetLeft); } else { if (mainimghint != null){mainimghint.style.display = 'none'}; if (delAllimgButton != null){delAllimgButton.style.display ='none'}; } //if (delAllimgButton != null){delAllimgButton.style.display =''}; } function BigImage(PhotoUrl) { //PhotoUrl = decodeURIComponent(PhotoUrl); PhotoUrl = PhotoUrl.replace('_th.','.'); //window.open(PhotoUrl,'_blank','width=500,height=375,resizable,scrollbars=yes'); var x; var newTab = window.open(x,'_blank','width=500,height=375,resizable,scrollbars=yes'); newTab.document.body.innerHTML = '' } var ImageInputID = document.getElementById('PhotoURL01'); if (ImageInputID != null) {ImageInputID.addEventListener('change', checkFile, false)}; function checkFile(e) { /// get list of files var file_list = e.target.files; /// go through the list of files for (var i = 0, file; file = file_list[i]; i++) { var sFileName = file.name; var sFileExtension = sFileName.split('.')[sFileName.split('.').length - 1].toLowerCase(); var iFileSize = file.size; var iConvert = (file.size / 20000000).toFixed(2); /// OR together the accepted extensions and NOT it. Then OR the size cond. /// It's easier to see this way, but just a suggestion - no requirement. if (!(sFileExtension === "png" || sFileExtension === "gif" || sFileExtension === "webp" || sFileExtension === "jpeg" || sFileExtension === "jfif" || sFileExtension === "avif" || sFileExtension === "jpg") || iFileSize > 20000000) { /// 20 mb //txt = "File type : " + sFileExtension + "\n\n"; //txt += "Size: " + iConvert + " MB \n\n"; txt = "\n\n بعض الصور لم يتم تحميلها، من فضلك تأكد أن الصورة من نوع png أو jpg أو jpeg أو gif أو jfif وأن حجم الصورة ليس أكثر من 10 ميجابايت\n\n"; //txt = "Please make sure your file is in pdf or doc format and less than 10 MB.\n\n"; alert(txt); return false; } } document.getElementById('SubmitUpload').click(); UploadImage = document.getElementById('UploadImage'); divPos = UploadImage.offsetTop; window.scrollTo(0, divPos-120); UploadImage.style.display = 'none'; document.getElementById('laodingImage').style.display = 'block'; } function preview_image(event, ImgID) { var reader = new FileReader(); reader.onload = function() { var output = document.getElementById(ImgID); output.style.display = 'inline-block'; output.src = reader.result; } //for (let i = 0; i < event.target.files.length; i++) { //text += cars[i] + "
"; //alert() //} reader.readAsDataURL(event.target.files[0]); } function previewFiles(contID) { const preview = document.getElementById(contID); const files = document.querySelector("input[type=file]").files; //var div = document.createElement('div'); function readAndPreview(file) { // Make sure `file.name` matches our extensions criteria if (/\.(jpe?g|png|gif)$/i.test(file.name)) { const reader = new FileReader(); //alert('dfdf'); //div = document.createElement('div'); reader.addEventListener( "load", () => { const div = document.createElement('div'); const image = new Image(); image.height = 100; image.title = file.name; image.src = reader.result; preview.appendChild(div); div.appendChild(image); }, false, ); reader.readAsDataURL(file); } } if (files) { Array.prototype.forEach.call(files, readAndPreview); } } //const picker = document.querySelector("#browse"); //picker.addEventListener("change", previewFiles);