From 66f704d650ddf66b86d2add825c43bcea8d84de5 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Wed, 12 Nov 2014 09:30:05 +0200 Subject: add a copy to url button, handle the resulting url This allows us to send small graphs (up to maximal length of query string - what is that anyway?). Just press the copy button, ctrl-c, and paste to irc, and other side should click it. The real deal, issue #65, needs to actually go to the server and load the graph, which means the server needs to have a document concept. --- src/buttons.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/buttons.js') diff --git a/src/buttons.js b/src/buttons.js index 500d56fc..e5e37f52 100644 --- a/src/buttons.js +++ b/src/buttons.js @@ -20,6 +20,13 @@ $('.export a').click(function() { saveAs(blob, filename); }); +$('.url-copy a').click(function() { + var json = rz_core.graph.save_to_json(); + // TODO use jquery BBQ $.param({json: json}); + var encoded = document.location.origin + '/?json=' + encodeURIComponent(json); + window.prompt('Copy to clipboard: Ctrl-C, Enter (or Cmd-C for Mac)', encoded); +}); + var really_load = function() { if (!rz_core.graph.empty()) { return confirm('All unsaved changes will be deleted, are you sure?'); -- cgit v1.3.1