//* // * jsQari: JavaScript Quran Recitation widget // * http://www.qurantracker.com/jsQari // * // * Copyright (c) 2011 Ziad Mannan //* Dual licensed under the MIT and GPL licenses. //* - http://www.opensource.org/licenses/mit-license.php //* - http://www.gnu.org/copyleft/gpl.html //* //* Author: Ziad Mannan //* Version: 1.2.1 //* Date: 9th May 2012 //*/ var imgg = new Image(); var selected_ayah var JSQari = function () { this.jsqariPlayer = $("#jquery_jplayer_1"); this.jsqariBasmalahPlayed = false; this.jsqariSurah; this.jsqariAyah; this.jsqariReciter; this.jsqariMode; this.surahAyahs = [0, 7, 286, 200, 176, 120, 165, 206, 75, 129, 109, 123, 111, 43, 52, 99, 128, 111, 110, 98, 135, 112, 78, 118, 64, 77, 227, 93, 88, 69, 60, 34, 30, 73, 54, 45, 83, 182, 88, 75, 85, 54, 53, 89, 59, 37, 35, 38, 29, 18, 45, 60, 49, 62, 55, 78, 96, 29, 22, 24, 13, 14, 11, 11, 18, 12, 12, 30, 52, 52, 44, 28, 28, 20, 56, 40, 31, 50, 40, 46, 42, 29, 19, 36, 25, 22, 17, 19, 26, 30, 20, 15, 21, 11, 8, 8, 19, 5, 8, 8, 11, 11, 8, 3, 9, 5, 4, 7, 3, 6, 3, 5, 4, 5, 6]; this.uiSurahSelector = $('#jsqari-ui-surah-selector'); this.uiAyahSelector = $('#jsqari-ui-ayah-selector'); this.uiReciterSelector = $('#jsqari-ui-reciter-selector'); this.uiModeSelector = $('#jsqari-ui-mode-selector'); }; JSQari.prototype = { init: function () { var _this = this; this.jsqariSurah = this.uiSurahSelector.val(); this.jsqariAyah = this.uiAyahSelector.val(); this.jsqariReciter = this.uiReciterSelector.val(); this.jsqariMode = this.uiModeSelector.val(); this.jsqariBasmalahPlayed = true; this.jsqariPlayer.jPlayer({ // ready: function () // { // document.getElementById('3').src = 'Play.gif'; // $(_this.jsqariPlayer).jPlayer("setMedia", { // mp3: "http://www.server1.quran4u.net/abdelbasit_ayah/001001.mp3" // }); // }, ended: function () { _this.handleJSQariAyahEnd(); }, swfPath: "jsqari_new" }); // set up event handlers this.uiSurahSelector.change(function () { _this.jsqariSurah = $(this).val(); _this.handleSurahChange(); _this.setMediaFile(); }); this.uiAyahSelector.change(function () { _this.jsqariAyah = $(this).val(); _this.setBasmalahStatus(); _this.setMediaFile(); }); this.uiReciterSelector.change(function () { _this.jsqariReciter = $(this).val(); _this.setBasmalahStatus(); _this.setMediaFile(); }); this.uiModeSelector.change(function () { _this.jsqariMode = $(this).val(); _this.setBasmalahStatus(); _this.setMediaFile(); }); this.setMediaFile(); }, // CONTROLLER methods handleSurahChange: function () { ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // document.getElementById("Srurah_img").src = 'Surah_Name_Banner/' + this.pad(this.jsqariSurah,3) + '.jpg'; document.getElementById("Srurah_img").src = this.jsqariSurah + '.gif'; document.getElementById("frm_Man").src = "https://archive.org/download/Quran4u_Maany_Surah_Part_Page/w-" + this.jsqariSurah + ".htm"; document.getElementById("frm_Moyassar").src = "https://archive.org/download/Quran4u_Tafsir_Page_Part_Surah_Moyassar/taf-sur" + this.jsqariSurah + ".htm"; var Allsurahs = [0, 7, 286, 200, 176, 120, 165, 206, 75, 129, 109, 123, 111, 43, 52, 99, 128, 111, 110, 98, 135, 112, 78, 118, 64, 77, 227, 93, 88, 69, 60, 34, 30, 73, 54, 45, 83, 182, 88, 75, 85, 54, 53, 89, 59, 37, 35, 38, 29, 18, 45, 60, 49, 62, 55, 78, 96, 29, 22, 24, 13, 14, 11, 11, 18, 12, 12, 30, 52, 52, 44, 28, 28, 20, 56, 40, 31, 50, 40, 46, 42, 29, 19, 36, 25, 22, 17, 19, 26, 30, 20, 15, 21, 11, 8, 8, 19, 5, 8, 8, 11, 11, 8, 3, 9, 5, 4, 7, 3, 6, 3, 5, 4, 5, 6]; //------------------------------------------------------------------------------------ var j = 1; var ourdiv = document.getElementById('Put_Here'); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// this.jsqariAyah = 1; this.setBasmalahStatus(); this.uiAyahSelector.children().remove(); var surahAyahNumber = this.surahAyahs[this.jsqariSurah]; for (i = 1; i <= surahAyahNumber; i++) { this.uiAyahSelector.append(''); } }, handleJSQariAyahEnd: function (event) { document.getElementById('3').src = 'Play.gif'; if (this.jsqariAyah == 1) { } ; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (this.jsqariMode == 'continious') { // go to next ayah and play again this.jsqariAyah = parseInt(this.jsqariAyah) + 1; if (this.jsqariAyah > this.surahAyahs[this.jsqariSurah]) { this.jsqariAyah = 1; this.jsqariSurah = parseInt(this.jsqariSurah) + 1; if (this.jsqariSurah > 114) { this.jsqariSurah = 1; } this.handleSurahChange(); } this.setMediaFile(); this.jsqariPlayer.jPlayer("play"); } else if (this.jsqariMode == 'repeatayah') { // play again if (this.jsqariAyah == 0) { this.jsqariAyah = 1; this.setMediaFile(); } this.jsqariPlayer.jPlayer("play"); } else if (this.jsqariMode == 'singleayah') { // play first ayah after basmalah if (this.jsqariAyah == 0) { this.jsqariAyah = 1; this.setMediaFile(); this.jsqariPlayer.jPlayer("play"); } } else if (this.jsqariMode == 'surah') { // play to end of surah if (this.jsqariAyah < this.surahAyahs[this.jsqariSurah]) { this.jsqariAyah = parseInt(this.jsqariAyah) + 1; this.setMediaFile(); this.jsqariPlayer.jPlayer("play"); } } else if (this.jsqariMode == 'repeatsurah') { // play to end of surah if (this.jsqariAyah < this.surahAyahs[this.jsqariSurah]) { this.jsqariAyah = parseInt(this.jsqariAyah) + 1; this.setMediaFile(); this.jsqariPlayer.jPlayer("play"); } else { this.jsqariAyah = 1; this.setBasmalahStatus(); this.setMediaFile(); this.jsqariPlayer.jPlayer("play"); } } this.updateUI(); }, // VIEW functions updateUI: function () { this.uiSurahSelector.val(this.jsqariSurah); this.uiAyahSelector.val(this.jsqariAyah); this.uiModeSelector.val(this.jsqariMode); }, // API functions setPlayMode: function (playMode) { this.jsqariMode = playMode; this.updateUI(); }, playSurah: function (surahNumber) { document.getElementById('Put_Here').scrollTop = 0 return this.playSurahAyah(surahNumber, 1); }, playSurahAyah: function (surahNumber, ayahNumber) { // check surah number surahNumberParsed = parseInt(surahNumber); if (isNaN(surahNumberParsed)) { alert('إكتب رقم السورة ورقم الآية'); return false; } else if (surahNumberParsed > 114 || surahNumberParsed < 1) { alert('إكتب رقم السورة ورقم الآية'); return false; } // check ayah number ayahNumberParsed = parseInt(ayahNumber); if (isNaN(ayahNumberParsed)) { alert('رقم الآية غير صحيح'); return false; } else if (ayahNumberParsed > this.surahAyahs[surahNumberParsed] || ayahNumberParsed < 1) { alert('رقم الآية غير صحيح'); return false; } if (this.jsqariSurah != surahNumberParsed) { this.jsqariSurah = surahNumberParsed; this.handleSurahChange(); } this.jsqariAyah = ayahNumberParsed; this.setBasmalahStatus(); this.updateUI(); this.setMediaFile(); this.jsqariPlayer.jPlayer("play"); }, // 'PRIVATE' functions setMediaFile: function () { document.getElementById('3').src = 'Play_On.gif'; document.getElementById('4').src = 'Pause.gif'; document.getElementById('5').src = 'Stop.gif'; if (this.jsqariAyah == 0) { this.jsqariAyah = 1; } ; // handle basmalah /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// document.getElementById("surahNumber").value = this.jsqariSurah; document.getElementById("ayahNumber").value = this.jsqariAyah; var tempSurah = false; var tempSurahNumber; if (!this.jsqariBasmalahPlayed) { // Quran4u_Mohaffez_Animated_Ayah.html tempSurah = true; tempSurahNumber = this.jsqariSurah; this.jsqariSurah = 1; this.jsqariAyah = 1; this.jsqariBasmalahPlayed = true; } var base = ''; var mp3file = base + this.jsqariReciter + this.pad(this.jsqariSurah, 3) + this.pad(this.jsqariAyah, 3) + '.mp3'; // var mp3file = get_ayah_mp3file('jsqari-ui-reciter-selector',this.jsqariReciter, this.jsqariSurah, this.jsqariAyah); //------------------------------------------------------------------------------------------------------------------------------------------------------------------------- var surahAyahsss = [0, 7, 286, 200, 176, 120, 165, 206, 75, 129, 109, 123, 111, 43, 52, 99, 128, 111, 110, 98, 135, 112, 78, 118, 64, 77, 227, 93, 88, 69, 60, 34, 30, 73, 54, 45, 83, 182, 88, 75, 85, 54, 53, 89, 59, 37, 35, 38, 29, 18, 45, 60, 49, 62, 55, 78, 96, 29, 22, 24, 13, 14, 11, 11, 18, 12, 12, 30, 52, 52, 44, 28, 28, 20, 56, 40, 31, 50, 40, 46, 42, 29, 19, 36, 25, 22, 17, 19, 26, 30, 20, 15, 21, 11, 8, 8, 19, 5, 8, 8, 11, 11, 8, 3, 9, 5, 4, 7, 3, 6, 3, 5, 4, 5, 6]; if (this.jsqariAyah < surahAyahsss[this.jsqariSurah]) { document.getElementById('6').style.width = "40px"; } ; if (this.jsqariAyah >= surahAyahsss[this.jsqariSurah]) { document.getElementById('6').style.width = "0px"; } ; if (this.jsqariAyah < 2) { document.getElementById('2').style.width = "0px"; } ; if (this.jsqariAyah > 1) { document.getElementById('2').style.width = "40px"; } ; //------------------------------------------------------------------------------------------------------------------------------------------------------------- if (tempSurah) { this.jsqariSurah = tempSurahNumber; this.jsqariAyah = 0; } this.jsqariPlayer.jPlayer("setMedia", { mp3: mp3file }); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// if (this.jsqariAyah == 0) { document.getElementById("frm_Taf").src = "https://archive.org/download/Quran4u_Tafsir_Ayah_Jal/" + this.pad(this.jsqariSurah, 3) + '001.html'; document.getElementById("Ayaimg1").src = "http://archive.org/download/Quran4u_Quran_Ayat/" + this.jsqariSurah + "_1.gif"; } ; if (this.jsqariAyah > 0) { document.getElementById("frm_Taf").src = "https://archive.org/download/Quran4u_Tafsir_Ayah_Jal/" + this.pad(this.jsqariSurah, 3) + this.pad(this.jsqariAyah, 3) + '.html'; document.getElementById("Ayaimg1").src = "http://archive.org/download/Quran4u_Quran_Ayat/" + this.jsqariSurah + "_" + this.jsqariAyah + '.gif'; }; // alert( this.jsqariSurah + "_" + this.jsqariAyah + '.gif') /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }, setBasmalahStatus: function () { // alert(this.jsqariReciter); if (this.jsqariAyah == 1 && (this.jsqariSurah != 1 && this.jsqariSurah != 9)) { this.jsqariBasmalahPlayed = false; } else { this.jsqariBasmalahPlayed = true; } ; }, pad: function (number, length) { var str = '' + number; while (str.length < length) { str = '0' + str; } return str; } } function play_next() { var sAyahs = [0, 7, 286, 200, 176, 120, 165, 206, 75, 129, 109, 123, 111, 43, 52, 99, 128, 111, 110, 98, 135, 112, 78, 118, 64, 77, 227, 93, 88, 69, 60, 34, 30, 63, 54, 45, 83, 182, 88, 75, 85, 54, 53, 89, 59, 37, 35, 38, 29, 18, 45, 60, 49, 62, 55, 78, 96, 29, 22, 24, 13, 14, 11, 11, 18, 12, 12, 30, 52, 52, 44, 28, 28, 20, 56, 40, 31, 50, 40, 46, 42, 29, 19, 36, 25, 22, 17, 19, 26, 30, 20, 15, 21, 11, 8, 8, 19, 5, 8, 8, 11, 11, 8, 3, 9, 5, 4, 7, 3, 6, 3, 5, 4, 5, 6]; var ourayah = document.getElementById("ayahNumber").value var oursurah = document.getElementById("surahNumber").value var sAyahNumber = sAyahs[oursurah]; document.getElementById("ayahNumber").value = parseInt(document.getElementById("ayahNumber").value) + 1 jsQari.playSurahAyah($('#surahNumber').val(), $('#ayahNumber').val()); }; function scrollFunc(iimg) { if (document.getElementById(iimg)) { var docPos = f_scrollTop(); window.scrollTo(0, docPos); } ; } ; function adjustmoshaf() { var est = document.getElementById(selected_ayah); // ggggggg window.location = '#Here'; if (est) { var docPos = f_scrollTop(); est.scrollIntoView(); window.scrollTo(0, docPos) toTop(selected_ayah); } ; } ; function f_scrollTop() { return f_filterResults( window.pageYOffset ? window.pageYOffset : 0, document.documentElement ? document.documentElement.scrollTop : 0, document.body ? document.body.scrollTop : 0 ); } ; function scrollDivDown(id, step) { document.getElementById(id).scrollTop += step } ; function toTop(id) { document.getElementById(id).scrollTop = 0 } ; //------------------------------------------------------------------------------------------------ function createimage1(bbase, surah_num, ayah_num, ddiv) { imgg.id = "Ayaimg" + ayah_num; imgg.src = (bbase + surah_num + '_' + ayah_num + '.gif'); document.getElementById(ddiv).innerHTML = document.getElementById(ddiv).innerHTML + "جارى تحميل الآية - إنتظر من �?ضلك
" }; //----------------------------------------------------------------------------------------------- function createimage(bbase, surah_num, ayah_num, ddiv) { var divtest = document.createElement("div"); divtest.innerHTML = "جارى تحميل الآية - إنتظر من �?ضلك
" document.getElementById(ddiv).appendChild(divtest); } //--------------------------------------------------------------------------------------------------- function scrollIntoViewIfOutOfView(el) { var topOfPage = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop; var heightOfPage = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; var elY = 0; var elH = 0; if (document.layers) { // NS4 elY = el.y; elH = el.height; } else { for (var p = el; p && p.tagName != 'body'; p = p.offsetParent) { elY += p.offsetTop; } elH = el.offsetHeight; } if ((topOfPage + heightOfPage) < (elY + elH)) { el.scrollIntoView(false); } else if (elY < topOfPage) { el.scrollIntoView(true); } } function ClearDiv(hdiv) { document.getElementById(hdiv).innerHTML = ""; if ($('#surahNumber').val() > 1) { document.getElementById(hdiv).innerHTML = "
"; } ; if ($('#surahNumber').val() == 9) { document.getElementById(hdiv).innerHTML = "
"; } ; } ; function preloadimg(myimgsrc) { if (document.images) { preload_image = new Image(); preload_image.src = "myimgsrc"; } ; } ; function f_filterResults(n_win, n_docel, n_body) { var n_result = n_win ? n_win : 0; if (n_docel && (!n_result || (n_result > n_docel))) n_result = n_docel; return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result; } ; function PlayAya(thisayah) { if ($('#ayahNumber').val() > 0) { var selayah = thisayah.substr(6, 3) document.getElementById('ayahNumber').value = parseInt(selayah); } ; jsQari.playSurahAyah($('#surahNumber').val(), $('#ayahNumber').val()); } ; function PlaySura() { jsQari.playSurah($('#surahNumber').val()); } ; ///////////////////////////////////////////////////////////////////////////////////////////////////// function loadhtml2div(url, target) { document.getElementById(target).innerHTML = '





