jinlin
2024-09-26 7ec9326ce00d08f9d957981f2edff6df26f24a28
web/public/SVGOrigin/Method-Draw-master/method-draw/embedapi.html
@@ -12,7 +12,7 @@
        function init_embed() {
            var frame = document.getElementById('svgedit');
      svgCanvas = new embedded_svg_edit(frame);
      // Hide main button, as we will be controlling new/load/save etc from the host document
      var doc;
      doc = frame.contentDocument;
@@ -20,11 +20,11 @@
      {
        doc = frame.contentWindow.document;
      }
      var mainButton = doc.getElementById('main_button');
      mainButton.style.display = 'none';
      mainButton.style.display = 'none';
        }
        function handleSvgData(data, error) {
      if (error)
      {
@@ -33,15 +33,15 @@
            else
      {
        alert('Congratulations. Your SVG string is back in the host page, do with it what you will\n\n' + data);
      }
      }
        }
        function loadSvg() {
            var svgexample = '<svg width="640" height="480" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg"><g><title>Layer 1</title><rect stroke-width="5" stroke="#000000" fill="#FF0000" id="svg_1" height="35" width="51" y="35" x="32"/><ellipse ry="15" rx="24" stroke-width="5" stroke="#000000" fill="#0000ff" id="svg_2" cy="60" cx="66"/></g></svg>';
            svgCanvas.setSvgString(svgexample);
        }
    function saveSvg() {
    function saveSvg() {
      svgCanvas.getSvgString()(handleSvgData);
    }
    </script>
@@ -51,6 +51,6 @@
    <button onclick="saveSvg();">Save data</button>
    <br/>
    <iframe src="index.html" width="900px" height="600px" id="svgedit" onload="init_embed()"></iframe>
    <iframe src="index.html" width="900px" height="600px" id="svgedit" onload="init_embed()"></iframe>
</body>
</html>