am_dot_com

SW 2022-04-08 JS

Apr 8th, 2022 (edited)
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. window.onload=boot;
  2.  
  3. const GOOGLE_SEARCH_BASE = "https://www.google.com/search?"
  4.  
  5. const ID_QUERY="idQuery";
  6. const ID_QUANTITY="idQuantity";
  7. const ID_REJECT="idReject";
  8. const ID_FORM_SEARCH="idFormSearch";
  9. const ID_RECENCY="idSelectRecency"
  10. var oQuery, oQuantity, oFormSearch, oReject;
  11. var oSelectRecency;
  12.  
  13. function boot(){
  14. //1 - assocs
  15. oQuery=id(ID_QUERY);
  16. oQuantity=id(ID_QUANTITY);
  17. oFormSearch=id(ID_FORM_SEARCH);
  18. oReject=id(ID_REJECT);
  19. oSelectRecency=id(ID_RECENCY);
  20.  
  21. //2 - behaviors
  22. oFormSearch.onsubmit=ehGoSearch;
  23. }//boot
  24.  
  25. function ehGoSearch(){
  26. var strQueryString = ""
  27. var strQuery=encodeURIComponent(
  28. oQuery.value.trim()
  29. );
  30. var strQuantity=encodeURIComponent(
  31. oQuantity.value.trim()
  32. )
  33. var strReject=encodeURIComponent(
  34. oReject.value.trim()
  35. )
  36. var strRecency=encodeURIComponent(
  37. oSelectRecency.value.trim()
  38. )
  39.  
  40. //1 - q - the query
  41. strQueryString="q="+strQuery;
  42.  
  43. //2 - num - the quantity
  44. strQueryString+="&num="+strQuantity;
  45.  
  46. //3 - as_eq - to reject
  47. if(strReject!=""){
  48. strQueryString+="&as_eq="+strReject;
  49. }
  50.  
  51. //4 - as_qdr - the indexing recency
  52. if(strRecency!=""){
  53. strQueryString+="&as_qdr="+strRecency;
  54. }
  55.  
  56. var strURL = GOOGLE_SEARCH_BASE
  57. +strQueryString;
  58.  
  59. //document.write(strURL);
  60. window.document.location.href=strURL;
  61.  
  62. return false;//false more things to do
  63. }//boot
Add Comment
Please, Sign In to add comment