|
@ -23,7 +23,7 @@ var eth = (function ethScope() { |
|
|
m_reqId++ |
|
|
m_reqId++ |
|
|
var request = new XMLHttpRequest(); |
|
|
var request = new XMLHttpRequest(); |
|
|
request.open("POST", "http://localhost:8080", false); |
|
|
request.open("POST", "http://localhost:8080", false); |
|
|
console.log("Sending " + JSON.stringify(req)) |
|
|
// console.log("Sending " + JSON.stringify(req))
|
|
|
request.send(JSON.stringify(req)); |
|
|
request.send(JSON.stringify(req)); |
|
|
return JSON.parse(request.responseText).result; |
|
|
return JSON.parse(request.responseText).result; |
|
|
} |
|
|
} |
|
@ -66,15 +66,12 @@ var eth = (function ethScope() { |
|
|
var watching = []; |
|
|
var watching = []; |
|
|
for (var w in m_watching) |
|
|
for (var w in m_watching) |
|
|
watching.push(w) |
|
|
watching.push(w) |
|
|
console.log("Checking " + JSON.stringify(watching)); |
|
|
|
|
|
var changed = reqSync("check", { "a": watching } ); |
|
|
var changed = reqSync("check", { "a": watching } ); |
|
|
console.log("Got " + JSON.stringify(changed)); |
|
|
console.log("Got " + JSON.stringify(changed)); |
|
|
for (var c in changed) |
|
|
for (var c in changed) |
|
|
m_watching[c]() |
|
|
m_watching[changed[c]]() |
|
|
console.log("Setting timeout"); |
|
|
|
|
|
var that = this; |
|
|
var that = this; |
|
|
setTimeout(function() { that.check() }, 5000) |
|
|
setTimeout(function() { that.check() }, 5000) |
|
|
console.log("OK"); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
ret.watch = function(a, fx, f) { |
|
|
ret.watch = function(a, fx, f) { |
|
@ -88,17 +85,12 @@ var eth = (function ethScope() { |
|
|
this.check() |
|
|
this.check() |
|
|
} |
|
|
} |
|
|
ret.unwatch = function(f, fx) { |
|
|
ret.unwatch = function(f, fx) { |
|
|
console.log(JSON.stringify(m_watching) + " " + (m_watching == {})) |
|
|
|
|
|
delete m_watching[fx ? f + fx : f]; |
|
|
delete m_watching[fx ? f + fx : f]; |
|
|
console.log(JSON.stringify(m_watching) + " " + (m_watching == {})) |
|
|
|
|
|
} |
|
|
} |
|
|
ret.newBlock = function(f) { |
|
|
ret.newBlock = function(f) { |
|
|
console.log(JSON.stringify(m_watching) + " " + (m_watching == {})) |
|
|
|
|
|
var old = isEmpty(m_watching) |
|
|
var old = isEmpty(m_watching) |
|
|
m_watching[""] = f |
|
|
m_watching[""] = f |
|
|
f() |
|
|
f() |
|
|
console.log(JSON.stringify(m_watching) + " " + (m_watching == {})) |
|
|
|
|
|
console.log("Check?" + (m_watching === {}) + "!=" + old) |
|
|
|
|
|
if (isEmpty(m_watching) != old) |
|
|
if (isEmpty(m_watching) != old) |
|
|
this.check() |
|
|
this.check() |
|
|
} |
|
|
} |
|
|