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 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" : {}};
@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 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 / logger.js
Created February 13, 2013 16:41
Simple JavaScript logging framework.
/**
* Simple logging framwork
* Supports Chrome or Firefox
* Usage:
*
* AppHtml5.log.info('Dropdown value changed to something new!');
*
*/
//create logging functions
@gustinmi
gustinmi / gist:4952465
Last active December 13, 2015 17:59
jQuery Tables plugin. Below is the code that triggers the update ajax source via your own custom event handler, possibly passing http paramaters.
//This is the extension function for table plugin (My params are array of key value pairs). Make this script available to your //web page which is utilizing the table plugin
$.fn.dataTableExt.oApi.fnReloadAjax = function (oSettings, sNewSource, myParams ) {
if ( oSettings.oFeatures.bServerSide ) {
oSettings.aoServerParams = [];
oSettings.aoServerParams.push({"sName": "user",
"fn": function (aoData) {
for (var i=0;i<myParams.length;i++){
aoData.push( {"name" : myParams[i][0], "value" : myParams[i][1]});
@gustinmi
gustinmi / timeline.html
Created February 15, 2013 13:02
Creating simple mobile-style page navigation, where pages slide-in.
<!DOCTYPE html>
<html>
<head>
<title>Creating simple page navigator with remote pages</title>
<style type="text/css">
div.viewport {
position: relative;
border-collapse: collapse;
width: 800px;
height: 200px;
@gustinmi
gustinmi / html5template.html
Created April 16, 2013 10:35
HTML5 View Template Features: responsive layout, header, footer, content. Footer is always at bottom. Content occupies all available and remaining viewport. Preview: https://googledrive.com/host/0B-KXuLdFNBwiWG5TYzBmUjRzeVk/html5template.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<title>HTML5Template</title>
<style type="text/css">
html, body { height: 100%; width: 100%; } /* occupy whole viewport. */
body,div,p {
/* css reset techique; We are resetting the UserAgent (browser) style */
@gustinmi
gustinmi / jsmicrotmpl.js
Created November 23, 2014 18:59
JavaScript Templating Framework Easy 1
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>templator</title>
<style type="text/css">
#content {
padding: 5px;
@gustinmi
gustinmi / jstemplates2.html
Last active April 26, 2024 08:50
JavaScript Templating Full Edition (settings, localization, micro templates )
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>templator2</title>
<style type="text/css">
html, body {
font-size: 14px;
@gustinmi
gustinmi / gist:280ef29a18580eee7e4f
Created January 23, 2015 21:31
Javascript tab panel using pure javascript
<!DOCTYPE html>
<html>
<head>
<title>tabs demo</title>
<style type="text/css">
.tabs ul {
list-style-type: none;
margin: 0 2em;
padding: 0;
cursor: pointer;