<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>javascript &amp;mdash; berkough.com</title>
    <link>https://berkough.com/tag:javascript</link>
    <description></description>
    <pubDate>Thu, 16 Apr 2026 22:11:38 +0000</pubDate>
    <image>
      <url>https://i.snap.as/fMfRWXNN.png</url>
      <title>javascript &amp;mdash; berkough.com</title>
      <link>https://berkough.com/tag:javascript</link>
    </image>
    <item>
      <title>What Framework Should I Use?</title>
      <link>https://berkough.com/what-framework-should-i-use?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[#JavaScript #fontend #backend #nodejs #fullstack #devdiary #tarotjs&#xA;&#xA;This is a common question that I feel a lot of people face every day, from season vets to newbies looking to learn something that might be useful elsewhere.&#xA;&#xA;One thing I can say, from what I&#39;ve learned, is that the framework isn&#39;t really all that important, it&#39;s the fundamentals that matter. When I was younger and and the commercial internet was still in its infancy, the big saying was &#34;RTFM,&#34; read the fucking manual. Which is still true to this day. If it doesn&#39;t have good documentation, move on.&#xA;&#xA;As far as a language, I&#39;m sticking to JavaScript. I like it. I was never hardcore into programming like all of the Rust and Go people out there. I just want to be able to do stuff. If I ever hit a point where JavaScript isn&#39;t doing what I need it to do, then I&#39;ll move on.&#xA;!--more--&#xA;&#xA;OKAY, I get it, I know some people are annoyed by the term fullstack... Some people don&#39;t agree that you can do everything in JavaScript... I&#39;m not convinced that you can&#39;t. I&#39;m really impressed with projects like enimga 1/2 bbs... Curious what The Primeagen would have to say about that one in particular. He&#39;s around my age, he must have some BBS experience. But in any case, I want to write a PWA. I want to turn my idea into a usable application experience across a multitude of platforms with as little resistance to using it as possible; desktops, laptops, tablets, and mobile. The last thing that I want to do is learn Rust or Go just to have a solid backend. This project isn&#39;t going to support a bunch of users, it&#39;s just going to be a local experience (for now).&#xA;&#xA;In terms of hosting, it&#39;ll either be a standard VPS with someone like GoDaddy, or I might use DigitalOcean for their App Platform. I think I&#39;m pretty much set on DigitalOcean though. I could go the AWS route just for the hell of it because that&#39;s what a lot of people use (we use it at work), but this is my own personal project. Whether or not it makes any money is also going to be dependent on how easily I can use my toolchain to deploy fixes and patches and everything else, as well as how much I enjoy working on the project. AWS is not fun... Stop it.&#xA;&#xA;Project requirements&#xA;&#xA;Progressive Web App (Priority)&#xA;I personally think this is going to be the way things progress in the future. giving up 30% of gross revenue to Apple or Google is just kind of depressing. Also, it&#39;s interesting to me that even Microsoft is pushing to replace the Office Suite with PWAs. I&#39;ve been using the new Outlook at work and I really like it.&#xA;&#xA;Backend API functionality&#xA;The application will make calls to ChatGPT or another AI to return spread interpretations.&#xA;&#xA;Simple file structure&#xA;Next.js makes my head hurt when I create a new project directory. Vue can be complicated as well, but there are very easy ways to get started without the boilerplate.&#xA;&#xA;Lightweight and simple UI library&#xA;This one isn&#39;t as easy as it seems... I&#39;m using Bootstrap right now, but as I move to a more touch-focused interface, I&#39;m going to need to replace it. Also, I&#39;m not really doing a whole lot with Bootstrap right now anyway.&#xA;&#xA;Frameworks&#xA;&#xA;Here are the frameworks I&#39;m looking at and my thought process behind the pros and cons. I may very well be wrong, or my opinions could be based on misinterpretations, or not knowing different ways to approach certain obstacles. So, if there is something that I&#39;m missing or something that is misstated because I don&#39;t fully understand how something works, please reach out to me. Let me try and learn from your experiences.&#xA;&#xA;1. ExpressJS&#xA;Express is appealing because I can do everything in vanilla JS if I want, and just keep building on the project as-is. OR, I can do all the Express-specific stuff and combine it with pretty much any other framework, and I only have to write the AI API calls once--at least that&#39;s my theory.&#xA;&#xA;2. Preact&#xA;Incredibly lightweight, and I did learn React, and this is similar enough to it... Do I really remember React? No, I&#39;m not a big fan of React.&#xA;&#xA;3. Vue.js&#xA;I really like the philosophy behind Vue. As well as the idea that you can just use it through a CDN is incredibly appealing, but we&#39;re shooting for a local experience, which means installing it as a dependency. The biggest pain with Vue will be re-writing a bunch of stuff.&#xA;&#xA;4. Svelte&#xA;Other than watching Primeagen interview Rich Harris, I know nothing about how Svelte works or any of its design philosophies.&#xA;&#xA;5. Angular&#xA;Again, I don&#39;t know much about this, I&#39;ve never played around with this dialect. I know it&#39;s essentially Google&#39;s answer to React, but Google also has Polymer. &#xA;&#xA;6. Polymer&#xA;Last I checked this was a UI toolkit for Dart or some shit like that... This was many years ago though. At that time it wasn&#39;t exactly its own framework in the same way that we understand modern JavaScript frameworks. &#xA;&#xA;7. PWABuilder&#xA;Fucking Microsoft... They really are a different company these days.&#xA;I recently watched a Primeagean video where he read through a Medium article called &#34;From VSCode to VIM&#34; and the point was brought up: The mindset of VSCode is to use it, not learn it. The mindset of VIM is to learn it then use it. PWAs really aren&#39;t all that complicated; it&#39;s a manifest and a service worker (essentially), but PWABuilder just does it all for you! Use it, don&#39;t learn it. Honestly though, I will take the time to learn it, but I played around with the VSCode PWABuilder Studio today, and I might be sold on the idea!&#xA;&#xA;Yeah...&#xA;&#xA;I think ExpressJS with vanilla JS and PWABuilder Studio might be the way that I go... Just have to decide on a lightweight UI library. Maybe I stick with Bootstrap??&#xA;&#xA;iframe width=&#34;560&#34; height=&#34;315&#34; src=&#34;https://www.youtube.com/embed/FrMRyXtiJkc?si=KgYJ0Ql_gVXP-0eh&#34; title=&#34;YouTube video player&#34; frameborder=&#34;0&#34; allow=&#34;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share&#34; allowfullscreen/iframe&#xA;&#xA; : It was pointed out to me that Angular was first, and React was Facebook&#39;s answer to Google.&#xA;&#xA; : Apparently Polymer is being replaced by Lit. ]]&gt;</description>
      <content:encoded><![CDATA[<p><a href="https://berkough.com/tag:JavaScript" class="hashtag"><span>#</span><span class="p-category">JavaScript</span></a> <a href="https://berkough.com/tag:fontend" class="hashtag"><span>#</span><span class="p-category">fontend</span></a> <a href="https://berkough.com/tag:backend" class="hashtag"><span>#</span><span class="p-category">backend</span></a> <a href="https://berkough.com/tag:nodejs" class="hashtag"><span>#</span><span class="p-category">nodejs</span></a> <a href="https://berkough.com/tag:fullstack" class="hashtag"><span>#</span><span class="p-category">fullstack</span></a> <a href="https://berkough.com/tag:devdiary" class="hashtag"><span>#</span><span class="p-category">devdiary</span></a> <a href="https://berkough.com/tag:tarotjs" class="hashtag"><span>#</span><span class="p-category">tarotjs</span></a></p>

<p>This is a common question that I feel a lot of people face every day, from season vets to newbies looking to learn something that might be useful elsewhere.</p>

<p>One thing I can say, from what I&#39;ve learned, is that the framework isn&#39;t really all that important, it&#39;s the fundamentals that matter. When I was younger and and the commercial internet was still in its infancy, the big saying was “RTFM,” <em>read the fucking manual</em>. Which is still true to this day. If it doesn&#39;t have good documentation, move on.</p>

<p>As far as a language, I&#39;m sticking to JavaScript. I like it. I was never hardcore into programming like all of the Rust and Go people out there. I just want to be able to do stuff. If I ever hit a point where JavaScript isn&#39;t doing what I need it to do, then I&#39;ll move on.
</p>

<p>OKAY, I get it, I know some people are annoyed by the term <em>fullstack</em>... Some people don&#39;t agree that you can do everything in JavaScript... I&#39;m not convinced that you can&#39;t. I&#39;m really impressed with projects like <a href="https://enigma-bbs.github.io/">enimga ½ bbs</a>... Curious what The Primeagen would have to say about that one in particular. He&#39;s around my age, he must have some BBS experience. But in any case, I want to write a PWA. I want to turn my idea into a usable application experience across a multitude of platforms with as little resistance to using it as possible; desktops, laptops, tablets, and mobile. The last thing that I want to do is learn Rust or Go just to have a solid backend. This project isn&#39;t going to support a bunch of users, it&#39;s just going to be a local experience (for now).</p>

<p>In terms of hosting, it&#39;ll either be a standard VPS with someone like GoDaddy, or I might use DigitalOcean for their <em>App Platform</em>. I think I&#39;m pretty much set on DigitalOcean though. I could go the AWS route just for the hell of it because that&#39;s what a lot of people use (we use it at work), but this is my own personal project. Whether or not it makes any money is also going to be dependent on how easily I can use my toolchain to deploy fixes and patches and everything else, as well as how much I enjoy working on the project. AWS is not fun... Stop it.</p>

<p><img src="https://i.snap.as/8qDtrboo.gif" alt=""/></p>

<h2 id="project-requirements" id="project-requirements">Project requirements</h2>
<ul><li><p><strong>Progressive Web App (Priority)</strong>
I personally think this is going to be the way things progress in the future. giving up 30% of gross revenue to Apple or Google is just kind of depressing. Also, it&#39;s interesting to me that even Microsoft is pushing to replace the Office Suite with PWAs. I&#39;ve been using the new Outlook at work and I really like it.</p></li>

<li><p><strong>Backend API functionality</strong>
The application will make calls to ChatGPT or another AI to return spread interpretations.</p></li>

<li><p><strong>Simple file structure</strong>
Next.js makes my head hurt when I create a new project directory. Vue can be complicated as well, but there are very easy ways to get started without the boilerplate.</p></li>

<li><p><strong>Lightweight and simple UI library</strong>
This one isn&#39;t as easy as it seems... I&#39;m using Bootstrap right now, but as I move to a more touch-focused interface, I&#39;m going to need to replace it. Also, I&#39;m not really doing a whole lot with Bootstrap right now anyway.</p></li></ul>

<h2 id="frameworks" id="frameworks">Frameworks</h2>

<p>Here are the frameworks I&#39;m looking at and my thought process behind the pros and cons. I may very well be wrong, or my opinions could be based on misinterpretations, or not knowing different ways to approach certain obstacles. So, if there is something that I&#39;m missing or something that is misstated because I don&#39;t fully understand how something works, please reach out to me. Let me try and learn from your experiences.</p>

<h3 id="1-expressjs" id="1-expressjs">1. ExpressJS</h3>

<p>Express is appealing because I can do everything in vanilla JS if I want, and just keep building on the project as-is. OR, I can do all the Express-specific stuff and combine it with pretty much any other framework, and I only have to write the AI API calls once—at least that&#39;s my theory.</p>

<h3 id="2-preact" id="2-preact">2. Preact</h3>

<p>Incredibly lightweight, and I did learn React, and this is similar enough to it... Do I really remember React? No, I&#39;m not a big fan of React.</p>

<h3 id="3-vue-js" id="3-vue-js">3. Vue.js</h3>

<p>I really like the philosophy behind Vue. As well as the idea that you can just use it through a CDN is incredibly appealing, but we&#39;re shooting for a local experience, which means installing it as a dependency. The biggest pain with Vue will be re-writing a bunch of stuff.</p>

<h3 id="4-svelte" id="4-svelte">4. Svelte</h3>

<p>Other than watching Primeagen interview Rich Harris, I know nothing about how Svelte works or any of its design philosophies.</p>

<h3 id="5-angular" id="5-angular">5. Angular</h3>

<p>Again, I don&#39;t know much about this, I&#39;ve never played around with this dialect. I know it&#39;s essentially Google&#39;s answer to React, but Google also has Polymer. [^1]</p>

<h3 id="6-polymer" id="6-polymer">6. Polymer</h3>

<p>Last I checked this was a UI toolkit for Dart or some shit like that... This was many years ago though. At that time it wasn&#39;t exactly its own framework in the same way that we understand modern JavaScript frameworks. [^2]</p>

<h3 id="7-pwabuilder" id="7-pwabuilder">7. PWABuilder</h3>

<p>Fucking Microsoft... They really are a different company these days.
I recently watched a <a href="https://www.youtube.com/watch?v=-cn3MAovsN4">Primeagean video</a> where he read through a Medium article called “From VSCode to VIM” and the point was brought up: The mindset of VSCode is to use it, not learn it. The mindset of VIM is to learn it then use it. PWAs really aren&#39;t all that complicated; it&#39;s a manifest and a service worker (essentially), but PWABuilder just does it all for you! Use it, don&#39;t learn it. Honestly though, I will take the time to learn it, but I played around with the VSCode PWABuilder Studio today, and I might be sold on the idea!</p>

<p>Yeah...</p>

<p>I think ExpressJS with vanilla JS and PWABuilder Studio might be the way that I go... Just have to decide on a lightweight UI library. Maybe I stick with Bootstrap??</p>

<iframe width="560" height="315" src="https://www.youtube.com/embed/FrMRyXtiJkc" title="YouTube video player" frameborder="0" allowfullscreen=""></iframe>

<p>[^1] : It was pointed out to me that <a href="https://ieji.de/@juliangonggrijp/111275548658316396">Angular was first</a>, and React was Facebook&#39;s answer to Google.</p>

<p>[^2] : Apparently Polymer is being <a href="https://lit.dev/articles/lit-for-polymer-users/">replaced by Lit</a>.</p>
]]></content:encoded>
      <guid>https://berkough.com/what-framework-should-i-use</guid>
      <pubDate>Sat, 21 Oct 2023 03:28:05 +0000</pubDate>
    </item>
    <item>
      <title>Code for Top 20 Lists</title>
      <link>https://berkough.com/code-for-top-20-lists?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[#javascript #coding #journal&#xA;&#xA;Not too long ago, one of the members of the Pixel Pints shared with us a simple webapp that he found for building top-whatever lists, called Topsters.&#xA;&#xA;I decided to play around with it a bit, and, as I mentioned in the last post--which was itself a top 20 list--I wanted to have an overlay for links on top of the image, so it was more like a widget instead of just an image. The power of Topsters is not the image that it generates necessarily, but how easily you can generate the image by querying a bunch of APIs based on your media selection (books, albums, movies, or games). So, in that regard adding a little flare to the image seemed appropriate, and why not give it some interactivity? Topsters itself utilizes a canvas element to arrange the pictures of the book, album, movie, or game covers. I could always consider maybe doing that myself, or&#xA;!--more--&#xA;&#xA;As I&#39;ve mentioned, Write.as does give you a script area that you can use, and I don&#39;t think you can just inject JavaScript anywhere... I did try simply putting script tags in the markdown of a singular post, but it wasn&#39;t passing through when I inspected the live version of the site.&#xA;&#xA;The next best option was to write an if statement which launches a specific function to act on a specific div when certain conditions are met.&#xA;&#xA;You can clone from here, or simply take a look at the code:&#xA;&#xA;//Global Variables to use:&#xA;const path = document.location.pathname;&#xA;/--------------------------------------/&#xA;function albumNum() {&#xA;  let covers = document.getElementById(&#34;covers&#34;);&#xA;  covers.style = &#34;position: relative;&#34;;&#xA;&#xA;  for (let i = 1; i &lt;= 20; i++) {&#xA;    let numbers = a href=&#34;#item${i}&#34;p class=&#34;albNumber&#34; id=&#34;cover-${i}&#34;#${i}./p/a;&#xA;    covers.innerHTML += numbers;&#xA;&#xA;    setNumPos(i);&#xA;  }&#xA;}&#xA;&#xA;function setNumPos(num) {&#xA;  let displayedNumber = document.getElementById(cover-${num});&#xA;&#xA;  let imgHeight = covers.getElementsByTagName(&#34;img&#34;)[0].height;&#xA;  console.log(imgHeight);&#xA;  let imgWidth = covers.getElementsByTagName(&#34;img&#34;)[0].width;&#xA;  console.log(imgWidth);&#xA;&#xA;  let row = [&#xA;    imgWidth  0.25, &#xA;    imgWidth  0.5, &#xA;    imgWidth - imgWidth  0.25&#xA;  ];&#xA;  let col = [&#xA;    imgHeight  0.02,&#xA;    imgHeight  0.23,&#xA;    imgHeight  0.43,&#xA;    imgHeight  0.63,&#xA;    imgHeight  0.83&#xA;  ];&#xA;&#xA;  console.log(&#34;Widths &#34; + row);&#xA;  console.log(&#34;Heights &#34; + col);&#xA;&#xA;  switch (num) {&#xA;    case 1:&#xA;      displayedNumber.style = position: absolute; top: ${col[0]}px; left: 0px;;&#xA;      break;&#xA;    case 2:&#xA;      displayedNumber.style = position: absolute; top: ${col[0]}px; left: ${row[0]}px;;&#xA;      break;&#xA;    case 3:&#xA;      displayedNumber.style = position: absolute; top: ${col[0]}px; left: ${row[1]}px;;&#xA;      break;&#xA;    case 4:&#xA;      displayedNumber.style = position: absolute; top: ${col[0]}px; left: ${row[2]}px;;&#xA;      break;&#xA;    case 5:&#xA;      displayedNumber.style = position: absolute; top: ${col[1]}px; left: 0px;;&#xA;      break;&#xA;    case 6:&#xA;      displayedNumber.style = position: absolute; top: ${col[1]}px; left: ${row[0]}px;;&#xA;      break;&#xA;    case 7:&#xA;      displayedNumber.style = position: absolute; top: ${col[1]}px; left: ${row[1]}px;;&#xA;      break;&#xA;    case 8:&#xA;      displayedNumber.style = position: absolute; top: ${col[1]}px; left: ${row[2]}px;;&#xA;      break;&#xA;    case 9:&#xA;      displayedNumber.style = position: absolute; top: ${col[2]}px; left: 0px;;&#xA;      break;&#xA;    case 10:&#xA;      displayedNumber.style = position: absolute; top: ${col[2]}px; left: ${row[0]}px;;&#xA;      break;&#xA;    case 11:&#xA;      displayedNumber.style = position: absolute; top: ${col[2]}px; left: ${row[1]}px;;&#xA;      break;&#xA;    case 12:&#xA;      displayedNumber.style = position: absolute; top: ${col[2]}px; left: ${row[2]}px;;&#xA;      break;&#xA;    case 13:&#xA;      displayedNumber.style = position: absolute; top: ${col[3]}px; left: 0px;;&#xA;      break;&#xA;    case 14:&#xA;      displayedNumber.style = position: absolute; top: ${col[3]}px; left: ${row[0]}px;;&#xA;      break;&#xA;    case 15:&#xA;      displayedNumber.style = position: absolute; top: ${col[3]}px; left: ${row[1]}px;;&#xA;      break;&#xA;    case 16:&#xA;      displayedNumber.style = position: absolute; top: ${col[3]}px; left: ${row[2]}px;;&#xA;      break;&#xA;    case 17:&#xA;      displayedNumber.style = position: absolute; top: ${col[4]}px; left: 0px;;&#xA;      break;&#xA;    case 18:&#xA;      displayedNumber.style = position: absolute; top: ${col[4]}px; left: ${row[0]}px;;&#xA;      break;&#xA;    case 19:&#xA;      displayedNumber.style = position: absolute; top: ${col[4]}px; left: ${row[1]}px;;&#xA;      break;&#xA;    case 20:&#xA;      displayedNumber.style = position: absolute; top: ${col[4]}px; left: ${row[2]}px;;&#xA;  }&#xA;}&#xA;&#xA;if (path !==&#39;/&#39; &amp;&amp; document.querySelector(&#34;#covers&#34;)) {&#xA;  setTimeout(() =  {&#xA;    albumNum();&#xA;  }, 500);&#xA;}&#xA;&#xA;I need to do a bunch of stuff to this code;&#xA;re-write the switch statement as a function that checks for the number of rows and columns; and&#xA;re-write the for loop&#39;s iteration condition to be the rows multiplied by the columns.&#xA;&#xA;I&#39;m thinking I can signify by either reading the image file name, or using the id or class attributes.&#xA;&#xA;The cool thing is that I can put it anywhere and the image will render.&#xA;div id=&#34;covers&#34;&#xA;&#xA;/div&#xA;Watch out for more on this stuff. I&#39;ll might work on coming up with a format for the code so that I can start to chain blocks and widgets together. Also, I posted in the official forums, so I&#39;m curious what others have to say about my approach.]]&gt;</description>
      <content:encoded><![CDATA[<p><a href="https://berkough.com/tag:javascript" class="hashtag"><span>#</span><span class="p-category">javascript</span></a> <a href="https://berkough.com/tag:coding" class="hashtag"><span>#</span><span class="p-category">coding</span></a> <a href="https://berkough.com/tag:journal" class="hashtag"><span>#</span><span class="p-category">journal</span></a></p>

<p>Not too long ago, one of the members of the <a href="https://www.twitch.tv/pixelpints">Pixel Pints</a> shared with us a simple webapp that he found for building top-<em>whatever</em> lists, called <a href="https://topsters.org/">Topsters</a>.</p>

<p>I decided to play around with it a bit, and, as I mentioned in the last post—which was itself a top 20 list—I wanted to have an overlay for links on top of the image, so it was more like a widget instead of just an image. The power of Topsters is not the image that it generates necessarily, but how easily you can generate the image by querying a bunch of APIs based on your media selection (books, albums, movies, or games). So, in that regard adding a little flare to the image seemed appropriate, and why not give it some interactivity? Topsters itself utilizes a canvas element to arrange the pictures of the book, album, movie, or game covers. I could always consider maybe doing that myself, or
</p>

<p>As I&#39;ve mentioned, Write.as does give you a script area that you can use, and I don&#39;t think you can just inject JavaScript anywhere... I did try simply putting script tags in the markdown of a singular post, but it wasn&#39;t passing through when I inspected the live version of the site.</p>

<p>The next best option was to write an if statement which launches a specific function to act on a specific div when certain conditions are met.</p>

<p>You can clone from <a href="https://github.com/berkough/berkoughcom-scripts">here</a>, or simply take a look at the code:</p>

<pre><code class="language-javascript">//Global Variables to use:
const path = document.location.pathname;
/*--------------------------------------*/
function albumNum() {
  let covers = document.getElementById(&#34;covers&#34;);
  covers.style = &#34;position: relative;&#34;;

  for (let i = 1; i &lt;= 20; i++) {
    let numbers = `&lt;a href=&#34;#item${i}&#34;&gt;&lt;p class=&#34;albNumber&#34; id=&#34;cover-${i}&#34;&gt;#${i}.&lt;/p&gt;&lt;/a&gt;`;
    covers.innerHTML += numbers;

    setNumPos(i);
  }
}

function setNumPos(num) {
  let displayedNumber = document.getElementById(`cover-${num}`);

  let imgHeight = covers.getElementsByTagName(&#34;img&#34;)[0].height;
  console.log(imgHeight);
  let imgWidth = covers.getElementsByTagName(&#34;img&#34;)[0].width;
  console.log(imgWidth);

  let row = [
    imgWidth * 0.25, 
    imgWidth * 0.5, 
    imgWidth - imgWidth * 0.25
  ];
  let col = [
    imgHeight * 0.02,
    imgHeight * 0.23,
    imgHeight * 0.43,
    imgHeight * 0.63,
    imgHeight * 0.83
  ];

  console.log(&#34;Widths &#34; + row);
  console.log(&#34;Heights &#34; + col);

  switch (num) {
    case 1:
      displayedNumber.style = `position: absolute; top: ${col[0]}px; left: 0px;`;
      break;
    case 2:
      displayedNumber.style = `position: absolute; top: ${col[0]}px; left: ${row[0]}px;`;
      break;
    case 3:
      displayedNumber.style = `position: absolute; top: ${col[0]}px; left: ${row[1]}px;`;
      break;
    case 4:
      displayedNumber.style = `position: absolute; top: ${col[0]}px; left: ${row[2]}px;`;
      break;
    case 5:
      displayedNumber.style = `position: absolute; top: ${col[1]}px; left: 0px;`;
      break;
    case 6:
      displayedNumber.style = `position: absolute; top: ${col[1]}px; left: ${row[0]}px;`;
      break;
    case 7:
      displayedNumber.style = `position: absolute; top: ${col[1]}px; left: ${row[1]}px;`;
      break;
    case 8:
      displayedNumber.style = `position: absolute; top: ${col[1]}px; left: ${row[2]}px;`;
      break;
    case 9:
      displayedNumber.style = `position: absolute; top: ${col[2]}px; left: 0px;`;
      break;
    case 10:
      displayedNumber.style = `position: absolute; top: ${col[2]}px; left: ${row[0]}px;`;
      break;
    case 11:
      displayedNumber.style = `position: absolute; top: ${col[2]}px; left: ${row[1]}px;`;
      break;
    case 12:
      displayedNumber.style = `position: absolute; top: ${col[2]}px; left: ${row[2]}px;`;
      break;
    case 13:
      displayedNumber.style = `position: absolute; top: ${col[3]}px; left: 0px;`;
      break;
    case 14:
      displayedNumber.style = `position: absolute; top: ${col[3]}px; left: ${row[0]}px;`;
      break;
    case 15:
      displayedNumber.style = `position: absolute; top: ${col[3]}px; left: ${row[1]}px;`;
      break;
    case 16:
      displayedNumber.style = `position: absolute; top: ${col[3]}px; left: ${row[2]}px;`;
      break;
    case 17:
      displayedNumber.style = `position: absolute; top: ${col[4]}px; left: 0px;`;
      break;
    case 18:
      displayedNumber.style = `position: absolute; top: ${col[4]}px; left: ${row[0]}px;`;
      break;
    case 19:
      displayedNumber.style = `position: absolute; top: ${col[4]}px; left: ${row[1]}px;`;
      break;
    case 20:
      displayedNumber.style = `position: absolute; top: ${col[4]}px; left: ${row[2]}px;`;
  }
}

if (path !==&#39;/&#39; &amp;&amp; document.querySelector(&#34;#covers&#34;)) {
  setTimeout(() =&gt; {
    albumNum();
  }, 500);
}
</code></pre>

<p>I need to do a bunch of stuff to this code;
– re-write the switch statement as a function that checks for the number of rows and columns; and
– re-write the for loop&#39;s iteration condition to be the rows multiplied by the columns.</p>

<p>I&#39;m thinking I can signify by either reading the image file name, or using the id or class attributes.</p>

<p>The cool thing is that I can put it anywhere and the image will render.
<div id="covers" id="covers">
<img src="https://i.snap.as/DnXDPaxu.png" alt=""/>
</div>
Watch out for more on this stuff. I&#39;ll might work on coming up with a format for the code so that I can start to chain blocks and widgets together. Also, I posted in the <a href="https://discuss.write.as/">official forums</a>, so I&#39;m curious what others have to say about my approach.</p>
]]></content:encoded>
      <guid>https://berkough.com/code-for-top-20-lists</guid>
      <pubDate>Wed, 11 Oct 2023 01:50:43 +0000</pubDate>
    </item>
    <item>
      <title>What is MTK Ultra?</title>
      <link>https://berkough.com/what-is-mtk-ultra?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[#webcomics #webcomic #art #comics #javascript&#xA;&#xA;As the quality of televised and digital entertainment has degraded over the years, and not wanting to be bombarded by the sheer negativity of it all, I&#39;ve found myself spending more time listening to music and reading comics. It&#39;s been a gradual transition for me... That isn&#39;t to say that I don&#39;t spend entirely way too much time watching garbage on YouTube or mindlessly surfing, looking at things I&#39;ll never buy, or researching video games, or learning things that have no real practical purpose in my life other than to be interesting topics for cocktail parties that I&#39;ll never attend, etc.&#xA;&#xA;Something happened though... A tipping point? I did attempt doing a web comic maybe a year or so ago, but I never stuck with it. I have revisited the idea though, and this time I sat and thought about the story ahead of putting pencil to paper, I drew a few outlines and sketches first.&#xA;&#xA;Just from my 9-to-5 and thinking about the type of comic that I wanted to read, I came upon the idea of an insurance company in the relatively near future. But it&#39;s going to evolve beyond that, because, fuck it, I have a story universe where people live on Europa and Titan, and giant monsters are a real thing. So I&#39;m going to play with the surreal and the supernatural, the pragmatic and the practical, and I want to put it together to highlight the absurdity of life and the human condition.&#xA;!--more--&#xA;&#xA;We&#39;re really in a timeline where aliens are real and just a few years ago we globally went into lock down for a novel communicable virus which may or may not have been created in a laboratory. That&#39;s some Depression-era level shit right there. So of course there is a need for art to reflect on that stuff.&#xA;&#xA;I don&#39;t really care to debate the details, I just want to examine the greater implications and the social structures behind how civilization deals with those types of situations.&#xA;&#xA;Super hero-adjacent characters exist, but won&#39;t necessarily be the focus of the stories that are told. Corporate espionage and libertarian -slash- anarcho-capitalist theory will be themes explored--because I find it interesting, the actual practicalities of implementing such civic systems aside. But it&#39;s all just flavor for the world and to inform the behavior of the characters.&#xA;&#xA;Switching gears a bit. One of the things that I need to do is think about how to implement a page navigation system. WriteFreely doesn&#39;t really have a &#34;web comic&#34; module like Wordpress does. However, Matt Baer has thought about the utility of his writing platform, and he&#39;s implemented a place where you can inject some js into every page. I like that, and it should serve this particular purpose just fine.&#xA;&#xA;I&#39;ve intentionally labeled each entry as the page number, so the url slug and the title as well as page number are all the same. I do not anticipate ever going beyond 999 pages. &#xA;&#xA;That being said, here&#39;s how I implemented an automated page navigation:&#xA;&#xA;let path = document.location.pathname;&#xA;&#xA;function displayNav(){&#xA;    let page = parseInt(path.substring(1,4));&#xA;    let next = (new Array(3).join(&#39;0&#39;)+((page + 1).toString())).slice(-3);&#xA;    let prev = (new Array(3).join(&#39;0&#39;)+((page - 1).toString())).slice(-3);&#xA;&#xA;    let div = `div class=&#34;page-nav&#34;&#xA;                table cellspacing=&#34;0&#34; cellpadding=&#34;0&#34;&#xA;                    tr&#xA;                        td id=&#34;first&#34;a href=&#34;/001&#34;i class=&#34;bx bxs-chevrons-left&#34;/i/a/td&#xA;                        td id=&#34;last&#34;a href=&#34;/${prev}&#34;i class=&#34;bx bxs-chevron-left&#34;/i/a/td&#xA;                        td id=&#34;next&#34;a href=&#34;/${next}&#34;i class=&#34;bx bxs-chevron-right&#34;/i/a/td&#xA;                        td id=&#34;recent&#34;a href=&#34;/&#34;i class=&#34;bx bxs-chevrons-right&#34;/i/a/td&#xA;                    /tr&#xA;                /table&#xA;            /div`;&#xA;    &#xA;    let content = document.querySelector(&#39;.e-content&#39;).children.item(&#39;p&#39;);&#xA;    content.insertAdjacentHTML(&#39;beforeend&#39;, div);&#xA;    return content&#xA;}&#xA;&#xA;if (path !== &#39;/&#39;){&#xA;   setTimeout(() =  {&#xA;    displayNav();&#xA;   }, 200);&#xA;}&#xA;&#xA;Everything hinges on the url path, so that&#39;s defined at the top level scope. I figured this would be the easiest way to deal with pages. Stylistically I wanted to go with three digits, so working with that in javascript is a little clunky.&#xA;&#xA;Originally I had an lpad function that was taken wholesale from stack. It seemed like the most elegant solution. But I wouldn&#39;t have used that function anywhere else, or more than twice, so I refactored what the function did right into the declaration of my next and last variables.&#xA;&#xA;Once we have those variables we know what our URL is going to be for going backwards and forwards. So I defined a template literal with the HTML of our navigation block.&#xA;&#xA;How do we know where to place it? Well, I want to make sure it&#39;s right after the picture and that&#39;s the only paragraph we have. Writefreely dumps your post into a div with the class &#34;e-content&#34;. Despite the fact that it&#39;s not an id, it does only show up once on the DOM. So, we query that class, look for the p and dump our div variable as html at the end.&#xA;&#xA;Writefreely also provides user-specified CSS, so I&#39;ve imported the Boxicons cdn so I can use it like FontAwesome and have some icons to represent first, last, previous and next.&#xA;&#xA;Might not be the most elegant way to do what I need it to do, and might not be the most robust, but it works, and I&#39;m happy about that. I don&#39;t have to keep writing a table/navigation element for each page.&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<p><a href="https://berkough.com/tag:webcomics" class="hashtag"><span>#</span><span class="p-category">webcomics</span></a> <a href="https://berkough.com/tag:webcomic" class="hashtag"><span>#</span><span class="p-category">webcomic</span></a> <a href="https://berkough.com/tag:art" class="hashtag"><span>#</span><span class="p-category">art</span></a> <a href="https://berkough.com/tag:comics" class="hashtag"><span>#</span><span class="p-category">comics</span></a> <a href="https://berkough.com/tag:javascript" class="hashtag"><span>#</span><span class="p-category">javascript</span></a></p>

<p><img src="https://i.snap.as/PC0angUK.jpg" alt=""/></p>

<p>As the quality of televised and digital entertainment has degraded over the years, and not wanting to be bombarded by the sheer negativity of it all, I&#39;ve found myself spending more time listening to music and reading comics. It&#39;s been a gradual transition for me... That isn&#39;t to say that I don&#39;t spend entirely way too much time watching garbage on YouTube or mindlessly surfing, looking at things I&#39;ll never buy, or researching video games, or learning things that have no real practical purpose in my life other than to be interesting topics for cocktail parties that I&#39;ll never attend, etc.</p>

<p>Something happened though... A tipping point? I did attempt doing a web comic maybe a year or so ago, but I never stuck with it. I have revisited the idea though, and this time I sat and thought about the story ahead of putting pencil to paper, I drew a few outlines and sketches first.</p>

<p>Just from my 9-to-5 and thinking about the type of comic that I wanted to read, I came upon the idea of an insurance company in the relatively near future. But it&#39;s going to evolve beyond that, because, fuck it, I have a story universe where people live on Europa and Titan, and giant monsters are a real thing. So I&#39;m going to play with the surreal and the supernatural, the pragmatic and the practical, and I want to put it together to highlight the absurdity of life and the human condition.
</p>

<p>We&#39;re really in a timeline where aliens are real and just a few years ago we globally went into lock down for a novel communicable virus which may or may not have been created in a laboratory. That&#39;s some Depression-era level shit right there. So of course there is a need for art to reflect on that stuff.</p>

<p>I don&#39;t really care to debate the details, I just want to examine the greater implications and the social structures behind how civilization deals with those types of situations.</p>

<p>Super hero-<em>adjacent</em> characters exist, but won&#39;t necessarily be the focus of the stories that are told. Corporate espionage and libertarian -slash- anarcho-capitalist theory will be themes explored—because I find it interesting, the actual practicalities of implementing such civic systems aside. But it&#39;s all just flavor for the world and to inform the behavior of the characters.</p>

<p>Switching gears a bit. One of the things that I need to do is think about how to implement a page navigation system. WriteFreely doesn&#39;t really have a “web comic” module like Wordpress does. However, Matt Baer has thought about the utility of his writing platform, and he&#39;s implemented a place where you can inject some js into every page. I like that, and it should serve this particular purpose just fine.</p>

<p>I&#39;ve intentionally labeled each entry as the page number, so the url slug and the title as well as page number are all the same. I do not anticipate ever going beyond 999 pages.</p>

<p>That being said, here&#39;s how I implemented an automated page navigation:</p>

<pre><code class="language-javascript">let path = document.location.pathname;

function displayNav(){
    let page = parseInt(path.substring(1,4));
    let next = (new Array(3).join(&#39;0&#39;)+((page + 1).toString())).slice(-3);
    let prev = (new Array(3).join(&#39;0&#39;)+((page - 1).toString())).slice(-3);

    let div = `&lt;div class=&#34;page-nav&#34;&gt;
                &lt;table cellspacing=&#34;0&#34; cellpadding=&#34;0&#34;&gt;
                    &lt;tr&gt;
                        &lt;td id=&#34;first&#34;&gt;&lt;a href=&#34;/001&#34;&gt;&lt;i class=&#34;bx bxs-chevrons-left&#34;&gt;&lt;/i&gt;&lt;/a&gt;&lt;/td&gt;
                        &lt;td id=&#34;last&#34;&gt;&lt;a href=&#34;/${prev}&#34;&gt;&lt;i class=&#34;bx bxs-chevron-left&#34;&gt;&lt;/i&gt;&lt;/a&gt;&lt;/td&gt;
                        &lt;td id=&#34;next&#34;&gt;&lt;a href=&#34;/${next}&#34;&gt;&lt;i class=&#34;bx bxs-chevron-right&#34;&gt;&lt;/i&gt;&lt;/a&gt;&lt;/td&gt;
                        &lt;td id=&#34;recent&#34;&gt;&lt;a href=&#34;/&#34;&gt;&lt;i class=&#34;bx bxs-chevrons-right&#34;&gt;&lt;/i&gt;&lt;/a&gt;&lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/table&gt;
            &lt;/div&gt;`;
    
    let content = document.querySelector(&#39;.e-content&#39;).children.item(&#39;p&#39;);
    content.insertAdjacentHTML(&#39;beforeend&#39;, div);
    return content
}

if (path !== &#39;/&#39;){
   setTimeout(() =&gt; {
    displayNav();
   }, 200);
}
</code></pre>

<p>Everything hinges on the url path, so that&#39;s defined at the top level scope. I figured this would be the easiest way to deal with pages. Stylistically I wanted to go with three digits, so working with that in javascript is a little clunky.</p>

<p>Originally I had an <em>lpad</em> function that was taken wholesale <a href="https://stackoverflow.com/questions/10841773/javascript-format-number-to-day-with-always-3-digits">from stack</a>. It seemed like the most elegant solution. But I wouldn&#39;t have used that function anywhere else, or more than twice, so I refactored what the function did right into the declaration of my next and last variables.</p>

<p>Once we have those variables we know what our URL is going to be for going backwards and forwards. So I defined a template literal with the HTML of our navigation block.</p>

<p>How do we know where to place it? Well, I want to make sure it&#39;s right after the picture and that&#39;s the only paragraph we have. Writefreely dumps your post into a div with the class “e-content”. Despite the fact that it&#39;s not an id, it does only show up once on the DOM. So, we query that class, look for the p and dump our div variable as html at the end.</p>

<p>Writefreely also provides user-specified CSS, so I&#39;ve imported the <a href="https://boxicons.com/">Boxicons</a> cdn so I can use it like FontAwesome and have some icons to represent first, last, previous and next.</p>

<p>Might not be the most elegant way to do what I need it to do, and might not be the most robust, but it works, and I&#39;m happy about that. I don&#39;t have to keep writing a table/navigation element for each page.</p>
]]></content:encoded>
      <guid>https://berkough.com/what-is-mtk-ultra</guid>
      <pubDate>Fri, 15 Sep 2023 19:00:00 +0000</pubDate>
    </item>
  </channel>
</rss>