{"url":"https://api.github.com/gists/558596","forks_url":"https://api.github.com/gists/558596/forks","commits_url":"https://api.github.com/gists/558596/commits","id":"558596","node_id":"MDQ6R2lzdDU1ODU5Ng==","git_pull_url":"https://gist.github.com/558596.git","git_push_url":"https://gist.github.com/558596.git","html_url":"https://gist.github.com/mbostock/558596","files":{"jsonp.diff":{"filename":"jsonp.diff","type":"text/plain","language":"Diff","raw_url":"https://gist.githubusercontent.com/mbostock/558596/raw/73af42b39f67b7cf783045f3429b83cc1672af32/jsonp.diff","size":1624,"truncated":false,"content":"diff --git a/src/Queue.js b/src/Queue.js\nindex d243c13..616dbc6 100644\n--- a/src/Queue.js\n+++ b/src/Queue.js\n@@ -99,5 +99,41 @@ po.queue = (function() {\n     return {abort: abort};\n   }\n \n-  return {text: text, xml: xml, json: json, image: image};\n+  function jsonp(src, callback) {\n+    var script, head, callbackId = \"p01YmAp5\" + po.id();\n+\n+    function send() {\n+      window[callbackId] = callback;\n+      script = document.createElement(\"script\");\n+      script.setAttribute(\"type\", \"text/javascript\");\n+      script.setAttribute(\"src\", src.replace(/{C}/g, callbackId));\n+      script.addEventListener(\"load\", cleanup, false);\n+      (head = document.head).appendChild(script);\n+    }\n+\n+    function abort(hard) {\n+      if (dequeue(send)) return true;\n+      if (hard && script) { head.removeChild(script); return true; }\n+      return false;\n+    }\n+\n+    function cleanup() {\n+      active--;\n+      head.removeChild(script);\n+      delete window[callbackId];\n+      process();\n+    }\n+\n+    queued.push(send);\n+    process();\n+    return {about: abort};\n+  }\n+\n+  return {\n+    text: text,\n+    xml: xml,\n+    json: json,\n+    jsonp: jsonp,\n+    image: image\n+  };\n })();\ndiff --git a/src/Url.js b/src/Url.js\nindex b4798f6..f786769 100644\n--- a/src/Url.js\n+++ b/src/Url.js\n@@ -8,6 +8,7 @@ po.url = function(template) {\n     return template.replace(/{(.)}/g, function(s, v) {\n       switch (v) {\n         case \"S\": return hosts[(Math.abs(c.zoom) + c.row + column) % hosts.length];\n+        case \"C\": return \"{C}\";\n         case \"Z\": return c.zoom;\n         case \"X\": return column;\n         case \"Y\": return c.row;","encoding":"utf-8"}},"public":true,"created_at":"2010-08-31T05:32:39Z","updated_at":"2015-09-05T22:24:42Z","description":"Polymaps / JSONP Queue","comments":1,"user":null,"comments_enabled":true,"comments_url":"https://api.github.com/gists/558596/comments","owner":{"login":"mbostock","id":230541,"node_id":"MDQ6VXNlcjIzMDU0MQ==","avatar_url":"https://avatars.githubusercontent.com/u/230541?v=4","gravatar_id":"","url":"https://api.github.com/users/mbostock","html_url":"https://github.com/mbostock","followers_url":"https://api.github.com/users/mbostock/followers","following_url":"https://api.github.com/users/mbostock/following{/other_user}","gists_url":"https://api.github.com/users/mbostock/gists{/gist_id}","starred_url":"https://api.github.com/users/mbostock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbostock/subscriptions","organizations_url":"https://api.github.com/users/mbostock/orgs","repos_url":"https://api.github.com/users/mbostock/repos","events_url":"https://api.github.com/users/mbostock/events{/privacy}","received_events_url":"https://api.github.com/users/mbostock/received_events","type":"User","user_view_type":"public","site_admin":false},"forks":[],"history":[{"user":null,"version":"faaddc4ce3a7825affcbe83b4a4a3d3bb5106855","committed_at":"2010-08-31T05:32:39Z","change_status":{"total":59,"additions":59,"deletions":0},"url":"https://api.github.com/gists/558596/faaddc4ce3a7825affcbe83b4a4a3d3bb5106855"}],"truncated":false}