Adventures in JavaScript

Yet another coding project that has been sitting on the back burner for years, 14 to be exact. How time flies. My original concept was a slick JavaScript based single page web app that would replace the clunky dotNET version of Antibiotic Kinetics.

Per MSDN: “A Single-Page Application (SPA) is a web app that loads a single HTML page and dynamically updates content via JavaScript as users interact with it, eliminating full-page reloads. It offers a fast, native-like experience (e.g., Gmail, Netflix) by fetching only necessary data (JSON) rather than reloading entire pages.”

JavaScript is relatively easy to learn, but very difficult to master. It has many pitfalls and drawbacks. From it’s aggressive coercion to implied global variables, JavaScript code can be extremely bug prone.

JavaScript is a dynamically and loosely typed language, which means type-related errors might only become apparent during runtime, making debugging more challenging compared to statically typed languages.

I’ve tried so many HTML/JavaScript editors over the years it’s ridiculous. Many I paid good money for, none ever worked for me. Here are a few that I can remember trying, buying, and failing:

  • Antechinus
  • BlueGriffin
  • Dreamweaver
  • Komodo
  • NetBeans
  • NSB App Studio
  • RadPHP

There was an online editor that worked pretty well (up to a point), but so much time has passed I’ve forgotten its name.

This time around I used Visual Studio Code, the price was right (free). It does a nice job of color formatting the code, plus a few bug insights, albeit very few. Because JavaScript is a interpreted language, it does not have a compilation step. You don’t know if you have made a syntax error until you run the entire application. The Chrome console and Claude AI were helpful in sussing out the bugs.

So far I’ve only coded the prospective half of Antibiotic Kinetics. There is no serum level analysis methodology (yet?). I’m calling it Antibiotic Kinetics “Express”, to differentiate from the full dotNET web app, renamed Antibiotic Kinetics “Classic”.

When I paused this project 14 years ago, the jQuery mobile library (now deprecated) was the shiz. I kept it, giving the UI an iPhone classic look with rounded buttons and nice looking dialogs. The retro aesthetic evokes a warm sense of nostalgia:

I think the app icon is a winner too </sarcasm>.

Here is the link to Antibiotic Kinetics Express, enjoy.

Web update update

Three years ago I switched this web site to a secure server (HTTPS). The main difference between HTTP and HTTPS is that HTTPS has the additional SSL/TLS layer to ensure all data being transferred is encrypted and secure. 

The side effect of the switch was the web update functions of APK and AbPK stopped functioning.

Originally I thought the fix would be to simply change the URL in the updaters from HTTP to HTTPS. But it had no effect so I had to dig into the source code.

mxWebUpdate is freeware offered by Max Components. It is still available on the Torry Delphi Developer Library. However the Max Components website is no longer online, and no way to contact the author. Fortunately the source code was included. The component wraps the Windows Internet Library, so my next step was to delve into the Wininet API.

StackOverflow to the rescue. It was simply a matter of setting the correct flag in the call to HttpOpenRequest.

  • Original code: InternetFlag := INTERNET_FLAG_RELOAD
  • Revised code: InternetFlag := INTERNET_FLAG_SECURE

A simple fix that took me three years to discover. I will be posting an update to AbPK soon, still working on significant improvements to APK, stay tuned.

Android app update

It’s been awhile since I’ve posted here. I am currently in the process of updating the AbPK for Android app.

When I originally wrote the app I targeted an older version of Android, assuming Google would maintain backwards compatibility. But, silly me, they don’t think like that. Update or get deleted is their motto, which is exactly what happened to my apps on Google’s play store.

According to them, the state-of-the-art method for developing apps for Android is to use Google’s own tool, Android studio. So I downloaded, installed and fired up Android studio “Koala”. Then clicked Import and selected the original project manifest. The “Importing” dialog appeared and then ran and ran and ran. I let it go on for 48 hours before giving up. So much for Android studio. What a disappointment, the splash screen with the koala icon is so cute.

Since the original version was written in the Eclipse IDE, I thought to give it a go, why not? So I went to download the latest version of Eclipse and, guess what, it doesn’t have a pre-built Android dev package anymore.

Fortunately I did find this post from 2022 that details how to install the Android SDK and the necessary dev tools into the Eclipse Java package:

How to Install and Setup Eclipse IDE For Android App Development

Several errors later I discovered that Eclipse uses a different folder structure, e.g., it looks for the Emulator under tools instead of its own folder, etc. So I ended up duplicating the 35 SDK that was installed with Android Studio. I mean, who cares about hard disk space anymore? After several more starts and stops the project eventually loaded, albeit with 3 fatal errors and 105 warnings. All the errors and warnings stem from deprecated methods no longer available in the most recent Android SDK. To say this will take some time to fix all this is an understatement.

Even if all 108 problems are fixable, I’m not optimistic the code will compile into an app that is acceptable to the google gods. Wish me luck.