/*$(document).ready(function(){ $(".btn").on('click', function(){ $.getJSON("https://www.quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1", function(data){ $.each(data, function(i, data){ $('.quote__container--text').html(JSON.stringify(data.content)) $('.quote__container--author').html(JSON.stringify(data.title)) console.log("working"); }) }); }); });*/ /*var randomQuote; var author; var url = "http://quotesondesign.com/wp-json/posts"; function getQuote(){ } })*/ $(".quote__container--generator-btn").on("click", function() { $.ajax({ method: "GET", url: "http://www.quotesondesign.com/wp-json/posts?filter[orderby]=rand&filter[posts_per_page]=1", cache: false, dataType: "json" }).then(function(data) { $(".quote__container--text").html('"' + data[0].content.replace(/^

(.*)<\/p>\n$/, "$1") + '"'); $(".quote__container--author").html("- " + data[0].title); var a = document.getElementById('tweet'); var linkText = document.createTextNode(""); a.appendChild(linkText); a.title = "Tweet"; a.href = "https://twitter.com/intent/tweet?text=" + '"' + encodeURIComponent(data[0].content.replace(/^

(.*)<\/p>\n$/, "$1")).replace(/'/g, "%27") + '"' + " -" + data[0].title; a.target = "_blank"; document.getElemenysByClassName('quote__container--buttons').appendChild(a); }); }); // var a = document.getElementById('tweet'); // var linkText = document.createTextNode("Tweet"); // a.appendChild(linkText); // a.title = "Tweet"; // a.href = "https://twitter.com/intent/tweet?text="; // a.target = "_blank"; // document.getElemenysByClassName('quote__container--buttons').appendChild(a); // $(".quote__container--tweet-btn").on('click', function(){ // $.ajax({ // method: "GET", // url: "https://twitter.com/intent/tweet?text=", // cache: false, // dataType: "json" // }).then(function(data){ // console.log(url); // // var url = "https://twitter.com/intent/tweet?text=" + data[0].content.replace(/^

(.*)<\/p>\n$/, "$1" + "-" + data[0].title // }); /*let colors = ['#4286f4', '#7a42f4', '#f44141', '#450e47', '#053c3d', '#0b2111']; let randColor = colors[Math.floor(Math.random()*colors.length)]; $(".btn").on("click", function() { $('.quote__container--text').css({"color", "randColor"}); })*/