css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <div class="container-fluid bg-dark">
  <br>
  <p class="title text-center">Random Q<i class="fa fa-quote-right" aria-hidden="true"></i>ote Generator</p>

  <br>

  <div class="d-flex flex-column box-style">
    <div class="mt-auto mr-auto p-2">

      <div class="p-2 box-quote">
        <i class="fa fa-quote-left fa-3x icon-color" aria-hidden="true"></i>
        <a id="quote-text"></a>
        <i class="fa fa-quote-right icon-color fa-lg" aria-hidden="true"></i>
      </div>

    </div>

    <div class="d-flex">
      <div class="ml-auto p-2 box-author" style="margin-right: 10%" id="quote-author">

      </div>
    </div>
    <div class="d-flex justify-content-center">
      <button class="btn btn-dark" id="new-quote" style="border-radius: 20px"> 
          new quote
        </button>
    </div>
    <div class="d-flex justify-content-start" style="margin: 0px 0px 0px 20px;">
      <div class="p-2"><a href=# id="share-tw" target="_blank"><i class="fa fa-twitter fa-3x tw-icon-color" data-toggle="tooltip" data-placement="bottom" title="tweet quote"></i></a></div>


      <div class="ml-auto" style="margin: 0px 20px 0px 0px;">
        <fieldset class="form-group" style="margin: 0px; padding: 0px;">
          <div class="form-check">
            <label class="form-check-label box-radios">
              <input type="radio" class="form-check-input" name="optionsRadios" id="optionsRadios1" value="eng" checked>
              English
            </label>
          </div>
          <div class="form-check">
            <label class="form-check-label box-radios">
              <input type="radio" class="form-check-input" name="optionsRadios" id="optionsRadios2" value="rus">
              русский
            </label>
          </div>
        </fieldset>
        </div>
      </div>
        <div class="d-flex justify-content-center">
          <div class="box-radios">powered by <a href="https://forismatic.com/en/" target="_blank">forismatic.com</a></div>
        </div>
      


    
  </div>

  <br>


</div>

<p class="text-center" style="background-color: #AAAAAA; font-family: monospace; color: black; margin-bottom: 0px">coded by <a href="https://codepen.io/timothypslattery/full/MOGBVK" target="_blank" style="color: black; font-style: italic; margin-bottom: 0px">timothy slattery</a></p>
            
          
!
            
              .title {
    font-family: Bitter, "Courier New", monospace;
    font-size: 32px;
    color: green;
    border-color: green;
    border-width: 6px;
    border-style: dashed;
    text-shadow: 4px 4px 0px #000;
    box-shadow: 4px 4px 0px #111;
    background-color: rgb(0,64,0);
  }

.box-style{
  background-color: black; 
  margin-right: 5%; 
  margin-left: 5%; 
  border-radius: 20px;
}

.box-author {
  font-family: "Courier New", monospace;
  font-size: 16px;
  font-style: italic;
  color: white;
  
}

.box-quote{
  
  font-family: "Courier New", monospace;
  font-size: 14px;
  color: white;
  
}

.icon-color{
  color: #333333;
}

.box-radios{
  
  font-family: "Courier New", monospace;
  font-size: 12px;
  color: white;
  margin-left: 20px;
  padding: 0px;
  
}
.tw-icon-color{
 color:  #0084b4;  
}

            
          
!
            
              /*
features to add:
previous quote button (back scroll through quotes already displayed)
translate shown quote ru<-->en google translate api?
        -->https://www.npmjs.com/package/google-translate-api
        or
        -->google api
*/

console.clear();

var initQuote = "You can't con people, at least not for long. You can create excitement, you can do wonderful promotion and get all kinds of press, and you can throw in a little hyperbole. But if you don't deliver the goods, people will eventually catch on.";
var initAuthor = "--Donald Trump, The Art of the Deal";

var lang = "";
var baseUrl =
  "https://api.forismatic.com/api/1.0/?format=jsonp&method=getQuote&jsonp=?&lang=";
var apiUrl = "";
var twitterUrl = "https://twitter.com/intent/tweet?";
var tweetUrl = "";

$(document).ready(function() {
  $("#quote-text").html(initQuote);
  $("#quote-author").html(initAuthor);

  tweetUrl =
    twitterUrl +
    "text=%22" +
    initQuote +
    "%22%0D%09--" +
    initAuthor +
    "%0D&hashtags=freecodecamp,randomquotes,forismatic";
  tweetUrl = tweetUrl.replace(/ /g, "%20");
  tweetUrl = tweetUrl.replace(/;/g, "%3B");

  $("#share-tw").attr("href", tweetUrl);

  
});

$("#new-quote").on("click", function() {
  if ($("input[name=optionsRadios]:checked").val() == "eng") {
    lang = "en";
  } else if ($("input[name=optionsRadios]:checked").val() == "rus") {
    lang = "ru";
  }

  apiUrl = baseUrl + lang;

  apiCall(apiUrl);
});

function apiCall(aurl) {
  $.ajax({
    dataType: "jsonp",
    url: aurl,
    success: function(data) {
      //$("#quote-text").html(data["quoteText"]);
      fadeOut("#quote-text",data["quoteText"]);

      if (data["quoteAuthor"] == "") {
        if (data["quoteLink"].slice(22, 24) == "ru") {
          fadeOut("#quote-author","--неизвестный");
        } else {
          fadeOut("#quote-author","--Unknown");
        }
      } else {
        fadeOut("#quote-author","--"+data["quoteAuthor"]);
      }

      tweetUrl =
        twitterUrl +
        "text=%22" +
        data["quoteText"] +
        "%22%0D%09--" +
        data["quoteAuthor"] +
        "%0D&hashtags=freecodecamp,randomquotes,forismatic";
      tweetUrl = tweetUrl.replace(/ /g, "%20");
      tweetUrl = tweetUrl.replace(/;/g, "%3B");

      $("#share-tw").attr("href", tweetUrl);
    },
    error: function(XMLHttpRequest, textStatus, errorThrown) {
      console.log(XMLHttpRequest["status"]);
    }
  });
}

function fadeOut(target, newText) {
  $(target).animate(
    {
      opacity: 0.3
    },
    200,
    function() {
      $(this).animate(
        {
          opacity: 1.0
        },
        800
      );
      $(target).html(newText);
    }
  );
}
/*
  fetch(url, {
    method: "POST",
    body: apiform
  })
    .then(response => response.json())
    .then(function(data) {
      $("#quote-text").html(data["quoteText"]);
      if (data["quoteAuthor"] == "") {
        if ((data["quoteLink"].slice(22, 24)) == "ru") {
          $("#quote-author").html("неизвестный");
        } else {
          $("#quote-author").html("Unknown");
        }
      } else {
        $("#quote-author").html(data["quoteAuthor"]);
      }
    });
  */

//$.ajaxSetup({ cache: false});

/*
  $.getJSON(url, function(data) {
    console.log(data);
    $("#quote-text").html(data["quoteText"]);
    if (data["quoteAuthor"] == "") {
      if (data["quoteLink"].slice(22, 24) == "ru") {
        $("#quote-author").html("неизвестный");
      } else {
        $("#quote-author").html("Unknown");
      }
    } else {
      $("#quote-author").html(data["quoteAuthor"]);
    }

  });
  */

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console