summaryrefslogtreecommitdiff
path: root/examples/phrasebook/www
diff options
context:
space:
mode:
authoraarne <aarne@chalmers.se>2010-10-25 19:56:47 +0000
committeraarne <aarne@chalmers.se>2010-10-25 19:56:47 +0000
commitc5334613c514e129c1bd0d6f489f2c4f61516300 (patch)
tree7fca452fa631b3a35d1bf81339c0a37798c5f76f /examples/phrasebook/www
parentad28e99f35fe032b0a9ff764acae72016d15c57f (diff)
trying to find some inefficiencies in Finnish resource
Diffstat (limited to 'examples/phrasebook/www')
-rw-r--r--examples/phrasebook/www/support.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/examples/phrasebook/www/support.js b/examples/phrasebook/www/support.js
index b322aae86..7c34bad82 100644
--- a/examples/phrasebook/www/support.js
+++ b/examples/phrasebook/www/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); }