Removed jQuery Dependency from My Math Editor

Background jQuery provides many handy functions to speed up the development, for example document.ready(), element.toggle(), element.hide(), etc. My math editor used some of them. However, I replaced them with Vanilla JavaScript at commit 4a35c45b. Goal Some users complained about the white background in the past versions of my editor. That had motivated me to refactor the code, so that it would be easier to maintain and to add in new features. [Read More]

Staticman Script in Pure JS

Staticman without jQuery

The official Staticman script sample depends on jQuery. I have been using jQuery in my Staticman script for nested comments for more than six months. Recently, in the new release of Hugo Swift Theme, in which I’m a collaborator, one has removed all jQuery methods at commit f137efa4. Here’s the structure of the script: auxiliary functions like elem, elems, pushClass, deleteClass, etc. A self-executing function comments() some necessary local variables handleForm() consisting merely of an event listener handling form submission. [Read More]

JavaScript Copy Button

Goal To create a copy button for my Math.SE comment template in order to save the trouble of copying and pasting. My first attempt I put the boilerplate inside a Markdown codeblock to prevent them from getting interpreted by Hugo’s Markdown parser. Under each codeblock, I placed the copy button. Comment boilerplate goes here ... 📝 Another comment boilerplate goes here ... 📝 … My page’s original layout $(document).ready(function() { $('. [Read More]

Fix Hugo Table of Contents

Removal of wrapping HTML tag in JavaScript

Background (TL;DR) While setting up the new version of Staticman for my demo GitLab pages, I’ve read developers’ documentations, setup guide and some community blog posts so as to come up with my own guide. It’s originated and inspired from a variety of sources, and refined according to hours of testing. Consequently, despite the original intention to keep things simple, I’ve finally come up with a post with over a thousand words. [Read More]