Permalink
Browse files

Added a Dict object.

  • Loading branch information...
1 parent 1f050aa commit 40da1520e64a215bf9790490f857988381f41e53 @matthewpblog matthewpblog committed Apr 28, 2012
Showing with 119 additions and 0 deletions.
  1. +1 −0 Makefile
  2. +57 −0 js/atwork.js
  3. +52 −0 src/dict.js
  4. +1 −0 src/eventable.js
  5. +4 −0 src/sessionlist.js
  6. +4 −0 style/atwork.css
View
@@ -5,6 +5,7 @@ endef
modules = src/rAF.js\
src/prefixes.js\
src/transform.js\
+ src/dict.js\
src/database.js\
src/extend.js\
src/timespan.js\
View
@@ -47,6 +47,59 @@ function gimmePrefix(prop){
var transformStyle = gimmePrefix('transform');
var transitionStyle = gimmePrefix('transition');
+function Dict() {
+ this.items = {};
+
+ return this;
+}
+
+Dict.prototype = {
+
+ prop: function(key) {
+ return ':' + key;
+ },
+
+ get: function(key, def) {
+ var p = this.prop(key),
+ k = this.items;
+
+ return k.hasOwnProperty(p) ? k[p] : def;
+ },
+
+ set: function(key, value) {
+ var p = this.prop(key);
+
+ this.items[p] = value;
+
+ return value;
+ },
+
+ count: function() {
+ return Object.keys(this.items).length;
+ },
+
+ has: function(key) {
+ var p = this.prop(key);
+
+ return this.items.hasOwnProperty(p);
+ },
+
+ del: function(key) {
+ var p = this.prop(key),
+ k = this.items;
+
+ if(k.hasOwnProperty(p))
+ delete k[p];
+ },
+
+ keys: function() {
+ return Object.keys(this.items).map(function(key) {
+ return key.substring(1);
+ });
+ }
+
+};
+
var OS_NAME = 'sessions',
DB_NAME = 'atwork',
DB_VERSION = 1.1;
@@ -277,6 +330,10 @@ var SessionList = {
this.sessions.push(session);
},
+ on: function(evt, action) {
+
+ },
+
show: function() {
var base = this.base,
ce = document.createElement.bind(document);
View
@@ -0,0 +1,52 @@
+function Dict() {
+ this.items = {};
+
+ return this;
+}
+
+Dict.prototype = {
+
+ prop: function(key) {
+ return ':' + key;
+ },
+
+ get: function(key, def) {
+ var p = this.prop(key),
+ k = this.items;
+
+ return k.hasOwnProperty(p) ? k[p] : def;
+ },
+
+ set: function(key, value) {
+ var p = this.prop(key);
+
+ this.items[p] = value;
+
+ return value;
+ },
+
+ count: function() {
+ return Object.keys(this.items).length;
+ },
+
+ has: function(key) {
+ var p = this.prop(key);
+
+ return this.items.hasOwnProperty(p);
+ },
+
+ del: function(key) {
+ var p = this.prop(key),
+ k = this.items;
+
+ if(k.hasOwnProperty(p))
+ delete k[p];
+ },
+
+ keys: function() {
+ return Object.keys(this.items).map(function(key) {
+ return key.substring(1);
+ });
+ }
+
+};
View
@@ -0,0 +1 @@
+
View
@@ -26,6 +26,10 @@ var SessionList = {
this.sessions.push(session);
},
+ on: function(evt, action) {
+
+ },
+
show: function() {
var base = this.base,
ce = document.createElement.bind(document);
View
@@ -180,6 +180,10 @@ nav div#buttons span:nth-child(2) {
width: 50%;
}
+.sessions .item .del span:hover {
+ background: yellow;
+}
+
.sessions .item .del span:first-child {
background: red;
}

0 comments on commit 40da152

Please sign in to comment.