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/main.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'src/main.js') diff --git a/src/main.js b/src/main.js index 67213056..b55a3a3d 100644 --- a/src/main.js +++ b/src/main.js @@ -1,5 +1,12 @@ -define(['textanalysis.ui', 'buttons', 'history', 'drag_n_drop', 'robot'], -function(textanalysis_ui, buttons, history, drag_n_drop, robot) { +define(['jquery', 'textanalysis.ui', 'buttons', 'history', 'drag_n_drop', 'robot', 'rz_core'], +function($, textanalysis_ui, buttons, history, drag_n_drop, robot, rz_core) { + + function getParameterByName(name) { + name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); + var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), + results = regex.exec(location.search); + return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " ")); + } function expand(obj){ if (!obj.savesize) { @@ -9,6 +16,8 @@ function(textanalysis_ui, buttons, history, drag_n_drop, robot) { } this.main = function() { + var json; + console.log('Rhizi main started'); drag_n_drop.init(); $('#editname').onkeyup = function() { expand(this); }; @@ -16,6 +25,11 @@ function(textanalysis_ui, buttons, history, drag_n_drop, robot) { $('#textanalyser').onkeyup = function() { expand(this); }; textanalysis_ui.main(); + // TODO: jquery BBQ: $.deparam.querystring().json; + json = getParameterByName('json'); + if (json) { + rz_core.load_from_json(json); + } } return { -- cgit v1.3.1