/* * 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 selectedmoshah; 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: "http://www.quran4u.net/quran/abdelbasit_Pages/001.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 = 'https://archive.org/download/Quran4u_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 //* selectedmoshah = document.getElementById("moshaf_type").selectedIndex if (selectedmoshah == 0) { document.getElementById("Aya-img").src = 'http://archive.org/download/Quran4u_Quran_tjwd/' + this.pad(this.jsqariAyah, 3) + '.gif'; }; if (selectedmoshah == 1) { document.getElementById("Aya-img").src = 'http://archive.org/download/Quran4u_Quran_jawamee/' + this.pad(this.jsqariAyah, 4) + '.jpg'; }; if (selectedmoshah == 2) { document.getElementById("Aya-img").src = 'http://archive.org/download/Quran4u_Quran_Brown/' + this.pad(this.jsqariAyah, 4) + '.jpg'; }; if (selectedmoshah == 3) { document.getElementById("Aya-img").src = 'http://archive.org/download/Quran4u_Quran_Green/' + this.pad(this.jsqariAyah, 4) + '.jpg'; }; if (selectedmoshah == 4) { document.getElementById("Aya-img").src = 'http://archive.org/download/Quran4u_Quran_Hefs_Shubah/' + this.pad(this.jsqariAyah, 3) + '.jpg'; }; //* //var base = 'http://www.everyayah.com/data/'; var base = ''; //var mp3file = base + this.jsqariReciter + this.pad(this.jsqariAyah, 3) + '.mp3'; var selrec = document.getElementById("jsqari-ui-reciter-selector").selectedIndex this.jsqariReciter = document.getElementById("jsqari-ui-reciter-selector").value if (selrec < warsh_number) { var mp3file = base + this.jsqariReciter + this.pad(this.jsqariAyah, 3) + '.mp3'; } if (selrec > warsh_number-1) { var mp3file = base + this.jsqariReciter + this.jsqariAyah + '.mp3'; } this.jsqariPlayer.jPlayer("setMedia", { mp3: mp3file }); //--------------------------------------------------------------------------------------------------------- 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) }; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 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 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) { //change_moshaf() var finalsurah = document.getElementById('jsqari-ui-surah-selector').selectedIndex; var finalayah = document.getElementById('jsqari-ui-ayah-selector').selectedIndex ; var finalreciter = document.getElementById('jsqari-ui-reciter-selector').selectedIndex; var moshaftype = document.getElementById('moshaf_type').selectedIndex createCookie('pageall_lastsurah', finalsurah, '365'); createCookie('pageall_lastayah', finalayah, '365'); createCookie('pageall_reciternum', finalreciter, '365'); createCookie('pageall_moshaf', moshaftype, '365'); var oursurah = document.getElementById("surahNumber").value var ourayah = document.getElementById("ayahNumber").value createCookie('pageall_ayah', ourayah, '365'); createCookie('pageall_surah', oursurah, '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('pageall_lastsurah'); eraseCookie('pageall_lastayah'); eraseCookie('pageall_reciternum'); }; function get_it() { // alert(readCookie('pageall_lastsurah') + " - " + readCookie('pageall_lastayah') + " - " + readCookie('pageall_reciternum')); if (document.cookie.indexOf("pageall_lastsurah") >= 0) { var savedsurah = readCookie('pageall_lastsurah'); var savedayah = readCookie('pageall_lastayah'); var savedrecieternum = readCookie('pageall_reciternum'); var savedmos = readCookie('pageall_moshaf'); var savedsurahhh = readCookie('pageall_surah'); var savedayahhh = readCookie('pageall_ayah'); document.getElementById('jsqari-ui-reciter-selector').selectedIndex = savedrecieternum; jsQari.jsqariReciter = document.getElementById('jsqari-ui-reciter-selector').value; document.getElementById('moshaf_type').selectedIndex = savedmos; //* selectedmoshah = document.getElementById("moshaf_type").selectedIndex //* if (selectedmoshah == 0) { document.getElementById("Aya-img").src = 'http://archive.org/download/Quran4u_Quran_jawamee/' + this.pad(this.jsqariAyah, 4) + '.jpg'; }; if (selectedmoshah == 1) { document.getElementById("Aya-img").src = 'http://archive.org/download/Quran4u_Quran_Brown/' + this.pad(this.jsqariAyah, 4) + '.jpg'; }; if (selectedmoshah == 2) { document.getElementById("Aya-img").src = 'http://archive.org/download/Quran4u_Quran_Green/' + this.pad(this.jsqariAyah, 4) + '.jpg'; }; if (selectedmoshah == 3) { document.getElementById("Aya-img").src = 'http://archive.org/download/Quran4u_Quran_Hefs_Shubah/' + this.pad(this.jsqariAyah, 3) + '.jpg'; }; //* document.getElementById("surahNumber").value = savedsurahhh; document.getElementById("ayahNumber").value = savedayahhh; // change_moshaf() jsQari.playSurahAyah($('#surahNumber').val(), $('#ayahNumber').val()) jsQari.jsqariPlayer.jPlayer('stop'); } } function padd (number, length) { var str = '' + number; while (str.length < length) { str = '0' + str; } return str; } function change_moshaf() { //disab() // var selectedmoshah2 = document.getElementById("moshaf_type").selectedIndex // if (selectedmoshah2 == 0) // { // // document.getElementById("jsqari-ui-reciter-selector").selectedIndex = 0 // } // if (selectedmoshah2 == 1) // { // document.getElementById("jsqari-ui-reciter-selector").selectedIndex = 36 // } // if (selectedmoshah2 == 2) // { // document.getElementById("jsqari-ui-reciter-selector").selectedIndex = 43 // } jsQari.playSurahAyah($('#surahNumber').val(), $('#ayahNumber').val()) jsQari.jsqariPlayer.jPlayer('stop'); document.getElementById('Aya-img').focus() } function disab() { //* var op if (selectedmoshah == 0) { op = document.getElementById("jsqari-ui-reciter-selector").getElementsByTagName("option"); for (var i = 0; i < 50; i++) { op[i].disabled = false; } for (var i = 36; i < 50; i++) { op[i].disabled = true; } } //* //* else if (selectedmoshah == 1) { op = document.getElementById("jsqari-ui-reciter-selector").getElementsByTagName("option"); for (var i = 0; i < 50; i++) { op[i].disabled = true; } for (var i = 36 ; i < 42; i++) { op[i].disabled = false; } } //* else if (selectedmoshah == 2) { op = document.getElementById("jsqari-ui-reciter-selector").getElementsByTagName("option"); for (var i = 0; i < 50; i++) { op[i].disabled = true; } for (var i = 41; i < 50; i++) { op[i].disabled = false; } //* } }