Skip to content

Instantly share code, notes, and snippets.

View SethVandebrooke's full-sized avatar

Seth Vandebrooke SethVandebrooke

View GitHub Profile
@SethVandebrooke
SethVandebrooke / README.md
Last active August 17, 2018 17:32
SSPAF: Simple SPA functionality

SSPAF

Simple Single Page Application Functionality

Navigating between pages is easy:

<app-page class="default-page" id="home">
  <h1>Home page</h1>
 <a data-goto="new">go to new page</a>
@SethVandebrooke
SethVandebrooke / UCB64URL.js
Last active January 18, 2021 21:23
Upload and file and convert it into a base64 data url
function uploadAndConvertToBase64DataURL(callback) {
if (!document.getElementById("B64DURL_UL")) {
var input = document.createElement("input");
input.id = "B64DURL_UL";
input.style.display = "none";
input.type = "file";
document.body.appendChild(input);
}
var input = document.getElementById("B64DURL_UL");
input.addEventListener("change", function (e){
@SethVandebrooke
SethVandebrooke / JSModel.js
Last active January 18, 2021 21:25
Create models with enforced data types that can reference other models as data types themselves
function Model(name, OBJ) {
function model(obj) {
var PUBLIC = this;
var PRIVATE = {};
PUBLIC.MODEL_TYPE = name;
for (let key in obj) {
let value = obj[key];
// Ensure property is set correctly
@SethVandebrooke
SethVandebrooke / DotSequence.js
Created July 19, 2018 18:48
An easy way to build a custom sequence of callable operations using dot notation.
function DotSequence(seq) {
var self = this;
seq = seq || [];
self.commands = {};
self.addCommand = function (name,operation) {
self.commands[name] = operation;
self[name] = function (...params) {
seq.push({
command: name,
params
@SethVandebrooke
SethVandebrooke / baseCompression.js
Created July 17, 2018 17:47
Using base conversion to compress number values
function compress(z) {
z = z.toString();
var a = [];
z.split("").forEach((e,i)=>{a[i] = parseInt(e);});
var u = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM!?";
var x = u.substring(0,Math.max(...a)+1);
var s = x.length;
var d = u.length;
var v = 0;
var n = z.length;
@SethVandebrooke
SethVandebrooke / StateMapper64.js
Last active September 19, 2018 15:19
Map keys and values (keys being subjects and values being states that the subjects are in) and compress the mappings into small strings that can be decompressed into the original javacript object.
function StateMapper(subjects,states) {
var self = this;
self.states = states || [];
self.subjects = subjects || [];
self.encode = function(z) {
z = z.toString();
var x = "0123456789";
var u = "0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM!?";
var s = x.length;
@SethVandebrooke
SethVandebrooke / JSlnline.js
Created July 6, 2018 15:42
Process JS in your html
function processJSin(target) {
var html = target.innerHTML;
var temp = html.match(/\{\{.*\}\}/);
if (temp !== null) {
temp.forEach(function(item){
var e = item.replace("{{","").replace("}}","");
html = html.replace(item,eval(e));
});
target.innerHTML = html;
}
var Observable = function(v){
var d, l = [], t = () => {
for (var i = 0; i < l.length; i++) {
if (typeof l[i] == "function") {
l[i](d);
}
}
};
var observable = function (v) {
@SethVandebrooke
SethVandebrooke / TDROM.js
Last active March 30, 2018 19:35
3D Relational Object Mapping
function TDROM() {
var THIS = this;
THIS.data = [];
THIS.props = {};
THIS.vals = {};
THIS.map = [];
THIS.add = function(obj) {
var index = THIS.data.push(obj) - 1, p, v, k;
for (k in obj) {
@SethVandebrooke
SethVandebrooke / personList.hta
Last active August 3, 2022 04:54
Self Modifying HTA file ( HTML + VBS + JavaScript)
<head>
<title>HTA Test</title>
<HTA:APPLICATION
APPLICATIONNAME="Application"
SCROLL="no"
SINGLEINSTANCE="yes"
>
</head>