جارى تحميل السورة - أذكر الله

'; if (window.XMLHttpRequest) { req = new XMLHttpRequest(); } else if (window.ActiveXObject) { req = new ActiveXObject("Microsoft.XMLHTTP"); } if (req != undefined) { req.onreadystatechange = function () { loadhtml2divDone(url, target); }; req.open("GET", url, true); req.send(""); } } function loadhtml2divDone(url, target) { if (req.readyState == 4) { // only if req is "loaded" if (req.status == 200) { // only if "OK" document.getElementById(target).innerHTML = req.responseText; } else { document.getElementById(target).innerHTML = " Error:\n" + req.status + "\n" + req.statusText; } } } function load(name, div) { loadhtml2div(name, div); return false; } function loadhtmlfile(surah_num, ddiv) { loadhtml2div(('Surah_Html/' + surah_num + '.htm'), ddiv); return false; } ; function opentafsir() { var ourayah1 = document.getElementById("ayahNumber").value var oursurah1 = document.getElementById("surahNumber").value var width = 660; var height = 500; var x = (800 - width) / 2; var y = (600 - height) / 2; if (screen) { y = (screen.availHeight - height) / 2; x = (screen.availWidth - width) / 2; } window.open('Quran-Ayah-Tafseer.aspx?Surah=' + oursurah1 + '&Ayah=' + ourayah1, 'newWin', 'width=' + width + ',height=' + height + ',screenX=' + x + ',scrollbars=yes,screenY=' + y + ',top=' + y + ',left=' + x) } ; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function createCookie(name, value, days) { if (days) { var date = new Date(); date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); var expires = "; expires=" + date.toGMTString(); } else var expires = ""; document.cookie = escape(name) + "=" + escape(value) + expires + "; path=/"; } function readCookie(name) { var nameEQ = escape(name) + "="; var ca = document.cookie.split(';'); for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0) == ' ') c = c.substring(1, c.length); if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length, c.length)); } return null; } function eraseCookie(name) { createCookie(name, "", -1); } //---------------------------------------------------------------------------------------------------------------------- function save_it() { if (are_cookies_enabled() == true) { var finalsurah = document.getElementById('jsqari-ui-surah-selector').selectedIndex + 1; var finalayah = document.getElementById('jsqari-ui-ayah-selector').selectedIndex + 1; var finalreciter = document.getElementById('jsqari-ui-reciter-selector').selectedIndex; createCookie('ayah_lastsurah', finalsurah, '365'); createCookie('ayah_lastayah', finalayah, '365'); createCookie('ayah_reciternum', finalreciter, '365'); } else { alert("المتصفح المستعمل لايقبل الحفظ - Please Allow cookies") } }; //----------------------------------------------------------------- function are_cookies_enabled() { var cookieEnabled = (navigator.cookieEnabled) ? true : false; if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) { document.cookie = "testcookie"; cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false; } return (cookieEnabled); } function del_it() { eraseCookie('ayah_lastsurah'); eraseCookie('ayah_lastayah'); eraseCookie('ayah_reciternum'); }; //--------------------------------------------------------------------------------------------------------------------------------------------------------------- function get_it() { if (document.cookie.indexOf("ayah_lastsurah") >= 0) { var savedsurah = readCookie('ayah_lastsurah'); var savedayah = readCookie('ayah_lastayah'); var savedrecieternum = readCookie('ayah_reciternum'); document.getElementById('jsqari-ui-surah-selector').selectedIndex = savedsurah; document.getElementById('jsqari-ui-ayah-selector').selectedIndex = savedayah; //* document.getElementById('jsqari-ui-reciter-selector').selectedIndex = savedrecieternum; jsQari.jsqariReciter = document.getElementById('jsqari-ui-reciter-selector').value; //* document.getElementById("surahNumber").value = savedsurah; document.getElementById("ayahNumber").value = savedayah; //* jsQari.playSurahAyah(savedsurah, savedayah); jsQari.jsqariPlayer.jPlayer('stop'); //* } }