1/** 2 * Front-end: sura/language change, prev/next, lazy-load verses, URL sync. 3 */ 4jQuery(document).ready(function($) { 5 var qtmLazyLoading = false; 6 7 function qtmInitLazyVerses() { 8 var $wrapper = $('#result').find('#quran_verses_wrapper'); 9 if (!$wrapper.length) return; 10 var totalAyas = parseInt($wrapper.data('total-ayas'), 10); 11 var chunkSize = parseInt($wrapper.data('chunk-size'), 10) || 20; 12 if (totalAyas <= chunkSize) return; 13 14 function tryLoadMore() { 15 if (qtmLazyLoading) return; 16 var $w = $('#result').find('#quran_verses_wrapper'); 17 if (!$w.length) return; 18 var loaded = $w.children('.aya').length; 19 var total = parseInt($w.data('total-ayas'), 10); 20 if (loaded >= total) return; 21 var sura = $w.data('sura'); 22 var lang = $w.data('lang') || ''; 23 var fromAya = loaded + 1; 24 var toAya = Math.min(loaded + chunkSize, total); 25 var ajaxUrl = (typeof qtm_ajax !== 'undefined' && qtm_ajax.url) ? qtm_ajax.url : ajaxurl; 26 var nonce = (typeof qtm_ajax !== 'undefined' && qtm_ajax.verses_nonce) ? qtm_ajax.verses_nonce : ''; 27 qtmLazyLoading = true; 28 jQuery.post(ajaxUrl, { 29 action: 'qtm_load_verses_chunk', 30 nonce: nonce, 31 sura: sura, 32 lang: lang, 33 from_aya: fromAya, 34 to_aya: toAya 35 }, function(response) { 36 qtmLazyLoading = false; 37 if (response && response.length) { 38 $w.append(response); 39 } 40 }).fail(function() { 41 qtmLazyLoading = false; 42 }); 43 } 44 45 function onScroll() { 46 var $w = $('#result').find('#quran_verses_wrapper'); 47 if (!$w.length) return; 48 var loaded = $w.children('.aya').length; 49 var total = parseInt($w.data('total-ayas'), 10); 50 if (loaded >= total) return; 51 var bottom = $w.offset().top + $w.outerHeight(); 52 var viewBottom = (window.pageYOffset || document.documentElement.scrollTop) + (window.innerHeight || document.documentElement.clientHeight); 53 if (viewBottom >= bottom - 400) { 54 tryLoadMore(); 55 } 56 } 57 58 $(window).off('scroll.qtmLazy').on('scroll.qtmLazy', function() { 59 onScroll(); 60 }); 61 onScroll(); 62 } 63 64 $.urlParam = function(name) { 65 var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href); 66 if (results == null) { 67 return null; 68 } 69 else { 70 return results[1] || 0; 71 } 72 73 }; 74 75 function getParameterByName(name, url) { 76 if (!url) url = window.location.href; 77 name = name.replace(/[\[\]]/g, "\\$&"); 78 var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"); 79 results = regex.exec(url); 80 if (!results) return null; 81 if (!results[2]) return ''; 82 return decodeURIComponent(results[2].replace(/\+/g, " ")); 83 } 84 85 $('#change_sura').change(function() { 86 $.each($('audio'), function () { 87 this.pause(); 88 this.currentTime = 0; 89 }); 90 var clickBtnValue = $(this).val(); 91 var paramsLang = getParameterByName('lang'); 92 history.pushState({ path: this.path }, '', ''+clickBtnValue+'&lang='+paramsLang+''); 93 var sura = clickBtnValue.match( /\d+/ ); 94 95 jQuery.post( 96 ajaxurl, 97 { 98 'action': 'qtm_changesura', 99 'sura': clickBtnValue, 100 'lang': paramsLang 101 }, 102 function(response){ 103 104 $('#result').html(response); 105 qtmInitLazyVerses(); 106 } 107 ); 108 109 }); 110/*************************************************CHANGE LANGUAGE*****************************************************/ 111 $('#select_language').change(function(){ 112 113 var paramsSura = getParameterByName('sourate'); 114 var clickBtnValue = $(this).val(); 115 var sura = paramsSura.match( /\d+/ ); 116 history.pushState({ path: this.path }, '', '?sourate='+paramsSura+'&lang='+clickBtnValue+''); 117 118 jQuery.post( 119 ajaxurl, 120 { 121 'action': 'qtm_changelanguage',
122 'lang': clickBtnValue, 123 'paramsSura': paramsSura 124 }, 125 function(response){ 126 $('#result').html(response); 127 qtmInitLazyVerses(); 128 } 129 ); 130 131 }); 132/*************************************************BUTTON PREVIOUS SURA**********************************************************************/ 133 $("body").on("click","#PrevSourate", function(){ 134 135 var sourate = $.urlParam('sourate'); 136 137 var lang = $.urlParam('lang'); 138 139 var Nbrsourate = sourate.match( /\d+/ ); 140 141 var PrevSourate = Nbrsourate - 1; 142 143 var UrlPrevSourate = "?sourate="+PrevSourate+""; 144 145 if(Nbrsourate < 114 && Nbrsourate >= 2){ 146 147 history.pushState({ path: this.path }, '', ''+UrlPrevSourate+'&lang='+lang+''); 148 149 jQuery.post( 150 ajaxurl, 151 { 152 'action': 'qtm_changeprevsura', 153 'sura': PrevSourate, 154 'lang': lang 155 }, 156 function(response){ 157 $('#result').html(response); 158 qtmInitLazyVerses(); 159 } 160 ); 161 162 } 163 if(Nbrsourate == 1){$("#PrevSourate").hide();} 164 165 }); 166 167/*************************************************BUTTON NEXT SURA**********************************************************************/ 168 169 170 $("body").on("click","#NextSourate", function(){ 171 172 var sourate = $.urlParam('sourate'); 173 174 var lang = $.urlParam('lang'); 175 176 var Nbrsourate = sourate.match( /\d+/ ); 177 178 var NextSourate = parseInt(Nbrsourate) + 1; 179 180 var UrlNextSourate = "?sourate="+NextSourate+""; 181 182 if(Nbrsourate < 114 && Nbrsourate >= 1){ 183 184 history.pushState({ path: this.path }, '', ''+UrlNextSourate+'&lang='+lang+''); 185 186 187 jQuery.post( 188 ajaxurl, 189 { 190 'action': 'qtm_changenextsura', 191 'sura': NextSourate, 192 'lang': lang 193 }, 194 function(response){ 195 $('#result').html(response); 196 qtmInitLazyVerses(); 197 } 198 ); 199 200 } 201 if(Nbrsourate == 114){$("#NextSourate").hide();} 202 203 }); 204 205 qtmInitLazyVerses(); 206 207}); 208 209jQuery(function($) { 210 211 $("body").on("click","#click_params_kb", function(){ 212 213 $.each($('audio'), function () { 214 this.pause(); 215 this.currentTime = 0; 216 }); 217 218 $('.params_kb').css('height', 'auto'); 219 $('.params1_kb').hide(); 220 $('.params_download_kb').hide(); 221 $('#playeraya2').html(""); 222 $('#playeraya').html(""); 223 $('kb-select_text').prop('selectedIndex',0); 224 $('#select_name_recitator').prop('selectedIndex',0); 225 $('#kb-select_debut').prop('selectedIndex',0); 226 $('#kb-select_fin').prop('selectedIndex',0); 227 $('#play_select_quran').hide(); 228 $('#suraplayer').empty(); 229 230 $('.params_kb').toggle( "fast", function() { 231 $('#kb-select_text').prop( "disabled", true ); 232 $('#kb-select_debut').prop( "disabled", true ); 233 $('#kb-select_fin').prop( "disabled", true ); 234 }); 235 236 $('.quran').removeAttr("style"); 237 $('.trans').removeAttr("style"); 238 239 }); 240 241 $("body").on("click","#click_playsura_kb", function(){ 242 243 $.each($('audio'), function () { 244 this.pause(); 245 this.currentTime = 0; 246 }); 247 $('.aya').css('display', 'block'); 248 $('#playeraya2').html(""); 249 $('.params1_kb').toggle('fast'); 250 251 $('.params1_kb').css('height', 'auto'); 252 253 $('#playeraya').html(""); 254 255 $('.params_kb').hide(); 256 $('.params_download_kb').hide(); 257 $('.quran').removeAttr("style"); 258 $('.trans').removeAttr("style"); 259 260 }); 261 262 $("body").on("click","#click_download_kb", function(){ 263 264 $.each($('audio'), function () { 265 this.pause(); 266 this.currentTime = 0; 267 }); 268 $('.params_download_kb').toggle('fast'); 269 $('#name_recitator').show(); 270 $('.params1_kb').hide(); 271 $('.params_kb').hide(); 272 }); });
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.