Subversion Repositories wimsdev

Rev

Rev 2388 | Rev 5316 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1. !!hotspot questions  var1 = xmin,xmax,ymin,ymax in coordinatesystem of the graph.
  2. !! without ISMAP
  3.  
  4. !set xmin=!item 1 of $var1
  5. !set xmax=!item 2 of $var1
  6. !set ymin=!item 3 of $var1
  7. !set ymax=!item 4 of $var1
  8. <div id="mouse_coords" style="opacity:0.6;filter:alpha(opacity=60);position:absolute;z-index:100;display:block;background-color:lightgreen;top:0px;left:0px;font-size:16px;border:1px solid #ff0000"></div>
  9. <div id="mouse_dot_ie" style="position:absolute;z-index:100;display:none;background-color:red;top:0px;left:0px;width:4px;min-height:4px;max-height:4px;height:auto!important;height:4px;"><table summary="" bgcolor="red" width="4" height="4"><tr><th></th></tr></table></div>
  10. <div id="mouse_dot_w3c" style="position:absolute;z-index:100;display:none;background-color:red;top:0px;left:0px;width:6px;height:6px;"></div>
  11.  
  12. !set n=$counter
  13. <p align="center">
  14.     <table summary="" bgcolor="$bgcolor1" cellpadding="$cellpadding" cellspacing="$cellspacing">
  15.         <tr>
  16.         <td>
  17.         !if $(question$n) != $empty
  18.             $(question$n)
  19.             <br>
  20.         !endif
  21.         !if $(formula$n) != $empty
  22.             !insmath $(formula$n)
  23.             <br>
  24.         !endif
  25.         !if $exotext != $empty
  26.             $exotext
  27.         !endif
  28.         </td>
  29.         !if $XSIZE>640
  30.             </tr><tr>
  31.         !endif
  32.         <td>
  33.         !if $draw=1
  34.             !! for fly
  35.             !set insdraw_size=$xsize,$ysize
  36.             !set ins_attr= id="myimage"
  37.             <div id="mydiv">
  38.                 !insdraw $(image$n)
  39.             </div>
  40.         !endif
  41.         !if $plot=1
  42.             !! for GNUplot
  43.             !set ins_attr= id="myimage"
  44.             !set insplot_set=$(image_settings$n)
  45.             <div id="mydiv">
  46.                 !insplot $(image$n)
  47.             </div>
  48.         !endif
  49.         </td>
  50.         </tr>
  51.     </table>
  52.     <table summary="">
  53.         <tr>
  54.         <th>
  55.             <input type=button style="$mybuttonstyle" onclick="sendanswer();" value="$send">
  56.         </th>
  57.         <th>
  58.             <input type=button style="$mybuttonstyle" onclick="dontknow();" name="but2" value="$dontknow">
  59.         </th>
  60.         </tr>
  61.     </table>
  62. </p>
  63.  
  64. <script type="text/javascript">
  65.     var URL;
  66.     function dontknow(){
  67.         var t=confirm(r0+"\n$dontknow ?");
  68.         if(t==true){
  69.             URL = '$wims_ref_name?session=$session&+module=$module&+cmd=reply&+reply$n=%3F' ;
  70.             document.location.href = URL;
  71.         }
  72.     }
  73.    
  74.     function sendanswer(){
  75.         t=confirm(r0+"\n ("+relx+":"+rely+")");
  76.         if(t==true){
  77.             reply=relx+","+rely;
  78.             reply = encodeURIComponent(reply)
  79.             URL = '$wims_ref_name?session=$session&+module=$module&+cmd=reply&+reply$n='+reply ;
  80.             document.location.href = URL;
  81.         }
  82.     }
  83.     !! wims variables
  84.     var sizex=$xsize;
  85.     var sizey=$xsize;
  86.     var xmin=$xmin,xmax=$xmax,ymin=$ymin,ymax=$ymax;
  87.     var rounding=$rounding
  88.     var relx=0;
  89.     var rely=0;
  90.     var IE=false;
  91.  
  92.     function showit(){
  93.         recalculate(event.x,event.y);
  94.     }    
  95.     function showitMOZ(e){
  96.         recalculate(e.pageX,e.pageY);
  97.         e.stopPropagation();   
  98.     }    
  99.     if (!document.all){
  100.         window.captureEvents(Event.CLICK);
  101.         document.getElementById('myimage').onclick=showitMOZ;
  102.         //document.onclick=showitMOZ;
  103.     }
  104.     else
  105.     {
  106.         IE=true;
  107.         document.getElementById('myimage').onclick=showit;
  108.         //document.onclick=showit;
  109.     }
  110.    
  111.     function recalculate(x,y){
  112.         var xi = findPosX('myimage');
  113.         var yi = findPosY('myimage');
  114.         if(IE){xi=xi-document.body.scrollLeft ;yi=yi-document.body.scrollTop ;}
  115.         if(x > xi && x < xi+sizex && y > yi && y < yi+sizey){
  116.             xi=x - xi;yi=y - yi;
  117.             relx=px2x(xi);rely=px2y(yi);
  118.             relx=(Math.round(rounding*relx))/rounding;
  119.             rely=(Math.round(rounding*rely))/rounding;
  120.            
  121.             if(IE){
  122.             // Horrible...please avoid Internet Explorer and use a W3C compliant browser...
  123.             // Serious issues with mouse coordinate system...moving with scollX/scrollY...windowposition...problems with "div height"
  124.             // I've spent 90% of my time for this module trying to get it working on WinXP...hacking around these issues :(
  125.             // And I've only tested it on IE6...
  126.             // Other WinXP browsers Opera 10 / Firefox / Safari / Google Chrome work fine !!
  127.            
  128.                 document.getElementById('mouse_coords').style.top = y+6+document.body.scrollTop;
  129.                 document.getElementById('mouse_coords').style.left = x+6+document.body.scrollLeft;
  130.                 document.getElementById('mouse_dot_ie').style.top = y-4+document.body.scrollTop;
  131.                 document.getElementById('mouse_dot_ie').style.left = x-4+document.body.scrollLeft;          
  132.                 document.getElementById('mouse_dot_ie').style.display = "block"
  133.             }else{
  134.                 document.getElementById('mouse_coords').style.top = y+6;
  135.                 document.getElementById('mouse_coords').style.left = x+6;          
  136.                 document.getElementById('mouse_dot_w3c').style.top = y-3;
  137.                 document.getElementById('mouse_dot_w3c').style.left = x-3;          
  138.                 document.getElementById('mouse_dot_w3c').style.display = "block"
  139.             }
  140.             document.getElementById('mouse_coords').innerHTML='<b>('+relx+':'+rely+')</b>';
  141.         }
  142.     }
  143.    
  144.     function findPosX(i){
  145.         obj = document.getElementById(i);
  146.         var curleft = 0;
  147.         if(obj.offsetParent){
  148.             while(1){
  149.                 curleft += obj.offsetLeft;
  150.                 if(!obj.offsetParent){break;}
  151.                 obj = obj.offsetParent;
  152.             }
  153.         }
  154.         else
  155.         {
  156.             if(obj.x){
  157.                 curleft += obj.x;
  158.             }
  159.         }
  160.         return curleft;
  161.     }
  162.  
  163.     function findPosY(i){
  164.         obj = document.getElementById(i);
  165.         var curtop = 0;
  166.         if(obj.offsetParent){
  167.             while(1){
  168.                 curtop += obj.offsetTop;
  169.                 if(!obj.offsetParent){break;}
  170.                 obj = obj.offsetParent;
  171.             }
  172.         }
  173.         else
  174.         {
  175.             if(obj.y){
  176.                 curleft += obj.y;
  177.             }
  178.         }
  179.         return curtop;
  180.     }
  181.    
  182.     function px2x(px){ //pixel to x-coords                                                                                        
  183.         var X = eval(px*(xmax - xmin)/sizex + xmin);                                                                                        
  184.         return X;                                                                                                                          
  185.     }
  186.    
  187.     function px2y(py){ // pixel to y-coords                                                                                      
  188.         Y = eval(ymax -  py*(ymax - ymin)/sizey);                                                                                          
  189.         return Y;                                                                                                                          
  190.     }
  191. </script>
  192.