Created
October 19, 2011 20:31
-
-
Save dodeja/1299572 to your computer and use it in GitHub Desktop.
PPMetrics
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// User | |
var PPM = { | |
user_id: 0, | |
init: function(uid){ | |
var self = this; | |
this.user_id = uid; | |
Plankton.sync('http://draw.test.envolve.com/ppmetrics/', function(data){ self.after_sync(self, data) }); | |
}, | |
after_sync: function(self, data){ | |
self.sync_user = data.get('picplum_user').get('u'+self.user_id); | |
console.log('after_sync') | |
console.log(self.sync_user) | |
}, | |
track: function(str){ | |
console.log(this) | |
resp = { on: new Date(), e: str} | |
this.sync_user.push(str); | |
this.sync_user.log(); | |
} | |
} | |
PPM.init(1) | |
// Admin | |
pp_metrics_admin = { | |
user_id: 0, | |
sync_user: undefined, | |
init: function(uid){ | |
var self = this; | |
this.user_id = uid; | |
Plankton.sync('http://draw.test.envolve.com/ppmetrics/', function(data) { self.after_sync(self, data) }); | |
}, | |
// | |
after_sync: function(self, data){ | |
self.sync_user = data.get('picplum_user').get('u'+self.user_id); | |
var all_events = self.sync_user.getAll(); | |
for(var i = 0; i < all_events.length; i++) | |
self.new_tracking(all_events[i]); | |
//and now listen for any new messages | |
self.sync_user.watch(function(event) { | |
self.new_tracking(event.data); | |
}); | |
}, | |
new_tracking: function(data){ | |
console.log(data); | |
} | |
} | |
pp_metrics_admin.init(1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment