Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added a Dict object.

  • Loading branch information...
commit 40da1520e64a215bf9790490f857988381f41e53 1 parent 1f050aa
@matthewpblog matthewpblog authored
View
1  Makefile
@@ -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
57 js/atwork.js
@@ -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
52 src/dict.js
@@ -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
1  src/eventable.js
@@ -0,0 +1 @@
+
View
4 src/sessionlist.js
@@ -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
4 style/atwork.css
@@ -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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.