Skip to content

Instantly share code, notes, and snippets.

View magnetardev's full-sized avatar
🎮
Working on Eclipse v3

Magnetar magnetardev

🎮
Working on Eclipse v3
View GitHub Profile
@magnetardev
magnetardev / example.html
Last active March 20, 2024 20:06
A client-side HTML templating library that allows you to create and update elements based on objects. It should be more efficient than comparable implementations.
<template>
<div class="person">
<p x-tmpl="innerText::name"></p>
<input type="number" x-tmpl="value::age" />
</div>
</template>

How do I use these scripts?

If you're on desktop, just paste them into the browser's console and hit enter.

On mobile, you're unlikely to have access to the browser's actual console. That's why we've included Eruda, which allows you to have a console on mobile:

  1. To access Eruda, go to Settings -> Web Inspector.
  2. You should see a little box show up in the corner of your screen, tap on it.
  3. In the view that pops up, you should be on the "Console" tab. At the very bottom of it, there should be a little input box, tap on that.
  4. Paste in the script to the input that shows, hide your keyboard, and press "Execute"
/**
* Takes a form and converts the names and values into an object.
* @param {string} selector The CSS Selector of the form element you wish to serialize.
* @returns
*/
const serializeForm = (selector: string) => {
const output: any = {};
const form = document.querySelector(selector);
if (!!form) {
[...form.querySelectorAll('input, textarea, select')].map((el) => {
@magnetardev
magnetardev / serializeForm.js
Last active August 3, 2020 09:47
An ES6 version of the jQuery .serializeArray function.
/**
* Takes a form and converts the names and values into an object.
* @param {string} selector The CSS Selector of the form element you wish to serialize.
* @returns
*/
const serializeForm = (selector) => {
const output = {};
const form = document.querySelector(selector);
[...form.querySelectorAll('input, textarea, select')].map((el) => {
switch (el.localName) {

Keybase proof

I hereby claim:

  • I am magnetardev on github.
  • I am magnetardev (https://keybase.io/magnetardev) on keybase.
  • I have a public key ASD8TievijOKSp1VddP6KV6m4ohsMBObxxQjn8JSxc3K0Qo

To claim this, I am signing this object: