Skip to content
This repository was archived by the owner on Feb 8, 2026. It is now read-only.

Commit cbadfe4

Browse files
authored
Merge pull request #185 from joelthorner/2.x
2.3.14
2 parents 4142b47 + 56cca11 commit cbadfe4

7 files changed

Lines changed: 65 additions & 36 deletions

File tree

js/background.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,22 @@ chrome.runtime.onInstalled.addListener(function (details) {
8686

8787
// TicketConsume system
8888
function openTicketConsumeTab() {
89-
chrome.tabs.create({
89+
chrome.windows.create({
9090
url: 'http://192.168.110.109:12853/zdreports/rtm.cfm?TicketConsume=true',
9191
// url: 'https://joelthorner.github.io/temp/?TicketConsume=true',
92-
active: false,
93-
// index: 0,
94-
pinned: true
92+
state: 'minimized',
93+
// focused: true
94+
}, function (window) {
95+
// console.log(window);
96+
97+
// chrome.tabs.create({
98+
// // url: 'http://192.168.110.109:12853/zdreports/rtm.cfm?TicketConsume=true',
99+
// url: 'https://joelthorner.github.io/temp/?TicketConsume=true',
100+
// active: false,
101+
// index: 0,
102+
// pinned: true,
103+
// windowId: window.id
104+
// });
95105
});
96106
}
97107
chrome.runtime.onMessage.addListener(function (message, sender) {

js/inject/zendesk/ticket-consume-source-tab.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,30 @@
55
*/
66

77
function TicketConsumeTab_getDataTrs(trs) {
8-
let data = ''
8+
var data = '';
99
for (let index = 0; index < trs.length; index++) {
10-
let organization = $(trs[index]).find('td:first-child').text().toLowerCase().trim(),
11-
tickets = parseInt($(trs[index]).find('td:last-child').text()),
12-
sla = $(trs[index]).closest('table').attr('id').replace('table', '').toLowerCase();
10+
if ($(trs[index]).find('td').length) {
11+
let organization = $(trs[index]).find('td:first-child').text().toLowerCase().trim(),
12+
tickets = parseInt($(trs[index]).find('td:last-child').text()),
13+
sla = $(trs[index]).closest('table').attr('id').replace('table', '').toLowerCase();
1314

14-
data += `
15-
"${organization}": {
16-
"tickets": ${tickets},
17-
"sla": "${sla}"
18-
}${index < trs.length - 1 ? ',' : ''}`;
15+
data += `
16+
"${organization}": {
17+
"tickets": ${tickets},
18+
"sla": "${sla}"
19+
}${index < trs.length - 1 ? ',' : ''}`;
20+
}
1921
}
2022
return data;
2123
}
2224

23-
let data = '{';
25+
var data = '{';
2426

2527
let si = setInterval(() => {
26-
const doc = $(document).contents()[1];
27-
let trs = doc.querySelectorAll('#tablePlatinium tbody tr, #tableGold tbody tr, #tableSilver tbody tr');
28+
const doc = $(document)[0];
29+
let trs = doc.querySelectorAll('#tablePlatinium tbody tr:not(.no-records-found), #tableGold tbody tr:not(.no-records-found), #tableSilver tbody tr:not(.no-records-found)');
30+
console.log(trs);
31+
2832

2933
if (trs.length) {
3034
clearInterval(si);

js/inject/zendesk/ticket-consume.js

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ TicketConsume = {
6161
if (TicketConsume.user.role == 'agent') {
6262
try {
6363
chrome.runtime.sendMessage({ name: 'openTicketConsumeTab' });
64-
} catch (error) {}
64+
} catch (error) {
65+
console.log(error);
66+
67+
}
6568
}
6669
});
6770
}
@@ -78,23 +81,28 @@ TicketConsume = {
7881
console.log(data);
7982
$.extend(true,TicketConsume.data, data)
8083

81-
$('[data-test-id="customercontext-userinfo-organization"] [href*="organizations"]').each(function (index, ticketOrg) {
82-
let $ticketOrg = $(ticketOrg);
83-
if (typeof $ticketOrg.data('ovserved-org') === 'undefined') {
84-
85-
$ticketOrg.data('ovserved-org', true);
86-
let findOrgId = $ticketOrg.attr('href').match(/\d{1,}/);
87-
88-
if (findOrgId) {
89-
let orgId = findOrgId[0], orgName = $ticketOrg.text().trim().toLowerCase();
90-
91-
TicketConsume.observerInit(orgId, orgName, $ticketOrg);
92-
}
84+
$(document).off('DOMSubtreeModified').on('DOMSubtreeModified', function (event) {
85+
if ($(event.target).find('[href*="organizations"]').length) {
86+
$('[data-test-id="customercontext-userinfo-organization"] [href*="organizations"]').each(function (index, ticketOrg) {
87+
let $ticketOrg = $(ticketOrg);
88+
if (typeof $ticketOrg.data('ovserved-org') === 'undefined') {
89+
90+
$ticketOrg.data('ovserved-org', true);
91+
let findOrgId = $ticketOrg.attr('href').match(/\d{1,}/);
92+
93+
if (findOrgId) {
94+
let orgId = findOrgId[0], orgName = $ticketOrg.text().trim().toLowerCase();
95+
96+
TicketConsume.observerInit(orgId, orgName, $ticketOrg);
97+
}
98+
}
99+
})
100+
TicketConsume.initIntervals();
93101
}
94-
})
95-
TicketConsume.initIntervals();
102+
});
96103
} catch (error) {
97104
log('TicketConsume invalid data', 'danger');
105+
console.log(message.data);
98106
}
99107
});
100108
},
@@ -133,7 +141,7 @@ TicketConsume = {
133141

134142
ZendeskApi_showOrganization(TicketConsume.data[orgName].id).then((responseData) => {
135143
let newData = TicketConsume.getNotesText(responseData.organization.notes);
136-
newData += TicketConsume.splitVal + '\n' + JSON.stringify(TicketConsume.data[orgName].customData);
144+
newData += `\n\n${TicketConsume.splitVal}\n${JSON.stringify(TicketConsume.data[orgName].customData)}`;
137145

138146
ZendeskApi_updateOrganization(TicketConsume.data[orgName].id, {
139147
"organization": { "notes": newData }
@@ -344,7 +352,7 @@ TicketConsume = {
344352
let json = [],
345353
valueSplitted = value.trim().split(TicketConsume.splitVal);
346354

347-
if (value.trim().length && valueSplitted) {
355+
if (value.trim().length && valueSplitted && value.trim().match(TicketConsume.splitVal)) {
348356
json = valueSplitted[valueSplitted.length - 1];
349357
try {
350358
json = JSON.parse(json);
@@ -372,6 +380,7 @@ TicketConsume = {
372380
if (typeof TicketConsume.user !== 'undefined' && TicketConsume.user.role == 'agent') {
373381
ZendeskApi_showOrganization(orgId).then((responseData) => {
374382
let customData = TicketConsume.parseOrganizationNotes(responseData.organization.notes);
383+
375384
if (TicketConsume.data[orgName]) {
376385
TicketConsume.data[orgName].id = orgId;
377386
TicketConsume.data[orgName].customData = customData;

js/options/changelog.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
const CHANGELOG = [
22
{
3+
version: 'v2.3.14', date: '04 Sep 2019',
4+
lines: [
5+
'FIXED Ticket consume get wrong data #184',
6+
'IMPROVED Ticket consume better open window minimized instead of sticky tab #184#issuecomment-528098098'
7+
]
8+
}, {
39
version: 'v2.3.13', date: '02 Sep 2019',
410
lines: [
511
'CHANGED Update dependencies #182',

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "__MSG_appName__",
3-
"version": "2.3.13",
3+
"version": "2.3.14",
44
"manifest_version": 2,
55
"author": "joelthorner",
66
"description": "__MSG_appDesc__",

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tlmanager",
3-
"version": "2.3.13",
3+
"version": "2.3.14",
44
"description": "Development tool",
55
"scripts": {
66
"test": "echo \"Error: no test specified\" && exit 1"

0 commit comments

Comments
 (0)