Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <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>
              
            
!

CSS

              
                .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;  
}

              
            
!

JS

              
                /*
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

Console