/* * 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 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: "" }); // 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 = 'https://archive.org/download/Quran4u_Surah_lable_images/' + this.jsqariSurah + '.gif'; window.location = '#Here'; toTop('Put_Here'); document.getElementById("frm_Man").src = "https://archive.org/download/Quran4u_Surah_Maany/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 Allayah = "
"; //---------------------------------------------------------------------------------- if (this.jsqariSurah < 41) { loadhtmlfile(this.jsqariSurah, 'Put_Here'); //Gamal }; //-------------------------------------------------------------------------------------------- if (this.jsqariSurah >= 41) { //ClearDiv('Put_Here'); var gdiv = document.getElementById('Put_Here'); gdiv.innerHTML = Allayah //'





جارى تحميل السورة

'; var gj = 1; for (gj = 1; gj <= this.surahAyahs[this.jsqariSurah]; gj++) { if ((gj) <= this.surahAyahs[this.jsqariSurah]) { createimage(this.jsqariSurah, gj, 'Put_Here'); }; }; }; //------------------------------------------------------------------------------------ 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) { // scrollFunc('Ayaimg' + $('#ayahNumber').val()); // window.location = '#Here'; }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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 > 77) { this.jsqariSurah = 67; } 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) { return this.playSurahAyah(surahNumber, 1); }, playSurahAyah: function (surahNumber, ayahNumber) { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// alert(1); //var j = 1; // for (j = 1; j <= this.surahAyahs[this.jsqariSurah]; j++) { // if (document.getElementById("Ayaimg" + (j))) { // document.getElementById("Ayaimg" + (j)).style.background = "#E3E9F2"; // document.getElementById("Ayaimg" + (j)).style.border = "0"; // }; // }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 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; //--------------------------------------------------------------- Reset Back Ground --------------------------------------------------------------------- var j = 1; // var j = this.jsqariAyah - 1; // alert(this.surahAyahs[this.jsqariSurah]); for (j = 1; j <= this.surahAyahs[this.jsqariSurah]; j++) { if (document.getElementById("Ayaimg" + (j))) { document.getElementById("Ayaimg" + (j)).style.background = "#E3E9F2"; document.getElementById("Ayaimg" + (j)).style.border = "0"; }; }; //-------------------------------------------------------------------- Select Ayah --------------------------------------------------------------------- selected_ayah = 'Ayaimg' + this.jsqariAyah var el_div = document.getElementById("quran_tbl") // scrollIntoViewIfOutOfView(el_div); var ourimg = document.getElementById("Ayaimg" + this.jsqariAyah); if (ourimg) { ourimg.style.background = "#FFE7C1"; ourimg.style.border = "thick solid #FFE7C1"; }; center_image(this.jsqariAyah); // var ouroldimg = document.getElementById("Ayaimg" + (parseInt(this.jsqariAyah) - 1)); // if (ouroldimg) { // scrollDivDown('Put_Here', ouroldimg.height); // }; //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// var tempSurah = false; var tempSurahNumber; if (!this.jsqariBasmalahPlayed) { 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 = "60px"; } ; 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 = "60px"; } ; //------------------------------------------------------------------------------------------------------------------------------------------------------------- if (tempSurah) { this.jsqariSurah = tempSurahNumber; this.jsqariAyah = 0; } //alert(mp3file); this.jsqariPlayer.jPlayer("setMedia", { mp3: mp3file }); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // document.getElementById("frm_Taf").src = "Quran-Ayah-Tafseer.aspx?Surah=" + this.jsqariSurah + "&Ayah=" + this.jsqariAyah; // if (this.jsqariAyah == 0) { // document.getElementById("frm_Taf").src = "https://archive.org/download/Quran4u_Tafsir_Ayah_Jal/" + this.pad(this.jsqariSurah, 3) + '001.html'; // }; 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'; }; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// }, 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, 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 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()); // alert(sAyahNumber); if (ourayah < sAyahNumber) { //scrollFunc('Ayaimg' + ourayah); }; }; function scrollFunc(iimg) { if (document.getElementById(iimg)) { var est = document.getElementById(iimg); var docPos = f_scrollTop(); est.scrollIntoView(); window.scrollTo(0, docPos); }; }; 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 //timerDown = setTimeout("scrollDivDown('" + id + "')", 0) }; function toTop(id) { document.getElementById(id).scrollTop = 0 }; function createimage(surah_num, ayah_num, ddiv) { var base = "https://archive.org/download/Quran4u_Quran_Ayat/" var imgg = new Image(); imgg.id = "Ayaimg" + ayah_num; imgg.src = (base + surah_num + '_' + ayah_num + '.gif'); if (!document.getElementById(imgg.id)) { document.getElementById(ddiv).innerHTML = document.getElementById(ddiv).innerHTML + "جارى تحميل الآية - إنتظر من فضلك
" }; }; 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) { //alert(thisayah.substr(6, 3)); if ($('#ayahNumber').val() > 1) { var selayah = thisayah.substr(6, 3) document.getElementById('ayahNumber').value = parseInt(selayah); }; jsQari.playSurahAyah($('#surahNumber').val(), $('#ayahNumber').val()); // scrollFunc('Ayaimg' + $('#ayahNumber').val()); }; // }; function PlaySura() { jsQari.playSurah($('#surahNumber').val()); toTop('Put_Here'); }; 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()); // alert(sAyahNumber); if (ourayah < sAyahNumber) { // scrollFunc('Ayaimg' + ourayah); }; }; ///////////////////////////////////////////////////////////////////////////////////////////////////// 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) { //document.getElementById(ddiv).innerHTML = 'Surah_Html/2.htm'; 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; } // alert('Quran-Ayah-Tafseer.aspx?Surah=' + oursurah1 + '&Ayah=' + ourayah1) 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 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 center_image(ayah_num) { var topPos = document.getElementById("Ayaimg" + parseInt (ayah_num)).offsetTop; document.getElementById('Put_Here').scrollTop = topPos - 80; };