diff --git a/src/components/Background.jsx b/src/components/Background.jsx index 69425261..1380d077 100644 --- a/src/components/Background.jsx +++ b/src/components/Background.jsx @@ -1,11 +1,6 @@ import React from 'react'; import Fetch from 'unfetch'; -const getCookie = (cookiename) => { - const cookiestring = RegExp('' + cookiename + '[^;]+').exec(document.cookie); - return unescape(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./,'') : ''); -}; - const randomInt = (min, max) => { return Math.floor(Math.random() * (max - min + 1)) + min; }; export default class Background extends React.Component { @@ -17,18 +12,9 @@ export default class Background extends React.Component { let data = await Fetch('https://api.muetab.xyz/getImage?category=Outdoors'); data = await data.json(); - const checkRepeat = getCookie('backgroundimageurl'); + root.style.backgroundImage = `url(${data.file})`; document.getElementById('photographer').innerText = `Photo by ${data.photographer}`; - document.getElementById('location').innerText = `${data.location}`; - - if (checkRepeat !== root.style.backgroundImage) root.style.backgroundImage = `url(${data.file})`; - else { - /*let data = await Fetch('https://api.muetab.xyz/getImage?category=Outdoors'); - data = await data.json();*/ - document.cookie = 'backgroundimageurl; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;'; - root.style.backgroundImage = `url(${data.file})`; - document.cookie = `backgroundimageurl=${data.file}`; - } + document.getElementById('location').innerText = `${data.location}`; } catch (e) { document.getElementById('backgroundCredits').style.display = 'none'; document.getElementById('photographer').innerText = 'Photo from Pexels';