summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--index.html7
-rw-r--r--src/buttons.js7
-rw-r--r--src/main.js18
3 files changed, 30 insertions, 2 deletions
diff --git a/index.html b/index.html
index d2978099..170a94d7 100644
--- a/index.html
+++ b/index.html
@@ -91,11 +91,18 @@
</div>
</div>
</div>
+ <div class="debug-ui-row">
<div class="debug-ui-left">
<div class="local-storage-load">
<a href="#">Load</a>
</div>
</div>
+ <div class="debug-ui-right">
+ <div class="url-copy">
+ <a href="#">Copy to URL</a>
+ </div>
+ </div>
+ </div>
<div class="debug-ui-row">
<form>
Import <input type="file" class="file-import" />
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?');
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 {