Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Created Session.create() for building Session object.

  • Loading branch information...
commit 632aa482387fff693fff5b5129c64a26189f86b4 1 parent 017844e
@matthewpblog matthewpblog authored
Showing with 30 additions and 2 deletions.
  1. +15 −1 js/atwork.js
  2. +15 −1 src/session.js
View
16 js/atwork.js
@@ -122,7 +122,7 @@ Timer.prototype = {
};
function Session(times) {
- this.times = times;
+ this.times = times || [];
}
Session.prototype = {
@@ -192,12 +192,26 @@ Session.getAll = function(callback) {
return;
}
+ if(!cursor.value.hasOwnProperty('save'))
+ console.log('Is not a session object.');
+
+ if(!(cursor.value instanceof Session))
+ console.log('Really is not a session object.');
+
sessions.push(cursor.value);
cursor.continue();
};
});
};
+Session.create = function(obj) {
+ var session = new Session();
+ obj.times.forEach(function(timeData) {
+ var time = TimeSpan.create(timeData);
+ session.times.push(time);
+ });
+};
+
var SessionList = {
init: function() {
this.sessions = [];
View
16 src/session.js
@@ -1,5 +1,5 @@
function Session(times) {
- this.times = times;
+ this.times = times || [];
}
Session.prototype = {
@@ -69,8 +69,22 @@ Session.getAll = function(callback) {
return;
}
+ if(!cursor.value.hasOwnProperty('save'))
+ console.log('Is not a session object.');
+
+ if(!(cursor.value instanceof Session))
+ console.log('Really is not a session object.');
+
sessions.push(cursor.value);
cursor.continue();
};
});
};
+
+Session.create = function(obj) {
+ var session = new Session();
+ obj.times.forEach(function(timeData) {
+ var time = TimeSpan.create(timeData);
+ session.times.push(time);
+ });
+};
Please sign in to comment.
Something went wrong with that request. Please try again.