Subversion Repositories wimsdev

Rev

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

  1. #!/bin/sh
  2. # do not run compile time !
  3. # just to generate simple canvasdraw usage html-page
  4.  
  5.  
  6. helpdir="../../../public_html/scripts/help/en"
  7. in="canvasdraw.c"
  8. phtml="canvasdraw.phtml"
  9. html="canvasdraw.html"
  10. tmp="canvas_index"
  11. keys="keywords"
  12. datum=`date +%d-%m-%Y`
  13.  
  14. echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1 plus MathML 2.0//EN\" \"http://www.w3.org/Math/DTD/mathml2/xhtml-math11-f.dtd\">
  15. <html>
  16. <head><meta charset=\"UTF-8\"></head>
  17. <body xmlns=\"http://www.w3.org/1999/xhtml\" class=\"main_body\" dir=\"ltr\">
  18. <style type='text/css'>
  19. a:link {color:#004077;text-decoration:none;cursor:pointer;}
  20. a:hover {color:#dd6300;}
  21. a:visited {color:#004077;}
  22. </style>"> $html
  23.  
  24. echo "
  25. <input type='text' size='10' value='' id='search'  onkeydown='javascripts:if(event.keyCode == 13){look();}'/><input type='button' onclick='javascript:look();' value='search' />
  26. <h3 style="text-align:center">Implemented canvasdraw commands ($datum)</h3>
  27. <table style='color:blue;font-size:0.8em;'><tr>
  28. " > $phtml
  29.  
  30. p=0
  31. echo "<ul>" > $tmp
  32. cnt=0
  33. br=8
  34. while read line ; do
  35.  chk=`echo $line | grep "@"`
  36.  if [ ! -z "$chk" ] ; then
  37.   echo $line
  38.   if [ $p -eq 0 ]; then
  39.    string=`echo $line | tr '@' ' '`
  40.    idx=`echo $string | awk '{ print $1 }'`
  41.    echo ",'$idx'" >> $keys
  42.    if [ $cnt -gt $br ]; then
  43.     echo "</tr><tr>" >> $phtml
  44.     cnt=0
  45.    fi
  46.    cnt=$(($cnt+1))
  47.    echo "<td><a name='$idx top' href='#$idx'>$idx</a></td>" >> $phtml
  48.    echo "<li><a name='$idx' href='#$idx top'>$string</a><ul>"  >> $tmp
  49.    p=1
  50.   else
  51.    p=2
  52.    alt=`echo $line | grep "@ alternative :" | awk '{ print $4 }' | tr -d '[:blank:]'`
  53.    if [ ! -z $alt ] ; then
  54.     if [ $cnt -gt $br ]; then
  55.      echo "</tr><tr>" >> $phtml
  56.      cnt=0
  57.     fi
  58.     cnt=$(($cnt+1))
  59.     echo ",'$alt'" >> $keys
  60.     echo "<td><a name='$alt top' href='#$idx'>$alt</a></td>" >> $phtml
  61.     echo "<li><span style=\"color:blue;font-size:0.8em\">alternative command:<a name='$alt' href='#$alt top'>$alt</a></span></li>"  >> $tmp
  62.    else
  63.     echo $line | sed 's/@/<li><span style="color:blue;font-size:0.8em">/g'  >> $tmp
  64.     echo  "</span></li>" >> $tmp
  65.    fi
  66.   fi
  67.  else
  68.   if [ $p -eq 2 ]; then
  69.    echo  "</ul>" >> $tmp
  70.   fi
  71.   p=0
  72.  fi
  73. done < $in
  74.  
  75. while [ $cnt -le $br ] ; do
  76.  cnt=$(($cnt+1))
  77.  echo "<td>&nbsp;</td>" >> $phtml
  78. done
  79. echo "</tr></table>" >> $phtml
  80.  
  81. cat $tmp >> $phtml
  82.  
  83. keywords=`cat $keys | tr -d '\n'`
  84. echo "
  85. </li>
  86. </ul>
  87. <script type='text/javascript'>
  88. var keys = ['canvasdraw' $keywords];
  89. var keys_len = keys.length;
  90. function match(s1,s2){
  91.  var n1 = s1.length;
  92.  if(n1 < 3){return 0;}
  93.  var n2 = s2.length;
  94.  var c1,c2,found;
  95.  var count = n1 - Math.abs(n1 - n2);
  96.  for(var p = 0;p < n1;p++){
  97.   c1=s1.charAt(p);
  98.   found = false;
  99.   for(var i = 0;i < n2;i++){
  100.    c2 = s2.charAt(i);
  101.    if(c1 == c2){found = true;count = count + n1 - Math.abs(p - i);}
  102.   };
  103.   if(! found ){count = count - n2;}
  104.  };
  105.  return count;
  106. };
  107. function look(){
  108.  var s = ((document.getElementById('search').value).replace(/\s/g, '')).toLowerCase();
  109.  var typo;var next_best = -1;var next_idx = s.length;var tmp;var ss;
  110.  for(var p = 0; p < keys_len ; p++){
  111.   ss = keys[p];
  112.   if( s == ss ){
  113.    window.location.href = '#'+ss;
  114.    return;
  115.   };
  116.   /* not ok? ... try to find a match for a reasonable typo... */
  117.   tmp = match(s,ss);
  118.   if(tmp > next_idx){
  119.    next_idx = tmp;
  120.    next_best = p;
  121.   };
  122.  };
  123.  if(next_best != -1 ){
  124.   typo = keys[next_best];
  125.   if(confirm('\"'+s+'\" is not a valid canvasdraw command\ndid you mean \"'+typo+'\" ?')){
  126.    window.location.href = '#'+typo;
  127.    return;
  128.   };
  129.  }
  130.  else
  131.  {
  132.   alert(s+' is not a valid canvasdraw command');
  133.  };
  134.  return;
  135. };
  136. </script>" >> $phtml
  137.  
  138. cat $phtml >> $html
  139. echo "
  140. </body>
  141. </html>" >> $html
  142. mv $phtml $helpdir
  143. rm $tmp
  144. rm $keys
  145.  
  146.