-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun_entity.js
74 lines (49 loc) · 1.41 KB
/
run_entity.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
run an entity server side. The output may vary, depending on arguments, but probably is either nothing, error message, or entity data
- mostly the point is to run all the widgets, update their data, etc.
- and this is an important component of a crawler.
*/
console.log("starting");
var argv = require('minimist')(process.argv.slice(2));
var entityId = argv._[0];
console.log(argv);
console.log(entityId);
// requireses
var urlparser = require("url");
var pathparser = require("path");
// set up globals
GLOBAL = {};
GLOBAL.context = "server";
GLOBAL.params = {
root_dir : __dirname,
require_prefix : __dirname
};
var jsdom = require('jsdom');
var $;
jsdom.env({
html: "<html><body></body></html>",
scripts: [
'http://code.jquery.com/jquery-1.5.min.js'
],
done : function (err, window) {
console.log("running entitye " + entityId);
$ = window.jQuery;
GLOBAL.$ = $;
run_entity(entityId);
}
});
function run_entity(entityId){
var EntityManager = require(GLOBAL.params.root_dir+"/classes/entity/entity.js").EntityManager();
function callback(entity){
entity.addListener("allWidgetsRan", function(params){
console.log("this thing is all done!");
console.log(params.thing);
console.log(params.thing.widgetInstances);
console.log("done now?");
});
return;
}
EntityManager.generateEntity(entityId, callback);
return;
}
console.log("done");