console.error("smartSearch"); if (typeof smartSearch_scriptLoaded === 'undefined') { $(document).ready(function(){ $(document).on("input",".filterList",function(){ var input = $(this); var filterValue; if (input.attr('type') == 'number') { filterValue = parseInt(input.val()); } else { filterValue = input.val(); } var target = input.parents(".stSmallList").find(".stSmallListItem"); target.each(function() { var search = $(this).attr("data-search"); console.log("search:"); console.log(search); console.log("filterValue:"); console.log(filterValue); if (input.attr('type') == 'number') { console.warn("number"); if ((!filterValue) || search == filterValue) { $(this).show(); } else { $(this).hide(); } }else{ var regv = regExp_all_match(filterValue); //console.warn(regv); var ma = search.match(regv); if((!filterValue) || ma !=null){ $(this).show(); }else{ $(this).hide(); } } }); }); $(document).on("submit", ".smartSearchForm", function() { event.preventDefault(); var qForm = $(this); var sin = qForm.attr("data-sin"); var smartTabContent = qForm.closest(".smartTabContent"); var listItemsContainer = smartTabContent.find('.stSmallListItems'); var smartSearchInput = smartTabContent.find('.smartSearchInput'); $(".smartSearchSeeMore").remove(); var searchValue = smartSearchInput.val(); smartSearchInput.attr("data-last-q",searchValue); console.log('تم البحث عن: ' + searchValue); if(searchValue){ smartTabContent.find(".searchIntro").hide(); smartTabContent.find(".searchLoading").show(); smartSearchInput.prop("disabled", true); listItemsContainer.find(".json_search").remove(); deep = 0; listItemsContainer.find(".smallTitle").remove();deepSearchNum = 0; json_search(searchValue,0,sin,smartTabContent); }else{ smartTabContent.find(".searchIntro").show(); } deep = 0; numberOfSearchItems = 0; }); $(document).on("input", ".inputArabic", function() { var inputValue = $(this).val(); // تعبير منتظم لفحص إذا كانت الحروف هي حروف عربية var arabicLettersRegex = /[\u0600-\u06FF]/; // التحقق من أن الحروف هي حروف عربية if (!arabicLettersRegex.test(inputValue)) { // إذا كانت الحروف ليست حروف عربية، يتم حذفها $(this).val(inputValue.replace(/[^ء-ي]/g, '')); } }); $(document).on("input", ".smartSearchInput", function() { // قيمة الحقل var inputValue = $(this).val(); var lastValue = $(this).attr("data-last-q"); if(inputValue != lastValue){ $(".searchError").hide(); console.log("remove all res"); if(inputValue){ }else{ $(".searchIntro").show(); } deep = 0; numberOfSearchItems = 0; } }); $(document).on("click", ".smartSearchSeeMore", function() { console.warn("'); smartTabContent.find(".searchLoading").hide(); smartTabContent.find(".smartSearchInput").prop("disabled", false); } }else{ smartTabContent.find(".searchLoading").hide(); smartTabContent.find(".smartSearchInput").prop("disabled", false); $(".smartSearchSeeMore").remove(); } if((deep ==maxSearchs) && (numberOfSearchItems == 0)){ smartTabContent.find(".searchError .errorQ").html(searchValue); smartTabContent.find(".searchError").show(); }else{ smartTabContent.find(".searchError").hide(); } }, error: function(error){console.error('حدث خطأ:', error);} }); } function addSearchItem(item,smartTabContent){ var listItemsContainer = smartTabContent.find('.stSmallListItems'); if(item.sin == "quran"){ var aHref = "/quran/page/"+item.quran_aya_pagenumber; var aHtml = '
\ صـ '+item.pagenumber+' \ '+item.juzName+' \ '+item.suraName+' '+item.ayanumber+' \
\
\ ﴿'+item.highlight+' '; var newListItem = $('').addClass('stSmallListItem json_search').attr('href', aHref).html(aHtml); } if((item.sin == "all")||(item.sin == "event")||(item.sin == "book")||(item.sin == "dar")){ if(!item.n){item.n = " ";} if(!item.d){item.d = " ";} if(!item.a){item.a = " ";} var aHref = item.url; var itImg = ""; var itImgCover = ""; if(item.img){ var itImg = ''; } if(item.cover){ var itImgCover = '
'; } var aHtml = '\ '+itImgCover+'\
'+itImg+'\
\
\ '+item.d+' \ '+item.a+' \ '+item.name+' '+item.n+' \
\
\ '+item.info+'\
'; var newListItem = $('
').addClass('stSmallListItem json_search').attr('href', aHref).html(aHtml); } if(item.sin == "author"){ if(!item.n){item.n = " ";} if(!item.d){item.d = " ";} if(!item.a){item.a = " ";} var aHref = item.url; var itImg = ""; var itImgCover = ""; if(item.img){ var itImg = ''; } if(item.cover){ var itImgCover = '
'; } var aHtml = '\ '+itImgCover+'\
'+itImg+'\
\
\ '+item.d+' \ '+item.a+' \ '+item.name+' '+item.n+' \
\
\ '+item.info+'\
'; var newListItem = $('
').addClass('stSmallListItem json_search').attr('href', aHref).html(aHtml); } if(item.sin == "user"){ if(!item.n){item.n = " ";} if(!item.d){item.d = " ";} if(!item.a){item.a = " ";} if(!item.info){item.info = " ";} var aHref = item.url; var itImg = ""; var itImgCover = ""; if(item.img){ var itImg = ''; } if(item.cover){ var itImgCover = '
'; } var aHtml = '\ '+itImgCover+'\
'+itImg+'\
\
\ \ '+item.d+' \ '+item.a+' \ '+item.name+' '+item.n+' \
\
\ '+item.info+'\
'; var newListItem = $('
').addClass('stSmallListItem json_search').attr('href', aHref).html(aHtml); } if(item.sin == "link"){ if(!item.imgIcon){item.imgIcon = " ";} if(!item.d){item.d = " ";} if(!item.a){item.a = " ";} var aHref = item.url; var itImg = ""; if(item.img){ var itImg = ''; } var aHtml = '\
'+itImg+'\
\
\ '+item.imgIcon+' \ '+item.a+' \ '+item.name+' '+' \
\
\ '+item.info+'\
'; var newListItem = $('
').addClass('stSmallListItem json_search').attr('href', aHref).html(aHtml); } newListItem.attr("data-tbid",item.tbid); newListItem.attr("data-tbids", item.tbids ? item.tbids : ""); var sinTb = item.tbid.split(":")[0]; newListItem.attr("data-tbidname",item[sinTb+"_name"]); listItemsContainer.append(newListItem); } function centerListItem(tab, delay = 1000) { setTimeout(function() { var thiss = $("." + tab + " " + ".stSmallListItem.active"); var container = thiss.closest(".stSmallListItems"); var containerHeight = container.height(); var totalHeight = containerHeight; var zOom = thiss.css("zoom"); console.log("zOom"); console.log(zOom); console.log("totalHeight"); console.log(totalHeight); var thisTop = 0; var activeDone = false; container.find(".stSmallListItem").each(function() { totalHeight += $(this).outerHeight(true); if($(this).hasClass("active")){ activeDone = true; } if(activeDone === false){ thisTop += $(this).outerHeight(true); } }); console.log("thisTop"); console.log(thisTop); var scrollValue = (thisTop - ( containerHeight / 2 ) + (thiss.outerHeight(true))); if(zOom){ scrollValue = scrollValue * zOom; scrollValue = scrollValue + ((containerHeight / 6 ) * zOom); } console.log("scrollValue"); console.log(scrollValue); if ( scrollValue !== 0 ) { container.animate({ scrollTop: scrollValue }, 300, function() { var nextElement = thiss.attr('data-next'); if (nextElement) { centerListItem($(nextElement), delay); } }); } }, delay); } var smartSearch_scriptLoaded = true; }