Skip to content

Instantly share code, notes, and snippets.

View gustinmi's full-sized avatar

Mitja Guštin gustinmi

View GitHub Profile
@gustinmi
gustinmi / storage.js
Last active November 3, 2017 11:08
Simple JavaScript storage (webstorage or cookie based)
/**
*
* Component for utilizing local storage. It provides backup plan, if no WebStorage is available on client
*
*We support html5 storage, and cookie store if webStorage is not available.
*
*Cookies
* Are for older browsers only. A "session" cookie (one without expiration data) is available in all windows
* that have access to that domain until the browser is shut down. This is bad.
* 4096 chars limit
@gustinmi
gustinmi / tests.html
Created February 13, 2013 16:15
Simple JavaScript UnitTester.No frameworks. Very simple
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<title>Tests </title>
<style type="text/css">
div.results b {
color: green;
}
div.results b[class='err'] {
@gustinmi
gustinmi / storage.js
Last active December 13, 2015 17:08
Shorten your boilerplate JavaScript code
//Boiler plate code is usually consisted of simple patterns. Once you master them, there is no need for readability. It should be as compact as possible, to preserve space for the real implementation code. For example:
// adding interface "storage" to namespace "AppHtml5"
if (window.AppHtml5)
window.AppHtml5.storage = { "save" : {}, "load" : {}};
else {
window.AppHtml5 = {};
window.AppHtml5.storage = {};
window.AppHtml5.storage = { "save" : {}, "load" : {}};