Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $('#searchString').keyup(function(){
  2.         console.log('instant: ',instant);
  3.         //instant on content not replaced
  4.         if(instant && !replaced){
  5.             if($(this).val().length >= 3){
  6.                 log('length: >=3');
  7.                 replaced = true;
  8.                 oldc = $('#mainContent').html();
  9.                 $('#mainContent').fadeOut('fast', function(){
  10.                     $('#mainContent').html(loader);
  11.                     chrome.extension.sendRequest({
  12.                         'action' : 'searchGeneral',
  13.                         'search' : $('#searchString').val(),
  14.                         'type' : $('#searchType').val()
  15.                     }, showResult);
  16.  
  17.                 });
  18.             }
  19.         }
  20.         //instant on and content replaced
  21.         else if(instant && replaced){
  22.             log('instant: true - replaced: true');
  23.             if($(this).val().length >= 3){
  24.                 log('length; >= 3');
  25.                 $('#mainContent').fadeOut('fast', function(){
  26.                     $('#mainContent').html(loader)
  27.                     chrome.extension.sendRequest({
  28.                         'action' : 'searchGeneral',
  29.                         'search' : $('#searchString').val(),
  30.                         'type' : $('#searchType').val()
  31.                     }, showResult);
  32.                 });
  33.             }
  34.             else if($(this).val() == ''){
  35.                 log('length: == 0')
  36.                 $('#mainContent').fadeOut('fast', function(){
  37.                     $('#mainContent').html(oldc)
  38.                 });
  39.                 replaced = false;
  40.             }
  41.         }
  42.     });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement