annotate CADDSuite/data/OpenBabel/svgformat.script @ 0:bac3c274238f

Migrated tool version 0.93 from old tool shed archive to new tool shed repository
author marcel
date Tue, 07 Jun 2011 16:43:30 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
1 <script type="text/ecmascript">
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
2 <![CDATA[
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
3 addEventListener('DOMMouseScroll', wheel, false);
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
4 onmousewheel = wheel;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
5 var svgEl = document.getElementById("topsvg");
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
6 var startx=0;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
7 var starty=0;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
8 function wheel(evt){
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
9 evt = evt ? evt : window.event;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
10 var normal = evt.detail ? evt.detail * -1 : evt.wheelDelta / 40;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
11 var vb = new Array(4);
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
12 var vbtext = svgEl.getAttributeNS(null,"viewBox");
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
13 vb = vbtext.split(" ");
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
14 var zoom = (normal<0)? 1.41 : 0.71;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
15 //var dwidth = parseFloat(Math.max(vb[2],vb[3])) * (1-zoom);
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
16 vb[0] = parseFloat(vb[0]) + parseFloat(vb[2])*(1-zoom) * evt.clientX/innerWidth;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
17 vb[1] = parseFloat(vb[1]) + parseFloat(vb[3])*(1-zoom) * evt.clientY/innerHeight;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
18 vb[2] = parseFloat(vb[2]) * zoom;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
19 vb[3] = parseFloat(vb[3]) * zoom;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
20 svgEl.setAttributeNS(null, "viewBox", vb.join(" "));
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
21 }
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
22 onmousedown = function(evt) {
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
23 startx = evt.clientX;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
24 starty = evt.clientY;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
25 }
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
26 onmousemove=function(evt) {
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
27 if(startx!=0 && starty!=0
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
28 && ((evt.clientX - startx)*(evt.clientX - startx)+(evt.clientY - starty)*(evt.clientY - starty)>100))
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
29 {
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
30 var vbtext = svgEl.getAttributeNS(null,"viewBox");
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
31 vb = vbtext.split(" ");
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
32 var maxwh = Math.max(parseFloat(vb[2]),parseFloat(vb[3]));
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
33 vb[0] = parseFloat(vb[0]) - (evt.clientX - startx)*maxwh/innerWidth;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
34 vb[1] = parseFloat(vb[1]) - (evt.clientY - starty)*maxwh/innerHeight;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
35 svgEl.setAttributeNS(null, "viewBox", vb.join(" "));
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
36 startx = evt.clientX;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
37 starty = evt.clientY;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
38 }
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
39 }
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
40 onmouseup=function() {
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
41 startx=0;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
42 starty=0;
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
43 }
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
44 ]]>
bac3c274238f Migrated tool version 0.93 from old tool shed archive to new tool shed repository
marcel
parents:
diff changeset
45 </script>