var darfm_obj = new Object; darfm_obj.widget = null; darfm_obj.widget_id = 0; darfm_obj.partner_token = 2059751535; darfm_obj.showname = "Phil Hendrie Show"; darfm_obj.display_showname = "The Phil Hendrie Show"; darfm_obj.showinfo_id = "8295"; darfm_obj.language = 'en'; darfm_obj.source = 'https://www.dar.fm/'; darfm_obj.userid = null; // Local Dev Settings //darfm_obj.source = 'https://wwwmgn.dev.mp3tunes.com/dar/'; function darfm_widget_jquerycheck() { var rtn = true; try { rtn = jQuery; rtn = true; } catch(err) { rtn = false; } return rtn; } // jquery not found. Load from google if(!darfm_widget_jquerycheck()) { var darfm_widget_jsobj = document.createElement("script"); darfm_widget_jsobj.setAttribute("type","text/javascript"); darfm_widget_jsobj.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"); document.getElementsByTagName("head")[0].appendChild(darfm_widget_jsobj); } // Do not proceed until jquery has loaded. function darfm_widget_init() { if(darfm_widget_jquerycheck()) { jQuery.support.cors = true; darfm_widget_load(); } else { setTimeout('darfm_widget_init();',250); } } function darfm_widget_load() { darfm_obj.showname = escape(darfm_obj.showname); darfm_obj.display_showname = darfm_obj.display_showname.replace("\'","'"); var darfm_fan_widget_html = "
"; jQuery("#darfm_fan_widget_container").append(darfm_fan_widget_html); functionality_call(); } function functionality_call() { $('.record_but').live("click", function() { $('div.record_form').hide(); $('div.email').show(); $('span.customize').hide(); $('span.image').hide(); $('div.email').html(''); $('input.enter_email').css('color','gray'); }); $('.record_but2').live("click", function() { $('div.help_div').hide(); $('div.email').show(); $('span.customize').hide(); $('span.image').hide(); $('div.email').html(''); $('input.enter_email').css('color','gray'); }); $('.widget_footer').live("click", function(event) { if(darfm_widget_validate_email($('.enter_email').val())) { darfm_widget_rec(darfm_obj.showname , $('.enter_email').val(),event); $('div.email').hide(); $('div.record_form').show(); } else { alert("Please enter a valid email"); } }); function darfm_widget_validate_email(email) { var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); return pattern.test(email); } function darfm_widget_rec(show , email , event) { $('span.customize').show(); $('span.image').show(); var remote_url = darfm_obj.source +'schedule_logic.php?show_title='+show+'&user_email='+email+'&partner_token='+darfm_obj.partner_token+'&format_id=101'; if(event.handled != true) { event.handled = true; jQuery.ajax({ url: remote_url, success: function(msg) { if(msg.indexOf("Magic") > 0) { msg = msg.replace(/<\/?[^>]+>/gi,''); msg = msg.substr(111); alert(msg); } else { msg = msg.replace(/<\/?[^>]+>/gi,''); alert(msg); } } }); } } $('img.help').live('click',function() { $('div.record_form').hide(); $('div.help_div').show(); }); $('a.close').live('click',function(e) { e.preventDefault(); $('div.help_div').hide(); $('div.record_form').show(); }); $('.enter_email').live("focus", function() { $(this).val(''); $(this).css('color','black'); }); $('.enter_email').live("blur", function() { if($(this).val() == '') { $(this).val('enter your email'); $(this).css('color','gray'); } }); } darfm_widget_init();