Guest User

editorMarket.js

a guest
Dec 16th, 2013
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
jQuery 1.82 KB | None | 0 0
  1. var refresherID = 0;
  2. var currentID = 0;
  3.  
  4. $(document).ready(function(){
  5.  
  6.   $('.start-button').click(function(){
  7.  
  8.     oldGroupedHTML = null;
  9.     oldIndividualHTML = null;
  10.  
  11.     chrome.tabs.getSelected(null, function(tab){
  12.         currentID = tab.id;
  13.     });
  14.  
  15.     refresherID = setInterval(function(){
  16.         //
  17.         //I'd like to grab the DOM right here and save it as a variable.
  18.         //fullDOM = whateverIsNecessaryToGrabDOM(...);
  19.         //
  20.         //and the following lines would clearly change because of this.
  21.         //
  22.        
  23.         currentGroupedHTML = $(".grouped_jobs").html();
  24.         currentIndividualHTML = $(".individual_jobs").html();
  25.         comparator(currentGroupedHTML,currentIndividualHTML);
  26.         chrome.tabs.reload(currentID);
  27.     }, 4000);
  28.  
  29.   });
  30.  
  31.   $('.stop-button').click(function(){
  32.     clearInterval(refresherID);
  33.   });
  34.  
  35. });
  36.  
  37. function comparator(grouped, individual){
  38.        
  39.     IndyJobs = getNumberOfIndividualJobs();
  40.     GroupJobs = getNumberOfGroupedJobs();
  41.  
  42.     nIndyJobs = IndyJobs[1];
  43.     nGroupJobs = GroupJobs[1];
  44.     console.log(GroupJobs);
  45.  
  46.     $(".lt").text("Indy: " + nIndyJobs + "; Grouped: " + nGroupJobs);
  47.  
  48. }
  49.  
  50. function getNumberOfIndividualJobs(){
  51.     obviousCount = $(".individual_jobs").find("tbody").children().length;
  52.  
  53.     extraFullPages = 0;
  54.     //next line needs to be checked sometime
  55.     extraFullPages = $(".individual_jobs").find(".pagination.individual").children().length-4;
  56.  
  57.     if (extraFullPages < 1){
  58.         return ["exact", obviousCount];
  59.     }
  60.     else{
  61.         return ["estimate", obviousCount + extraFullPages*5 + 1];
  62.     }
  63. }
  64.  
  65. function getNumberOfGroupedJobs(){
  66.     obviousCount = $(".grouped_jobs").find("tbody").children().length;
  67.  
  68.     extraFullPages = $(".grouped_jobs").find(".pagination.group").children().length-4
  69.  
  70.     if (extraFullPages < 1){
  71.         return ["exact", obviousCount];
  72.     }
  73.     else{
  74.         return ["estimate", obviousCount + extraFullPages*5 + 1];
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment