Skip to content
Browse files

support list

  • Loading branch information...
1 parent 5a9be9b commit f0013b4c875dc2fd9d2e85dd061e9f735217bbaa @zdwalter committed Mar 5, 2012
Showing with 44 additions and 6 deletions.
  1. +0 −1 debug.sh
  2. +39 −4 public/javascripts/debug.js
  3. +5 −1 src/db.coffee
View
1 debug.sh
@@ -1,3 +1,2 @@
#!/bin/bash
-make
NODE_PATH=./src coffee src/app.coffee --port 8180
View
43 public/javascripts/debug.js
@@ -42,20 +42,55 @@ function listener(event, exec_state, event_data, data) {
//_print(_globals_internals);
}
var globals = {};
+ var globals_list = [];
for (var _i in globals_) {
if (globals_.hasOwnProperty(_i) && _globals_internals.indexOf(_i) < 0) {
- globals[_i] = globals_[_i];
+ var _value = globals_[_i];
+ var _type = typeof _value;
+ //_print(_type);
+ if (_type === 'number' || _type === 'string') {
+ globals[_i] = _value;
+ }
+ if (_type === 'object') {
+ var _id = globals_list.indexOf(_value);
+ if (_id < 0) {
+ _id = globals_list.push(_value);
+ }
+ else {
+ _id++;
+ }
+ //_print(_id);
+ var _copy = ['LIST',_id].concat(_value);
+ globals[_i] = _copy;
+ }
}
}
//_print(JSON.stringify(globals));
//_print(JSON.stringify(details_));
var local = 9;
var locals = {};
while(local+1 < details_.length) {
- var key = details_[local];
- var value = details_[local+1];
- locals[key] = value;
+ var _key = details_[local];
+ var _value = details_[local+1];
local += 2;
+ var _type = typeof _value;
+ if (_type === 'number' || _type === 'string') {
+ locals[_i] = _value;
+ }
+ if (_type === 'object') {
+ var _id = globals_list.indexOf(_value);
+ if (_id < 0) {
+ _id = globals_list.push(_value);
+ }
+ else {
+ _id++;
+ }
+ //_print(_id);
+ var _copy = ['LIST',_id].concat(_value);
+ locals[_i] = _copy;
+ }
+
+ locals[_key] = _value;
}
var step = {
event: "step_line",
View
6 src/db.coffee
@@ -67,6 +67,7 @@ db.mongodb.collection = (mongodb, name, callback) ->
self = this
if (mongodb.state isnt 'connected')
mongodb.open (err, mongodb) ->
+ return callback(err) if err
mongodb.collection name, callback
else
mongodb.collection name, callback
@@ -81,7 +82,7 @@ db.mongodb.findOne = (collection, condition, callback) ->
db.mongodb.insert = (collection, object, callback) ->
mongodb = db.mongodb.createClient()
db.mongodb.collection mongodb, collection, (err, collection) ->
- console.log err if err
+ return callback(err) if err
collection.insert object, {safe:true}, (err, res) ->
db.mongodb.releaseClient(mongodb)
callback(err, res)
@@ -103,10 +104,13 @@ db.mongodb.update = (collection, condition, data, callback) ->
db.mongodb.addToSet = (collection, condition, field, value, callback) ->
mongodb = db.mongodb.createClient()
+ return callback('mongodb createClient fail') if not mongodb
db.mongodb.collection mongodb, collection, (err, collection) ->
+ return callback(err) if err or not collection
data = {}
data[field] = value
collection.update condition, {'$addToSet': data}, {safe: true}, (err, res) ->
+ return callback(err) if err
db.mongodb.releaseClient(mongodb)
return callback(err, res)

0 comments on commit f0013b4

Please sign in to comment.
Something went wrong with that request. Please try again.