const swalWithBootstrapButtons = Swal.mixin({ customClass: { confirmButton: 'btn btn-primary', cancelButton: 'btn btn-danger' }, buttonsStyling: false }) const Toast = Swal.mixin({ toast: true, position: 'top-end', showConfirmButton: false, timer: 2000, timerProgressBar: true, onOpen: (toast) => { toast.addEventListener('mouseenter', Swal.stopTimer) toast.addEventListener('mouseleave', Swal.resumeTimer) } }); // Show Hide Password function showhidepassword(element) { $(element).toggleClass("mdi-eye-outline mdi-eye-off-outline"); var input = $($(element).attr("toggle")); if (input.attr("type") == "password") { input.attr("type", "text"); } else { input.attr("type", "password"); } } //LOGIN function signin(){ Swal.fire({ // position: 'top-end', icon: '', html: '
no result

جاري التحميل..

', //imageUrl:'https://tamwil.ma/theme/images/tamwil/loader.svg', imageWidth:100, imageHeight:100, showConfirmButton: false, // timer: 2000 }); $.post("https://tamwil.ma/user/signin", { email: $('#signinemail').val(), password: $('#signinpwd').val(), remember:$('#rememberme').val() }, function(data, status){ if(data.status=='success'){ location.reload(); }else{ Swal.fire({ // position: 'top-end', icon: '', text: data.message, imageUrl:'https://tamwil.ma/theme/images/tamwil/error.svg', imageWidth:100, imageHeight:100, showConfirmButton: false, timer: 2000 }); } }); return false; } //Password RESET function pwdreset(){ Swal.fire({ icon: '', text: 'جاري التحميل..', imageUrl:'https://tamwil.ma/theme/images/tamwil/loader.svg', imageWidth:100, imageHeight:100, showConfirmButton: false, // timer: 2000 }); $.post("https://tamwil.ma/user/request", { credit_email: $('#resetpwdemail').val(), }, function(data, status){ Swal.fire({ icon: (data.status=='success')?data.status:'', text: data.message, imageUrl:(data.status=='error')?'https://tamwil.ma/theme/images/tamwil/error.svg':'', imageWidth:100, imageHeight:100, showConfirmButton: false, timer: 2000 }).then( function() { if(data.status=='success') window.location.href = "https://tamwil.ma"; } ); }); return false; } //compare dates function timeBetweenDates(toDate, element) { var dateEntered = toDate; var now = new Date(); var difference = dateEntered.getTime() - now.getTime(); if (difference <= 0) { // Timer done clearInterval(timer); } else { var seconds = Math.floor(difference / 1000); var minutes = Math.floor(seconds / 60); var hours = Math.floor(minutes / 60); var days = Math.floor(hours / 24); hours %= 24; minutes %= 60; seconds %= 60; $(element).html(''+days+' يوم '+ ''+hours+' س '+ ''+minutes+' د '+ ''+seconds+' ث '); } } $( document ).ready(function() { $('.popup-link').magnificPopup({ type: 'image', tClose: 'Fermer (Esc)', // Alt text on close button tLoading: 'جاري التحميل..', verticalFit: true, image: { tError: 'core.the_image core.could_not_be_loaded', } }); $('.countdown').each( function(index, element){ var compareDate = new Date($( element ).attr('target-date')); //compareDate.setDate(new Date($( element ).attr('target-date'))); var timer; timer = setInterval(function() { timeBetweenDates(compareDate, element); }, 1000); }); //select2 $(".select2").select2( { dir: "rtl", language: "ar" } ); $('.dragoff').on('dragstart', function(event) { event.preventDefault(); }); //var slider = new BeerSlider( document.getElementById( "beforeafter" ) ); }); //load more function loadmore(element){ $(element).addClass('load-more--loading'); var page=$(element).attr('data-page'); var pages=$(element).attr('data-pages'); var limit=$(element).attr('data-limit'); var url="https://tamwil.ma/"+$(element).attr('data-url')+"&page="+(parseInt(page)+1); if(page==pages){ setTimeout(function(e){ $('.load-more--loading').removeClass('load-more--loading'); $(element).remove(); }, 200); } $.post(url, {}, function(data, status){ if(data.status=='success'){ if(data.count>0){ $('#'+$(element).attr('data-target')).append(data.data); feather.replace(); $(element).attr('data-page', parseInt(page)+1); if(data.count تأكيد', cancelButtonText: ' إلغاء', }).then((result) => { if (result.isConfirmed) { description=$('#'+$(element).attr('data-src')).val(); val=$(element).attr('data-id'); url="https://tamwil.ma/notification/desmiss/"+val; $.post(url, { }, function(data, status){ Swal.fire({ icon: data.status, toast: true, position: 'top-end', showConfirmButton: false, html:data.message, timer: 1000, }); if(data.status=='success'){ var count = $("#notificationslist").children().length; $('#'+$(element).attr('data-target')).remove(); if(count==1){ var html='
'+ '
'+ '

لا يوجد أي إشعار !

'+ '

زوروا هذه الصفحة من وقت لآخر حتى يتسنى لكم معرفة آخر الإشعارات المتعلقة بتحديثات محتوى منصة تمويل وكذالك تلك المتعلقة بنشاطكم داخل المنصة.

'+ '
'+ '
'; $("#notificationslist").append(html); } } }); } }) } //password strengh function pwdstrength (element, password){ var desc = [{'width':'0px'}, {'width':'20%'}, {'width':'40%'}, {'width':'60%'}, {'width':'80%'}, {'width':'100%'}]; var descClass = ['', 'bg-danger', 'bg-warning', 'bg-primary', 'bg-success', 'bg-success']; var score = 0; if(password.length > 3){ score++; } if (password.match(/[a-z]/)){ score++; } if(password.match(/[A-Z]/)){ score++; } if(password.match(/.[!,@,#,$,%,^,&,*,?,_,~,-,(,)]/)){ score++; } if (password.length > 5){ score++; } element.removeClass( descClass[score-1] ).addClass( descClass[score] ).css( desc[score] ); } $(document).ready( function () { $('#edpwd').keyup(function() { pwdstrength($('#pwdprogressbar'), $(this).val()); }); $(document).on('click', '#edshowpassword', function(){ $('#edpwd').attr('type',this.checked?'text':'password'); $('#edpassword_confirmation').attr('type',this.checked?'text':'password'); $('#edactual_password').attr('type',this.checked?'text':'password'); }); }); function saveUserinfos(type='', value=''){ if(type!='' && value!=''){ url="https://tamwil.ma/user/saveinfos/"+type; $.post(url, { data:value }, function(data, status){ Swal.fire({ icon: data.status, toast: true, position: 'top-end', showConfirmButton: false, html:data.message, timer: 1000, }); }); }else{ Swal.fire({ icon: 'error', toast: true, position: 'top-end', showConfirmButton: false, html:"خانة ضرورية", timer: 1000, }); } } // change password function resetPasswordp(){ var actualp=$('#edactual_password').val(); var pwd=$('#edpwd').val(); var cpwd=$('#edpassword_confirmation').val(); msg=''; if(actualp=='')msg=msg+"خانة كلمة المرور الحالية إجبارية
"; if(pwd=='')msg=msg+"خانة كلمة المرور الجديدة إجبارية
"; if(cpwd=='' || cpwd!=pwd)msg=msg+"خطأ في كلمة المرور أو في قيمة خانة تأكيد كلمة المرور"; if(msg!=''){ Swal.fire({ title: "خطأ", html:msg, imageUrl:"https://tamwil.ma/theme/images/tamwil/success.svg", imageWidth:120, imageHeight:120, allowOutsideClick:false, showCancelButton: false, confirmButtonColor: '#cddc39', confirmButtonText: " حسنا", }); return false; } Swal.fire({ title: 'تأكيد تغيير كلمة المرور', imageUrl:'https://tamwil.ma/theme/images/tamwil/success.svg', imageWidth:120, imageHeight:120, allowOutsideClick:false, showCancelButton: true, confirmButtonColor: '#cddc39', cancelButtonColor: '#f44336', confirmButtonText: ' تأكيد', cancelButtonText: ' إلغاء', }).then((result) => { if (result.value) { var url="https://tamwil.ma/user/editpassword"; $.post(url, { password:pwd, password_confirmation:cpwd, actual_password:actualp }, function(data, status){ Swal.fire({ icon: data.status, toast: true, position: 'top-end', showConfirmButton: false, html:data.message, timer: 1000, }); if(data.status=='success'){ setTimeout(function(){ location.reload(); },1000); } }); } }); } //cookies //All the cookie setting stuff function SetCookie(cookieName, cookieValue, nDays) { "use strict"; var today = new Date(); var expire = new Date(); if (nDays == null || nDays == 0) nDays = 1; expire.setTime(today.getTime() + 3600000 * 24 * nDays); document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString() + "; path=/"; } function ReadCookie(cookieName) { "use strict"; var theCookie = " " + document.cookie; var ind = theCookie.indexOf(" " + cookieName + "="); if (ind == -1) ind = theCookie.indexOf(";" + cookieName + "="); if (ind == -1 || cookieName == "") return ""; var ind1 = theCookie.indexOf(";", ind + 1); if (ind1 == -1) ind1 = theCookie.length; return unescape(theCookie.substring(ind + cookieName.length + 2, ind1)); } function DeleteCookie(cookieName) { "use strict"; var today = new Date(); var expire = new Date() - 30; expire.setTime(today.getTime() - 3600000 * 24 * 90); document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" + expire.toGMTString(); } function AcceptCookies() { SetCookie('sgCookies', true, 30); jQuery("#cookie-bar").hide(); } function addFav(id, type, elm=$('#favBtn'), elmm=$('#favobtn')){ var pg=""; var url="https://tamwil.ma/user/addfav/"+id+"/"+type; $.post(url, {}, function(data, status){ if(data.status=='success'){ if(data.operation=='deleted'){ elm.html(''+data.count); elmm.html(' أضف إلى المفضلة'); elmm.removeClass('btn-success').addClass('btn-secondary'); if(pg=="layouts.tamwil.template.favouris"){ setTimeout(function(){ location.reload(); },500); } }else{ elmm.html(' مفضل'); elmm.removeClass('btn-secondary').addClass('btn-success'); elm.html(''+data.count); } } } ); } $(document).ready(function (e) { var toTop = $("").appendTo("body"); if (!ReadCookie("sgCookies")) { //If the cookie has not been set jQuery("#cookie-bar").show(); } else { jQuery("#cookie-bar").hide(); } $("body").css("-webkit-user-select","none"); $("body").css("-moz-user-select","none"); $("body").css("-ms-user-select","none"); $("body").css("-o-user-select","none"); $("body").css("user-select","none"); if ( document.getElementById('sharebtn') != null) { shareButton= document.getElementById('sharebtn'); shareButton.addEventListener('click', event => { if (navigator.share) { navigator.share({ title: document.getElementsByTagName("title")[0].innerHTML, url: window.location.href }).then(() => { console.log('Thanks for sharing!'); }) .catch(console.error); return false; } else { // fallback } }); if(navigator.share !== undefined){ shareButton.innerHTML=' شارك هذا المحتوى'; }else{ new needShareDropdown(document.getElementById('sharebtn'), { shareButtonClass: false, iconStyle: 'default', boxForm: 'horizontal', position: 'bottomCenter', buttonText: ' شارك هذا المحتوى', protocol: ['http', 'https'].indexOf(window.location.href.split(':')[0]) === -1 ? 'https://' : '//', url: window.location.href, //title: root.getTitle(), //image: root.getImage(), //description: root.getDescription(), networks: 'Mailto,Twitter,Facebook,GooglePlus,Linkedin,GoogleBookmarks' }); } } // feather icons feather.replace(); //count down $('[data-countdown]').each(function() { var $this = $(this), finalDate = $(this).data('countdown'); $this.countdown(finalDate, function(event) { var $this = $(this).html(event.strftime('' + '
%D يوم
' + '
%H ساعة
' + '
%M دقيقة
' + '
%S ثانية
' )); }); }); /* var player = videojs('contentvideo'); var lastScrollTop = $('#contentvideo').position().top; $(window).scroll(function() { var scroll = $(this).scrollTop(); player.ready(function() { if ( scroll > $('#vidp').position().top+600 && !player.paused() && !player.isInPictureInPicture() ) { player.requestPictureInPicture().catch((e)=> { //console.log(e) }) } if (scroll <= $('#vidp').position().top+600 && player.isInPictureInPicture()) { player.exitPictureInPicture(); } });*/ /*if ( scroll > $('#vidp').position().top+600 && !player.paused() && !player.isInPictureInPicture() ) { player.controls(false); $('#vjs-pip-container').addClass('stikyplayer').attr('disabled',true); } if (scroll <= $('#vidp').position().top+600 ) { player.controls(true); $('#vjs-pip-container').removeClass('stikyplayer'); }*/ // Back to normal video player if user scrolls top to the actual video player //}); /* Audio Player */ var mouseovertimer, audiostatus = 'off', playerControls = ".player-controls"; $(document).on('mouseenter', playerControls, function() { var getaudio =$('#'+$(this).attr('data-audio'))[0]; if (!mouseovertimer) { mouseovertimer = window.setTimeout(function() { mouseovertimer = null; if (!$(playerControls).hasClass("playing")) { getaudio.load(); getaudio.play(); $(playerControls).addClass('playing'); return false; } }, 2500); } }); $(document).on('mouseleave', playerControls, function() { if (mouseovertimer) { window.clearTimeout(mouseovertimer); mouseovertimer = null; } }); $(document).on('click touch', playerControls, function(e) { e.preventDefault(); var getaudio =$('#'+$(this).attr('data-audio'))[0]; console.log(getaudio); if (!$(this).hasClass("playing")) { if (audiostatus == 'off') { $(this).addClass('playing'); getaudio.load(); getaudio.play(); window.clearTimeout(mouseovertimer); audiostatus = 'on'; return false; } else if (audiostatus == 'on') { $(this).addClass('playing'); getaudio.play(); } } else if ($(this).hasClass("playing")) { getaudio.pause(); $(this).removeClass('playing'); window.clearTimeout(mouseovertimer); audiostatus = 'on'; } return false; }); $('.audioplayer').on('ended', function() { var quiz=$(this).attr('data-quiz'); if(quiz!="" && quiz!=null) $('#'+quiz).show(300); $(playerControls).removeClass('playing'); audiostatus = 'off'; }); /*if(isNaN(getaudio.duration)){ return timeRemaining.textContent = '00:00'; }*/ const repeatBtn = $('.areplayBtn'); const muteBtn = $('.avolume'); const progressBar = $('.aprogressbar'); var getaudio=$('.audioplayer'); getaudio.on('timeupdate', timeupdate); repeatBtn.on('click', repeat); muteBtn.on('click', mute); progressBar.on('click', ProgressBarClick); getaudio.on('progress',buffered); function mute(e){ var getaudio =$('#'+$(this).attr('data-audio'))[0]; if(!getaudio.muted){ getaudio.muted = true; this.className = "text-danger badge badge-secondary"; this.innerHTML=""; } else{ getaudio.muted = false; this.className = "text-secondary badge badge-light"; this.innerHTML=""; } } function ProgressBarClick(e){ var getaudio =$('#'+$(this).attr('data-audio'))[0]; var playerContainer=$('#'+$(this).attr('data-progressbar'))[0]; var r = ((( playerContainer.getBoundingClientRect().right-e.pageX ) / playerContainer.getBoundingClientRect().width) * 100); getaudio.currentTime = getaudio.duration * r / 100; } function timeupdate() { const timeRemaining = $('#'+$(this).attr('data-time'))[0]; var getaudio=this; var progressbar=$('#'+$(this).attr('data-progressbar'))[0]; progressbar.style.width = ((getaudio.currentTime / getaudio.duration) * 100) + "%"; //timeRemaining.textContent = timer(); if(progressbar.style.width == '100%'){ // } var timeleft = Math.ceil(getaudio.duration - getaudio.currentTime); var m = Math.floor(timeleft / 60); var s = Math.floor(timeleft % 60); if(s < 10){ s = '0' + s; } timeRemaining.textContent = m +':'+ s; } function repeat(e){ var getaudio =$('#'+$(this).attr('data-audio'))[0]; if(!getaudio.loop){ getaudio.loop = true; this.className="text-secondary badge badge-secondary"; } else{ getaudio.loop = false; this.className="text-dark badge badge-light"; } } function buffered(){ var getaudio=$('#'+this.id)[0]; var progressbar=$('#'+$(this).attr('data-buffer'))[0]; var bufferedEnd = getaudio.buffered.end(getaudio.buffered.length - 1); progressbar.style.width = ((bufferedEnd / getaudio.duration)*100) + "%"; } function toggleQuiz(id){ $('#'+id).css('opacity',$('#'+id).css('opacity')==0?1:0); $('#'+id).css('height',$('#'+id).css('height')=='0px'?'auto':'0px'); } }); function getComboselect(id, target, prm, prt){ if(id=='') id=0; var url="https://tamwil.ma/utils/getcomboselect/"+id+"/"+prm+"/"+prt; $.post(url, {}, function(data, status){ if(data.status=='success'){ $('#'+target).attr('disabled',false); $('#'+target).html(data.data); }else{ $('#'+target).attr('disabled',true); } } ); } var finData; function searchFinancing(tform){ finData=$(tform ).serialize(); $('#searchResult').html('
no result

