cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              <link href="//netdna.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<div class="bg-img">
	<div class="container" id = "my-page">

		<div class="row text-center">

			<div class="col-md-12 buttons-line">
				<button id="updateQuote" class="btn btn-primary">
					<span class="glyphicon glyphicon-refresh"></span>
					Update Quote
				</button>
				<!--a id = "twit-button" href="https://twitter.com/intent/tweet?text=hello" class="btn btn-primary" target="_blank"-->
				<a id = "twit-button" href="" class="btn btn-primary" target="_blank">
					<i class="fa fa-twitter fa-1x" aria-hidden="true"></i></a>
			</div>
		</div>
		<div class="row text-center">
			<div class="col-md-12">
				<div class="quote">
				</div>
			</div>
		</div>
	</div>
</div>
            
          
!
            
              body, html {
	height: 100%;
	margin:0;
}

#my-page {
	padding-top: 250px;
}

.fa-twitter {
	/*color: #55ACEE;*/
}

.quote {
	color: white;
	font-family: Lato;
}
.author {

}


.bg-img {
	/* The image used */

	background-image: 
		url("https://source.unsplash.com/a4gpTwtaAjw/1600x900");
	min-height: 100%;
	background-attachment: fixed;
	background-position: center;
	background-repeat: no-repeat;
	background-size: cover;
}


.buttons-line {
	margin-bottom: 20px;
}

            
          
!
            
              $(document).ready(function() {
	/* Prevent a browser to cache a single quote which prevents quotes update*/
	$.ajaxSetup({
		cache: false
	});

	const API_ENDPOINT = "https://quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1&callback=";

	/* Fires when the page loads*/
	update(API_ENDPOINT);
	/*
	$.getJSON(API_ENDPOINT, function(json) {
		console.log(json); 
		quoteHtml = "<><h2>" + json[0].content + "</h2><div class='text-right'><em>" + json[0].title + "</em></div></h1>";
		console.log(quoteHtml);
		$(".quote").html(quoteHtml);
	});
	*/
	/* Update a quote on button click*/

	$("#updateQuote").on('click', function() {
		update(API_ENDPOINT);

		/*
		$.getJSON(API_ENDPOINT, function(json) {
			quoteHtml = "<div><h2>" + json[0].content + "</h2><div class='text-right'><em>" + json[0].title + "</em></div></h1>";
			$(".quote").html(quoteHtml);

		});
		*/
	});

});

function update(API_ENDPOINT){
	var	quote = '';
	var author = '';
	$.getJSON(API_ENDPOINT, function(json) {
		var quoteHtml = "";
		author = json[0].title;
		let quoteRaw = json[0].content;
		let quotePr = $(quoteRaw).text();
		quote = quotePr.concat("(", author, ")");
		quoteHtml = '<div><h3>' + json[0].content +  '</h3><div class="text-center"><em>' + json[0].title + "</em></div></div>";
		$(".quote").html(quoteHtml);
		var text = "https://twitter.com/intent/tweet?text=".concat(quote);
		console.log("text", text);
		$("#twit-button").attr("href", text);
	});

}
            
          
!
999px
Loading ..................

Console