//$(function() { // $( "#accordion2" ).accordion(); //}); (function(window) { // Localize jQuery variable var Shaz = window.Shaz || {}; var jQuery; var appid; var onload = 0; var submit = 0; var clicked = 0; var base_url = 'https://easy.com.bd/widget/banglalink/'; if(Shaz.q[0][1] == undefined || Shaz.q[0][1] == null){ //console.log("Please provide appid to work"); } else{ appid = Shaz.q[0][1]; } if(Shaz.q[0][2] == undefined || Shaz.q[0][2] == null){ //console.log("Please provide appid to work"); } else{ if(Shaz.q[0][2] == 'load'){ onload = 1; } } Shaz.cell_no = ""; Shaz.amount = 0; Shaz.package = "prepaid"; Shaz.email = ""; /******** Load jQuery if not present *********/ //if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2') { if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.4.2') { var script_tag = document.createElement('script'); script_tag.setAttribute("type","text/javascript"); script_tag.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"); if (script_tag.readyState) { script_tag.onreadystatechange = function () { // For old versions of IE if (this.readyState == 'complete' || this.readyState == 'loaded') { scriptLoadHandler(); } }; } else { script_tag.onload = scriptLoadHandler; } // Try to find the head, otherwise default to the documentElement (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag); } else { // The jQuery version on the window is the one we want to use jQuery = window.jQuery; Shaz.$ = Shaz.jQuery = jQuery.noConflict(true); Shaz.main(); test(); } /******** Called once jQuery has loaded ******/ function scriptLoadHandler() { // Restore $ and window.jQuery to their previous values and store the // new jQuery in our local jQuery variable jQuery = window.jQuery.noConflict(true); // Call our main function main(); } /******** Our main function ********/ function main() { jQuery('#recharge_form').submit(function(e){ submit = 1; clicked = 0; e.preventDefault(); Shaz.open_modal_submit(); }); jQuery(document).ready(function($) { /******* Load CSS *******/ var css_link = $("", { rel: "stylesheet", type: "text/css", href: "https://easy.com.bd/widget_library/style_new_bl.css?weassssdfww=232" }); css_link.appendTo('head'); var css_link = $("", { rel: "stylesheet", type: "text/css", href: "https://fonts.googleapis.com/css?family=Raleway:400,600" }); css_link.appendTo('head'); var css_link = $("", { rel: "stylesheet", type: "text/css", href: "https://easy.com.bd/widget_library/animate.css" }); css_link.appendTo('head'); var css_link = $("", { rel: "stylesheet", type: "text/css", href: "https://fonts.googleapis.com/css?family=Roboto:400,300" }); css_link.appendTo('head'); addHtml(); addPopup(); var ua = navigator.userAgent, iOS = /iPad|iPhone|iPod/.test(ua), iOS11 = /OS 11_0_1|OS 11_0_2|OS 11_0_3|OS 11_1|OS 11_1_1|OS 11_1_2|OS 11_2|OS 11_2_1/.test(ua); // ios 11 bug caret position if ( iOS && iOS11 ) { // Add CSS class to body $("body").addClass("iosBugFixCaret"); } //Parse URL to get success or fail status var status = getUrlParameter('status'); var msg = getUrlParameter('message'); setTimeout( function() { if(typeof status != 'undefined' && status != null && status != ''){ if(typeof msg == 'undefined' && msg == ''){ msg=""; } if(status =="success"){ loadPopup('Success',msg, '#32AD48'); } if(status=="fail"){ loadPopup('Failed',msg, '#DD4444'); } } }, 500); // Get the modal var modal = document.getElementById('ssl_modal'); var btn2 = document.getElementsByClassName("ssl_button"); var btnid = document.getElementById("ssl_button"); var btnSubmit = document.getElementsByClassName('dbuttonSub')[0]; var closebut = document.getElementsByClassName('dclose-reveal-modal')[0]; var popupclose = document.getElementsByClassName('mynewpopupclose')[0]; var backButton = document.getElementsByClassName('dback')[0]; var alertMessage = document.getElementsByClassName('dnotice_box')[0]; if(typeof backButton != 'undefined') { backButton.style.display = "none"; } // Card option container var cardsCon = document.getElementsByClassName('dcards')[0]; var internetCon = document.getElementsByClassName('dinternet')[0]; var mobileCon = document.getElementsByClassName('dmobile')[0]; // //var pay_card_container = document.getElementsByClassName('dpay_cards')[0]; //var pay_mobile_container = document.getElementsByClassName('dpay_mobiles')[0]; //var pay_internet_container = document.getElementsByClassName('dpay_internets')[0]; if( typeof closebut != 'undefined'){ closebut.onclick = function(){ $('.ldr').hide('slow'); closeEverything(); } } // BACK BUTTON ACTION if(typeof backButton != 'undefined'){ backButton.onclick = function(e) { $('.dinput_form').show(); $('.dctabs').hide(); $('.dmodal-content #progressbar li').eq(0).addClass('active'); $('.dmodal-content #progressbar li').eq(1).removeClass('active'); Shaz.clean_input_all(); cardsCon.innerHTML = ""; internetCon.innerHTML = ""; mobileCon.innerHTML = ""; backButton.style.display = "none"; } } Shaz.just_open_modal = function(){ modal.style.display = 'block'; }; Shaz.open_modal_submit = function(){ var isMobile = /iPhone|iPod|Mobile|BlackBerry|IEMobile/i.test(navigator.userAgent); if (isMobile) { modal.style.display = 'block'; } else { modal.style.display = 'block'; } Shaz.takeinputs(); Shaz.checkPayPossible(); }; Shaz.takeinputs = function(){ if(typeof document.getElementsByName('cell_no')[0] != 'undefined'){ Shaz.cell_no = document.getElementsByName('cell_no')[0].value; document.getElementById('dcell_no').value = Shaz.cell_no; } if(typeof document.getElementsByName('amount')[0] != 'undefined'){ Shaz.amount = document.getElementsByName('amount')[0].value; document.getElementById('damount').value = Shaz.amount; } if(typeof document.getElementsByName('email')[0] != 'undefined'){ Shaz.email = document.getElementsByName('email')[0].value; document.getElementById('demail').value = Shaz.email; } if(typeof document.getElementsByName('package')[0] != 'undefined'){ Shaz.package = document.getElementsByName('package')[0].value; } }; Shaz.setAmount = function(amount){ Shaz.amount = amount; document.getElementById('damount').value = Shaz.amount; }; Shaz.setAmountAndShow = function(amount){ Shaz.amount = amount; document.getElementById('damount').value = Shaz.amount; modal.style.display = 'block'; }; Shaz.takeinputsinner = function(){ if(document.getElementById('dcell_no') != null){ Shaz.cell_no = document.getElementById('dcell_no').value; console.log(Shaz.cell_no+"\n"); } if( document.getElementById('damount') != null){ Shaz.amount = document.getElementById('damount').value; console.log(Shaz.amount+"\n"); } if( document.getElementById('demail') != null){ Shaz.email = document.getElementById('demail').value; console.log(Shaz.email+"\n"); } if(document.getElementById('dpackage') != null){ Shaz.package = document.getElementById('dpackage').value; console.log(Shaz.package+"\n"); } }; Shaz.clean_input = function(){ if(document.getElementById('dcell_no') != null){ document.getElementById('dcell_no').value = ""; } if( document.getElementById('damount') != null){ document.getElementById('damount').value = ""; } if( document.getElementById('demail') != null){ document.getElementById('demail').value = ""; } if(document.getElementById('dpackage') != null){ Shaz.package = document.getElementById('dpackage').value; } }; Shaz.clean_input_all = function(){ if(document.getElementById('dcell_no') != null){ document.getElementById('dcell_no').value = ""; } if( document.getElementById('damount') != null){ document.getElementById('damount').value = ""; } if( document.getElementById('demail') != null){ document.getElementById('demail').value = ""; } if(document.getElementById('dpackage') != null){ Shaz.package = document.getElementById('dpackage').value; } backButton.style.display = "none"; jQuery('.dinput_form').show(); jQuery('.dctabs').hide(); }; jQuery('.dbuttonSub').click(function(){ Shaz.takeinputsinner(); Shaz.checkPayPossible(); }); Shaz.checkPayPossible = function(){ if(Shaz.cell_no != '' && Shaz.amount != '' && Shaz.package != '' && Shaz.email != ''){ // Possible var cell_no = Shaz.validateNumber(Shaz.cell_no, 'bl'); //alert(cell_no); if(cell_no != 'invalid'){ // Number valid if(Shaz.amount >= 5){ if(Shaz.validateEmail(Shaz.email)){ // Email valid if(Shaz.package == 'prepaid' || Shaz.package == 'postpaid'){ jQuery('.dinput_form').hide(); jQuery('.dctabs').show(); $('.dmodal-content #progressbar li').eq(0).removeClass('active'); $('.dmodal-content #progressbar li').eq(1).addClass('active'); // Package Valid var domain = Shaz.domain = window.location.host; var data = { mobile_no: cell_no, amount: Shaz.amount, type: Shaz.package, domain: domain, email: Shaz.email }; //var old_text = Shaz.old_text = $('.dproceedpay').text(); //$('.dproceedpay').val("Please wait..."); backButton.style.display = "none"; callit(base_url+"create_trx", data, createTrx); } else{ // Invalid Package } } else{ // $('.dmodal-content #progressbar li').eq(0).addClass('active'); $('.dmodal-content #progressbar li').eq(1).removeClass('active'); jQuery('.dctabs').hide(); jQuery('#derror_email').text('Invalid email').show('slow'); jQuery('#dcell_no_error').hide(); jQuery('.dinput_form .bindText').hide(); jQuery('#derror_amount').hide(); jQuery('.dinput_form').show(); jQuery('#demail').show(); jQuery('#demail_label').show(); jQuery('#dcell_no').hide(); jQuery('#dcell_no_label').hide(); jQuery('#damount').hide(); jQuery('#damount_label').hide(); } } else{ $('.dmodal-content #progressbar li').eq(0).addClass('active'); $('.dmodal-content #progressbar li').eq(1).removeClass('active'); // Amount Invalid jQuery('.dctabs').hide(); jQuery('#derror_amount').text('Invalid amount').show('slow'); jQuery('#derror_email').hide(); jQuery('.dinput_form .bindText').hide(); jQuery('#dcell_no_error').hide(); jQuery('.dinput_form').show(); jQuery('#demail').hide(); jQuery('#demail_label').hide(); jQuery('#dcell_no').hide(); jQuery('#dcell_no_label').hide(); jQuery('#damount').show(); jQuery('#damount_label').show(); } } else{ $('.dmodal-content #progressbar li').eq(0).addClass('active'); $('.dmodal-content #progressbar li').eq(1).removeClass('active'); // Not valid jQuery('.dctabs').hide(); jQuery('#dcell_no_error').text('Invalid mobile number').show('slow'); jQuery('.dinput_form .bindText').show(); jQuery('#derror_email').hide(); jQuery('#derror_amount').hide(); jQuery('.dinput_form').show(); jQuery('#demail').hide(); jQuery('#demail_label').hide(); jQuery('#dcell_no').show(); jQuery('#dcell_no_label').show(); jQuery('#damount').hide(); jQuery('#damount_label').hide(); } } else{ $('.dmodal-content #progressbar li').eq(0).addClass('active'); $('.dmodal-content #progressbar li').eq(1).removeClass('active'); Shaz.inputvalidate(); // Not Possible jQuery('.dctabs').hide(); jQuery('.dinput_form').show(); jQuery('#demail').val(Shaz.email); jQuery('#dcell_no').val(Shaz.cell_no); jQuery('#damount').val(Shaz.amount); jQuery('#demail').show(); jQuery('#demail_label').show(); jQuery('.dinput_form .bindText').show(); jQuery('#dcell_no').show(); jQuery('#dcell_no_label').show(); jQuery('#damount').show(); jQuery('#damount_label').show(); Shaz.just_open_modal(); } }; Shaz.validateNumber = function(d, op){ console.log(d.length); if(d.length == 9){ return d = '01'+d; } else if(d.length == 11){ return d; } else{ return 'invalid'; } // if(d.length == 11 || d.length == 9){ // // Valid sequence // if(d.length == 9){ // if(op == 'bl'){ // return d = '019'+d; // } // else if(op == 'gp'){ // return d = '017'+d; // } // else{ // return 'invalid'; // } // } // else if(d.length == 11){ // if(d.substr(0,3) == 019){ // if(op == 'bl') { // return d; // } // else{ // return 'invalid'; // } // } // else if(d.substr(0,3) == 017){ // if(op == 'gp') { // return d; // } // else{ // return 'invalid'; // } // } // else{ // return 'invalid'; // } // } // } // else{ // return 'invalid'; // } }; Shaz.validateEmail = function(email) { var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); }; Shaz.inputvalidate = function(){ if(Shaz.email == ''){ jQuery('#derror_email').text('Invalid email address').show('slow'); } else{ jQuery('#derror_email').hide(); } if(Shaz.amount == ''){ jQuery('#derror_amount').text('Please provide correct amount').show('slow'); } else{ jQuery('#derror_amount').hide(); } if(Shaz.cell_no == ''){ jQuery('#dcell_no_error').text('Invalid mobile number').show('slow'); } else{ jQuery('#dcell_no_error').hide(); } }; Shaz.showAlert = function(){ alertMessage.style.display = "block"; setTimeout(function(){ alertMessage.style.display = "none"; }, 3000); }; jQuery('.ssl_button').click(function(){ Shaz.clean_input_all(); Shaz.just_open_modal(); }); function createTrx(d){ $('.ldr').hide('slow'); var data = ''; try { data = JSON.parse(d); } catch(error){ data = d; } if(typeof data.status != 'undefined'){ if(data.status == 'Success') { if (typeof data.cards != 'undefined') { cardsCon.innerHTML = ""; for (c in data.cards) { cardsCon.innerHTML += data.cards[c]; } } if (typeof data.internet_banking != 'undefined') { internetCon.innerHTML = ""; for (c in data.internet_banking) { internetCon.innerHTML += data.internet_banking[c]; } } if (typeof data.mobile_banking != 'undefined') { mobileCon.innerHTML = ""; for (c in data.mobile_banking) { mobileCon.innerHTML += data.mobile_banking[c]; } } $('.dacc_panel').hide('slow'); $('.dpay_panel').show('slow'); backButton.style.display = "block"; $('.dproceedpay').val("Proceed to pay"); } else if(data.status == 'Invalid'){ backButton.style.display = "none"; jQuery('.dctabs').hide(); jQuery('.dinput_form').show(); $('.dproceedpay').val("Pay Now"); alertMessage.innerHTML = data.reason; Shaz.showAlert(); //alert(data.message[0]); } else { $('.dproceedpay').text("Pay Now"); if(typeof data.data != 'undefined'){ var msg = JSON.parse(data.data); if(msg.recharge_status == 304 || msg.recharge_status == 307 || msg.recharge_status == 309){ backButton.style.display = "none"; jQuery('.dctabs').hide(); jQuery('.dinput_form').show(); //alert(data.message); alertMessage.innerHTML = data.message; Shaz.showAlert(); } else { backButton.style.display = "none"; jQuery('.dctabs').hide(); jQuery('.dinput_form').show(); alertMessage.innerHTML = msg.message; Shaz.showAlert(); //alert(msg.message); } } else if(typeof data.message != 'undefined'){ //alert(data.message); backButton.style.display = "none"; jQuery('.dctabs').hide(); jQuery('.dinput_form').show(); alertMessage.innerHTML = data.message; Shaz.showAlert(); } else{ backButton.style.display = "none"; jQuery('.dctabs').hide(); jQuery('.dinput_form').show(); //alert('Something Happened! Please try again'); alertMessage.innerHTML = 'Something Happened! Please try again'; Shaz.showAlert(); } } } else{ backButton.style.display = "none"; jQuery('.dctabs').hide(); jQuery('.dinput_form').show(); alertMessage.innerHTML = 'Our service is down right now. Please try again'; Shaz.showAlert(); //alert('Our service is down right now. Please try again'); } } function closeEverything(){ modal.style.display = "none"; cardsCon.innerHTML = ""; internetCon.innerHTML = ""; mobileCon.innerHTML = ""; var pay_panel = document.getElementsByClassName('dpay_panel')[0]; pay_panel.style.display = "none"; $('.dacc_panel').show('slow'); $('.dpay_panel').hide('slow'); backButton.style.display = "none"; } if(popupclose != 'undefined') { popupclose.onclick = function () { jQuery('#ssl_popup').hide(); var url = location.protocol + '//' + location.host + location.pathname window.location = url; }; } window.onclick = function(event) { if (event.target == modal) { closeEverything(); $('.embed-responsive-item').remove(); var trxid = Shaz.trxid; var params = {action:"cancel", trxid: trxid}; //callit(base_url+"qubee/cancel_widget", params, checkCancel); } }; }); } function addHtml(){ var html = '\
'; jQuery(html).appendTo("body"); } function addPopup() { var html = ' \