Skip to content

Instantly share code, notes, and snippets.

@jamesdaniels
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesdaniels/4ad347bf63d4b31b58f4 to your computer and use it in GitHub Desktop.
Save jamesdaniels/4ad347bf63d4b31b58f4 to your computer and use it in GitHub Desktop.
Desk.com fluid scripts
// Pattern *support.appblade.com\/login\/new
$('#user_session_email').val('USERNAME');
$('#user_session_password').val('PASSWORD')[0].form.submit();
// Pattern *support.appblade.com\/web\/agent\/filters*
window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 1000);
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 5000);
function updateDockBadge() {
window.fluid.dockBadge = $('.filter-view div.count').first().html();
$('tr.case').find('div.status').each(function() {
var $this = $(this);
if ($this.hasClass('new') && $this.data('growl') == undefined) {
var $tr = $this.parents('tr');
$this.data('growl', 'notified');
var title = "";
title += $tr.find('td[dd-dragging="Customer"] .text').html();
$($tr.find('.case-subject .icon').attr('class').split(' ')).each(function() {
if (this.indexOf('channel-') == 0) {
title += ' [' + this.split('-')[1] + ']';
}
});
window.fluid.showGrowlNotification({
title: title,
description: $tr.find('.case-subject .text').html(),
priority: 1,
sticky: false
});
}
});
};
// Pattern *support.appblade.com\/agent
window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 1000);
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 5000);
function updateDockBadge() {
var newItems = $('.ticket_filter_item_new');
var dockCount = 0;
dockCount += parseInt($($('.ticket_filter_row')[0]).find('.ticket_filter_row_count').html().replace(',', ''), 10);
dockCount += parseInt($($('.ticket_filter_row')[1]).find('.ticket_filter_row_count').html().replace(',', ''), 10);
if (dockCount > 0) {
window.fluid.dockBadge = '' + dockCount;
} else {
var dockPendingCount = 0;
dockPendingCount += parseInt($($('.ticket_filter_row')[2]).find('.ticket_filter_row_count').html().replace(',', ''), 10);
dockPendingCount += parseInt($($('.ticket_filter_row')[6]).find('.ticket_filter_row_count').html().replace(',', ''), 10);
if (dockPendingCount > 0) {
window.fluid.dockBadge = '·';
}
}
newItems.each(function() {
var $this = $(this);
if ($this.data('growl') == undefined) {
$this.data('growl', 'notified');
window.fluid.showGrowlNotification({
title: $.trim($this.find('.ticket_filter_item_tv_customer_name span').html()),
description: $.trim($this.find('.ticket_filter_item_tv_subject a').html()),
priority: 1,
sticky: false,
icon: $this.find('img.agent_icon_button').attr('src')
});
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment