Guest User

Untitled

a guest
May 23rd, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. $(document).ready(function(){
  2. $('#searchMe').keyup(function(){
  3.  
  4. lookup(this.value);
  5.  
  6. });
  7. });
  8.  
  9. function lookup(searchinput) {
  10.  
  11.  
  12.  
  13. if(searchinput.length == 0) {
  14. // Hide the suggestion box.
  15. $("#suggestions").hide();
  16. } else {
  17.  
  18. $('#loading').fadeIn();
  19.  
  20.  
  21. $.post("/RPCsearch.php", {queryString: ""+searchinput+""}, function(data){
  22. if(data.length > 0) {
  23. $("#suggestions").html(data).show();
  24. $('#loading').fadeOut();
  25. }
  26. });
  27. }
  28. } // lookup
  29.  
  30. $(function() {
  31. var timer;
  32. $("#searchMe").keyup(function() {
  33. clearTimeout(timer);
  34. var ms = 200; // milliseconds
  35. var val = this.value;
  36. timer = setTimeout(function() {
  37. lookup(val);
  38. }, ms);
  39. });
  40. });
  41.  
  42. OnKeyPress()
  43. txt = getTxt
  44. sleep(200)
  45. newTxt = getTxt
  46. if (txt == newTxt) // nothing has been typed so do something
  47. run my thing
  48.  
  49. var delay = 200;
  50. var search_timer = null;
  51. $("#searchMe").keydown(function(e) {
  52. if(search_timer) {
  53. clearTimeout(search_timer);
  54. }
  55. search_timer = setTimeout(lookup, delay);
  56. });
  57. $("#searchMe").keypress(function(e) {
  58. if(search_timer) {
  59. clearTimeout(search_timer);
  60. }
  61. search_timer = setTimeout(lookup, delay);
  62. });
  63. $("#searchMe").keyup(function(e) {
  64. if(search_timer) {
  65. clearTimeout(search_timer);
  66. }
  67. search_timer = setTimeout(lookup, delay);
  68. });
  69.  
  70. $(document).ready(function(){
  71.  
  72. $("#searchMe").keyup(function () {
  73.  
  74. try{window.clearTimeout(timeoutID);}catch(e){}
  75. timeoutID = window.setTimeout(run, 2000); //delay
  76.  
  77. function run()
  78. { //dowhatev
  79. var text = $("#searchMe").val();
  80. //$("#showit").html(text);
  81. }
  82. });
  83. });
Add Comment
Please, Sign In to add comment