Skip to content

Instantly share code, notes, and snippets.

View waldothedeveloper's full-sized avatar
🎖️
Never give up!

Waldo Lavaut waldothedeveloper

🎖️
Never give up!
View GitHub Profile
@waldothedeveloper
waldothedeveloper / app.js
Created May 18, 2018 11:56
Grabbing the icon with the id of quote-icon and creating an event listener to be able to tweet a quote after a click
$(document).ready(() => {
console.log('ready!');
$("i#tweet-icon").on("click", () => {
let quote = $.trim($("#quote").text());
window.open(`https://twitter.com/intent/tweet?text=${quote}`);
});
});// end of document.ready
@waldothedeveloper
waldothedeveloper / app.js
Created May 18, 2018 12:03
Making a getJSON request to the forismatic API and showing the data back in the HTML card.
$(document).ready(() => {
let endpoint = 'https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?';
let getRandomQuote = () => {
$.getJSON(`${endpoint}`, (data) => {
$("#quote").html(`<i class="fas fa-quote-left"></i> ${data.quoteText} <i class="fas fa-quote-right"></i>`);
//Checking if the quote does not have an author
if (data.quoteAuthor !== "") {
$("#quote-author").html(`${data.quoteAuthor} at <a href="${data.quoteLink}" target="_blank" class="card-link">forismatic</a>`);
@waldothedeveloper
waldothedeveloper / app.js
Created May 18, 2018 12:06
Creating a tweetQuote function to tweet a quote
$(document).ready(() => {
//Create a tweet function
function tweetQuote() {
window.open(`https://twitter.com/intent/tweet?text=${data.quoteText}`);
}
$("#tweet-icon").on("click", tweetQuote);
};//end of getRandomQuote
$("#quote-button").on("click", getRandomQuote);
@waldothedeveloper
waldothedeveloper / app.js
Created May 18, 2018 12:09
The full javascript file about the freecodecamp quote app
$(document).ready(() => {
console.log('ready!');
$("i#tweet-icon").on("click", () => {
let quote = $.trim($("#quote").text());
window.open(`https://twitter.com/intent/tweet?text=${quote}`);
});
let endpoint = 'https://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=jsonp&jsonp=?';
@waldothedeveloper
waldothedeveloper / app.js
Created May 18, 2018 12:10
Another workaround for the random quotes assuming you save a bunch of quotes in an array
$(document).ready(()=> {
console.log("ready");
let quotesArray = ["quote1", "quote2", "quote3", "quote4", "quote5", "quote6", "quote7", "quote8", "quote9", "quote10"];
function randomQuote() {
let randQuote = Math.floor(Math.random() * quotesArray.length);
return $("p#quote").text(quotesArray[randQuote]);
};
@waldothedeveloper
waldothedeveloper / index.html
Created May 18, 2018 12:12
The HTML for the workaround of the FreeCodeCamp random quotes app
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
@waldothedeveloper
waldothedeveloper / index.html
Created June 5, 2018 13:00
This is the HTML file for my Wikipedia Viewer from FreeCodeCamp
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB"
@waldothedeveloper
waldothedeveloper / wiki.js
Last active June 5, 2018 15:05
Binding a click event to our random button on the wikipedia search API challenge from FreeCodeCamp
$(document).ready(() => {
$("#random").click(() => {
return window.open("https://en.wikipedia.org/wiki/Special:Random");
});
});
@waldothedeveloper
waldothedeveloper / wiki.js
Created June 5, 2018 15:14
The JS file for my Shortcutpedia Freecodecamp challenge of the Wikipedia API
$(document).ready(() => {
$("#random").click(() => {
return window.open("https://en.wikipedia.org/wiki/Special:Random");
});
let endpoint =
"https://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max&gsrsearch=";
function thisWholeThing() {
if (data.query === undefined) {
$("#results").append(
`<div class="list-group">
<div class="list-group-item list-group-item-action flex-column align-items-start">
<div class="d-flex w-100 justify-content-between">
<h5 class="mb-1">Suggestions:</h5>
</div>
<li class="mb-1">Make sure all words are spelled correctly.</li>
<li class="mb-1">Try different keywords.</li>
<li class="mb-1">Try more general keywords.</li>