Problem with Random Code Machine

Problem with Random Code Machine
0

#1

My Random Quote Machine was working fine apart from I had trouble of open the twitter message box in order to tweet quotes. Now all the code stopped working together. Please help! Here is my url : https://codepen.io/Alimama/pen/ddyZMO
Thanks!


#2

You have many errors showing in your browser’s console that you need to fix. Also, your code is not easy to read, because you are not indenting your code. Clean it up and I will take a look at it.


#3

Below, I have corrected all your errors, reorganized your code so all your global functions are at the top , and I indented the code.

You were missing closing parentheses in some parts of your code and you were missing some closing brackets in other parts.

function showTime() {
  var time = document.getElementById("time");
  time.innerHTML = Date();
}

function tweet() {
  window.open("https://twitter.com/intent/tweet/?text=" + $("#quote").html() + " By" + $("#author").html());
}

function hideTime() {
  var time = document.getElementById("time");
  time.innerHTML = "";
}

function animate() {
  $("#me").fadeToggle(800);
}

function quote(url) {
  $("#author").innerHTML = "";
  $("#quote").innerHTML = "";
  url = "https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?";
  $.getJSON(url, function(data) {
    $("#author").html(data.quoteAuthor);
    $("#quote").html(data.quoteText);
  });
}

$("#getQuote").on("mouseenter", showTime);
$("#getQuote").on("mouseleave", hideTime);
$("#getQuote").on("click", animate);
$("#getQuote").on("click", quote);

$("#me").click(function() {
  function change() {
    $("#heading").css("color", "yellow").slideUp(2000, color);
  }

  function color() {
    function again() {
      $("#heading").css("color", "blue");
    }
    $("#heading")
      .css("color", "green").slideDown(2000, again);
  }
  
  $("#heading").css("color", "yellow");
  setInterval(change, 2000);
  setInterval(color, 3000);
});

$("#tweetOut").on("click", tweet);

#4

Thank you very very much!