rewritten for IE8, MKWS-309
authorWolfram Schneider <wosch@indexdata.dk>
Fri, 24 Oct 2014 12:11:51 +0000 (12:11 +0000)
committerWolfram Schneider <wosch@indexdata.dk>
Fri, 24 Oct 2014 12:11:51 +0000 (12:11 +0000)
examples/htdocs/dict.html

index c63f983..efcd608 100644 (file)
        <p>Conventionally, a computer consists of at least one processing element, typically a <a href="http://en.wikipedia.org/wiki/Central_processing_unit" title="Central processing unit">central processing unit</a> (CPU) and some form of <a href="http://en.wikipedia.org/wiki/Memory_(computers)" title="Memory (computers)" class="mw-redirect">memory</a>. The processing element carries out arithmetic and logic operations, and a sequencing and control unit that can change the order of operations based on stored information. Peripheral devices allow information to be retrieved from an external source, and the result of operations saved and retrieved.</p>\r
        <p>In <a href="http://en.wikipedia.org/wiki/World_War_II" title="World War II">World War II</a>, <a href="http://en.wikipedia.org/wiki/Mechanical_computer" title="Mechanical computer">mechanical</a> <a href="http://en.wikipedia.org/wiki/Analog_computers" title="Analog computers" class="mw-redirect">analog computers</a> were used for specialized military applications. During this time the first electronic <a href="http://en.wikipedia.org/wiki/Digital_data" title="Digital data">digital</a> computers were developed. Originally they were the size of a large room, consuming as much power as several hundred modern <a href="http://en.wikipedia.org/wiki/Personal_computer" title="Personal computer">personal computers</a> (PCs).<sup id="cite_ref-1" class="reference"><a href="http://en.wikipedia.org/wiki/Computer#cite_note-1"><span>[</span>1<span>]</span></a></sup></p>\r
        <p>Modern computers based on <a href="http://en.wikipedia.org/wiki/Integrated_circuit" title="Integrated circuit">integrated circuits</a> are millions to billions of times more capable than the early machines, and occupy a fraction of the space.<sup id="cite_ref-2" class="reference"><a href="http://en.wikipedia.org/wiki/Computer#cite_note-2"><span>[</span>2<span>]</span></a></sup> Simple computers are small enough to fit into <a href="http://en.wikipedia.org/wiki/Mobile_device" title="Mobile device">mobile devices</a>, and <a href="http://en.wikipedia.org/wiki/Mobile_computing" title="Mobile computing">mobile computers</a> can be powered by small <a href="http://en.wikipedia.org/wiki/Battery_(electricity)" title="Battery (electricity)">batteries</a>. Personal computers in their various forms are <a href="http://en.wikipedia.org/wiki/Icon" title="Icon">icons</a> of the <a href="http://en.wikipedia.org/wiki/Information_Age" title="Information Age">Information Age</a> and are what most people think of as “computers.” However, the <a href="http://en.wikipedia.org/wiki/Embedded_system" title="Embedded system">embedded computers</a> found in many devices from <a href="http://en.wikipedia.org/wiki/Digital_audio_player" title="Digital audio player" class="mw-redirect">MP3 players</a> to <a href="http://en.wikipedia.org/wiki/Fighter_aircraft" title="Fighter aircraft">fighter aircraft</a> and from toys to <a href="http://en.wikipedia.org/wiki/Industrial_robot" title="Industrial robot">industrial robots</a> are the most numerous.</p>\r
+       </div>\r
       </td>\r
       <td width="40%" align="top">\r
        <div class="mkws-search"></div>\r
        <div class="mkws-reference"></div>\r
+       <div class="search-query"></div>\r
       </td>\r
     </tr>\r
   </table>\r
-    <script type="text/javascript">\r
-      $(".mkws-search").hide();\r
-      $(".mkws-reference").hide();\r
 \r
-      document.onclick = clickfunc;\r
-      var selectedtext="";\r
-      var clicking = false;\r
-      function clickfunc(e) {\r
-       // may not work on older Browsers, as IE8\r
-        var sel = window.getSelection();\r
-        //console.log("click: " + sel + "  clicking=" + clicking );\r
-        if ( sel != "" && ! clicking ) {\r
-          clicking  = true;\r
-         $(".mkws-reference").show();\r
-          $("input.mkws-query").val(sel);\r
-          //console.log("click: Set value " + sel + "  clicking=" + clicking );\r
-          $("input.mkws-button").trigger("click");\r
-          clicking = false;\r
-        }\r
+  <script>\r
+    $(".mkws-search").hide();\r
+    $(".mkws-reference").hide();\r
+\r
+    if(!window.indexdata){\r
+      indexdata = {};\r
+    }\r
+\r
+    indexdata.Selector = { 'debug': false, 'clicking': false };\r
+\r
+    indexdata.Selector.getSelected = function(){\r
+      var t = '';\r
+      if(window.getSelection){\r
+       t = window.getSelection();\r
+      }else if(document.getSelection){\r
+       t = document.getSelection();\r
+      }else if(document.selection){\r
+       t = document.selection.createRange().text;\r
       }\r
-    </script>\r
+      return t;\r
+    };\r
+\r
+    indexdata.Selector.mouseup = function(){\r
+      var text = indexdata.Selector.getSelected();\r
+      if(text != ''){\r
+       if (indexdata.Selector.debug) {\r
+         alert("You selected:\n" + text);\r
+       }\r
+       indexdata.Selector.mkws(text);\r
+      }\r
+    };\r
+\r
+    indexdata.Selector.mkws = function(query) {\r
+      if ( query != "" && ! indexdata.Selector.clicking ) {\r
+       // no recursive calls\r
+       indexdata.Selector.clicking  = true;\r
+\r
+       $(".mkws-reference").show();\r
+       $("input.mkws-query").val(query);\r
+       $(".search-query").text(query);\r
+       $("input.mkws-button").trigger("click");\r
+       indexdata.Selector.clicking = false;\r
+      }\r
+    };\r
+\r
+    $(document).ready(function(){\r
+      $(document).bind("mouseup", indexdata.Selector.mouseup);\r
+    });\r
+\r
+  </script>\r
   </body>\r
 </html>\r