Advertisement
Guest User

Sales

a guest
Aug 16th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.99 KB | None | 0 0
  1. /* REPLACE YOUR QUEUE URL HERE */
  2.  
  3. var myQueue = "a[href='/agent/filters/64045648']";
  4. var generalQueue = "a[href='/agent/filters/85396808']";
  5.  
  6.  
  7. setInterval(function get_notified_new_tickets() {
  8. var notif_button = document.getElementById("notification_button");
  9. var open_cases_link, number_of_open_cases;
  10.  
  11. if (notif_button.className == "notification-button-check-queue notification-enabled") {
  12. var refresh_button = document.querySelectorAll('[data-ember-action]');
  13. var all_links = document.getElementsByTagName("a");
  14. var myqueue_checkbox = document.getElementById("myqueue_checkbox");
  15. var general_checkbox = document.getElementById("general_checkbox");
  16.  
  17. for (i=0 ; i < refresh_button.length ; i++) {
  18. if (refresh_button[i].className == "action_button") {
  19. refresh_button[i].click();
  20. }
  21. }
  22.  
  23.  
  24.  
  25. if (myqueue_checkbox.checked) {
  26. open_cases_link = document.querySelectorAll(myQueue);
  27. number_of_open_cases = open_cases_link[0].children[0].innerText;
  28.  
  29. if (parseInt(number_of_open_cases) > 0) {
  30. var notification1 = new Notification("It's ticket time!", {
  31. icon: 'https://res-2.cloudinary.com/crunchbase-production/image/upload/c_lpad,h_120,w_120,f_auto,b_white,q_auto:eco/v1485854662/gthtieml7aregjx1fbch.jpg',
  32. body: "Open case in your queue!",
  33. });
  34.  
  35. notification1.onclick = function() { window.focus(); };
  36.  
  37. }
  38. }
  39.  
  40. if (general_checkbox.checked) {
  41. open_cases_link = document.querySelectorAll(generalQueue);
  42. number_of_open_cases = open_cases_link[0].children[0].innerText;
  43.  
  44. if (parseInt(number_of_open_cases) > 0) {
  45. var notification2 = new Notification("It's ticket time!", {
  46. icon: 'https://res-2.cloudinary.com/crunchbase-production/image/upload/c_lpad,h_120,w_120,f_auto,b_white,q_auto:eco/v1485854662/gthtieml7aregjx1fbch.jpg',
  47. body: "New case in general queue!",
  48. });
  49.  
  50. notification2.onclick = function() { window.focus(); };
  51.  
  52. }
  53. }
  54. }
  55.  
  56. }, 30000);
  57.  
  58. function injectStyles(rule) {
  59. var div = $("<div />", {
  60. html: '&shy;<style>' + rule + '</style>'
  61. }).appendTo("body");
  62. }
  63.  
  64. $(document).ready(function() {
  65. injectStyles('.notification-button-check-queue { padding: 7px 13px; top: 30px; right: 130px; position: absolute; color: white; font-size: 14px; font-weight: bold; border-radius: 6px; cursor: pointer; user-select: none; width: 155px; text-align: center;}');
  66. injectStyles(".notification-enabled { background-color: rgb(120, 163, 0); }");
  67. injectStyles(".notification-disabled { background-color: #E82A2A }");
  68. injectStyles(".label-checkbox-notification { display: inline-block; margin-left: 5px; }");
  69. injectStyles("#div_checkbox { display: inline-block; position: absolute; right: 320px; top: 37px; user-select:none}");
  70. injectStyles("#myqueue_checkbox { display: inline-block; margin: 1px 6px; }");
  71. injectStyles("#general_checkbox { display: inline-block; margin: 1px 6px; }");
  72. });
  73.  
  74. var area_notification_button = document.getElementsByClassName(" play");
  75.  
  76. var notification_button = document.createElement("div");
  77. notification_button.id = "notification_button";
  78. notification_button.className = "notification-button-check-queue notification-enabled";
  79. notification_button.onclick = function (){ enable_disable_notification(this) };
  80. notification_button.appendChild(document.createTextNode("Notifications ENABLED"));
  81. area_notification_button[0].appendChild(notification_button);
  82.  
  83.  
  84. var div_checkbox = document.createElement("div");
  85. div_checkbox.id = "div_checkbox";
  86.  
  87. //CHECKBOX MY CASES
  88. var myqueue_checkbox = document.createElement("input");
  89. myqueue_checkbox.type = "checkbox";
  90. myqueue_checkbox.id = "myqueue_checkbox";
  91. myqueue_checkbox.name = "myqueue_checkbox";
  92. myqueue_checkbox.className = "checkbox-notification";
  93. var myqueue_label = document.createElement("label");
  94. myqueue_label.appendChild(myqueue_checkbox);
  95. myqueue_label.htmlFor = "myqueue_checkbox";
  96. myqueue_label.appendChild(document.createTextNode("My Open Cases"));
  97. myqueue_label.className = "label-checkbox-notification";
  98. div_checkbox.appendChild(myqueue_label);
  99. area_notification_button[0].appendChild(div_checkbox);
  100.  
  101. //CHECKBOX GENERAL QUEUE
  102. var general_checkbox = document.createElement("input");
  103. general_checkbox.type = "checkbox";
  104. general_checkbox.id = "general_checkbox";
  105. general_checkbox.name = "general_checkbox";
  106. general_checkbox.className = "checkbox-notification";
  107. var general_label = document.createElement("label");
  108. general_label.appendChild(general_checkbox);
  109. general_label.htmlFor = "general_checkbox";
  110. general_label.appendChild(document.createTextNode("FR Sales Tier 1"));
  111. general_label.className = "label-checkbox-notification";
  112. div_checkbox.appendChild(general_label);
  113. area_notification_button[0].appendChild(div_checkbox);
  114.  
  115. function enable_disable_notification(notification_button) {
  116. var checkbox = document.getElementsByClassName("checkbox-notification");
  117. var label = document.getElementsByClassName("label-checkbox-notification");
  118.  
  119. if (notification_button.className == "notification-button-check-queue notification-enabled") {
  120. notification_button.className = "notification-button-check-queue notification-disabled";
  121. notification_button.innerText = "Notifications DISABLED"
  122.  
  123. for (i=0 ; i<checkbox.length ; i++) {
  124. checkbox[i].disabled = true;
  125. label[i].style.color = "lightgray";
  126. }
  127. }
  128. else if (notification_button.className == "notification-button-check-queue notification-disabled") {
  129. notification_button.className = "notification-button-check-queue notification-enabled";
  130. notification_button.innerText = "Notifications ENABLED"
  131.  
  132. for (i=0 ; i<checkbox.length ; i++) {
  133. checkbox[i].disabled = false;
  134. label[i].style.color = "#68737D"
  135. }
  136. }
  137. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement