summaryrefslogtreecommitdiff
path: root/src/runtime/javascript/minibar/support.js
diff options
context:
space:
mode:
authorhallgren <hallgren@chalmers.se>2010-09-05 18:06:45 +0000
committerhallgren <hallgren@chalmers.se>2010-09-05 18:06:45 +0000
commit5290659c2c5d6f5fe8dab957854470bba5b3d736 (patch)
tree8a3dc27edf43e3e09af6814a11ffe0db980d2ace /src/runtime/javascript/minibar/support.js
parentc85c1e1c11b68d376cb41ed3b0fc3dc9a72d50e9 (diff)
Minibar: PGF server API: pass callback functions directly instead of passing function names as strings.
Diffstat (limited to 'src/runtime/javascript/minibar/support.js')
-rw-r--r--src/runtime/javascript/minibar/support.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/runtime/javascript/minibar/support.js b/src/runtime/javascript/minibar/support.js
index b322aae86..7c34bad82 100644
--- a/src/runtime/javascript/minibar/support.js
+++ b/src/runtime/javascript/minibar/support.js
@@ -25,6 +25,18 @@ function jsonp(url,callback)
document.body.appendChild(script);
}
+var json = {next:0};
+
+// Like jsonp, but instead of passing the name of the ballback function, you
+// pass the callback function directly, making it possible to use anonymous
+// functions.
+function jsonpf(url,callback)
+{
+ var name="callback"+(json.next++);
+ json[name]=function(x) { delete json[name]; callback(x); }
+ jsonp(url,"json."+name);
+}
+
/* --- HTML construction ---------------------------------------------------- */
function text(s) { return document.createTextNode(s); }