- 
      
- 
        Save jsimpson/b42a5bdbdd270b903e03 to your computer and use it in GitHub Desktop. 
    hn job query search
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function query() { | |
| var | |
| total = 0, shown = 0, | |
| job_list = Array.prototype.slice.call(document.querySelectorAll('.c00')), | |
| query_list = Array.prototype.slice.call(arguments); | |
| // turn them all off | |
| job_list.forEach(function(node) { | |
| node.parentNode.parentNode.parentNode.style.display = 'none'; | |
| total ++; | |
| }); | |
| query_list.forEach(function(query) { | |
| if (query.forEach) { | |
| var and_query_list = query.map(function(what) { return what.toLowerCase(); }); | |
| job_list.forEach(function(node) { | |
| var doesMatch = true, toTest = node.innerHTML.toLowerCase(); | |
| and_query_list.forEach(function(query) { | |
| doesMatch &= (toTest.search(query) > -1); | |
| }) | |
| if(doesMatch) { | |
| node.parentNode.parentNode.parentNode.style.display = 'block'; | |
| shown ++; | |
| } | |
| }); | |
| } else { | |
| query = query.toLowerCase(); | |
| job_list.forEach(function(node) { | |
| if(node.innerHTML.toLowerCase().search(query) !== -1) { | |
| node.parentNode.parentNode.parentNode.style.display = 'block'; | |
| shown ++; | |
| } | |
| }); | |
| } | |
| }); | |
| return {shown: shown, total: total} | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment