Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* REPLACE YOUR QUEUE URL HERE */
- var myQueue = "a[href='/agent/filters/64045648']";
- var generalQueue = "a[href='/agent/filters/85396808']";
- setInterval(function get_notified_new_tickets() {
- var notif_button = document.getElementById("notification_button");
- var open_cases_link, number_of_open_cases;
- if (notif_button.className == "notification-button-check-queue notification-enabled") {
- var refresh_button = document.querySelectorAll('[data-ember-action]');
- var all_links = document.getElementsByTagName("a");
- var myqueue_checkbox = document.getElementById("myqueue_checkbox");
- var general_checkbox = document.getElementById("general_checkbox");
- for (i=0 ; i < refresh_button.length ; i++) {
- if (refresh_button[i].className == "action_button") {
- refresh_button[i].click();
- }
- }
- if (myqueue_checkbox.checked) {
- open_cases_link = document.querySelectorAll(myQueue);
- number_of_open_cases = open_cases_link[0].children[0].innerText;
- if (parseInt(number_of_open_cases) > 0) {
- var notification1 = new Notification("It's ticket time!", {
- 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',
- body: "Open case in your queue!",
- });
- notification1.onclick = function() { window.focus(); };
- }
- }
- if (general_checkbox.checked) {
- open_cases_link = document.querySelectorAll(generalQueue);
- number_of_open_cases = open_cases_link[0].children[0].innerText;
- if (parseInt(number_of_open_cases) > 0) {
- var notification2 = new Notification("It's ticket time!", {
- 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',
- body: "New case in general queue!",
- });
- notification2.onclick = function() { window.focus(); };
- }
- }
- }
- }, 30000);
- function injectStyles(rule) {
- var div = $("<div />", {
- html: '­<style>' + rule + '</style>'
- }).appendTo("body");
- }
- $(document).ready(function() {
- 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;}');
- injectStyles(".notification-enabled { background-color: rgb(120, 163, 0); }");
- injectStyles(".notification-disabled { background-color: #E82A2A }");
- injectStyles(".label-checkbox-notification { display: inline-block; margin-left: 5px; }");
- injectStyles("#div_checkbox { display: inline-block; position: absolute; right: 320px; top: 37px; user-select:none}");
- injectStyles("#myqueue_checkbox { display: inline-block; margin: 1px 6px; }");
- injectStyles("#general_checkbox { display: inline-block; margin: 1px 6px; }");
- });
- var area_notification_button = document.getElementsByClassName(" play");
- var notification_button = document.createElement("div");
- notification_button.id = "notification_button";
- notification_button.className = "notification-button-check-queue notification-enabled";
- notification_button.onclick = function (){ enable_disable_notification(this) };
- notification_button.appendChild(document.createTextNode("Notifications ENABLED"));
- area_notification_button[0].appendChild(notification_button);
- var div_checkbox = document.createElement("div");
- div_checkbox.id = "div_checkbox";
- //CHECKBOX MY CASES
- var myqueue_checkbox = document.createElement("input");
- myqueue_checkbox.type = "checkbox";
- myqueue_checkbox.id = "myqueue_checkbox";
- myqueue_checkbox.name = "myqueue_checkbox";
- myqueue_checkbox.className = "checkbox-notification";
- var myqueue_label = document.createElement("label");
- myqueue_label.appendChild(myqueue_checkbox);
- myqueue_label.htmlFor = "myqueue_checkbox";
- myqueue_label.appendChild(document.createTextNode("My Open Cases"));
- myqueue_label.className = "label-checkbox-notification";
- div_checkbox.appendChild(myqueue_label);
- area_notification_button[0].appendChild(div_checkbox);
- //CHECKBOX GENERAL QUEUE
- var general_checkbox = document.createElement("input");
- general_checkbox.type = "checkbox";
- general_checkbox.id = "general_checkbox";
- general_checkbox.name = "general_checkbox";
- general_checkbox.className = "checkbox-notification";
- var general_label = document.createElement("label");
- general_label.appendChild(general_checkbox);
- general_label.htmlFor = "general_checkbox";
- general_label.appendChild(document.createTextNode("FR Sales Tier 1"));
- general_label.className = "label-checkbox-notification";
- div_checkbox.appendChild(general_label);
- area_notification_button[0].appendChild(div_checkbox);
- function enable_disable_notification(notification_button) {
- var checkbox = document.getElementsByClassName("checkbox-notification");
- var label = document.getElementsByClassName("label-checkbox-notification");
- if (notification_button.className == "notification-button-check-queue notification-enabled") {
- notification_button.className = "notification-button-check-queue notification-disabled";
- notification_button.innerText = "Notifications DISABLED"
- for (i=0 ; i<checkbox.length ; i++) {
- checkbox[i].disabled = true;
- label[i].style.color = "lightgray";
- }
- }
- else if (notification_button.className == "notification-button-check-queue notification-disabled") {
- notification_button.className = "notification-button-check-queue notification-enabled";
- notification_button.innerText = "Notifications ENABLED"
- for (i=0 ; i<checkbox.length ; i++) {
- checkbox[i].disabled = false;
- label[i].style.color = "#68737D"
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement