From 52b5bf3360e036ea37ad73dbfb219aab9b268404 Mon Sep 17 00:00:00 2001 From: techninja Date: Sat, 25 Oct 2014 01:13:08 -0700 Subject: [PATCH] Add SVG "save" interface for shared SVG ..and make it less picky about available libs --- resources/scripts/robopaint.mode.svg.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/resources/scripts/robopaint.mode.svg.js b/resources/scripts/robopaint.mode.svg.js index 2dde92c..4c4272e 100644 --- a/resources/scripts/robopaint.mode.svg.js +++ b/resources/scripts/robopaint.mode.svg.js @@ -135,7 +135,7 @@ $(function() { // Handle buffer status messages robopaint.socket.on('message update', messageUpdateEvent); function messageUpdateEvent(data){ - cncserver.wcb.status(data.message); + if (cncserver.wcb) cncserver.wcb.status(data.message); } // Remove globalized listeners from this local container/window @@ -183,7 +183,7 @@ $(function() { }); robopaint.cncserver.api.pen.stat(function(d){ - cncserver.wcb.status(['Connected Successfully!'], d); + if (cncserver.wcb) cncserver.wcb.status(['Connected Successfully!'], d); cncserver.state.pen.state = 1; // Assume down robopaint.cncserver.api.pen.up(); // Send to put up cncserver.state.pen.state = 0; // Assume it's up (doesn't return til later) @@ -235,6 +235,11 @@ $(function() { } } + // Public function to save SVG to the global localStorage area + cncserver.canvas.saveSVG = function(svgText) { + window.localStorage.setItem('svgedit-default', svgText); + }; + }); // Triggered on before close or switch mode, call callback to complete operation