جاري التحميل..

'); var url="https://tamwil.ma/financing/search/results"; $.post(url, $(tform ).serialize(), function(data, status){ if(data.status=='success'){ $('#searchResult').html(data.data); }else{ } } ); } function getDispositifcontent(pparent,id='',hello=''){ if(hello!='') finData=null; console.log(finData); $('#searchResult').html('
no result

جاري التحميل..

'); if(id!=''){ var url="https://tamwil.ma/financing/search/results/"+pparent+"/"+id; }else{ var url="https://tamwil.ma/financing/search/results/"+pparent; } $.post(url, finData, function(data, status){ if(data.status=='success'){ $('#searchResult').html(data.data); }else{ } } ); } function savefinRequestwithDisp(id=''){ if(id=='') return false; Swal.fire({ html: "تأكيد الطلب", imageUrl:'https://tamwil.ma/theme/images/tamwil/success.svg', imageWidth:120, imageHeight:120, allowOutsideClick:false, showCancelButton: true, confirmButtonColor: '#cddc39', cancelButtonColor: '#f44336', confirmButtonText: ' تأكيد', cancelButtonText: ' إلغاء', }).then((result) => { if (result.value) { // send request var url="https://tamwil.ma/financing/saverequest/"+id; $.post(url, finData, function(data, status){ if(data.data=='login'){ window.location.replace("https://tamwil.ma/login"); window.href="https://tamwil.ma/login"; } if(data.status=='success'){ setTimeout(function(){ location.reload(); },2000); } Swal.fire({ icon: data.status, toast: true, position: 'top-end', showConfirmButton: false, html:data.message, timer: 2000, }); } ); } }); } function savefinRequest(tform){ Swal.fire({ html: "تأكيد الطلب", imageUrl:'https://tamwil.ma/theme/images/tamwil/success.svg', imageWidth:120, imageHeight:120, allowOutsideClick:false, showCancelButton: true, confirmButtonColor: '#cddc39', cancelButtonColor: '#f44336', confirmButtonText: ' تأكيد', cancelButtonText: ' إلغاء', }).then((result) => { if (result.value) { // send request var url="https://tamwil.ma/financing/saverequest"; $.post(url, $(tform ).serialize(), function(data, status){ if(data.status=='success'){ $(tform )[0].reset(); $('#pro_act').html(''); $('#pro_act').attr('disabled',true); location.reload(); }else{ if(data.data=='login'){ window.location.replace("https://tamwil.ma/login"); window.href="https://tamwil.ma/login"; } } Swal.fire({ icon: data.status, toast: true, position: 'top-end', showConfirmButton: false, html:data.message, timer: 2000, }); } ); } }); } function downloadfile(t,u,a){ $('#'+a).addClass('spinnerL'); var link = document.createElement("a"); link.download = ''; link.target="_blank"; link.href = "https://tamwil.ma/download/"+u+"/"+t; link.click(); $('#'+a).removeClass('spinnerL'); } function subscribeNl(tform){ var url="https://tamwil.ma/user/subscribenl"; $.post(url, $(tform ).serialize(), function(data, status){ if(data.status=='success'){ $(tform )[0].reset(); } Swal.fire({ icon: data.status, toast: true, position: 'top-end', showConfirmButton: false, html:data.message, timer: 2000, }); } ); } function sendContactform(tform){ var url="https://tamwil.ma/user/sendcontactform"; $.post(url, $(tform ).serialize(), function(data, status){ if(data.status=='success'){ $(tform)[0].reset(); } Swal.fire({ icon: data.status, toast: true, position: 'top-end', showConfirmButton: false, html:data.message, timer: 2000, }); } ); } function logOut(){ Swal.fire({ text: "هل تود فعلا تسجيل الخروج؟", imageUrl:'https://tamwil.ma/theme/images/tamwil/success.svg', imageWidth:120, imageHeight:120, allowOutsideClick:false, showCancelButton: true, confirmButtonColor: '#cddc39', cancelButtonColor: '#f44336', confirmButtonText: ' تأكيد', cancelButtonText: ' إلغاء', }).then((result) => { if (result.value) { window.location.replace("https://tamwil.ma/user/logout"); window.href="https://tamwil.ma/user/logout"; } }); } function toggleText(eleme, sign) { document.getElementById(eleme).classList.toggle("truncate"); } function deleteMessage(){ Swal.fire({ title: 'تأكيد', text: "هل تريدون فعلا حذف هذا العنصر؟", icon: 'warning', showCancelButton: true, confirmButtonColor: '#cddc39', cancelButtonColor: '#f44336', // confirmButtonText: ' تأكيد', cancelButtonText: ' إلغاء', confirmButtonText: ' نعم' }).then((result) => { if (result.isConfirmed) { $.ajax({ url: "https://tamwil.ma/user/messages/delete", type: "post", data: $('.checkMessage:checked').serialize(), success: function(data) { if(data=="success"){ location.reload(); }else{ Swal.fire({ // position: 'top-end', icon: '', text: data, imageUrl:'https://tamwil.ma/theme/images/tamwil/error.svg', imageWidth:100, imageHeight:100, showConfirmButton: false, timer: 2000 }); } } }); } }) } function sendMessage(){ Swal.fire({ title: 'تأكيد', text: "هل تودون فعلا تأكيد إرسال هذه الرسالة؟", icon: 'warning', showCancelButton: true, confirmButtonColor: '#cddc39', cancelButtonColor: '#f44336', confirmButtonText: ' تأكيد', cancelButtonText: ' إلغاء', }).then((result) => { if (result.isConfirmed) { $.ajax({ url: "https://tamwil.ma/user/messages/send", type: "post", data: $('#contactForm').serialize(), success: function(data) { if(data=="success"){ location.reload(); }else{ Swal.fire({ // position: 'top-end', icon: '', text: data, imageUrl:'https://tamwil.ma/theme/images/tamwil/error.svg', imageWidth:100, imageHeight:100, showConfirmButton: false, timer: 2000 }); } } }); } }) }