Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var clickOnce = false;
- var intervalID;
- $(function() {
- var quote_index = getUrlParameter('quote');
- if(quote_index) {
- alert("Quote ID is " + quote_index);
- } else {
- startQuote();
- }
- });
- function startQuote() {
- if(clickOnce) {
- intervalID = setInterval(function() {
- var tempIndex = Math.floor(Math.random()*quotes.length);
- document.getElementById("trump").innerHTML = quotes[tempIndex].body;
- document.getElementById("dateObj").innerHTML = quotes[tempIndex].date;
- document.getElementById("dateObj").setAttribute('href', quotes[tempIndex].source);
- }, 1000);
- clickOnce = false;
- }
- }
- function stopQuote() {
- if(!clickOnce) {
- clearInterval(intervalID);
- clickOnce = true;
- history.pushState({}, document.title, newURL);
- }
- }
- var getUrlParameter = function getUrlParameter(sParam) {
- var sPageURL = decodeURIComponent(window.location.search.substring(1)),
- sURLVariables = sPageURL.split('&'),
- sParameterName,
- i;
- for (i = 0; i < sURLVariables.length; i++) {
- sParameterName = sURLVariables[i].split('=');
- if (sParameterName[0] === sParam) {
- return sParameterName[1] === undefined ? true : sParameterName[1];
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement