diff --git a/js/Svg.js b/js/Svg.js
index 87e065b..d61ce96 100644
--- a/js/Svg.js
+++ b/js/Svg.js
@@ -9,132 +9,132 @@
//SVG validator: http://validator.w3.org/
//SVG viewer: http://svg-edit.googlecode.com/svn/branches/2.6/editor/svg-editor.html
function saveToSvg() {
- var lastX = 0, lastY = 0, lastIsMove;
- var svg = '';
+ var lastX = 0, lastY = 0, lastIsMove = false;
+ var svg = '';
- var boundsWidth = doodleBounds[2] - doodleBounds[0];
- var boundsHeight = doodleBounds[3] - doodleBounds[1];
+ var boundsWidth = doodleBounds[2] - doodleBounds[0];
+ var boundsHeight = doodleBounds[3] - doodleBounds[1];
- svg += '\n';
- svg += '\n';
- svg += '\n';
- return svg;
+ return svg;
}
//TODO: use local variables instead of _points,numLayers,VERTICALSHAPE and rStep so we can leave a current doodle in tact if an error occurs while parsing
function loadFromSvg(svgData) {
- var mode = '', x = 0, y = 0;
+ var mode = '', x = 0, y = 0;
- console.log("loading " + svgData.length + " bytes of data...");
+ console.log("loading " + svgData.length + " bytes of data...");
- clearDoodle();
+ clearDoodle();
- var p = svgData.indexOf("-->", p);
- if (endP == -1) { console.log("loadFromSvg: could not find metadata end-marker"); return false; }
- var metaFields = JSON.parse(svgData.substr(p, endP - p));
- //TODO: log error and return false if parsing failed
- for (var k in metaFields) {
- var v = metaFields[k];
- switch (k) {
- case "height": numLayers = v; break;
- case "outlineShape": VERTICALSHAPE = v; break;
- case "twist": rStep = v; break;
- }
- }
+ var endP = svgData.indexOf("]]>-->", p);
+ if (endP == -1) { console.log("loadFromSvg: could not find metadata end-marker"); return false; }
+ var metaFields = JSON.parse(svgData.substr(p, endP - p));
+ //TODO: log error and return false if parsing failed
+ for (var k in metaFields) {
+ var v = metaFields[k];
+ switch (k) {
+ case "height": numLayers = v; break;
+ case "outlineShape": VERTICALSHAPE = v; break;
+ case "twist": rStep = v; break;
+ }
+ }
- renderToImageDataPreview();
+ renderToImageDataPreview();
- return true;
+ return true;
}