diff --git a/dist/api/blog/blogData.php b/dist/api/blog/blogData.php index cfa375b..d6128fb 100644 --- a/dist/api/blog/blogData.php +++ b/dist/api/blog/blogData.php @@ -673,11 +673,6 @@ EOD; */ public function changeHTMLSrc(string $body, string $to, string $from): string { -// $body = preg_replace_callback('/>([^<]+)' . htmlentities(trim($matches[1]), ENT_QUOTES | ENT_HTML5, 'UTF-8') . '<'; -// }, $body); - $htmlDoc = new DOMDocument(); // Load the raw HTML content into DOMDocument diff --git a/dist/blog/js/index.js b/dist/blog/js/index.js index cf5a174..9f44b29 100644 --- a/dist/blog/js/index.js +++ b/dist/blog/js/index.js @@ -1 +1 @@ -const scrollLimit=150;function goToURL(t){let e=t.split("/");if("accepted"===localStorage.getItem("cookiePopup")&&document.querySelector("#cookiePopup").classList.add("hidden"),"/blog"!==t&&"blog"!==t&&"/blog/"!==t)if("post"!==e[2]){if("category"===e[2])return e[3]?void loadPostsByCategory(e[e.length-1]):void loadAllCategories().catch((t=>console.log(t)));if("search"===e[2]&&e[3])loadSearchResults(e[e.length-1]);else{if("policy"===e[2]){if("privacy"===e[3])return void loadPrivacyPolicy();if("cookie"===e[3])return void loadCookiePolicy()}"unsubscribe"===e[2]&&e[3]?unsubscribe(e[e.length-1]):show404()}}else loadIndividualPost(e[e.length-1]).catch((t=>console.log(t)));else loadHomeContent()}function submitNewsletter(){fetch(`/api/blog/newsletter/${document.querySelector("#email").value}`,{method:"POST",headers:{"Content-Type":"application/json"}}).then((t=>t.json().then((e=>(document.querySelector("#newsletterMessage").classList.remove("hidden"),e.message.includes("exists")?(document.querySelector("#newsletterMessage").classList.add("error"),document.querySelector("#newsletterMessage").classList.remove("success"),void(document.querySelector("#newsletterMessage div").innerHTML='You"ve already signed up you silly goose!')):t.ok?(document.querySelector("#newsletterMessage div").innerHTML=e.message,void document.querySelector("#newsletterMessage").classList.add("success")):(document.querySelector("#newsletterMessage").classList.add("error"),document.querySelector("#newsletterMessage").classList.remove("success"),void(document.querySelector("#newsletterMessage div").innerHTML=e.error)))))))}function unsubscribe(t){fetch(`/api/blog/newsletter/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}}).then((t=>t.json().then((t=>{document.querySelector("#main").innerHTML="";let e=document.createElement("section");e.classList.add("unsubscribe"),e.id="unsubscribe";let n=document.createElement("div");n.classList.add("centered"),n.innerHTML=`\n\t\t\t

Unsubscribe

\n\t\t\t

${t.message}

\n \tSee all blog posts\n\t\t`,e.appendChild(n),document.querySelector("#main").appendChild(e)}))))}function createFormattedDate(t){return new Date(t).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}function createLargePost(t){let e=document.createElement("div");e.classList.add("outerContent");let n=document.createElement("img");n.className="banner",n.src=t.headerImg.replaceAll("%2F","/"),n.alt=t.title,e.appendChild(n);let o=document.createElement("div");o.classList.add("content");let a=document.createElement("div");a.classList.add("postContent");let i="";t.categories.split(", ").forEach((e=>{i+=`${e}`,t.categories.split(", ").length>1&&(i+=", ")})),i.endsWith(", ")&&(i=i.substring(0,i.length-2));let s=createFormattedDate(t.dateModified);return a.innerHTML=`\n

${t.title}

\n

Last updated: ${s} | ${i}

\n

${t.abstract}

\n See Post\n `,o.appendChild(a),e.appendChild(o),e}function createCardPost(t){let e=document.createElement("div");e.classList.add("cardItem"),e.id="post"+t.ID;let n=document.createElement("img");n.className="cardImg",n.src=t.headerImg.replaceAll("%2F","/"),n.alt=t.title,e.appendChild(n);let o=document.createElement("div");return o.classList.add("content"),o.innerHTML=`\n\t\t\t\t\t

${t.title}

\n\t\t\t\t\t

Last updated: ${createFormattedDate(t.dateModified)}

\n\t\t\t\t\tSee Post\n\t\t\t\t\t`,e.appendChild(o),e}function loadHomeContent(){fetch("/api/blog/post").then((t=>t.json().then((t=>{let e=document.createElement("section");e.classList.add("largePost"),e.id="olderPosts";let n=document.createElement("h1");n.innerHTML="older posts",e.appendChild(n);let o=document.createElement("div");o.classList.add("carousel"),o.innerHTML+='\n\t\t\t\t\t\t\t \n\t\t\t\t\t\t \t ';let a=document.createElement("div"),i=document.createElement("div"),s=document.createElement("div");a.classList.add("carouselOuter"),i.id="carouselInner",s.id="allCarouselItems",a.appendChild(s),a.appendChild(i),o.appendChild(a),e.appendChild(o);for(let e=0;e1&&s.appendChild(createCardPost(t[e]))}document.querySelector("#main").appendChild(e),carouselLoop(i,s)}))))}function carouselLoop(t,e){const n=document.querySelector("#prev"),o=document.querySelector("#next"),a=window.matchMedia("(max-width: 75em)"),i=window.matchMedia("(max-width: 30em)");let s=document.querySelectorAll("#allCarouselItems .cardItem"),r=3;a.matches&&(r=2),i.matches&&(r=1);let c=[];for(let e=0;e{const n=c.shift();n.style.visibility="hidden";const o=e.querySelector(".cardItem");o.style.transform="translateX(100%)",o.style.transition="none",t.appendChild(o),c.push(o),setTimeout((()=>{for(let e=0;e{n.style.transition="none",n.style.transform="translateX(0)",e.appendChild(n),n.style.visibility="visible";for(let e=0;e{const n=c.pop();n.style.visibility="hidden";const o=e.querySelector(".cardItem:last-child");o.style.transform="translateX(-100%)",o.style.transition="none",t.insertBefore(o,t.firstChild),c.unshift(o),setTimeout((()=>{for(let e=0;e{n.style.transition="none",n.style.transform="translateX(0)",e.insertBefore(n,e.firstChild),n.style.visibility="visible";for(let e=0;et.json())),await fetch("/api/blog/post/featured").then((t=>t.json()))]}function csvToArray(t){let e="",n=[""],o=0,a=!0,i=null;for(i of t)'"'===i?(a&&i===e&&(n[o]+=i),a=!a):","===i&&a?i=n[++o]="":"\n"===i&&a?("\r"===e&&(row[o]=row[o].slice(0,-1)),n=n[++r]=[i=""],o=0):n[o]+=i,e=i;return n}async function getCategories(){let t=await fetch("/api/blog/categories").then((t=>t.json())),e=[];return t.forEach((t=>e=e.concat(csvToArray(t.categories.replace(/\s*,\s*/g,","))))),[...new Set(e)]}function createCategories(t){let e="";return t.forEach((t=>e+=`${t}`)),e}function createButtonCategories(t){let e="";return t.forEach((t=>t.forEach((t=>e+=`${t}`)))),e}async function createSideContent(){let t=await getLatestAndFeaturedPosts(),e=t[0],n=t[1],o=createCategories(await getCategories()),a=document.createElement("aside");return a.classList.add("sideContent"),a.innerHTML=`\n
\n
\n My professional picture taken in brighton near\n                                        north street at night wearing a beige jacket and checkered shirt\n

Rohit Pai

\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n

Avid Full Stack Dev | Uni of Notts Grad | Amateur Blogger

\n
\n \n \n \n
\n\t\t\t\t\t\t\t\t

feeds

\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tAtom\n\t\t\t\t\t\t\t\t\tJSON\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n
\n

categories

\n ${o}\n
\n \n `,a}function createMetaTag(t,e,n){let o=document.querySelector(`meta[name="${t}"], meta[property="${t}"]`);if(!o){let o=document.createElement("meta");return o.setAttribute(t.includes("name")?"name":"property",t),o.setAttribute(e,n),void document.head.appendChild(o)}o.setAttribute(e,n)}function insertMetaTags(t){document.querySelector("meta[name='description']").setAttribute("content",t.abstract),createMetaTag("twitter:title","content",t.title),createMetaTag("twitter:description","content",t.abstract),createMetaTag("twitter:image","content",t.headerImg),createMetaTag("og:title","content",t.title),createMetaTag("og:description","content",t.abstract),createMetaTag("og:image","content",t.headerImg),createMetaTag("og:url","content",window.location.href),createMetaTag("og:type","content","blog"),createMetaTag("og:site_name","content",'Rohit Pai"s Blog'),createMetaTag("og:locale","content","en_GB");let e=document.querySelector("meta[name='keywords']"),n=e.getAttribute("content");n+=`, ${t.keywords}`,e.setAttribute("content",n)}async function loadIndividualPost(t){document.title="Rohit Pai - "+decodeURI(t),await fetch(`/api/blog/post/${t}`).then((async e=>{e.ok?await e.json().then((async e=>{insertMetaTags(e);let n=document.createElement("section");n.classList.add("post"),n.id="individualPost";let o=document.createElement("div");o.classList.add("mainContent");let a=document.createElement("article"),i=e.headerImg.replaceAll("%2F","/");a.innerHTML=`\n

${e.title}

\n \n
\n ${e.body}\n `;let s=document.createElement("section");s.classList.add("comments"),s.innerHTML='

Comments

\n
\n ',o.appendChild(a),o.appendChild(s);let r=await createSideContent();n.appendChild(o),n.appendChild(r),document.querySelector("#main").appendChild(n);var c,l;c=document,(l=c.createElement("script")).src="https://rohitpaiportfolio.disqus.com/embed.js",l.setAttribute("data-timestamp",+new Date),c.body.appendChild(l),Prism.highlightAll()})):show404()}))}async function loadAllCategories(){document.title="Rohit Pai - Categories";let t=await getCategories(),e=document.querySelector("#main"),n=document.createElement("section");n.classList.add("categories"),n.id="allCategories";let o=document.createElement("h1");o.innerHTML="Categories",e.appendChild(o);for(let e of t){let t=document.createElement("div");t.classList.add("btnContainer");let o=document.createElement("a");o.classList.add("btn"),o.classList.add("btnPrimary"),o.innerHTML=e,o.href=`/blog/category/${e}`,t.appendChild(o),n.appendChild(t)}e.appendChild(n)}function loadPostsByCategory(t){document.title="Rohit Pai - "+decodeURI(t),fetch(`/api/blog/categories/${t}`).then((e=>e.json().then((e=>{let n=document.querySelector("#main"),o=document.createElement("section");o.classList.add("catPosts"),o.id="postsByCategory";let a=document.createElement("h1");a.innerHTML=decodeURI(t),n.appendChild(a);for(let t=0;tt.json().then((t=>{let e=document.querySelector("#main"),n=document.createElement("section");n.classList.add("catPosts"),n.id="searchResults";let o=document.createElement("h1");o.innerHTML="Search Results",e.appendChild(o);for(let e=0;e\n\t\t\t
\n\n\t\t\t

Sources of Information and Tracking Technologies

\n\t\t\t

\n\t\t\t\tI collect information that you directly provide to me, such as when you submit a form or send me a message with your information. I may also receive information about you from my partners, including but not limited to distribution partners, data services, and marketing firms. I may combine this information with other information I collect from or about you. In these cases, my Privacy Policy governs the handling of the combined information. I and my partners may collect the information noted in this privacy policy using cookies, web beacons, pixels, and other similar technologies. These technologies are used for authentication, to store your preferences or progress, for analytics, and for advertising and analytics. Cookies are small text files stored on your computer. You can set your browser to reject cookies altogether, to reject my cookies in particular, or to delete cookies. However, this may cause some or all of my Services not to function on your computer or device.\n\t\t\t

\n\t\t\t
\n\t\t\t

How I Use Your Information

\n\t\t\t

\n\t\t\t\tI use information I collect about you to provide, maintain, and improve my Services and other interactions I have with you. For example, I use the information collected to:\n\t\t\t

\n\t\t\t
    \n\t\t\t\t
  • Facilitate and improve your online experience;
  • \n\t\t\t\t
  • Provide and deliver products and services, perform authentication, process transactions and returns, and send you related information, including confirmations, receipts, invoices, customer experience surveys, and product or Services-related notices;
  • \n\t\t\t\t
  • Process and deliver promotions;
  • \n\t\t\t\t
  • Respond to your comments and questions and provide customer service;
  • \n\t\t\t\t
  • If you have indicated to me that you wish to receive notifications or promotional messages;
  • \n\t\t\t\t
  • Detect, investigate and prevent fraudulent transactions and other illegal activities and protect my rights and property and others;
  • \n\t\t\t\t
  • Comply with my legal and financial obligations;
  • \n\t\t\t\t
  • Monitor and analyze trends, usage, and activities;
  • \n\t\t\t\t
  • Provide and allow my partners to provide advertising and marketing targeted toward your interests.
  • \n\t\t\t
\n\t\t\t
\n\t\t\t

How I May Share Information

\n\t\t\t

\n\t\t\t\tI may share your Personal Information in the following situations:\n\t\t\t

\n\t\t\t
    \n\t\t\t\t
  • \n\t\t\t\t\tThird Party Services Providers.\n\t\t\t\t\tI may share data with service providers, vendors, contractors, or agents who complete transactions or perform services on my behalf, such as those that assist me with my business and internal operations like shipping and delivery, payment processing, fraud prevention, customer service, gift cards, experiences, personalization, marketing, and advertising;\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tChange in Business.\n\t\t\t\t\tI may share data in connection with a corporate business transaction, such as a merger or acquisition of all or a portion of my business to another company, joint venture, corporate reorganization, insolvency or bankruptcy, financing or sale of company assets;\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tTo Comply with Law.\n\t\t\t\t\tI may share data to facilitate legal process from lawful requests by public authorities, including to meet national security or law enforcement demands as permitted by law.\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tWith Your Consent.\n\t\t\t\t\tI may share data with third parties when I have your consent.\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tWith Advertising and Analytics Partners.\n\t\t\t\t\tSee the section entitled “Advertising and Analytics” below.\n\t\t\t\t
  • \n\t\t\t
\n\t\t\t
\n\t\t\t

Advertising and Analytics

\n\t\t\t

\n\t\t\t\tI use advertising and analytics technologies to better understand your online activity on my Services to provide personalized products and services that may interest you. I may allow third-party companies, including ad networks, to serve advertisements, provide other advertising services, and/or collect certain information when you visit my website. Third-party companies may use pseudonymized personal data (e.g., click stream information, browser type, time and date, subject of advertisements clicked or scrolled over) during your visit to this website in order to provide advertisements about goods and services likely to be of interest to you, on this website and others. To learn more about Interest-Based Advertising or to opt-out of this type of advertising, you can visit AboutAds.info/choices or www.networkadvertising.org/choices. Some third-party companies may also use non-cookie technologies, such as statistical IDs. Please keep in mind that your web browser may not permit you to block the use of these non-cookie technologies, and those browser settings that block cookies may have no effect on such techniques. If the third-party company uses the non-cookie technologies for interest-based advertising, you can opt out at www.networkadvertising.org/choices. Please note the industry opt out only applies to use for interest-based advertising and may not apply to use for analytics or attribution. Some websites have “do not track” features that allow you to tell a website not to track you. These features are not all uniform. I do not currently respond to those signals.\n\t\t\t

\n\t\t\t
\n\t\t\t

Data Security

\n\t\t\t

\n\t\t\t\tI implement commercially reasonable security measures designed to protect your information. Despite my best efforts, however, no security measures are completely impenetrable.\n\t\t\t

\n\t\t\t
\n\t\t\t

Data Retention

\n\t\t\t

\n\t\t\t\tI store the information I collect about you for as long as necessary for the purpose(s) for which I collected it or for other legitimate business purposes, including to meet my legal, regulatory, or other compliance obligations.\n\t\t\t

\n\t\t\t
\n\n\t\t\t

EU Privacy Rights

\n\n\t\t\t

Individuals located in certain countries, including the European Economic Area (EEA) and the United Kingdom, have certain statutory rights under the General Data Protection Regulation (GDPR) in relation to their personal data.

\n\t\t\t

To the extent information I collect is associated with an identified or identifiable natural person and is protected as personal data under GDPR, it is referred to in this Privacy Policy as “Personal Data”.

\n\t\t\t

\n\t\t\t\tData Subject Access Requests\n\t\t\t

\n\t\t\t

\n\t\t\t\tSubject to any exemptions provided by law, you may have the right to request:\n\t\t\t

\n\t\t\t
    \n\t\t\t\t
  • \n\t\t\t\t\ta copy of the Personal Data I hold about you;\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tto correct the Personal Data I hold about you;\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tto delete your Account or Personal Data;\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tto object to processing of your Personal Data for certain purposes;\n\t\t\t\t
  • \n\t\t\t
\n\n\t\t\t

\n\t\t\t\tTo access your privacy rights, send me an email at rohit@rohitpai.co.uk.\n\t\t\t

\n\t\t\t

\n\t\t\t\tI will generally process requests within one month. I may need to request specific information from you to help me confirm your identity and/or the jurisdiction in which you reside. If your request is complicated or if you have made a large number of requests, it may take me longer. I will let you know if I need longer than one month to respond.\n\t\t\t

\n\t\t\t

\n\t\t\t\tLegal Bases For Processing Personal Data\n\t\t\t

\n\t\t\t

\n\t\t\t\tI may process your Personal Data under applicable data protection law on the following legal grounds:\n\t\t\t

\n\t\t\t
    \n\t\t\t\t
  • \n\t\t\t\t\tContractual Necessity:\n\t\t\t\t\tI may process your Personal Data to enter into or perform a contract with you.\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tConsent:\n\t\t\t\t\twhere you have provided consent to process your Personal Data. You may withdraw your consent at any time.\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tLegitimate interest:\n\t\t\t\t\tI process your Personal Data to provide my Services to you such as to provide my online user experience, communicate with you, provide customer service, market, analyze and improve my business, and to protect my Services.\n\t\t\t\t
  • \n\t\t\t
\n\t\t\t
\n\t\t\t

Age Limitations

\n\t\t\t

\n\t\t\t\tMy Service is intended for adults ages 18 years and above. I do not knowingly collect personally identifiable information from children. If you are a parent or legal guardian and think your child under 13 has given me information, please email or write to me at the address listed at the end of this Privacy Policy. Please mark your inquiries “COPPA Information Request.”\n\t\t\t

\n\t\t\t
\n\t\t\t

Changes to this Privacy Policy

\n\t\t\t

\n\t\t\t\tRohit Pai may change this Privacy Policy from time to time. I encourage you to visit this page to stay informed. If the changes are material, I may provide you additional notice to your email address or through my Services. Your continued use of the Services indicates your acceptance of the modified Privacy Policy.\n\t\t\t

\n\t\t\t
\n\t\t\t

Newsletters

\n\t\t\t

\n\t\t\t\tYou can opt in to receive my marketing emails and/or newsletters by below. I may still send you transactional messages, which include Services-related communications and responses to your questions.\n\t\t\t

\n\t\t\t
\n\t\t\t

Storage of Information in the United States

\n\t\t\t

\n\t\t\t\tInformation I maintain may be stored both within and outside of the United States. If you live outside of the United States, you understand and agree that I may transfer your information to the United States, and that U.S. laws may not afford the same level of protection as those in your country.\n\t\t\t

\n\t\t\t
\n\t\t\t

Contact Me

\n\t\t\t

\n\t\t\t\tIf you have questions, comments, or concerns about this Privacy Policy, you may contact me at:\n\t\t\t

\n\t\t\tContact\n\t\t\trohit@rohitpai.co.uk\n\t\t\n\t\t'}function loadCookiePolicy(){document.querySelector("#main").innerHTML='\n\t\t
\n\t\t\t

Cookies Policy

\n\t\t\t

I only use functional cookies for the blog which includes PHP Session ID, disqus. a cookie to disable the cookie popup, and maybe share this. I think that these are functional cookies, if you don\'t, you\'re welcome to exit the site or tell me by emailing me through the email address below, or the contact form on the contact section of my main website.

\n\t\t\t
\n\t\t\trohit@rohitpai.co.uk\n\t\t\t
\n\t\t\tcontact\n\t\t
\n\t'}function show404(){document.querySelector("#main").innerHTML='\n
\n
\n

Blog post, Category or page not found

\n See all blog posts\n
\n
\n '}document.addEventListener("DOMContentLoaded",(()=>{goToURL(window.location.pathname)})),window.addEventListener("popstate",(t=>{goToURL(window.history.state)})),window.onscroll=()=>{document.body.scrollTop>=150||document.documentElement.scrollTop>=150?document.querySelector("nav").classList.add("scrolled"):document.querySelector("nav").classList.remove("scrolled")},document.querySelector("#searchBtn").addEventListener("click",(t=>{let e=document.querySelector("#searchField").value;e.length>0&&(window.history.pushState(null,null,`/blog/search/${e}`),document.querySelector("#searchField").value="",document.querySelector("#main").innerHTML="",goToURL(`/blog/search/${e}`))})),document.querySelector("#searchField").addEventListener("keyup",(t=>{"Enter"===t.key&&document.querySelector("#searchBtn").click()})),document.querySelector("#cookieAccept").addEventListener("click",(t=>{document.querySelector("#cookiePopup").classList.add("hidden"),localStorage.setItem("cookiePopup","accepted")})); \ No newline at end of file +const scrollLimit=150;function goToURL(t){let e=t.split("/");if("accepted"===localStorage.getItem("cookiePopup")&&document.querySelector("#cookiePopup").classList.add("hidden"),"/blog"!==t&&"blog"!==t&&"/blog/"!==t)if("post"!==e[2]){if("category"===e[2])return e[3]?void loadPostsByCategory(e[e.length-1]):void loadAllCategories().catch((t=>console.log(t)));if("search"===e[2]&&e[3])loadSearchResults(e[e.length-1]);else{if("policy"===e[2]){if("privacy"===e[3])return void loadPrivacyPolicy();if("cookie"===e[3])return void loadCookiePolicy()}"unsubscribe"===e[2]&&e[3]?unsubscribe(e[e.length-1]):show404()}}else loadIndividualPost(e[e.length-1]).catch((t=>console.log(t)));else loadHomeContent()}function submitNewsletter(){fetch(`/api/blog/newsletter/${document.querySelector("#email").value}`,{method:"POST",headers:{"Content-Type":"application/json"}}).then((t=>t.json().then((e=>(document.querySelector("#newsletterMessage").classList.remove("hidden"),e.message.includes("exists")?(document.querySelector("#newsletterMessage").classList.add("error"),document.querySelector("#newsletterMessage").classList.remove("success"),void(document.querySelector("#newsletterMessage div").innerHTML='You"ve already signed up you silly goose!')):t.ok?(document.querySelector("#newsletterMessage div").innerHTML=e.message,void document.querySelector("#newsletterMessage").classList.add("success")):(document.querySelector("#newsletterMessage").classList.add("error"),document.querySelector("#newsletterMessage").classList.remove("success"),void(document.querySelector("#newsletterMessage div").innerHTML=e.error)))))))}function unsubscribe(t){fetch(`/api/blog/newsletter/${t}`,{method:"DELETE",headers:{"Content-Type":"application/json"}}).then((t=>t.json().then((t=>{document.querySelector("#main").innerHTML="";let e=document.createElement("section");e.classList.add("unsubscribe"),e.id="unsubscribe";let n=document.createElement("div");n.classList.add("centered"),n.innerHTML=`\n\t\t\t

Unsubscribe

\n\t\t\t

${t.message}

\n \tSee all blog posts\n\t\t`,e.appendChild(n),document.querySelector("#main").appendChild(e)}))))}function createFormattedDate(t){return new Date(t).toLocaleDateString("en-GB",{day:"2-digit",month:"short",year:"numeric"})}function createLargePost(t){let e=document.createElement("div");e.classList.add("outerContent");let n=document.createElement("img");n.className="banner",n.src=t.headerImg.replaceAll("%2F","/"),n.alt=t.title,e.appendChild(n);let o=document.createElement("div");o.classList.add("content");let a=document.createElement("div");a.classList.add("postContent");let i="";t.categories.split(", ").forEach((e=>{i+=`${e}`,t.categories.split(", ").length>1&&(i+=", ")})),i.endsWith(", ")&&(i=i.substring(0,i.length-2));let s=createFormattedDate(t.dateModified);return a.innerHTML=`\n

${t.title}

\n

Last updated: ${s} | ${i}

\n

${t.abstract}

\n See Post\n `,o.appendChild(a),e.appendChild(o),e}function createCardPost(t){let e=document.createElement("div");e.classList.add("cardItem"),e.id="post"+t.ID;let n=document.createElement("img");n.className="cardImg",n.src=t.headerImg.replaceAll("%2F","/"),n.alt=t.title,e.appendChild(n);let o=document.createElement("div");return o.classList.add("content"),o.innerHTML=`\n\t\t\t\t\t

${t.title}

\n\t\t\t\t\t

Last updated: ${createFormattedDate(t.dateModified)}

\n\t\t\t\t\tSee Post\n\t\t\t\t\t`,e.appendChild(o),e}function loadHomeContent(){fetch("/api/blog/post").then((t=>t.json().then((t=>{let e=document.createElement("section");e.classList.add("largePost"),e.id="olderPosts";let n=document.createElement("h1");n.innerHTML="older posts",e.appendChild(n);let o=document.createElement("div");o.classList.add("carousel"),o.innerHTML+='\n\t\t\t\t\t\t\t \n\t\t\t\t\t\t \t ';let a=document.createElement("div"),i=document.createElement("div"),s=document.createElement("div");a.classList.add("carouselOuter"),i.id="carouselInner",s.id="allCarouselItems",a.appendChild(s),a.appendChild(i),o.appendChild(a),e.appendChild(o);for(let e=0;e1&&s.appendChild(createCardPost(t[e]))}document.querySelector("#main").appendChild(e),carouselLoop(i,s)}))))}function carouselLoop(t,e){const n=document.querySelector("#prev"),o=document.querySelector("#next"),a=window.matchMedia("(max-width: 75em)"),i=window.matchMedia("(max-width: 30em)");let s=document.querySelectorAll("#allCarouselItems .cardItem"),r=3;a.matches&&(r=2),i.matches&&(r=1);let l=[];for(let e=0;e{const n=l.shift();n.style.visibility="hidden";const o=e.querySelector(".cardItem");o.style.transform="translateX(100%)",o.style.transition="none",t.appendChild(o),l.push(o),setTimeout((()=>{for(let e=0;e{n.style.transition="none",n.style.transform="translateX(0)",e.appendChild(n),n.style.visibility="visible";for(let e=0;e{const n=l.pop();n.style.visibility="hidden";const o=e.querySelector(".cardItem:last-child");o.style.transform="translateX(-100%)",o.style.transition="none",t.insertBefore(o,t.firstChild),l.unshift(o),setTimeout((()=>{for(let e=0;e{n.style.transition="none",n.style.transform="translateX(0)",e.insertBefore(n,e.firstChild),n.style.visibility="visible";for(let e=0;et.json())),await fetch("/api/blog/post/featured").then((t=>t.json()))]}function csvToArray(t){let e="",n=[""],o=0,a=!0,i=null;for(i of t)'"'===i?(a&&i===e&&(n[o]+=i),a=!a):","===i&&a?i=n[++o]="":"\n"===i&&a?("\r"===e&&(row[o]=row[o].slice(0,-1)),n=n[++r]=[i=""],o=0):n[o]+=i,e=i;return n}async function getCategories(){let t=await fetch("/api/blog/categories").then((t=>t.json())),e=[];return t.forEach((t=>e=e.concat(csvToArray(t.categories.replace(/\s*,\s*/g,","))))),[...new Set(e)]}function createCategories(t){let e="";return t.forEach((t=>e+=`${t}`)),e}function createButtonCategories(t){let e="";return t.forEach((t=>t.forEach((t=>e+=`${t}`)))),e}async function createSideContent(){let t=await getLatestAndFeaturedPosts(),e=t[0],n=t[1],o=createCategories(await getCategories()),a=document.createElement("aside");return a.classList.add("sideContent"),a.innerHTML=`\n
\n
\n My professional picture taken in brighton near\n                                        north street at night wearing a beige jacket and checkered shirt\n

Rohit Pai

\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n

Avid Full Stack Dev | Uni of Notts Grad | Amateur Blogger

\n
\n \n \n \n
\n\t\t\t\t\t\t\t\t

feeds

\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\tAtom\n\t\t\t\t\t\t\t\t\tJSON\n\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t\t
\n
\n

categories

\n ${o}\n
\n \n `,a}function createMetaTag(t,e,n){let o=document.querySelector(`meta[name="${t}"], meta[property="${t}"]`);if(!o){let o=document.createElement("meta");return o.setAttribute(t.includes("name")?"name":"property",t),o.setAttribute(e,n),void document.head.appendChild(o)}o.setAttribute(e,n)}function insertMetaTags(t){document.querySelector("meta[name='description']").setAttribute("content",t.abstract),createMetaTag("twitter:title","content",t.title),createMetaTag("twitter:description","content",t.abstract),createMetaTag("twitter:image","content",t.headerImg),createMetaTag("og:title","content",t.title),createMetaTag("og:description","content",t.abstract),createMetaTag("og:image","content",t.headerImg),createMetaTag("og:url","content",window.location.href),createMetaTag("og:type","content","blog"),createMetaTag("og:site_name","content",'Rohit Pai"s Blog'),createMetaTag("og:locale","content","en_GB");let e=document.querySelector("meta[name='keywords']"),n=e.getAttribute("content");n+=`, ${t.keywords}`,e.setAttribute("content",n)}async function loadIndividualPost(t){document.title="Rohit Pai - "+decodeURI(t),await fetch(`/api/blog/post/${t}`).then((async e=>{e.ok?await e.json().then((async e=>{insertMetaTags(e);let n=document.createElement("section");n.classList.add("post"),n.id="individualPost";let o=document.createElement("div");o.classList.add("mainContent");let a=document.createElement("article"),i=e.headerImg.replaceAll("%2F","/");a.innerHTML=`\n

${e.title}

\n \n
\n ${e.body}\n `;let s=document.createElement("section");s.classList.add("comments"),s.innerHTML='

Comments

\n
\n ',o.appendChild(a),o.appendChild(s);let r=await createSideContent();n.appendChild(o),n.appendChild(r),document.querySelector("#main").appendChild(n);var l,c;l=document,(c=l.createElement("script")).src="https://rohitpaiportfolio.disqus.com/embed.js",c.setAttribute("data-timestamp",+new Date),l.body.appendChild(c),Prism.highlightAll()})):show404()}))}async function loadAllCategories(){document.title="Rohit Pai - Categories";let t=await getCategories(),e=document.querySelector("#main"),n=document.createElement("section");n.classList.add("categories"),n.id="allCategories";let o=document.createElement("h1");o.innerHTML="Categories",e.appendChild(o);for(let e of t){let t=document.createElement("div");t.classList.add("btnContainer");let o=document.createElement("a");o.classList.add("btn"),o.classList.add("btnPrimary"),o.innerHTML=e,o.href=`/blog/category/${e}`,t.appendChild(o),n.appendChild(t)}e.appendChild(n)}function loadPostsByCategory(t){document.title="Rohit Pai - "+decodeURI(t),fetch(`/api/blog/categories/${t}`).then((e=>e.json().then((e=>{let n=document.querySelector("#main"),o=document.createElement("section");o.classList.add("catPosts"),o.id="postsByCategory";let a=document.createElement("h1");a.innerHTML=decodeURI(t),n.appendChild(a);for(let t=0;tt.json().then((t=>{let e=document.querySelector("#main"),n=document.createElement("section");n.classList.add("catPosts"),n.id="searchResults";let o=document.createElement("h1");o.innerHTML="Search Results",e.appendChild(o);for(let e=0;e\n\t\t\t
\n\n\t\t\t

Sources of Information and Tracking Technologies

\n\t\t\t

\n\t\t\t\tI collect information that you directly provide to me, such as when you submit a form or send me a message with your information. I may also receive information about you from my partners, including but not limited to distribution partners, data services, and marketing firms. I may combine this information with other information I collect from or about you. In these cases, my Privacy Policy governs the handling of the combined information. I and my partners may collect the information noted in this privacy policy using cookies, web beacons, pixels, and other similar technologies. These technologies are used for authentication, to store your preferences or progress, for analytics, and for advertising and analytics. Cookies are small text files stored on your computer. You can set your browser to reject cookies altogether, to reject my cookies in particular, or to delete cookies. However, this may cause some or all of my Services not to function on your computer or device.\n\t\t\t

\n\t\t\t
\n\t\t\t

How I Use Your Information

\n\t\t\t

\n\t\t\t\tI use information I collect about you to provide, maintain, and improve my Services and other interactions I have with you. For example, I use the information collected to:\n\t\t\t

\n\t\t\t
    \n\t\t\t\t
  • Facilitate and improve your online experience;
  • \n\t\t\t\t
  • Provide and deliver products and services, perform authentication, process transactions and returns, and send you related information, including confirmations, receipts, invoices, customer experience surveys, and product or Services-related notices;
  • \n\t\t\t\t
  • Process and deliver promotions;
  • \n\t\t\t\t
  • Respond to your comments and questions and provide customer service;
  • \n\t\t\t\t
  • If you have indicated to me that you wish to receive notifications or promotional messages;
  • \n\t\t\t\t
  • Detect, investigate and prevent fraudulent transactions and other illegal activities and protect my rights and property and others;
  • \n\t\t\t\t
  • Comply with my legal and financial obligations;
  • \n\t\t\t\t
  • Monitor and analyze trends, usage, and activities;
  • \n\t\t\t\t
  • Provide and allow my partners to provide advertising and marketing targeted toward your interests.
  • \n\t\t\t
\n\t\t\t
\n\t\t\t

How I May Share Information

\n\t\t\t

\n\t\t\t\tI may share your Personal Information in the following situations:\n\t\t\t

\n\t\t\t
    \n\t\t\t\t
  • \n\t\t\t\t\tThird Party Services Providers.\n\t\t\t\t\tI may share data with service providers, vendors, contractors, or agents who complete transactions or perform services on my behalf, such as those that assist me with my business and internal operations like shipping and delivery, payment processing, fraud prevention, customer service, gift cards, experiences, personalization, marketing, and advertising;\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tChange in Business.\n\t\t\t\t\tI may share data in connection with a corporate business transaction, such as a merger or acquisition of all or a portion of my business to another company, joint venture, corporate reorganization, insolvency or bankruptcy, financing or sale of company assets;\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tTo Comply with Law.\n\t\t\t\t\tI may share data to facilitate legal process from lawful requests by public authorities, including to meet national security or law enforcement demands as permitted by law.\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tWith Your Consent.\n\t\t\t\t\tI may share data with third parties when I have your consent.\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tWith Advertising and Analytics Partners.\n\t\t\t\t\tSee the section entitled “Advertising and Analytics” below.\n\t\t\t\t
  • \n\t\t\t
\n\t\t\t
\n\t\t\t

Advertising and Analytics

\n\t\t\t

\n\t\t\t\tI use advertising and analytics technologies to better understand your online activity on my Services to provide personalized products and services that may interest you. I may allow third-party companies, including ad networks, to serve advertisements, provide other advertising services, and/or collect certain information when you visit my website. Third-party companies may use pseudonymized personal data (e.g., click stream information, browser type, time and date, subject of advertisements clicked or scrolled over) during your visit to this website in order to provide advertisements about goods and services likely to be of interest to you, on this website and others. To learn more about Interest-Based Advertising or to opt-out of this type of advertising, you can visit AboutAds.info/choices or www.networkadvertising.org/choices. Some third-party companies may also use non-cookie technologies, such as statistical IDs. Please keep in mind that your web browser may not permit you to block the use of these non-cookie technologies, and those browser settings that block cookies may have no effect on such techniques. If the third-party company uses the non-cookie technologies for interest-based advertising, you can opt out at www.networkadvertising.org/choices. Please note the industry opt out only applies to use for interest-based advertising and may not apply to use for analytics or attribution. Some websites have “do not track” features that allow you to tell a website not to track you. These features are not all uniform. I do not currently respond to those signals.\n\t\t\t

\n\t\t\t
\n\t\t\t

Data Security

\n\t\t\t

\n\t\t\t\tI implement commercially reasonable security measures designed to protect your information. Despite my best efforts, however, no security measures are completely impenetrable.\n\t\t\t

\n\t\t\t
\n\t\t\t

Data Retention

\n\t\t\t

\n\t\t\t\tI store the information I collect about you for as long as necessary for the purpose(s) for which I collected it or for other legitimate business purposes, including to meet my legal, regulatory, or other compliance obligations.\n\t\t\t

\n\t\t\t
\n\n\t\t\t

EU Privacy Rights

\n\n\t\t\t

Individuals located in certain countries, including the European Economic Area (EEA) and the United Kingdom, have certain statutory rights under the General Data Protection Regulation (GDPR) in relation to their personal data.

\n\t\t\t

To the extent information I collect is associated with an identified or identifiable natural person and is protected as personal data under GDPR, it is referred to in this Privacy Policy as “Personal Data”.

\n\t\t\t

\n\t\t\t\tData Subject Access Requests\n\t\t\t

\n\t\t\t

\n\t\t\t\tSubject to any exemptions provided by law, you may have the right to request:\n\t\t\t

\n\t\t\t
    \n\t\t\t\t
  • \n\t\t\t\t\ta copy of the Personal Data I hold about you;\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tto correct the Personal Data I hold about you;\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tto delete your Account or Personal Data;\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tto object to processing of your Personal Data for certain purposes;\n\t\t\t\t
  • \n\t\t\t
\n\n\t\t\t

\n\t\t\t\tTo access your privacy rights, send me an email at rohit@rohitpai.co.uk.\n\t\t\t

\n\t\t\t

\n\t\t\t\tI will generally process requests within one month. I may need to request specific information from you to help me confirm your identity and/or the jurisdiction in which you reside. If your request is complicated or if you have made a large number of requests, it may take me longer. I will let you know if I need longer than one month to respond.\n\t\t\t

\n\t\t\t

\n\t\t\t\tLegal Bases For Processing Personal Data\n\t\t\t

\n\t\t\t

\n\t\t\t\tI may process your Personal Data under applicable data protection law on the following legal grounds:\n\t\t\t

\n\t\t\t
    \n\t\t\t\t
  • \n\t\t\t\t\tContractual Necessity:\n\t\t\t\t\tI may process your Personal Data to enter into or perform a contract with you.\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tConsent:\n\t\t\t\t\twhere you have provided consent to process your Personal Data. You may withdraw your consent at any time.\n\t\t\t\t
  • \n\t\t\t\t
  • \n\t\t\t\t\tLegitimate interest:\n\t\t\t\t\tI process your Personal Data to provide my Services to you such as to provide my online user experience, communicate with you, provide customer service, market, analyze and improve my business, and to protect my Services.\n\t\t\t\t
  • \n\t\t\t
\n\t\t\t
\n\t\t\t

Age Limitations

\n\t\t\t

\n\t\t\t\tMy Service is intended for adults ages 18 years and above. I do not knowingly collect personally identifiable information from children. If you are a parent or legal guardian and think your child under 13 has given me information, please email or write to me at the address listed at the end of this Privacy Policy. Please mark your inquiries “COPPA Information Request.”\n\t\t\t

\n\t\t\t
\n\t\t\t

Changes to this Privacy Policy

\n\t\t\t

\n\t\t\t\tRohit Pai may change this Privacy Policy from time to time. I encourage you to visit this page to stay informed. If the changes are material, I may provide you additional notice to your email address or through my Services. Your continued use of the Services indicates your acceptance of the modified Privacy Policy.\n\t\t\t

\n\t\t\t
\n\t\t\t

Newsletters

\n\t\t\t

\n\t\t\t\tYou can opt in to receive my marketing emails and/or newsletters by below. I may still send you transactional messages, which include Services-related communications and responses to your questions.\n\t\t\t

\n\t\t\t
\n\t\t\t

Storage of Information in the United States

\n\t\t\t

\n\t\t\t\tInformation I maintain may be stored both within and outside of the United States. If you live outside of the United States, you understand and agree that I may transfer your information to the United States, and that U.S. laws may not afford the same level of protection as those in your country.\n\t\t\t

\n\t\t\t
\n\t\t\t

Contact Me

\n\t\t\t

\n\t\t\t\tIf you have questions, comments, or concerns about this Privacy Policy, you may contact me at:\n\t\t\t

\n\t\t\tContact\n\t\t\trohit@rohitpai.co.uk\n\t\t\n\t\t'}function loadCookiePolicy(){document.querySelector("#main").innerHTML='\n\t\t
\n\t\t\t

Cookies Policy

\n\t\t\t

I only use functional cookies for the blog which includes PHP Session ID, disqus. a cookie to disable the cookie popup, and maybe share this. I think that these are functional cookies, if you don\'t, you\'re welcome to exit the site or tell me by emailing me through the email address below, or the contact form on the contact section of my main website.

\n\t\t\t
\n\t\t\trohit@rohitpai.co.uk\n\t\t\t
\n\t\t\tcontact\n\t\t
\n\t'}function show404(){document.querySelector("#main").innerHTML='\n
\n
\n

Blog post, Category or page not found

\n See all blog posts\n
\n
\n '}document.addEventListener("DOMContentLoaded",(()=>{goToURL(window.location.pathname)})),window.addEventListener("popstate",(t=>{goToURL(window.history.state)})),window.onscroll=()=>{document.body.scrollTop>=150||document.documentElement.scrollTop>=150?document.querySelector("nav").classList.add("scrolled"):document.querySelector("nav").classList.remove("scrolled")},document.querySelector("#searchBtn").addEventListener("click",(t=>{let e=document.querySelector("#searchField").value;e.length>0&&(window.history.pushState(null,null,`/blog/search/${e}`),document.querySelector("#searchField").value="",document.querySelector("#main").innerHTML="",goToURL(`/blog/search/${e}`))})),document.querySelector("#searchField").addEventListener("keyup",(t=>{"Enter"===t.key&&document.querySelector("#searchBtn").click()})),document.querySelector("#cookieAccept").addEventListener("click",(t=>{document.querySelector("#cookiePopup").classList.add("hidden"),localStorage.setItem("cookiePopup","accepted")})); \ No newline at end of file diff --git a/src/blog/js/index.js b/src/blog/js/index.js index e245f1b..fcc08c8 100644 --- a/src/blog/js/index.js +++ b/src/blog/js/index.js @@ -376,6 +376,14 @@ function carouselLoop(carouselInner, allItems) visibleCards.push(cards[i]); } + if (allItems.children.length === 0) + { + // if there are no cards in the carousel, don't show the arrows + prev.style.visibility = 'hidden'; + next.style.visibility = 'hidden'; + return; + } + next.addEventListener('click', () => { const firstCard = visibleCards.shift();