Use as script engine

Sep 16, 2010 at 3:07 AM
Edited Sep 16, 2010 at 3:07 AM

Hello,

I am working on an SVG viewer, and will like to support the embedded JavaScript.

A sample script is...

 

<g id="test-body-content">
	<defs>
		<script type="text/ecmascript"><![CDATA[
       
       function bubbleYes(evt, color){
         // Get Document
         var target = evt.target;
         target.setAttribute('fill', '' +color);
       }
       function bubbleNo(evt, color){
         // Get Document
         var target = evt.target;
         target.setAttribute('fill', '' +color); 
         evt.stopPropagation();
         evt.preventDefault();
       }
   
     ]]></script>
	</defs>
	<g fill="#000" font-family="Arial" font-size="40">
		<!-- Test the order of events -->
		<!-- Ensure that events get the event before the hyperlink. -->
		<a xlink:href="../images/interact-order-02-b-targ.svg">
			<circle onclick="bubbleNo(evt, 'red')" onmouseout="bubbleNo(evt, 'inherit')" cx="70" cy="120" r="50"/>
			<circle onclick="bubbleYes(evt, 'blue')" onmouseout="bubbleNo(evt, 'inherit')" cx="70" cy="240" r="50"/>
		</a>
	</g>
</g>

 

The DOM of the rendering engine is based on XmlDocument/XmlNode, so instead of the setAttribute in the script, we now have XmlNode.SetAttribute.
Is it still possible to use the Jint? If not what is needed to be done?

Best regards,
Paul.