Debt

by Matt Saul

JavaScript

var debt,marketLine;


$(document).ready(function() {


  // get market direction (channeled through one of my sites)
  url = 'https://voteforyou.co/Auxiliary/get_nasdaq_direction';
  $.get(url).done(function(response) {

    console.log('raw stock change ' + response);
    // start as string since +1 is not recognized as int
    num = response.toString();
    // remove + if present
    num = num.replace('+', '');

    // convert back to int
    num = parseInt(num);

    if (num > 0) {
      marketLine = "the market might help us";
    }
    else if (num >= -100 && num <= 0) {
      marketLine = "the market may not help us";
    }
    else if (num < -100) {
      marketLine = "the market is bleeding red";
    }
  });
    
    
    
// get latest tweet from national debt Twitter account
var k = "https://voteforyou.co/Auxiliary/tweets_puller/national_debt";

    $.ajax({
        dataType: 'json',
        url: k,
        success: function (data) {
        
         

            $.each(data, function (i, item) {  
                tweet = item.text;  
            })
            
            // just first part of tweet
            spaceSplit = tweet.split(" ");
            debt = spaceSplit[0];
            
        }
    });
    
    



  setTimeout(writePoem, 1600);


});


function writePoem() {
  document.write("our national debt is at: " + debt + '<br>');
  document.write(marketLine + '<br>');
  document.write('we can screw poor people out of healthcare<br>');
  document.write('or we can get corporations to pay their fair share<br>');
  
}