/* * 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.0.0 * Date: 23rd April 2011 */ var sura_no ; var Aya_no; var JSQari = function() { this.jsqariPlayer = $("#jquery_jplayer_1"); this.jsqariSurah; this.jsqariAyah; this.jsqariReciter; this.jsqariMode; this.surahAyahstart = [0,1,22,42,62, 82,102,122,142,162,182,202,222,242,262,282,302,322,342,362,382,402,422,442,462,482,502,522,542,562,582]; this.surahAyahs = [0,21,41,61,81,101,121,141,161,181,201,221,241,261,281,301,321,341,361,381,401,421,441,461,481,501,521,541,561,581,604]; 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.jsqariPlayer.jPlayer({ ready: function () { document.getElementById('3').src = 'Play.gif'; $(_this.jsqariPlayer).jPlayer("setMedia", { mp3: "https://archive.org/download/abd-alrasheed--soofy-rewayt-sho3bah-3n-3aasem---604-part-full-quran-604-page--/1.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.setMediaFile(); }); this.uiReciterSelector.change(function() { _this.jsqariReciter = $(this).val(); _this.setMediaFile(); }); this.uiModeSelector.change(function() { _this.jsqariMode = $(this).val(); _this.setMediaFile(); }); this.setMediaFile(); }, // CONTROLLER methods handleSurahChange: function() { //document.getElementById("Srurah_img").src = 'Surah_lable_images/' + this.jsqariSurah + '.gif' //------------------------------------------------------ Gamal ----------------------------------------------------------------------- this.jsqariAyah = this.surahAyahstart[this.jsqariSurah]; this.uiAyahSelector.children().remove(); var surahAyahNumber = this.surahAyahs[this.jsqariSurah]; for (i = this.jsqariAyah; i <= surahAyahNumber; i++) { this.uiAyahSelector.append(''); } }, handleJSQariAyahEnd: function (event) { document.getElementById('3').src = 'Play.gif'; 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 > 30) { this.jsqariSurah = 1; } this.handleSurahChange(); } this.setMediaFile(); this.jsqariPlayer.jPlayer("play"); } else if (this.jsqariMode == 'repeatayah') { // play again this.jsqariPlayer.jPlayer("play"); } this.updateUI(); }, // VIEW functions updateUI: function() { this.uiSurahSelector.val(this.jsqariSurah); this.uiAyahSelector.val(this.jsqariAyah); }, // API functions playSurah: function(surahNumber) { 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.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'; //---------------------------- Gamal ------------------------------------------------------- document.getElementById("surahNumber").value = this.jsqariSurah document.getElementById("ayahNumber").value = this.jsqariAyah document.getElementById("Aya-img").src = 'https://archive.org/download/Quran4u_Quran_Page_Shubah/' + this.pad(this.jsqariAyah, 3) + '.jpg'; //var base = 'http://www.everyayah.com/data/'; var base = ''; var mp3file = base + this.jsqariReciter + this.jsqariAyah + '.mp3'; //alert(mp3file); this.jsqariPlayer.jPlayer("setMedia", { mp3: mp3file }); //--------------------------------------------------------------------------------------------------------- //document.getElementById("frm_Taf").src = "Quran-Page-Tafseer.aspx?p=" + this.jsqariAyah; document.getElementById("frm_Man").src = "https://archive.org/download/Quran4u_Maany_Surah_Part_Page/wp-" + this.jsqariAyah + ".htm"; document.getElementById("frm_Taf").src = "https://archive.org/download/Quran4u_Tafsir_Jal_Surah_Page_Part/jal" + this.jsqariAyah + ".htm"; document.getElementById("frm_moyassar").src = "https://archive.org/download/Quran4u_Tafsir_Page_Part_Surah_Moyassar/taf-" + this.jsqariAyah + ".htm"; document.getElementById("frm_kath").src = "https://archive.org/download/Quran4u_Tafsir_Page_Kath/katheer-p" + this.jsqariAyah + ".htm"; }, pad: function(number, length) { var str = '' + number; while (str.length < length) { str = '0' + str; } return str; } } function Img_border_On(iid) { document.getElementById(iid).border = '1'; } function Img_border_Off(iiid) { document.getElementById(iiid).border = '0'; } function play_next() { //alert (kk.val()) document.getElementById("ayahNumber").value = parseInt(document.getElementById("ayahNumber").value) + 1 jsQari.playSurahAyah($('#surahNumber').val(), $('#ayahNumber').val()); } 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-Page-Tafseer.aspx?p=' + ourayah1, 'newWin', 'width=' + width + ',height=' + height + ',screenX=' + x + ',scrollbars=yes,screenY=' + y + ',top=' + y + ',left=' + x) };