From 6ecc805fd26da69fed106a5bf3b79e68fd3d8f59 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Tue, 14 Jun 2011 12:20:53 -0400 Subject: [PATCH] Added store module, ecapsulated QS module --- kis.js | 173 ++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 109 insertions(+), 64 deletions(-) diff --git a/kis.js b/kis.js index e8340c8..334ef17 100644 --- a/kis.js +++ b/kis.js @@ -14,6 +14,7 @@ $_ = {}; window.$_ = window.$_ || $_; + window.$_.hb = (history.pushState) ? false : true; $ = function(a) { @@ -102,82 +103,126 @@ * * Object for encoding and decoding querystrings and hashbang strings */ - $_.qs = { - _parse: function(hb) - { - hb = hb || $_.hb; - var h, i, hString, pairs, pLen, data, y; - - data = {}; - - if(hb === true) + (function(){ + var qs = { + parse: function(hb) { - h = location.hash.split('#!/'); - hString = (h.length > 1) ? h[1] : ''; - } - else if(hb === false || hb === undefined) - { - hString = window.location.search.substring(1); - } - else - { - return false; - } - - pairs = hString.split('&'); - - pLen = pairs.length; - - for(i=0;i 1) ? h[1] : ''; + } + else if(hb === false || hb === undefined) + { + hString = window.location.search.substring(1); + } + else + { + return false; } - data[y[0]] = y[1]; - } - - return data; - }, - set: function(key, value, hb) - { - hb = hb || $_.hb; - var pairs = this._parse(hb); - - if(key !== undefined && value !== undefined) + pairs = hString.split('&'); + + pLen = pairs.length; + + for(i=0;i