Jump to content

Recommended Posts

 

Hello everyone.  I am getting the following errors after an amount of time. That time can vary, it usually takes a few good minutes to come up.  https://gyazo.com/7e81b98065b5558d8697f90711c65331 sorry i accidentally hit the quote button twice & couldn't figure out how to remove it.

What i've read on the internet is that it's an addition that Extra life would have to make on their end.  Something similar to this, if you're using apache:

Header set Access-Control-Allow-Origin "*"
AllowOverride all
Order allow,deny
Allow from all

My site is http://extralifealerts.com & all my code can be seen by looking at the source code.  I don't have anything hidden.

Decided to post my code.  I two .html files that it happens to, both are almost exact mirrors of each other when it comes to grabbing the json data.  I am assuming if i can fix it in one then i can fix it in the other, assuming this error is a problem on my end.

<html>
<head>
    <title>Extra-Life Alerts</title>
    <meta charset="utf-8">
    <link href="controller_blue.ico" rel="shortcut icon" type="image/x-icon">
    <link href="teamAlert.css" rel="stylesheet">
</head>
<body>
<?php header('Access-Control-Allow-Origin: *'); ?>
<script type="text/javascript" src="./javascript/jQuery/jquery-2.1.4.js"></script>
<script type="text/javascript" src="./javascript/jQuery-url-parser/2.3.1/purl.js"></script>
<script type="text/javascript" src="./javascript/dropzone/dropzone.js"></script>
<!--<script type="text/javascript" src="./javascript/feedback/jquery.feedback-1.2.0.js"></script>-->
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.marquee/1.3.1/jquery.marquee.min.js"></script>
<!--<script type="text/javascript" src="./javascript/json-parse/json_parse.js"></script>-->

<script>
    var currentDonation;
    var priorDonation = "0";
    var getText;

    function init() {

        $.ajaxPrefilter(function( options ) {
            options.async = true;
            options.cache = false;
            options.crossDomain = true;
        });

        // Parse setup parameters.
        var id = $.url().param('id');
        var audio = $.url().param('audio');
        var playAudio = document.createElement('audio');
        var marquee = $.url().param('marquee');

        var xmlhttp = new XMLHttpRequest();
        //var url = "http://extralifealerts.com/tempTeamDonations.txt";
        var url = "http://www.extra-life.org/index.cfm?fuseaction=donordrive.team&teamID="+id+"&format=json";

        function startXMLHTTP() {

            xmlhttp.open("GET", url, true);

            /*xmlhttp.onreadystatechange = function () {
                getText = xmlhttp.responseText
            };*/

            /*$.ajax({
                url: url,
                type: "GET",
                async: true,
                dataType: "json",
            }).done(function(data){
                //console.log("IN AJAX Data is "+data);
                currentDonation = data;
            });*/

            $.ajax({
                url: url,
                type: "GET",
                async: true,
                dataType: "json",
                jsonp: true,
                crossDomain: true,
                success: function (data) {
                    //console.log("IN AJAX Data is "+data);
                    currentDonation = data;
                }
            });

            //currentDonation = JSON.parse(getText);

            //console.log("after function currentDonation:  " + currentDonation);

            xmlhttp.onreadystatechange = function () {
                if ((xmlhttp.readyState == '4' && ( xmlhttp.status == '200' || xmlhttp.status == '204' ) ) &&
                        ( ( currentDonation.totalRaisedAmount != "0" || currentDonation.totalRaisedAmount >= priorDonation ) )) {
                    if(currentDonation.totalRaisedAmount == priorDonation)
                    {
                        return true;
                    }
                    else {
                        extraLifeAlert(xmlhttp.responseText);
                        //console.log("Executing the extralifealert function");
                    }
                }
            };

            xmlhttp.send();

            /* Debugging steps*/
            //console.log(xmlhttp.onreadystatechange);
            //console.log("TEST BEGINNING Amount:   Current: " + currentDonation + " | Prior: " + priorDonation);
        }

        setInterval(startXMLHTTP,5000);

        function extraLifeAlert(response) {
            var teamName = JSON.parse(response);
            var teamGoal = JSON.parse(response);
            var raisedAmount = JSON.parse(response);

            document.documentElement.style.overflow = 'hidden';  // firefox, chrome
            document.body.scroll = "no"; // ie only

            if (teamName.name) {
                $('#posts').find('.teamName').text(teamName.name);
            }
            if (teamGoal.fundraisingGoal) {
                $('#posts').find('.fundraisingGoal').text(teamGoal.fundraisingGoal);
            }
            if (raisedAmount.totalRaisedAmount) {
                $('#posts').find('.totalRaisedAmount').text("$" + raisedAmount.totalRaisedAmount);
            }

            if(priorDonation == "0"){
                setTimeout(function () {
                    $(document.getElementById('posts')).fadeIn(1000);
                }, 1000);
            }

            if (currentDonation.totalRaisedAmount > priorDonation) {
                setTimeout( function() {
                    $('#posts').find('.totalRaisedAmount').fadeOut(1000);
                }, 0);

                setTimeout(function() {
                    $('#posts').find('.totalRaisedAmount').fadeIn(1000);
                }, 2000);

                setTimeout(function(){
                    if (audio) {
                        playAudio.setAttribute('src', './audio/'+ audio);
                        playAudio.loop = false;
                        playAudio.load();
                        playAudio.play();
                    }
                }, 1000);
            }
            priorDonation = currentDonation.totalRaisedAmount;
            /** Debugging steps */
            //console.log("TEST END Amount:   Current: " + currentDonation.totalRaisedAmount + " | Prior: " + priorDonation);
        }

    }
    setInterval(init, 5000);
</script>

<div id="posts" class="entireMessage" style="display:none">
    <div id="teamGoal">
        <span class="teamName"></span><br>
        Goal: $<span class="fundraisingGoal"></span><br>
        Total Raised: <span class="totalRaisedAmount"></span>
    </div>
</div>

<script>
    /*$('.entireMessage').marquee({
     duration: 8000,
     gap: 50,
     delayBeforeStart: 8000,
     direction: 'left',
     duplicated: true
     });*/
</script>

<script>
    var effect = $.url().param('effect');
    var font = $.url().param('font');
    var headID = document.getElementsByTagName('head')[0];
    var link = document.createElement('link');
    link.rel = 'stylesheet';
    link.type = 'text/css';
    link.href = 'http://fonts.googleapis.com/css?family='+font+'&effect='+effect;
    headID.appendChild(link);

    document.getElementById('teamGoal').className = 'font-effect-'+effect;
    document.getElementById('teamGoal').style.fontFamily = font;
</script>

</body>
</html>

 

Edited by agentc0re

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...