· 6 years ago · Oct 18, 2019, 08:14 PM
1// ==UserScript==
2// @name MyDay_Tweaks_V3
3// @namespace MyDay_Tweaks_V3
4// @include https://myday-website-*.*.proxy.amazon.com/*
5// @include https://myday-website-*.amazon.com/*
6// @exclude https://myday-website-*.amazon.com/search*
7// @require https://internal-cdn.amazon.com/w.amazon.com/extensions/JS/jquery/jquery-all.min.js
8// @require https://btk.amazon.com/ajax/libs/jquery/2.1.3/jquery.min.js
9// @require https://internal-cdn.amazon.com/oneg.amazon.com/assets/3.2.5/js/bootstrap-tooltip.min.js
10// @require https://cdn.rawgit.com/zenorocha/clipboard.js/master/dist/clipboard.min.js
11// @downloadURL http://pdx-tools.pdx2.amazon.com:3000/mylbooth/MyDay_Tweaks_V3/raw/branch/master/MyDay_Tweaks_V3.user.js
12// @updateURL http://pdx-tools.pdx2.amazon.com:3000/mylbooth/MyDay_Tweaks_V3/raw/branch/master/MyDay_Tweaks_V3.user.js
13// @version 10.20
14// @grant GM.xmlHttpRequest
15// @grant GM.info
16// @author Myles Booth (mylbooth@)
17// @description Place holder
18// ==/UserScript==
19// @require http://pdx-tools.pdx2.amazon.com/mylbooth/GM/clipboard.min.js
20
21var activeFlag = 0;
22var manufacturer = '';
23var model = '';
24$(document).ready(function() {
25 //checkForUpdates();
26 var clipboard = new ClipboardJS('.fa-clipboard');
27
28 clipboard.on('success', function(e) {
29 console.info('Action:', e.action);
30 console.info('Text:', e.text);
31 console.info('Trigger:', e.trigger);
32
33 e.clearSelection();
34 });
35
36 clipboard.on('error', function(e) {
37 console.error('Action:', e.action);
38 console.error('Trigger:', e.trigger);
39 });
40
41 setTimeout(function() {
42 $('body').css('font-size', '12px');
43 // Fix the left menu items
44 leftMenu();
45 // Detect clicks as the user navigates
46 clickAction();
47 // Show an identifier at the bottom of the page that lets users know tweaks is running
48 identify();
49 POST2API();
50 }, 3000);
51});
52
53// Show an identifier at the bottom of the page that lets users know tweaks is running
54function identify(){
55 var idendityScript = $('#identifyScript').length;
56 if (idendityScript == 0){
57 var text = '<div id="identifyScript"> \
58 <a href="http://pdx-tools.pdx2.amazon.com:3000/mylbooth/MyDay_Tweaks_V3" target="_blank">MyDay_Tweaks_V3</a> \
59 </div>';
60 $('body').append(text);
61 $('#identifyScript').css({
62 'z-index': '1000',
63 'position': 'fixed',
64 'bottom': '10px',
65 'left': '50%'
66 });
67 $('#identifyScript a').css({
68 'text-decoration': 'none',
69 'padding-right': '20px',
70 'font-size': 'xx-small',
71 'color': 'rgba(255,0,0,.5)'
72 });
73 }
74}
75/*
76 ██████╗██╗ ██████╗ ██╗ ██╗██████╗ ███████╗ ██████╗ ██████╗ ██████╗ ███████╗
77██╔════╝██║ ██╔═══██╗██║ ██║██╔══██╗██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██╔════╝
78██║ ██║ ██║ ██║██║ ██║██║ ██║█████╗ ██║ ██║██████╔╝██║ ███╗█████╗
79██║ ██║ ██║ ██║██║ ██║██║ ██║██╔══╝ ██║ ██║██╔══██╗██║ ██║██╔══╝
80╚██████╗███████╗╚██████╔╝╚██████╔╝██████╔╝██║ ╚██████╔╝██║ ██║╚██████╔╝███████╗
81 ╚═════╝╚══════╝ ╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
82 */
83function Cloudforge() {
84 var found = 0;
85 var RackAssetId = '';
86 var Loc = '';
87 var hardware_id = '';
88
89 $('related-host table tbody tr td:first-child, host-details table tbody tr td:first-child').each(function(td) {
90 $(this).css("font-weight", "Bold");
91
92 if ($(this).text() == "Location") {
93 Loc = $(this).next().text().toUpperCase();
94 }
95 if ($(this).text() == "Asset Id" && $(this).next().text() != "-") {
96 Asset = $(this).next().text();
97 $(this).parent().css('background-color', '#DDDEDF');
98 // Make sure Copy2Clipboard doesn't already exist
99 if ($('#clip_assetID').length == 0) {
100 Copy2Clipboard($(this), 'assetID', Asset);
101 }
102 }
103
104 // Grab the Hardware ID
105 if ($(this).text() == "Hardware Id" && hardware_id == "" && $(this).next().text().trim() != '-') {
106 // Only grabs the text from the td and not the span that's also within the td.
107 // Some hosts show OOW next to the hwid
108 hardware_id = $(this).next().contents().filter(function() {
109 return this.nodeType == 3;
110 }).text();
111
112 $(this).html('<a id="hwmonDecoder" href="https://ryanon-tools.corp.amazon.com/hwmon_decoder/' + hardware_id.trim() + '" target=_blank>Hardware Id</a>');
113 }
114
115 // Grab Rack asset ID and create a link to the rack handoff page
116 if ($(this).text() == "Rack Asset Id" && $(this).next().text().trim() != '-') {
117 RackAssetId = $(this).next().text();
118 $(this).html('<a href="https://infrastructure.amazon.com/automation/rackHandoff.cgi?rack_asset_id=' + RackAssetId.trim() + '" target=_blank>Rack Asset Id</a>');
119 }
120
121 // Check if the U Position was already added
122 if ($(this).text() == "U Position") {
123 found = 1;
124 }
125 });
126
127 $('related-host table:eq(2) tbody tr td:first-child, host-details table:eq(2) tbody tr td:first-child').each(function(td) {
128 // Grab the manufacturer
129 if ($(this).text() == "Manufacturer") {
130 manufacturer = $(this).next().text();
131 }
132 // Grab the model
133 if ($(this).text() == "Model") {
134 model = $(this).next().text();
135 }
136 });
137
138
139 $('console-details table tbody tr td:first-child').each(function() {
140 var newLocation = '';
141 // Create the cloudforge link using HWID
142 if ($(this).text() == "IP Address" && hardware_id != "") {
143 consoleIP = $(this).next().find('.label.label-success.ng-binding').text().trim();
144 newLocation = Loc.substr(0, 3);
145 $(this).html('<a href="https://cloudforge-external-' + newLocation + '.amazon.com/consoles?hardware_id=' + hardware_id.trim() + '" target=_blank>IP Address</a>');
146 // Make sure Copy2Clipboard doesn't already exist
147 if ($('#clip_consoleIP').length == 0 && consoleIP != '-') {
148 Copy2Clipboard($(this), 'consoleIP', consoleIP);
149 }
150 }
151
152 // Create the cloudforge link using MAC
153 if ($(this).text() == "Mac Address" && $(this).next().text().trim() != "-") {
154 MACAddress = $(this).next().text();
155 newLocation = Loc.substr(0, 3);
156 $(this).html('<a href="https://cloudforge-external-' + newLocation + '.amazon.com/consoles?console_mac=' + MACAddress.trim() + '" target=_blank>Mac Address</a>');
157 }
158 });
159
160 // Auto load the important tabs
161 //var checkAttr = $('console-details:eq(0) thead tr th').text();
162 var checkAttr = $('a[ng_click="viewHwMonStatus(true)"]:eq(0)').parent().attr('style');
163 // Verify the page has fully loaded before continuing
164 //if (checkAttr == "Console Data" && hardware_id != "" && $('related-host .container-fluid.padding-top-5 .row.ng-scope').length > 0) {
165 // Verify the stethoscope exists and doesn't have a style attribute
166 if (typeof checkAttr == typeof undefined && checkAttr !== false) {
167 // Add a period to 'Console Data' so that we now the script ran and loaded the page.
168 //$('console-details:eq(0) thead tr th').html("Console Data.");
169
170 // Store the current active tab so that we can have it default back to it
171 var currentActive = $('related-host ul .ng-isolate-scope.active a');
172 // Create a click element
173 var clickEvent = document.createEvent("HTMLEvents");
174 clickEvent.initEvent("click", true, true);
175 //HWMon
176 $('a[ng_click="viewHwMonStatus(true)"]:eq(0):parent').parent()[0].dispatchEvent(clickEvent);
177 $('a[ng_click="viewHwMonStatus(true)"]:eq(0)').parent().css('color', 'black');
178 //Host Details
179 $('a[ng_click="viewHostDetails(true)"]:eq(0):parent').parent()[0].dispatchEvent(clickEvent);
180 //$('a[ng_click="viewHostDetails(true)"]:eq(0)').parent().css('color', 'grey');
181 $('a[ng_click="viewHostDetails(true)"]:eq(0) i').addClass('fa-spin');
182 // Wait for tab to load
183 $('iframe[iframe_on_load=\'loaded("host_details_url")\']').on('load', function() {
184 $('a[ng_click="viewHostDetails(true)"]:eq(0)').parent().css('color', 'black');
185 $('a[ng_click="viewHostDetails(true)"]:eq(0) i').removeClass('fa-spin');
186 });
187 //DCO Pile
188 $('a[ng_click="viewDCOPile(true)"]:eq(0):parent').parent()[0].dispatchEvent(clickEvent);
189 //$('a[ng_click="viewDCOPile(true)"]:eq(0)').parent().css('color', 'grey');
190 $('a[ng_click="viewDCOPile(true)"]:eq(0) i').addClass('fa-spin');
191 // Wait for tab to load
192 $('iframe[iframe_on_load=\'loaded("dco_pile_url")\']').on('load', function() {
193 $('a[ng_click="viewDCOPile(true)"]:eq(0)').parent().css('color', 'black');
194 $('a[ng_click="viewDCOPile(true)"]:eq(0) i').removeClass('fa-spin');
195 });
196 //Toaster
197 if ($('a[ng_click="viewToaster(true)"]').length > 0) {
198 $('a[ng_click="viewToaster(true)"]:eq(0):parent').parent()[0].dispatchEvent(clickEvent);
199 //$('a[ng_click="viewToaster(true)"]:eq(0)').parent().css('color', 'grey');
200 $('a[ng_click="viewToaster(true)"]:eq(0) i').addClass('fa-spin');
201 // Wait for tab to load
202 $('iframe[iframe_on_load=\'loaded("toaster_url")\']').on('load', function() {
203 $('a[ng_click="viewToaster(true)"]:eq(0)').parent().css('color', 'black');
204 $('a[ng_click="viewToaster(true)"]:eq(0) i').removeClass('fa-spin');
205 });
206 }
207 //Admiral
208 /*if ($('a[ng_click="viewAdmiral(true)"]').length > 0) {
209 $('a[ng_click="viewAdmiral(true)"]:eq(0):parent').parent()[0].dispatchEvent(clickEvent);
210 $('a[ng_click="viewAdmiral(true)"]:eq(0)').parent().css('color', 'grey');
211 // Wait for tab to load
212 $('iframe[iframe_on_load=\'loaded("admiral_url")\']').on('load', function() {
213 $('a[ng_click="viewAdmiral(true)"]:eq(0)').parent().css('color', 'black');
214 });
215 }*/
216 //Basic Info
217 //$('related-host ul li a')[0].dispatchEvent (clickEvent);
218 $(currentActive)[0].dispatchEvent(clickEvent);
219 }
220
221
222}
223/*
224██╗ ███████╗███████╗████████╗ ███╗ ███╗███████╗███╗ ██╗██╗ ██╗
225██║ ██╔════╝██╔════╝╚══██╔══╝ ████╗ ████║██╔════╝████╗ ██║██║ ██║
226██║ █████╗ █████╗ ██║ ██╔████╔██║█████╗ ██╔██╗ ██║██║ ██║
227██║ ██╔══╝ ██╔══╝ ██║ ██║╚██╔╝██║██╔══╝ ██║╚██╗██║██║ ██║
228███████╗███████╗██║ ██║ ██║ ╚═╝ ██║███████╗██║ ╚████║╚██████╔╝
229╚══════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═════╝
230*/
231function leftMenu() {
232 //console.log('left menu called')
233 // Expand the assigned group on the left menu
234 $('available-groups div').each(function() {
235 // Remove ng-hide from all the divs so that we can see all the assigned groups
236 $(this).removeClass('ng-hide');
237 $(this).find('.fa.fa-angle-down').addClass('ng-hide');
238 });
239
240 // Remove the garbage on the side panel so that the rooms are readable
241 $('facets-section[title="Rooms"] .facet-hover .facet-name').each(function() {
242 var room = $(this).text().trim();
243 var newRoom = room.replace(room.substr(room.indexOf('.') + 1, room.indexOf('POD') - room.indexOf('.') - 1), "");
244 // Set the new rooms on the left menu
245 $(this).text(newRoom);
246 });
247
248 // Only show PDX and PDT for AZ2
249 /*var regex = new RegExp("PD[TX]51 Data|PD[TX]2 Data");
250 $('available-groups .assigned-group-section div span:nth-child(1)').each(function () {
251 //console.log($(this).text().trim() + ' ' + regex.test($(this).text().trim()))
252 if (!regex.test($(this).text().trim())){
253 $(this).closest('.assigned-group-entry').remove();
254 }
255 });*/
256
257 $('#navigation tech-result').each(function () {
258 var ttNumber = $(this).find('div:eq(0) div:eq(0) div').text().trim();
259 $(this).find('div:eq(0) div:eq(0) div').html('<a href="https://tt.amazon.com/' + ttNumber + '" target=_blank>'+ttNumber+'</a>');
260 });
261
262 var chromeBrowser = /chrom(e|ium)/.test(navigator.userAgent.toLowerCase());
263 if (!chromeBrowser){
264 setTimeout(function() {
265 // Create a tooltip so when you hover over the ticket on the left it shows the full text
266 $('#wf-navigation').append('<div id="title"></div>');
267 var len = $('#navigation filtered-result').length || $('#navigation tech-result').length;
268 $('#navigation filtered-result, #navigation tech-result').each(function(index) {
269 var fullText = $(this).find('div div:nth-child(2) div:eq(0)').text().trim();
270 /*$(this).mouseout(function(){
271 $('#title').text(" ");
272 });
273 $(this).mouseover(function(){
274 $('#title').text(" " + fullText);
275 });*/
276
277 //$(this).prop('title', fullText);
278 $(this).attr('data-original-title', fullText);
279 $(this).attr('data-toggle', 'tooltip');
280 if (index == len - 1) {
281 $(this).attr('data-placement', 'top');
282 } else {
283 $(this).attr('data-placement', 'bottom');
284 }
285 });
286 $('[data-toggle="tooltip"]').tooltip();
287 }, 2000);
288 };
289
290 // Display the online status of the techs on the left menu
291 /*$('facets-section[title="Assigned Individual"]').unbind().on('click', function(event) {
292 onlineStatus();
293 });*/
294}
295/*
296 ██████╗██╗ ██╗ ██████╗██╗ ██╗ █████╗ ██████╗████████╗██╗ ██████╗ ███╗ ██╗
297██╔════╝██║ ██║██╔════╝██║ ██╔╝ ██╔══██╗██╔════╝╚══██╔══╝██║██╔═══██╗████╗ ██║
298██║ ██║ ██║██║ █████╔╝ ███████║██║ ██║ ██║██║ ██║██╔██╗ ██║
299██║ ██║ ██║██║ ██╔═██╗ ██╔══██║██║ ██║ ██║██║ ██║██║╚██╗██║
300╚██████╗███████╗██║╚██████╗██║ ██╗ ██║ ██║╚██████╗ ██║ ██║╚██████╔╝██║ ╚████║
301 ╚═════╝╚══════╝╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
302*/
303function clickAction() {
304 console.log("clickaction called");
305 //setTimeout(function() {
306 $('body').unbind().on('click', function(event) {
307 console.log('clicked');
308 setTimeout(function() {
309 //$('body').css('font-size', '12px');
310 leftMenu();
311 hideDriveHold();
312 priorityTickets()
313 identify();
314
315 // Check if this is a individual ticket
316 if ($('#current-result').length > 0 || $('#taskContent').length > 0 || $('#tool active').length > 0 || $('#instruction-pane').length > 0) {
317 // Add the myday and remedy links
318 $('#current-result div div a').remove();
319 var ttNumber = $('#current-result div div span:eq(0)').text().trim();
320 $('#current-result div div span:eq(0)').after('<a id="ttNumber" href="https://myday-website-pdx.amazon.com/ticket/' + ttNumber + '" target=_blank>M</a> <a href="https://tt.amazon.com/' + ttNumber + '" target=_blank>R</a> <a id="togglePage"></a>');
321 if ($('#wf-pane .tools').length > 0 || $('#active-type .tab-content').length > 0 || $('host-details').length > 0) {
322 // Fix v1
323 setTimeout(function() {
324 showCorrespondence();
325 Cloudforge();
326 showWorklog();
327
328 var diagStep = $('#states .ng-binding.ng-scope.active').text().trim();
329 if (diagStep == "Setup Instructions") {
330 descriptionTags();
331 // Auto fill the task drop downs
332 /*$('instruction-builder').each(function() {
333 $(this).find('.col-md-4:eq(0) .ui-select-match-text.pull-left').unbind().one("DOMSubtreeModified", function() {
334 setDefualtInstruction();
335 });
336 });*/
337 $('.instruction-updated-entry').each(function() {
338 var that = $(this);
339 // Set a DOM so if the user clicks the dropdown it will populate
340 $(this).find('.col-md-3:eq(0) .ui-select-match-text.pull-left').unbind().one("DOMSubtreeModified", function() {
341 // Get the index number of which dropdown was selected
342 //var dropdownIndex = $('.instruction-updated-entry').find('.col-md-3:eq(0) .ui-select-match-text.pull-left').index(this);
343 var dropdownIndex = $('.instruction-updated-entry.created').index(that);
344 console.log('instruction index',dropdownIndex);
345 setDefualtInstruction(dropdownIndex);
346 });
347 });
348 $('.instruction-updated-arrow-expander i.fa-caret-right').each(function() {
349 var that = $(this);
350 $(this).css('color', 'orange');
351 $(this).unbind().bind('click', function(event) {
352 // Get the index number of which dropdown was selected
353 var dropdownIndex = $('.instruction-updated-arrow-expander i.fa-caret-right').index(that);
354 console.log('instruction index',dropdownIndex);
355 setDefualtInstruction(dropdownIndex);
356 $('.instruction-updated-arrow-expander i.fa-caret-right').css('color', 'black');
357 });
358 });
359 }
360 // DCO Approval popup
361 if ($('.fade.modal-backdrop.in').length > 0 && $('.modalV3-header').text().trim() == 'DCO Approval') {
362 DCOApproval();
363 }
364 }, 1000);
365 }
366
367 // Make asset tag selectable
368 findAssetTag();
369
370 // Add console IP to sanity check
371 //findConsoleIP();
372
373 // Add charactor count to part serials
374 countChar();
375
376 moveWorkReady();
377
378 // When user clicks severity it will hide the side bar
379 hideSideBar();
380
381 // Add a icon to the assignment page to show/hide techs
382 var cntRunning = 0;
383 setTimeout(checkButton, 500);
384
385 // Color the root cause red if it's not one we should be using
386 // colorRootCause();
387
388 // Add the ticket number to the title
389 var newTitle = '';
390 // Grab the current title of the page
391 var title = $(document).prop('title');
392 var index1 = title.indexOf('[');
393 if (index1 > -1) {
394 newTitle = title.substr(0, index1 - 1) + ' [' + ttNumber + ']';
395 } else {
396 newTitle = title + ' [' + ttNumber + ']';
397 }
398 // Set the title of the page
399 $(document).prop('title', newTitle);
400
401 setTimeout(checkLoading, 1000);
402 //checkLoading();
403
404 // Sticky the top bar
405 //$('#wf-pane .nav.nav-tabs').sticky({topSpacing:0});
406 var firstTabTitle = $('#wf-pane .nav.nav-tabs li:eq(0) a').text().trim();
407 if ($('#sticky').length == 0 && (firstTabTitle == "Ticket information" || firstTabTitle == "Setup Instructions" || firstTabTitle == "Verify Fix")) {
408 $('#wf-pane .nav.nav-tabs').wrap('<div id="sticky" style="height:39px;"></div>');
409 $('#wf-pane .nav.nav-tabs:eq(0)').css({
410 'z-index': '1000',
411 'position': 'fixed',
412 'top': '185px',
413 'background-color': 'white',
414 'height': '39px',
415 'width': '75%'
416 });
417 // use outerHeight() to get the height of the element
418 }
419 // Color the previous tickets if they are still open
420 colorRelatedTickets();
421 }
422
423 function checkButton() {
424 // If any of the Assign buttons are clicked then remove the predefined filters so that it can rerun
425 $('#team-members .assignment_panel button').unbind().on('click', function(event) {
426 $('#hideInstructions').remove();
427 $('#assignTechs').remove();
428 $('#onlineTechs').remove();
429 });
430 //console.log('checkbutton')
431 // Add a icon to the assignment page to show/hide techs
432 if ($('#states .ng-binding.ng-scope.active').text().trim() == "Assignment" && !$('#assignTechs').length && $('#team-members assignment-individual').length) {
433 $('#wf-pane ui-view').before('<ul class="nav nav-pills nav-stacked"><li id="hideInstructions" class="tool"><a><i class="fa fa-file-text-o"></i> - Hide Instructions</a></li><li id="assignTechs" class="tool"><a><i class="fa fa-user"></i> - Show CTI Defaults</a></li><li id="onlineTechs" class="tool"><a><i class="fa fa-keyboard-o"></i> - Show Online Techs Only</a></li></ul>');
434 $('#hideInstructions').click(function() {
435 $('#hideInstructions').hasClass('active') ? $('#hideInstructions').removeClass('active') : $('#hideInstructions').addClass('active');
436 $('instructions-summary').toggle();
437 });
438 $('#assignTechs').click(function() {
439 $('#assignTechs').hasClass('active') ? $('#assignTechs').removeClass('active') : $('#assignTechs').addClass('active');
440 assignTechs();
441 // Deselect the onlineTechs if the user clicks assignTechs
442 if ($('#onlineTechs').hasClass('active')) {
443 $('#onlineTechs').removeClass('active');
444 onlineTechs();
445 }
446 });
447 $('#onlineTechs').click(function() {
448 $('#onlineTechs').hasClass('active') ? $('#onlineTechs').removeClass('active') : $('#onlineTechs').addClass('active');
449 onlineTechs();
450 // Deselect the assignTechs if the user clicks onlineTechs
451 if ($('#assignTechs').hasClass('active')) {
452 $('#assignTechs').removeClass('active');
453 assignTechs();
454 }
455 });
456 //onlineStatus();
457 descriptionTags();
458 }
459 // If the assignTechs button is not on the page yet then rerun this function
460 if (!$('#assignTechs').length && cntRunning < 10) {
461 cntRunning++;
462 //console.log('running')
463 setTimeout(checkButton, 500);
464 }
465 }
466
467 function checkLoading() {
468 // Auto load the stethoscope
469 //var checkStyle = $('#wf-pane ul li a:eq(0)').attr('style');
470 var checkStyle = $('li[heading="Diagnostics"]:eq(0)').children().attr('style');
471 // Verify the stethoscope exists and doesn't have a style attribute
472 if (typeof checkStyle == typeof undefined && checkStyle !== false && $('li[heading="Diagnostics"]:eq(0)').length > 0) {
473 var clickEvent = document.createEvent("HTMLEvents");
474 clickEvent.initEvent("click", true, true);
475 // Store the current active tab so that we can have it default back to it
476 var currentActive = $('.nav.nav-tabs:eq(0) .ng-isolate-scope.active a');
477 // Wait for tab to load
478 $('li[heading="Diagnostics"]:eq(0)').children().css('color', 'black');
479 /*$('a[track_click="triage-qm-workflow"]:eq(0)')[0].dispatchEvent (clickEvent);
480 $('a[track_click="triage-qm-workflow"]:eq(0)')[0].dispatchEvent (clickEvent);
481 $('a[track_click="triage-qm-workflow"]:eq(0)').css('color','blue');*/
482 $('li[heading="Diagnostics"]:eq(0)').children()[0].dispatchEvent(clickEvent);
483 /*if ($('li[heading="Review Ticket"]:eq(0)').length > 0){
484 $('li[heading="Review Ticket"]:eq(0)').children()[0].dispatchEvent (clickEvent);
485 }else if ($('li[heading="Remote Diagnostics"]:eq(0)').length > 0){
486 $('li[heading="Remote Diagnostics"]:eq(0)').children()[0].dispatchEvent (clickEvent);
487 }else if ($('li[heading="Verify Fix"]:eq(0)').length > 0){
488 $('li[heading="Verify Fix"]:eq(0)').children()[0].dispatchEvent (clickEvent);
489 }else if ($('li[heading="Validate Host Readiness"]:eq(0)').length > 0){
490 $('li[heading="Validate Host Readiness"]:eq(0)').children()[0].dispatchEvent (clickEvent);
491 }*/
492
493 // Reselect the first active tab
494 //$('.nav.nav-tabs:eq(0) li:eq(0) a')[0].dispatchEvent (clickEvent);
495 $(currentActive)[0].dispatchEvent(clickEvent);
496 return 1;
497 } else if (checkStyle) {
498 // Break the loop as the stethoscope has already been clicked
499 return 1;
500 }
501
502 if (cntRunning < 10) {
503 cntRunning++;
504 setTimeout(checkLoading, 1000);
505 }
506 }
507
508 // Color Bin location red or green based on location
509 // Check if this is the parts allocation screen or the request parts
510 var diagStep = $('#tickets .ng-binding.ng-scope.active').text().trim();
511 if (diagStep == "Allocate Parts" || diagStep == "Request Parts") {
512 colorBins();
513 }
514 setTimeout(function() {
515 if ($('.modalV3-header.ng-scope').length == 1 && $('.modalV3-header.ng-scope .modalV3-title').text().trim() == "Request parts") {
516 //requestParts();
517 }
518 }, 4000);
519 // Color correspondence
520 if ($('#communication-entries').length > 0) {
521 setTimeout(function() {
522 communicationTab();
523 }, 1000);
524 }
525 // Jump to the parts section in DCO Pile
526 dcopileTab();
527 }, 1000);
528 });
529 //}, 1000);
530}
531/*
532██████╗ ██████╗ ██████╗ ██████╗ ██╗██╗ ███████╗ ████████╗ █████╗ ██████╗
533██╔══██╗██╔════╝██╔═══██╗██╔══██╗██║██║ ██╔════╝ ╚══██╔══╝██╔══██╗██╔══██╗
534██║ ██║██║ ██║ ██║██████╔╝██║██║ █████╗ ██║ ███████║██████╔╝
535██║ ██║██║ ██║ ██║██╔═══╝ ██║██║ ██╔══╝ ██║ ██╔══██║██╔══██╗
536██████╔╝╚██████╗╚██████╔╝██║ ██║███████╗███████╗ ██║ ██║ ██║██████╔╝
537╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═════╝
538*/
539function dcopileTab() {
540 // Jump to the parts section in DCO Pile
541 var isActive = $('iframe[iframe_on_load=\'loaded("dco_pile_url")\']').parent().parent().hasClass('active');
542 // If the DCO Pile tab is not active then remove and add the element
543 console.log(isActive + ' ' + activeFlag);
544 if (!isActive) {
545 if (!activeFlag) {
546 console.log('add/remove ' + activeFlag);
547 // Remove the element from the src if it exists
548 $('iframe[iframe_on_load=\'loaded("dco_pile_url")\']').attr('src', function() {
549 return $(this).attr("src").trim().replace('#Parts_in_server', '');
550 });
551 // Add the element to the attr
552 $('iframe[iframe_on_load=\'loaded("dco_pile_url")\']').attr('src', function() {
553 return $(this).attr("src").trim() + "#Parts_in_server";
554 });
555 activeFlag = 1;
556 }
557 if ($('iframe[iframe_on_load=\'loaded("dco_pile_url")\']').attr('src').indexOf('#Parts_in_server') == -1) {
558 // Add the element to the attr
559 $('iframe[iframe_on_load=\'loaded("dco_pile_url")\']').attr('src', function() {
560 return $(this).attr("src").trim() + "#Parts_in_server";
561 });
562 }
563 } else {
564 // If the DCO Pile tab is not active then don't allow it to add/remove the element
565 activeFlag = 0;
566 console.log(activeFlag);
567 }
568}
569
570/*
571 ██████╗ ██████╗ ██╗ ██████╗ ██████╗ ██████╗ ███████╗██╗ █████╗ ████████╗███████╗██████╗ ████████╗██╗ ██████╗██╗ ██╗███████╗████████╗███████╗
572██╔════╝██╔═══██╗██║ ██╔═══██╗██╔══██╗ ██╔══██╗██╔════╝██║ ██╔══██╗╚══██╔══╝██╔════╝██╔══██╗ ╚══██╔══╝██║██╔════╝██║ ██╔╝██╔════╝╚══██╔══╝██╔════╝
573██║ ██║ ██║██║ ██║ ██║██████╔╝ ██████╔╝█████╗ ██║ ███████║ ██║ █████╗ ██║ ██║ ██║ ██║██║ █████╔╝ █████╗ ██║ ███████╗
574██║ ██║ ██║██║ ██║ ██║██╔══██╗ ██╔══██╗██╔══╝ ██║ ██╔══██║ ██║ ██╔══╝ ██║ ██║ ██║ ██║██║ ██╔═██╗ ██╔══╝ ██║ ╚════██║
575╚██████╗╚██████╔╝███████╗╚██████╔╝██║ ██║ ██║ ██║███████╗███████╗██║ ██║ ██║ ███████╗██████╔╝ ██║ ██║╚██████╗██║ ██╗███████╗ ██║ ███████║
576 ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚══════╝╚═════╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚══════╝
577 */
578function colorRelatedTickets() {
579 // Loop through the list of replaced hardware and grab the model for each (Repair History)
580 $('related-tickets tbody tr').each(function() {
581 var ticketList = $(this).find('td:eq(2)').text().trim();
582 //console.log("+" + ticketList + "+");
583 if (ticketList != "RESOLVED" && ticketList != "CLOSED") {
584 $(this).find('td').css({
585 "background-color": '#91BF70',
586 "font-weight": 'bold'
587 });
588 }
589 });
590
591 /*if (cnt > 0){
592 if (foundKeywordMin.substr(0,1) != '[') {
593 $(this).find('.entry-min.ng-binding:eq(0)').prepend('[' + modelType + '] ');
594 }
595 if (foundKeywordMax.substr(0,1) != '[') {
596 $(this).find('.entry-max.ng-binding.ng-scope:eq(0)').prepend('[' + modelType + '] ');
597 }
598 }*/
599}
600/*
601██████╗ ██████╗ ██████╗ █████╗ ██████╗ ██████╗ ██████╗ ██████╗ ██╗ ██╗ █████╗ ██╗
602██╔══██╗██╔════╝██╔═══██╗ ██╔══██╗██╔══██╗██╔══██╗██╔══██╗██╔═══██╗██║ ██║██╔══██╗██║
603██║ ██║██║ ██║ ██║ ███████║██████╔╝██████╔╝██████╔╝██║ ██║██║ ██║███████║██║
604██║ ██║██║ ██║ ██║ ██╔══██║██╔═══╝ ██╔═══╝ ██╔══██╗██║ ██║╚██╗ ██╔╝██╔══██║██║
605██████╔╝╚██████╗╚██████╔╝ ██║ ██║██║ ██║ ██║ ██║╚██████╔╝ ╚████╔╝ ██║ ██║███████╗
606╚═════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝╚══════╝
607*/
608function DCOApproval() {
609 $('#approvalTags').remove();
610 $('.modalV3-body').after('<div id="approvalTags" style="display:block;width:500px;margin:10px auto;"> \
611 <h6>Auto Fill Tags</h6> \
612 <button class="float-left btn btn-default" id="BigBird">BigBird</button> \
613 <button class="float-left btn btn-default" id="state_name: PendingHardwareFix">EBS</button> \
614 <button class="float-left btn btn-default" id="R2D2">R2D2</button> \
615 <button class="float-left btn btn-default" id="LEMON">LEMON</button> \
616 <button class="float-left btn btn-default" id="Host is Powered Off">OFF</button> \
617 <button class="float-left btn btn-default" id="Vetting">Vetting</button> \
618 <button class="float-left btn btn-default" id="Requester Approved">Requester Approved</button> \
619 <br /><br /> \
620 </div>');
621 // If any button is clicked then update the Description tag
622 $('#approvalTags button').unbind().on('click', function(event) {
623 // Grab the ID of the button the user clicked
624 var buttonId = $(this).attr('id');
625 $('input[ng_model="reason"]').val(buttonId);
626 // Simulate a keypress
627 var typeEvent = document.createEvent("HTMLEvents");
628 typeEvent.initEvent("change", false, true);
629 $('input[ng_model="reason"]')[0].dispatchEvent(typeEvent);
630 });
631
632 if ($('#workready').length == 0){
633 // Store the short description
634 var shortDes = $('#current-result span:eq(1)').text().trim();
635 var index = shortDes.indexOf('assetId');
636 // Check if the asset ID is in the short description
637 if (index > -1){
638 var ttNumber = $('#current-result div div span:eq(0)').text().trim();
639 GM.xmlHttpRequest({
640 method: "GET",
641 url: 'https://myday-website-pdx.amazon.com/tickets/' + ttNumber + '/location',
642 synchronous: false,
643 headers: {
644 "Content-Type": "application/json"
645 },
646 onload: function(response) {
647 // Verify the request has finished
648 if (response.readyState == "4") {
649 // Check if the response is ready for processing
650 if (response.status === 200) {
651 // JSON is recieved. Parse it
652 var jsonResponse = JSON.parse(response.responseText);
653 // Grab the site
654 var apiSite = jsonResponse.site;
655 }
656 }
657 },
658 onerror: function(response) {
659 // Display a notice that check failed.
660 console.log(response);
661 }
662 });
663
664 $('#approvalTags').after('<div id="workready" style="display:block;width:500px;margin:10px auto;"><h6>EBS Workready Status</h6></div>');
665 var beginning = shortDes.indexOf(': ', index) + 2;
666 // Find the index of the comma that comes after the asset id, then subtract the beginning to get the length
667 var ending = shortDes.indexOf(', ', beginning) - beginning;
668 // Store the asset id
669 var foundAsset = shortDes.substr(beginning, ending);
670
671 var checkPDT = shortDes.indexOf('PDT');
672 if (checkPDT > -1){
673 var array = ['pdt1','pdt2','pdt4'];
674 for (var apiSite in array){
675 GM.xmlHttpRequest({
676 method: "GET",
677 url: 'https://ebs-stats.pdt.amazon.com/platform/'+array[apiSite]+'/platform-list?q='+foundAsset,
678 headers: {
679 "Content-Type": "application/json"
680 },
681 onload: function(response) {
682 // JSON is recieved. Parse it
683 var jsonResponse = JSON.parse(response.responseText);
684 var stateName = jsonResponse[0].placementView.stateName;
685 //var color = (stateName == "PendingHardwareFix" ? 'green' : 'red');
686 if (stateName == "PendingHardwareFix" || stateName == "PendingInvestigation"){
687 var color = 'green';
688 }else{
689 var color = 'red';
690 }
691 $('#workready').append('Asset: '+foundAsset+'<br/><div style="color:'+color+'">Status: '+stateName+'</div>');
692 }
693 });
694 }
695 if ($('#workready div').length == 0){
696 $('#workready').append('Asset: '+foundAsset+'<br/><div style="color:red">Please check your Safenet Token</div>');
697 }
698 }else{
699 var array = ['pdx1','pdx2','pdx4'];
700 for (var apiSite in array){
701 GM.xmlHttpRequest({
702 method: "GET",
703 url: 'https://ebs-stats-pdx.amazon.com/platform/'+array[apiSite]+'/platform-list?q='+foundAsset,
704 headers: {
705 "Content-Type": "application/json"
706 },
707 onload: function(response) {
708 // JSON is recieved. Parse it
709 var jsonResponse = JSON.parse(response.responseText);
710 var stateName = jsonResponse[0].placementView.stateName;
711 //var color = (stateName == "PendingHardwareFix" ? 'green' : 'red');
712 if (stateName == "PendingHardwareFix" || stateName == "PendingInvestigation"){
713 var color = 'green';
714 }else{
715 var color = 'red';
716 }
717 $('#workready').append('Asset: '+foundAsset+'<br/><div style="color:'+color+'">Status: '+stateName+'</div>');
718 }
719 });
720 }
721 }
722 }
723 }
724
725}
726
727/*
728███╗ ███╗ ██████╗ ██╗ ██╗███████╗ ██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗ ██████╗ ███████╗ █████╗ ██████╗ ██╗ ██╗
729████╗ ████║██╔═══██╗██║ ██║██╔════╝ ██║ ██║██╔═══██╗██╔══██╗██║ ██╔╝ ██╔══██╗██╔════╝██╔══██╗██╔══██╗╚██╗ ██╔╝
730██╔████╔██║██║ ██║██║ ██║█████╗ ██║ █╗ ██║██║ ██║██████╔╝█████╔╝ ██████╔╝█████╗ ███████║██║ ██║ ╚████╔╝
731██║╚██╔╝██║██║ ██║╚██╗ ██╔╝██╔══╝ ██║███╗██║██║ ██║██╔══██╗██╔═██╗ ██╔══██╗██╔══╝ ██╔══██║██║ ██║ ╚██╔╝
732██║ ╚═╝ ██║╚██████╔╝ ╚████╔╝ ███████╗ ╚███╔███╔╝╚██████╔╝██║ ██║██║ ██╗ ██║ ██║███████╗██║ ██║██████╔╝ ██║
733╚═╝ ╚═╝ ╚═════╝ ╚═══╝ ╚══════╝ ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═════╝ ╚═╝
734*/
735function moveWorkReady() {
736 setTimeout(function() {
737 if ($("#moved").length == 0) {
738 // Move the status summary
739 if ($('#validate-ticket status-summary .communication-label').length > 0) {
740 $('#validate-ticket').prepend($('#validate-ticket status-summary').append('<div id="moved" class="col-md-12 separator"></div>'));
741 }
742 // Move the work ready
743 $('#validate-ticket').prepend($('host-ready-check').parent().append('<div id="moved" class="col-md-12 separator"></div>'));
744 }
745 }, 1000);
746}
747/*
748██╗ ██╗██╗██████╗ ███████╗ ███████╗██╗██████╗ ███████╗ ██████╗ █████╗ ██████╗
749██║ ██║██║██╔══██╗██╔════╝ ██╔════╝██║██╔══██╗██╔════╝ ██╔══██╗██╔══██╗██╔══██╗
750███████║██║██║ ██║█████╗ ███████╗██║██║ ██║█████╗ ██████╔╝███████║██████╔╝
751██╔══██║██║██║ ██║██╔══╝ ╚════██║██║██║ ██║██╔══╝ ██╔══██╗██╔══██║██╔══██╗
752██║ ██║██║██████╔╝███████╗ ███████║██║██████╔╝███████╗ ██████╔╝██║ ██║██║ ██║
753╚═╝ ╚═╝╚═╝╚═════╝ ╚══════╝ ╚══════╝╚═╝╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝
754*/
755function hideSideBar() {
756 // Hide side bar when sev banner is clicked
757 $('#summary-banner-right #current-result div:eq(0)').unbind().on('click', function(event) {
758 $('#summary-banner-left').toggle();
759 $('#navigation').toggle();
760
761 if ($('#summary-banner-right').css('left') == '215px') {
762 $('#summary-banner-right').css('left', '0');
763 } else {
764 $('#summary-banner-right').css('left', '215px');
765 }
766
767 if ($('#result-pane').css('margin-left') == '215px') {
768 $('#result-pane').css({
769 width: 'calc(100vw)',
770 'margin-left': '0px'
771 });
772 } else {
773 $('#result-pane').css({
774 width: 'calc(100vw - 214px)',
775 'margin-left': '215px'
776 });
777 }
778 /*if ($('#summary-banner-left').is(":hidden")){
779 var breakLoop0;
780 window.clearInterval(breakLoop0);
781 prevTT = "";
782 ttNumber = $('#current-result div div span:eq(0)').text().trim();
783 alias = $('.nav.navbar-nav.navbar-right .dropdown .dropdown-toggle .ng-binding').text().trim();
784 console.log("banner click")
785 loopAjax();
786 breakLoop0 = setInterval(function() {
787 loopAjax();
788 }, 600000);
789 }*/
790
791 //POST2API();
792 });
793}
794function POST2API(){
795 var alias = $('.nav.navbar-nav.navbar-right .dropdown .dropdown-toggle .ng-binding').text().trim();
796 var currentVersion = GM.info.script.version;
797 // Get todays date
798 var d = new Date();
799 var month = d.getMonth() + 1;
800 var day = d.getDate();
801 var year = d.getFullYear().toString();
802 var today = year + '-' + (month < 10 ? '0' : '') + month + '-' + (day < 10 ? '0' : '') + day;
803 // Get current time
804 var hours = d.getHours()+7;
805 var currHour = d.getHours();
806 var minutes = d.getMinutes();
807 var seconds = d.getSeconds();
808 var time = (currHour < 10 ? '0' : '') + currHour + ':' + (minutes < 10 ? '0' : '') + minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
809 var dateTime = today + ' ' + time;
810
811 if (alias == ""){
812 return 0;
813 }
814 GM.xmlHttpRequest({
815 method: "GET",
816 url: 'http://pdx-tools.pdx2.amazon.com:2000/api/tech',
817 headers: {
818 "Content-Type": "application/json"
819 },
820 onload: function(response) {
821 // JSON is recieved. Parse it
822 var jsonResponse = JSON.parse(response.responseText);
823 var flag = 0;
824 for (var results in jsonResponse) {
825 var id = jsonResponse[results].id;
826 var tech = jsonResponse[results].alias;
827 if (alias == tech){
828 flag = 1;
829 GM.xmlHttpRequest({
830 method: "PUT",
831 url: "http://pdx-tools.pdx2.amazon.com:2000/api/tech/"+id,
832 headers: {
833 "Content-type": "application/json;charset=UTF-8"
834 },
835 data: JSON.stringify({"alias":alias,"date":dateTime,"version":currentVersion,"id":id}),
836 onload: function(response) {
837 console.log('Done with UPDATE');
838 }
839 });
840 }
841 }
842 if (!flag){
843 GM.xmlHttpRequest({
844 method: "POST",
845 url: "http://pdx-tools.pdx2.amazon.com:2000/api/tech/create",
846 headers: {
847 "Content-type": "application/json;charset=UTF-8"
848 },
849 data: JSON.stringify({"alias":alias,"date":dateTime,"version":currentVersion}),
850 onload: function(response) {
851 console.log('Done with POST');
852 }
853 });
854 }
855 }
856 });
857
858
859
860
861}
862
863function loopAjax(){
864 getTT = $('#current-result div div span:eq(0)').text().trim();
865 console.log(getTT,prevTT,ttNumber)
866 if (getTT != prevTT && getTT != ""){
867 prevTT = getTT;
868 ttNumber = getTT;
869 }
870
871 // Get todays date
872 var d = new Date();
873 var month = d.getMonth() + 1;
874 var day = d.getDate();
875 var year = d.getFullYear().toString();
876 var today = year + '-' + (month < 10 ? '0' : '') + month + '-' + (day < 10 ? '0' : '') + day;
877 // Get current time
878 var hours = d.getHours()+7;
879 var currHour = d.getHours();
880 var minutes = d.getMinutes();
881 var seconds = d.getSeconds();
882 var time = (currHour < 10 ? '0' : '') + currHour + ':' + (minutes < 10 ? '0' : '') + minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
883 var dateTime = today + ' ' + time;
884 //2018-03-29 14:27:00
885 //hide sidebar 03-30-18 10:21 0145376135 tech.workflow.next||work.active.ticket.review|0145376135|PDX|03-30-18 10:21
886
887 $('#summary-banner-right #current-result div:eq(0)').css("color","orange").text(minutes).attr('title', 'Next POST: '+time);
888 var data = "tech.workflow.next|"+alias+"|work.active.ticket.review|"+ttNumber+"|PDX|"+dateTime+"\n";
889 var data1 = "tech.workflow.correspondence|"+alias+"|work.active.ticket.do|"+ttNumber+"|PDX|"+dateTime;
890 console.log('hide sidebar',dateTime,ttNumber,data);
891 //$.post("https://myday-website-pdx.amazon.com/ab/click", {"params":data});
892 // Myday is using JSON.parse on the server. dataType is not needed. Uncomment below line if that changes in the future.
893 //$.ajax({type:'POST',url:'https://myday-website-pdx.amazon.com/ab/click',data: JSON.stringify({"params":data}),dataType:'json',contentType: 'application/json; charset=utf-8'});
894 $.ajax({type:'POST',url:'https://myday-website-pdx.amazon.com/ab/click',data: JSON.stringify({"params":data}),contentType: 'application/json; charset=utf-8'});
895 $.ajax({type:'POST',url:'https://myday-website-pdx.amazon.com/ab/click',data: JSON.stringify({"params":data1}),contentType: 'application/json; charset=utf-8'});
896}
897
898
899/*
900 ██████╗ ██████╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ██████╗ ████████╗ ██████╗ █████╗ ██╗ ██╗███████╗███████╗
901██╔════╝██╔═══██╗██║ ██╔═══██╗██╔══██╗ ██╔══██╗██╔═══██╗██╔═══██╗╚══██╔══╝ ██╔════╝██╔══██╗██║ ██║██╔════╝██╔════╝
902██║ ██║ ██║██║ ██║ ██║██████╔╝ ██████╔╝██║ ██║██║ ██║ ██║ ██║ ███████║██║ ██║███████╗█████╗
903██║ ██║ ██║██║ ██║ ██║██╔══██╗ ██╔══██╗██║ ██║██║ ██║ ██║ ██║ ██╔══██║██║ ██║╚════██║██╔══╝
904╚██████╗╚██████╔╝███████╗╚██████╔╝██║ ██║ ██║ ██║╚██████╔╝╚██████╔╝ ██║ ╚██████╗██║ ██║╚██████╔╝███████║███████╗
905 ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝
906 */
907function colorRootCause() {
908 // Verify that this is the VOF screen
909 if ($('#states .ng-binding.ng-scope.active').text().trim() == "Verification of Fix" && $('#tickets .ng-binding.ng-scope.active').text().trim() == "Verify Fix") {
910 var rootCause = ['Hardware - BBU',
911 'Hardware - Backplane',
912 'Hardware - CPU',
913 'Hardware - Cable',
914 'Hardware - Chassis',
915 'Hardware - Console',
916 'Hardware - Controller',
917 'Hardware - DIMM',
918 'Hardware - Dongle',
919 'Hardware - Fan',
920 'Hardware - GPU',
921 'Hardware - Hard Drive',
922 'Hardware - Jumpers',
923 'Hardware - Motherboard',
924 'Hardware - Network Card',
925 'Hardware - Power Button',
926 'Hardware - Power Supply',
927 'Network - Cable',
928 'Network - Configuration',
929 'Network - Device Replacement',
930 'Network - Fiber',
931 'Network - Interconnect Cable',
932 'Network - Optic',
933 'Network - PSU',
934 'Network - Port Disabled',
935 'Network - Upstream Failure',
936 'Ops - CM',
937 'Ops - Critical Spares Audit',
938 'Ops - Drill',
939 'Ops - Environmental',
940 'Ops - Housekeeping',
941 'Ops - Installation',
942 'Ops - Power Event',
943 'Ops - Project',
944 'Ops - Queue Master',
945 'Ops - Site Audit',
946 'Ops - Training',
947 'Other - Duplicate Ticket',
948 'Other - Need New Resolver Code',
949 'Rack Install - Cabling',
950 'Rack Install - DMI/FRU Error',
951 'Rack Install - Fabric Mismatch',
952 'Rack Install - Invalid Host Asset Scan',
953 'Rack Install - Rack Move',
954 'Software - Automation Error',
955 'Software - BIOS Settings',
956 'Software - File System',
957 'Software - Firmware',
958 'Software - Host Set To Return / DNR',
959 'Software - Provisioning Issue',
960 'Shipment - Snowball',
961 ''
962 ];
963
964 var selectedRootCause = $('#verify div:eq(0) .btn.btn-default.form-control.ui-select-toggle .ui-select-match-text.pull-left span').text();
965 console.log(selectedRootCause);
966 var flag = 0;
967 for (var i = 0; i < rootCause.length; i++) {
968 if (selectedRootCause == rootCause[i]) {
969 flag = 1;
970 console.log('found');
971 }
972 }
973 if (flag == 0) {
974 console.log('red');
975 $('#verify div:eq(0) .btn.btn-default.form-control.ui-select-toggle span.ng-binding.ng-scope').css('color', 'red');
976 } else {
977 console.log('green');
978 $('#verify div:eq(0) .btn.btn-default.form-control.ui-select-toggle span.ng-binding.ng-scope').css('color', 'green');
979 }
980
981 // Check if the root cause has been picked by the user. If so re-run colorRootCause()
982 $('#verify div:eq(0) .btn.btn-default.form-control.ui-select-toggle .ui-select-match-text.pull-left').unbind().one("DOMSubtreeModified", function() {
983 colorRootCause();
984 });
985
986 // Only show the root causes that are usable by our group
987 /*$('.ui-select-choices.ui-select-choices-content.dropdown-menu.ng-scope .ui-select-choices-row.ng-scope').each(function() {
988 var listedRootCause = $(this).text().trim();
989 var flag = 0;
990 for (var i = 0; i < rootCause.length; i++) {
991 if (listedRootCause == rootCause[i]) {
992 flag = 1;
993 }
994 }
995 if (flag == 0) {
996 $(this).remove();
997 }
998 });*/
999
1000 setTimeout(function() {
1001 // Mouseover the top entry as the user filters
1002 if (!$('.ui-select-choices[role="listbox"] div a div:hover').length) {
1003 // Create the event for the mouseover
1004 var triggerEvent = document.createEvent("MouseEvents");
1005 triggerEvent.initEvent("mouseover", true, false);
1006 // Mouseover the site
1007 $('.ui-select-choices[role="listbox"] div a div')[0].dispatchEvent(triggerEvent);
1008 }
1009 }, 500);
1010
1011 // Check if the root cause has been filtered by the user. If so re-run colorRootCause()
1012 $('#verify div:eq(0) .form-control.ui-select-search.ng-valid').unbind().one("DOMSubtreeModified", function() {
1013 colorRootCause();
1014 });
1015 }
1016}
1017/*
1018███████╗███████╗████████╗ ██████╗ ███████╗███████╗██╗ ██╗ █████╗ ██╗ ████████╗ ██╗███╗ ██╗███████╗████████╗██████╗ ██╗ ██╗ ██████╗████████╗██╗ ██████╗ ███╗ ██╗
1019██╔════╝██╔════╝╚══██╔══╝ ██╔══██╗██╔════╝██╔════╝██║ ██║██╔══██╗██║ ╚══██╔══╝ ██║████╗ ██║██╔════╝╚══██╔══╝██╔══██╗██║ ██║██╔════╝╚══██╔══╝██║██╔═══██╗████╗ ██║
1020███████╗█████╗ ██║ ██║ ██║█████╗ █████╗ ██║ ██║███████║██║ ██║ ██║██╔██╗ ██║███████╗ ██║ ██████╔╝██║ ██║██║ ██║ ██║██║ ██║██╔██╗ ██║
1021╚════██║██╔══╝ ██║ ██║ ██║██╔══╝ ██╔══╝ ██║ ██║██╔══██║██║ ██║ ██║██║╚██╗██║╚════██║ ██║ ██╔══██╗██║ ██║██║ ██║ ██║██║ ██║██║╚██╗██║
1022███████║███████╗ ██║ ██████╔╝███████╗██║ ╚██████╔╝██║ ██║███████╗██║ ██║██║ ╚████║███████║ ██║ ██║ ██║╚██████╔╝╚██████╗ ██║ ██║╚██████╔╝██║ ╚████║
1023╚══════╝╚══════╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
1024*/
1025function setDefualtInstruction(dropdownIndex) {
1026 // Auto fill the HWID and part if it's a replace task
1027 setTimeout(function() {
1028 $('.instruction-updated-entry').each(function() {
1029 if ($(this).find('.ng-scope.col-md-11 textarea').length == 1) {
1030 var currTask = $(this).find('.col-md-3:eq(0) .ng-binding.ng-scope').text().trim();
1031 var currHost = $(this).find('.col-md-3:eq(1) .ng-binding.ng-scope').text().trim();
1032 //var currPart = $(this).find('.col-md-3:eq(2) .ng-binding.ng-scope').text().trim();
1033 // Create the event for the mouseover
1034 var triggerEvent = document.createEvent("MouseEvents");
1035 triggerEvent.initEvent("mouseover", true, false);
1036 // Create the event for the click
1037 var clickEvent = document.createEvent("HTMLEvents");
1038 clickEvent.initEvent("click", true, true);
1039 // Create the event for the focus
1040 var focusEvent = document.createEvent("HTMLEvents");
1041 focusEvent.initEvent("focus", false, false);
1042
1043 // Get the current index number of the instruction in this loop
1044 var checkedIndex = $('.instruction-updated-entry.created').index(this);
1045 console.log(dropdownIndex,'instructions index2',checkedIndex);
1046 if (currHost == "") {
1047 // Click the Target Host dropdown
1048 $(this).find('.col-md-3:eq(1) .ng-binding.ng-scope')[0].dispatchEvent(clickEvent);
1049 // Make sure it doesn't contain more than 1 item
1050 if ($(this).find('.col-md-3:eq(1) div[role="option"] .fa-server').length == 1) {
1051 // Mouseover the Target Host
1052 $(this).find('.col-md-3:eq(1) div[role="option"]')[0].dispatchEvent(triggerEvent);
1053 // Click the site
1054 $(this).find('.col-md-3:eq(1) div[role="option"]')[0].dispatchEvent(clickEvent);
1055
1056 // Store $(this) as it can't be passed through setTimeout
1057 var that = $(this);
1058 setTimeout(function() {
1059 // Check if the dropdown that was changed is the same as the one in this loop
1060 if (dropdownIndex == checkedIndex) {
1061 that.find('textarea')[0].dispatchEvent(focusEvent);
1062 }
1063 }, 200);
1064 } else {
1065 $(this).find('.col-md-12')[0].dispatchEvent(clickEvent);
1066 }
1067 }else{
1068 // Check if the dropdown that was changed is the same as the one in this loop
1069 if (dropdownIndex == checkedIndex) {
1070 $(this).find('textarea')[0].dispatchEvent(focusEvent);
1071 }
1072 }
1073
1074 /*if (currTask == "Replace component" && currPart == ""){
1075 // Click the Part dropdown
1076 $(this).find('.col-md-4:eq(2) .ng-binding.ng-scope')[0].dispatchEvent (clickEvent);
1077 // Make sure it doesn't contain more than 1 item
1078 if ($(this).find('.col-md-4:eq(2) div[role="option"]').length == 1){
1079 // Mouseover the Target Host
1080 $(this).find('.col-md-4:eq(2) div[role="option"]')[0].dispatchEvent(triggerEvent);
1081 // Click the site
1082 $(this).find('.col-md-4:eq(2) div[role="option"]')[0].dispatchEvent(clickEvent);
1083 }else{
1084 $(this).find('.col-md-12')[0].dispatchEvent(clickEvent);
1085 }
1086 }*/
1087 }
1088 });
1089 }, 300);
1090}
1091/*
1092██████╗ ███████╗███████╗ ██████╗██████╗ ██╗██████╗ ████████╗██╗ ██████╗ ███╗ ██╗ ████████╗ █████╗ ██████╗ ███████╗
1093██╔══██╗██╔════╝██╔════╝██╔════╝██╔══██╗██║██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║ ╚══██╔══╝██╔══██╗██╔════╝ ██╔════╝
1094██║ ██║█████╗ ███████╗██║ ██████╔╝██║██████╔╝ ██║ ██║██║ ██║██╔██╗ ██║ ██║ ███████║██║ ███╗███████╗
1095██║ ██║██╔══╝ ╚════██║██║ ██╔══██╗██║██╔═══╝ ██║ ██║██║ ██║██║╚██╗██║ ██║ ██╔══██║██║ ██║╚════██║
1096██████╔╝███████╗███████║╚██████╗██║ ██║██║██║ ██║ ██║╚██████╔╝██║ ╚████║ ██║ ██║ ██║╚██████╔╝███████║
1097╚═════╝ ╚══════╝╚══════╝ ╚═════╝╚═╝ ╚═╝╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
1098*/
1099function descriptionTags() {
1100 // If this is the instruction screen and the description tags don't already exist
1101 //if (($('#wf-pane .instructions').text().indexOf('Configure instructions for technician') > -1 || $('#tickets .ng-binding.ng-scope.active').text().trim() == "Review Instructions") && !$('#descriptionTags').length > 0){
1102 console.log('called tags');
1103 if ($('#descriptionTags').length == 0) {
1104 console.log('run tags');
1105 // Get the ticket number
1106 ttNumber = $('#current-result div div span:eq(0)').text().trim();
1107 // Create the Description tag area
1108 //$('#wf-navigation').before('<div id="descriptionTags" style="position:absolute;bottom:0;right:10px"> \
1109 //style="display:block;width:500px;margin:10px auto;"
1110 $('#setup-instructions-index, #hideInstructions').parent().prepend('<div id="descriptionTags"> \
1111 <h6>Description Tags</h6> \
1112 <button class="float-left btn btn-default" id="OOB-IVT">OOB-IVT</button> \
1113 <button class="float-left btn btn-default" id="REDDOT">REDDOT</button> \
1114 <button class="float-left btn btn-default" id="UNSEATED">UNSEATED</button> \
1115 <button class="float-left btn btn-default" id="RSD">RSD</button> \
1116 <button class="float-left btn btn-default" id="MOBO">MOBO</button> \
1117 <button class="float-left btn btn-default" id="HDD">HDD</button> \
1118 <button class="float-left btn btn-default" id="SSD">SSD</button> \
1119 <button class="float-left btn btn-default" id="DIMM">DIMM</button> \
1120 <button class="float-left btn btn-default" id="PSU">PSU</button> \
1121 <button class="float-left btn btn-default" id="OS Rebuild">OS Rebuild</button> \
1122 <br /><br /> \
1123 </div>');
1124
1125 // If any button is clicked then update the Description tag
1126 $('#descriptionTags button').unbind().on('click', function(event) {
1127 // Grab the ID of the button the user clicked
1128 var buttonId = '[' + $(this).attr('id') + ']';
1129 var ID = $(this).attr('id');
1130 var currDescription = '';
1131 var newDescription = '';
1132 var color = '';
1133 var status = '';
1134
1135 // Grab the current description for the API
1136 // {"id": "0087255372","description": "[PDX2-Room1-POD16-2121] Host requires troubleshooting s3-prod-r2d2-b63309.pdx2.amazon.com"}]
1137 GM.xmlHttpRequest({
1138 method: "GET",
1139 url: 'https://myday-website-pdx.amazon.com/tickets/' + ttNumber + '/simple',
1140 headers: {
1141 "Content-Type": "application/json"
1142 },
1143 onload: function(response) {
1144 // JSON is recieved. Parse it
1145 var jsonResponse = JSON.parse(response.responseText);
1146 currDescription = jsonResponse.description;
1147 console.log(currDescription.length);
1148 // Verify that the API was able to grab the description
1149 if (currDescription.length > 2) {
1150 if (currDescription.indexOf(buttonId) > -1) {
1151 newDescription = currDescription.replace(buttonId, '');
1152 color = 'red';
1153 status = 'Removed';
1154 } else {
1155 newDescription = buttonId + currDescription;
1156 color = 'green';
1157 status = 'Added';
1158 }
1159
1160 // Update the description with the tags and notify user when it's done
1161 GM.xmlHttpRequest({
1162 method: "POST",
1163 url: "https://myday-website-pdx.amazon.com/tickets/update_description",
1164 headers: {
1165 "Content-type": "application/x-www-form-urlencoded"
1166 },
1167 data: "ticket_id=" + ttNumber + "&description=" + newDescription,
1168 onload: function(response) {
1169 console.log('Done Updating Tags');
1170 console.log(color + ' ' + status + ' ' + buttonId);
1171 // Notify user when it's done
1172 $('#descriptionTags').append('<div id="notify"><div style="display: inline-block"><h4><font color="' + color + '">' + status + ' tag ' + buttonId + '</font></h4></div> <a><i id="showAlert" class="fa fa-times-circle"></i></a><br /></div>');
1173 $('#showAlert').click(function(event) {
1174 $('#notify').remove();
1175 });
1176 if (color == 'green') {
1177 $('#' + ID).css('color', 'green');
1178 } else {
1179 $('#' + ID).css('color', 'black');
1180 }
1181 }
1182 });
1183 } else {
1184 console.log('currDescription is <= 2');
1185 }
1186 }
1187 });
1188 });
1189 }
1190 // Display a warning if the replace task needs a drive map
1191 var hostTypes = [
1192 {manufacturer: 'FOXCONN',model: 'ASH13'},
1193 {manufacturer: 'SYNNEX',model: 'ASH13'},
1194 {manufacturer: 'ZT',model: 'ASH13'},
1195 {manufacturer: 'FOXCONN',model: 'ASH14'},
1196 {manufacturer: 'QUANTA',model: 'ASH14'},
1197 {manufacturer: 'SYNNEX',model: 'ASH14'},
1198 {manufacturer: 'ZT',model: 'ASH14'},
1199 {manufacturer: 'FOXCONN',model: 'ASH15'},
1200 {manufacturer: 'FOXCONN',model: 'SPICY15'},
1201 {manufacturer: 'FOXCONN',model: 'DDBSPICY15'},
1202 {manufacturer: 'QUANTA',model: 'ASH15'},
1203 {manufacturer: 'SYNNEX',model: 'ASH15'},
1204 {manufacturer: 'ZT',model: 'SATURN14'},
1205 {manufacturer: 'QUANTA',model: 'SATURN14'},
1206 {manufacturer: 'FOXCONN',model: 'SATURN14'},
1207 {manufacturer: 'QUANTA',model: 'SATURNB14'},
1208 {manufacturer: 'FOXCONN',model: 'JUNO15'},
1209 {manufacturer: 'QUANTA',model: 'OHIO6T14'},
1210 {manufacturer: 'ZT',model: 'OHIO6T14'}
1211 ];
1212 // Make sure the blurb is not already displayed and that there is a replace task
1213 var collapsed = $('.col-md-3 div').text().trim().indexOf('Replace component');
1214 var uncollapsed = $('.ui-select-match-text.pull-left span').text().trim().indexOf('Replace component');
1215 if (collapsed > -1 || uncollapsed > -1){
1216 if ($('#driveMap').length == 0) {
1217 for (var i = 0; i < hostTypes.length; i++) {
1218 if (hostTypes[i].manufacturer.toUpperCase() == manufacturer.toUpperCase() && hostTypes[i].model.toUpperCase() == model.toUpperCase()){
1219 //http://pdx-tools.pdx2.amazon.com/drivemapper_v1.9.py
1220 $('#instruction-updated-list .row:last').before('<div id=driveMap><h4><font color=red> \
1221 Please include a <a href="http://pdx-tools.pdx2.amazon.com:3000/crusade/DriveMap" target=_blank>drive map</a> for the replace task if this ticket is for the media team.\
1222 </font></h4><div>');
1223 }
1224 }
1225 }
1226 }else{
1227 $('#driveMap').remove();
1228 }
1229}
1230/*
1231███████╗██╗ ██╗ ██████╗ ██╗ ██╗ ██████╗ ██████╗ ██████╗ ██████╗ ███████╗███████╗██████╗ ██████╗ ███╗ ██╗██████╗ ███████╗███╗ ██╗ ██████╗███████╗
1232██╔════╝██║ ██║██╔═══██╗██║ ██║ ██╔════╝██╔═══██╗██╔══██╗██╔══██╗██╔════╝██╔════╝██╔══██╗██╔═══██╗████╗ ██║██╔══██╗██╔════╝████╗ ██║██╔════╝██╔════╝
1233███████╗███████║██║ ██║██║ █╗ ██║ ██║ ██║ ██║██████╔╝██████╔╝█████╗ ███████╗██████╔╝██║ ██║██╔██╗ ██║██║ ██║█████╗ ██╔██╗ ██║██║ █████╗
1234╚════██║██╔══██║██║ ██║██║███╗██║ ██║ ██║ ██║██╔══██╗██╔══██╗██╔══╝ ╚════██║██╔═══╝ ██║ ██║██║╚██╗██║██║ ██║██╔══╝ ██║╚██╗██║██║ ██╔══╝
1235███████║██║ ██║╚██████╔╝╚███╔███╔╝ ╚██████╗╚██████╔╝██║ ██║██║ ██║███████╗███████║██║ ╚██████╔╝██║ ╚████║██████╔╝███████╗██║ ╚████║╚██████╗███████╗
1236╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚══════╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═════╝ ╚══════╝╚═╝ ╚═══╝ ╚═════╝╚══════╝
1237*/
1238function showCorrespondence() {
1239 // If the correspondence box doesn't exist yet and this is not in a batch then add it to the page
1240 if ($('#showTitle').length == 0 && $('#batch-details-container').length == 0) {
1241 ttNumber = $('#current-result div div span:eq(0)').text().trim();
1242 // Create the correspondence box
1243 $('#diag-form').parent().prepend(`<h6 id="showTitle" title="Myday_Tweaks">Correspondence</h6>
1244 <div class="form-group">
1245 <textarea id="showTextarea" class="form-control ng-pristine ng-untouched ng-invalid ng-invalid-required" ng_disabled="adding_chat" placeholder="Correspondence" required="true" rows="3"></textarea>
1246 </div>
1247 <div class="form-group">
1248 <button class="float-right btn btn-default" id="showButton">Add</button>
1249 </div> <br />`);
1250
1251 // If the Add button is clicked then update the correspondence
1252 $('#showButton').unbind().on('click', function(event) {
1253 console.log($('#showTextarea').val());
1254 var textArea = $('#showTextarea').val();
1255 GM.xmlHttpRequest({
1256 method: "POST",
1257 url: "https://myday-website-pdx.amazon.com/tickets/update_correspondence",
1258 headers: {
1259 "Content-type": "application/x-www-form-urlencoded"
1260 },
1261 data: `ticket_id=${ttNumber}&entry=${textArea}`,
1262 onload: function(response) {
1263 // Check and post the update in the correspondence
1264 // [{"log": "This case was automatically closed."},{"log": "resolving"}]
1265 GM.xmlHttpRequest({
1266 method: "GET",
1267 url: 'https://myday-website-pdx.amazon.com/tickets/' + ttNumber + '/communication',
1268 headers: {
1269 "Content-Type": "application/json"
1270 },
1271 onload: function(response) {
1272 // JSON is recieved. Parse it
1273 var jsonResponse = JSON.parse(response.responseText);
1274 // Grab the first line of the correspondence
1275 var newTextArea = textArea.split("\n", 1);
1276
1277 // Grab the most recent entry (Should be the one just submitted above)
1278 var apiLog = jsonResponse[0].log;
1279 if (apiLog.indexOf(newTextArea) > -1) {
1280 // Update the communication area
1281 $('#communication-entries-section').prepend('<communication-entry class="ng-scope ng-isolate-scope" entry="entry" add_toggleable_entry_callback="addToggleableEntryCallback" ng_repeat="entry in ticket.communication track by (ticket.communication.length - $index)" ticket="ticket" read-only="read_only"> \
1282 <div class="communication-entry"> \
1283 <div class="entry-type ng-binding">Correspondence</div> \
1284 <div class="ng-binding">MyDay_Tweaks - 1 second ago</div> \
1285 <div class="entry-min ng-binding" ng_class="{visibility-hidden: view_props && view_props.toggleable && view_props.expanded}">' + textArea + '</div> \
1286 </div> \
1287 </communication-entry>');
1288 $('#communication-entries-section').prepend('<!-- ngRepeat: entry in ticket.communication track by (ticket.communication.length - $index) -->');
1289
1290 $('#showTextarea').val('');
1291 } else {
1292 // Failed to find the new entry. Let user know that it may have still gone through
1293 $('#communication-entries-section').prepend('<communication-entry class="ng-scope ng-isolate-scope" entry="entry" add_toggleable_entry_callback="addToggleableEntryCallback" ng_repeat="entry in ticket.communication track by (ticket.communication.length - $index)" ticket="ticket" read-only="read_only"> \
1294 <div class="communication-entry"> \
1295 <div class="entry-type ng-binding">Correspondence</div> \
1296 <div class="ng-binding">MyDay_Tweaks - 1 second ago</div> \
1297 <div class="entry-min ng-binding" ng_class="{visibility-hidden: view_props && view_props.toggleable && view_props.expanded}">[Unable to find new entry. Check V1 to verify that it went through]<br />' + textArea + '</div> \
1298 </div> \
1299 </communication-entry>');
1300 $('#communication-entries-section').prepend('<!-- ngRepeat: entry in ticket.communication track by (ticket.communication.length - $index) -->');
1301
1302 $('#showTextarea').val('');
1303 }
1304 },
1305 onerror: function(response) {
1306 // Display a notice that check failed.
1307 console.log(response);
1308 }
1309 });
1310 },
1311 onerror: function(e) {
1312 textArea = 'Error - Unable to post';
1313 console.error('**** error ', e);
1314 },
1315 onabort: function(e) {
1316 textArea = 'Error - Unable to post';
1317 console.error('**** abort ', e);
1318 },
1319 ontimeout: function(e) {
1320 textArea = 'Error - Unable to post';
1321 console.error('**** timeout ', e);
1322 }
1323 });
1324 });
1325 }
1326}
1327
1328function showWorklog(){
1329 // If the worklog box doesn't exist yet and it's in a batch then add it to the page
1330 console.log('showWorklog')
1331 if ($('#showTitle').length == 0 && $('#batch-details-container').length > 0 && $('#diag-form').parent().find('h6').text().trim() != 'Diagnostics'){
1332 console.log('showWorklog success')
1333 ttNumber = $('#current-result div div span:eq(0)').text().trim();
1334 // Create the worklog box
1335 $('#diag-form').parent().append('<h6 id="showTitle" title="Myday_Datatech">Diagnostics</h6> \
1336 <div class="form-group"> \
1337 <textarea id="showTextarea" class="form-control ng-pristine ng-untouched ng-invalid ng-invalid-required" ng_disabled="adding_chat" placeholder="Diagnostics" required="true" rows="3"></textarea> \
1338 </div> \
1339 <div class="form-group"> \
1340 <button class="float-right btn btn-default" id="showWorklogButton">Add</button> \
1341 </div> <br /><br /><br />');
1342
1343 // If the Add button is clicked then update the worklog
1344 $('#showWorklogButton').unbind().on('click', function(event) {
1345 console.log($('#showTextarea').val())
1346 var textArea = $('#showTextarea').val();
1347 GM.xmlHttpRequest({
1348 method: "POST",
1349 url: "https://myday-website-pdx.amazon.com/tickets/update_work_log",
1350 headers: { "Content-type" : "application/x-www-form-urlencoded" },
1351 data: "ticket_id="+ttNumber+"&entry="+textArea,
1352 onload: function(response) {
1353 // Check and post the update in the worklog
1354 // [{"log": "This case was automatically closed."},{"log": "resolving"}]
1355 GM.xmlHttpRequest({
1356 method: "GET",
1357 url: 'https://myday-website-pdx.amazon.com/tickets/'+ttNumber+'/communication',
1358 headers: {
1359 "Content-Type": "application/json"
1360 },
1361 onload: function(response) {
1362 // JSON is recieved. Parse it
1363 var jsonResponse = JSON.parse(response.responseText);
1364 // Grab the first line of the correspondence
1365 var newTextArea = textArea.split("\n",1);
1366
1367 // Grab the most recent entry (Should be the one just submitted above)
1368 var apiLog = jsonResponse[0].log;
1369 if (apiLog.indexOf(newTextArea) > -1){
1370 // Update the communication area
1371 $('#communication-entries-section').prepend('<communication-entry class="ng-scope ng-isolate-scope" entry="entry" add_toggleable_entry_callback="addToggleableEntryCallback" ng_repeat="entry in ticket.communication track by (ticket.communication.length - $index)" ticket="ticket" read-only="read_only"> \
1372 <div class="communication-entry"> \
1373 <div class="entry-type ng-binding">Correspondence</div> \
1374 <div class="ng-binding">MyDay_Tweaks - 1 second ago</div> \
1375 <div class="entry-min ng-binding" ng_class="{visibility-hidden: view_props && view_props.toggleable && view_props.expanded}">'+textArea+'</div> \
1376 </div> \
1377 </communication-entry>');
1378 $('#communication-entries-section').prepend('<!-- ngRepeat: entry in ticket.communication track by (ticket.communication.length - $index) -->');
1379
1380 $('#showTextarea').val('');
1381 }else{
1382 // Failed to find the new entry. Let user know that it may have still gone through
1383 $('#communication-entries-section').prepend('<communication-entry class="ng-scope ng-isolate-scope" entry="entry" add_toggleable_entry_callback="addToggleableEntryCallback" ng_repeat="entry in ticket.communication track by (ticket.communication.length - $index)" ticket="ticket" read-only="read_only"> \
1384 <div class="communication-entry"> \
1385 <div class="entry-type ng-binding">Correspondence</div> \
1386 <div class="ng-binding">MyDay_Tweaks - 1 second ago</div> \
1387 <div class="entry-min ng-binding" ng_class="{visibility-hidden: view_props && view_props.toggleable && view_props.expanded}">[Unable to find new entry. Check V1 to verify that it went through]<br />'+textArea+'</div> \
1388 </div> \
1389 </communication-entry>');
1390 $('#communication-entries-section').prepend('<!-- ngRepeat: entry in ticket.communication track by (ticket.communication.length - $index) -->');
1391
1392 $('#showTextarea').val('');
1393 }
1394 },
1395 onerror: function(response) {
1396 // Display a notice that check failed.
1397 console.log(response);
1398 }
1399 });
1400 },
1401 onerror: function(e) {
1402 textArea = 'Error - Unable to post';
1403 console.error('**** error ', e);
1404 },
1405 onabort: function(e) {
1406 textArea = 'Error - Unable to post';
1407 console.error('**** abort ', e);
1408 },
1409 ontimeout: function(e) {
1410 textArea = 'Error - Unable to post';
1411 console.error('**** timeout ', e);
1412 }
1413 });
1414 });
1415 }
1416}
1417
1418/*
1419██████╗ ███████╗ ██████╗ ██╗ ██╗███████╗███████╗████████╗ ██████╗ █████╗ ██████╗ ████████╗███████╗
1420██╔══██╗██╔════╝██╔═══██╗██║ ██║██╔════╝██╔════╝╚══██╔══╝ ██╔══██╗██╔══██╗██╔══██╗╚══██╔══╝██╔════╝
1421██████╔╝█████╗ ██║ ██║██║ ██║█████╗ ███████╗ ██║ ██████╔╝███████║██████╔╝ ██║ ███████╗
1422██╔══██╗██╔══╝ ██║▄▄ ██║██║ ██║██╔══╝ ╚════██║ ██║ ██╔═══╝ ██╔══██║██╔══██╗ ██║ ╚════██║
1423██║ ██║███████╗╚██████╔╝╚██████╔╝███████╗███████║ ██║ ██║ ██║ ██║██║ ██║ ██║ ███████║
1424╚═╝ ╚═╝╚══════╝ ╚══▀▀═╝ ╚═════╝ ╚══════╝╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚══════╝
1425*/
1426// Auto populate the CTI
1427function requestParts() {
1428 var ttNumber = $('#current-result div div span:eq(0)').text().trim();
1429 GM.xmlHttpRequest({
1430 method: "GET",
1431 url: 'https://myday-website-pdx.amazon.com/tickets/' + ttNumber + '/location',
1432 synchronous: false,
1433 headers: {
1434 "Content-Type": "application/json"
1435 },
1436 onload: function(response) {
1437 // Verify the request has finished
1438 if (response.readyState == "4") {
1439 // Check if the response is ready for processing
1440 if (response.status === 200) {
1441 // JSON is recieved. Parse it
1442 var jsonResponse = JSON.parse(response.responseText);
1443 // Grab the site
1444 var apiSite = jsonResponse.site;
1445 // Create the event for the click
1446 var clickEvent = document.createEvent("HTMLEvents");
1447 clickEvent.initEvent("click", true, true);
1448 // Create the event for the mouseover
1449 var triggerEvent = document.createEvent("MouseEvents");
1450 triggerEvent.initEvent("mouseover", true, false);
1451
1452 console.log('Request Parts ' + apiSite);
1453 /* Request Parts Screen */
1454 if (typeof apiSite != typeof undefined && $('assignment-save').length == 1) {
1455 // Click on the dropdown to show the Favorites
1456 $('div[placeholder="Select one"] span')[0].dispatchEvent(clickEvent);
1457 // Loop through the sites and find the current site for the host
1458 $('.ui-select-choices-row[role="option"] a div').each(function() {
1459 var dropdownCategory = $(this).text().trim();
1460 if (dropdownCategory == apiSite.replace('PDT', 'PDX') + ' Logistics') {
1461 // Mouseover the site
1462 $(this)[0].dispatchEvent(triggerEvent);
1463 // Click the site
1464 $(this)[0].dispatchEvent(clickEvent);
1465 return false;
1466 }
1467 });
1468
1469 /*// Click on the dropdown to show the sites
1470 $('.ui-select-match[placeholder="Site"] span')[0].dispatchEvent (clickEvent);
1471 // Loop through the sites and find the current site for the host
1472 $('.ui-select-choices[role="listbox"] div a div').each(function() {
1473 var dropdownSite = $(this).text().trim();
1474 if (dropdownSite == apiSite.replace('PDT','PDX')){
1475 // Mouseover the site
1476 $(this)[0].dispatchEvent(triggerEvent);
1477 // Click the site
1478 $(this)[0].dispatchEvent (clickEvent);
1479 return false;
1480 }else{
1481 // Remove sites we don't want
1482 $(this).parent().parent().remove();
1483 }
1484 });*/
1485 }
1486 }
1487 }
1488 },
1489 onerror: function(response) {
1490 // Display a notice that check failed.
1491 console.log(response);
1492 }
1493 });
1494}
1495
1496
1497/*
1498 ██████╗ ██████╗ ██╗ ██████╗ ██████╗ ██████╗ ██╗███╗ ██╗███████╗
1499██╔════╝██╔═══██╗██║ ██╔═══██╗██╔══██╗ ██╔══██╗██║████╗ ██║██╔════╝
1500██║ ██║ ██║██║ ██║ ██║██████╔╝ ██████╔╝██║██╔██╗ ██║███████╗
1501██║ ██║ ██║██║ ██║ ██║██╔══██╗ ██╔══██╗██║██║╚██╗██║╚════██║
1502╚██████╗╚██████╔╝███████╗╚██████╔╝██║ ██║ ██████╔╝██║██║ ╚████║███████║
1503 ╚═════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝╚═╝ ╚═══╝╚══════╝
1504*/
1505function colorBins() {
1506 var excludeBins = ['PDX2.PARTS.MS201A38',
1507 'PDX2.PARTS.MS201A39',
1508 'PDX2.PARTS.MS201A40',
1509 'PDX2.PARTS.MS201A41',
1510 'PDX2.PARTS.MS201A42',
1511 'PDX2.PARTS.MS201B39',
1512 'PDX2.PARTS.MS201B40',
1513 'PDX2.PARTS.MS201B41',
1514 'PDX2.PARTS.MS201B42',
1515 'PDX2.PARTS.MS201C38',
1516 'PDX2.PARTS.MS201C39',
1517 'PDX2.PARTS.MS201C40',
1518 'PDX2.PARTS.MS201C41',
1519 'PDX2.PARTS.MS201C42',
1520 'PDX4.PARTS.NCR1C1',
1521 'PDX4.PARTS.MS201E41',
1522 'PDX4.PARTS.MS201D41',
1523 'PDX4.PARTS.MS201C41',
1524 'PDX4.PARTS.MS201B41',
1525 'PDX4.PARTS.MS201A41',
1526 'PDX4.PARTS.MS201E42',
1527 'PDX4.PARTS.MS201D42',
1528 'PDX4.PARTS.MS201C42',
1529 'PDX4.PARTS.MS201B42',
1530 'PDX4.PARTS.MS201A42',
1531 'PDX4.PARTS.MS201D6',
1532 'PDX4.PARTS.MS201B5',
1533 'PDX4.PARTS.MS201B6',
1534 'PDX4.PARTS.MS201B21',
1535 'PDX4.PARTS.MS201E20',
1536 'PDX4.PARTS.MS201E6',
1537 'PDX4.PARTS.MS201A3',
1538 ];
1539
1540 //$('#allocate-table tbody tr').each(function() {
1541 $('#parts-search-results table tbody tr').each(function() {
1542 var binLoc = $(this).find('td:eq(2)').text().trim();
1543 var siteIndex = binLoc.indexOf('.');
1544 var binIndex = binLoc.indexOf('.', siteIndex);
1545
1546 var found = 0;
1547 for (var i = 0; i < excludeBins.length; i++) {
1548 if (binLoc == excludeBins[i] || binLoc.indexOf('LIQ1A1') > -1 || binLoc.indexOf('PDX2.PARTS.MS40') > -1) {
1549 found = 1;
1550 }
1551 // S3 Project Bin for S3 R2D2 tickets
1552 console.log(binLoc);
1553 if (binLoc.indexOf('PDX2.PARTS.MS402A4') > -1) {
1554 $(this).find('td:eq(2)').empty().append('PDX2.PARTS.MS402A4 (S3 Project)');
1555 console.log('found bin');
1556 }
1557 }
1558 if (found) {
1559 $(this).css("color", "red");
1560 } else {
1561 $(this).css("color", "green");
1562 }
1563 });
1564
1565 // Align the 'Allocate' button to the right
1566 $('#parts-search-results .btn.btn-primary').css('float', 'right');
1567
1568 // Expand the IPNs/MPNs search field
1569 $('#allocate-main .col-md-3').css('width', '50%');
1570
1571 // Auto choose site
1572 setTimeout(function() {
1573 // Check if the location field is empty
1574 var diagStep = $('#tickets .ng-binding.ng-scope.active').text().trim();
1575 if (($('#allocate-main .col-md-2 .ui-select-match span').length == 0 && diagStep == "Allocate Parts") || ($('.ui-select-match[placeholder="Site"]').text().trim() == "Site" && diagStep == "Request Parts")) {
1576 var ttNumber = $('#current-result div div span:eq(0)').text().trim();
1577 GM.xmlHttpRequest({
1578 method: "GET",
1579 url: 'https://myday-website-pdx.amazon.com/tickets/' + ttNumber + '/location',
1580 synchronous: false,
1581 headers: {
1582 "Content-Type": "application/json"
1583 },
1584 onload: function(response) {
1585 // Verify the request has finished
1586 if (response.readyState == "4") {
1587 // Check if the response is ready for processing
1588 if (response.status === 200) {
1589 // JSON is recieved. Parse it
1590 var jsonResponse = JSON.parse(response.responseText);
1591 // Grab the site
1592 var apiSite = jsonResponse.site;
1593 // Create the event for the click
1594 var clickEvent = document.createEvent("HTMLEvents");
1595 clickEvent.initEvent("click", true, true);
1596 // Create the event for the mouseover
1597 var triggerEvent = document.createEvent("MouseEvents");
1598 triggerEvent.initEvent("mouseover", true, false);
1599 /* Allocate Parts Screen */
1600 var diagStep = $('#tickets .ng-binding.ng-scope.active').text().trim();
1601 if (diagStep == "Allocate Parts") {
1602 var loops = (apiSite.indexOf('PDT') > -1 ? 2 : 1);
1603 for (var i = 0; i < loops; i++) {
1604 // Click on the dropdown to show the sites
1605 $('#allocate-main .col-md-2 input')[0].dispatchEvent(clickEvent);
1606 // Loop through the sites and find the current site for the host
1607 $('#allocate-main .col-md-2 ul:eq(0) div span').each(function() {
1608 var dropdownSite = $(this).text().trim();
1609 if (dropdownSite == apiSite.replace('PDT', 'PDX') || dropdownSite == apiSite) {
1610 // Mouseover the site
1611 $(this)[0].dispatchEvent(triggerEvent);
1612 // Click the site
1613 $(this)[0].dispatchEvent(clickEvent);
1614 return false;
1615 } else {
1616 // Remove sites we don't want
1617 $(this).parent().parent().remove();
1618 }
1619 });
1620 }
1621 } else if (diagStep == "Request Parts") {
1622 console.log('Request Parts ' + apiSite);
1623 /* Request Parts Screen */
1624 if (typeof apiSite != typeof undefined) {
1625 // Click on the dropdown to show the Favorites
1626 $('div[placeholder="Favorites"] span')[0].dispatchEvent(clickEvent);
1627 // Loop through the sites and find the current site for the host
1628 $('.ui-select-choices[role="listbox"] div a div').each(function() {
1629 var dropdownCategory = $(this).text().trim();
1630 if (dropdownCategory == apiSite.replace('PDT', 'PDX') + ' Logistics') {
1631 // Mouseover the site
1632 $(this)[0].dispatchEvent(triggerEvent);
1633 // Click the site
1634 $(this)[0].dispatchEvent(clickEvent);
1635 return false;
1636 }
1637 });
1638
1639 // Click on the dropdown to show the sites
1640 $('.ui-select-match[placeholder="Site"] span')[0].dispatchEvent(clickEvent);
1641 // Loop through the sites and find the current site for the host
1642 $('.ui-select-choices[role="listbox"] div a div').each(function() {
1643 var dropdownSite = $(this).text().trim();
1644 if (dropdownSite == apiSite.replace('PDT', 'PDX')) {
1645 // Mouseover the site
1646 $(this)[0].dispatchEvent(triggerEvent);
1647 // Click the site
1648 $(this)[0].dispatchEvent(clickEvent);
1649 return false;
1650 } else {
1651 // Remove sites we don't want
1652 $(this).parent().parent().remove();
1653 }
1654 });
1655 }
1656 }
1657 }
1658 }
1659 },
1660 onerror: function(response) {
1661 // Display a notice that check failed.
1662 console.log(response);
1663 }
1664 });
1665 }
1666 }, 1000);
1667}
1668
1669/*
1670██╗ ██╗██╗██████╗ ███████╗ ██████╗ ██████╗ ██╗██╗ ██╗███████╗ ██╗ ██╗ ██████╗ ██╗ ██████╗
1671██║ ██║██║██╔══██╗██╔════╝ ██╔══██╗██╔══██╗██║██║ ██║██╔════╝ ██║ ██║██╔═══██╗██║ ██╔══██╗
1672███████║██║██║ ██║█████╗ ██║ ██║██████╔╝██║██║ ██║█████╗ ███████║██║ ██║██║ ██║ ██║
1673██╔══██║██║██║ ██║██╔══╝ ██║ ██║██╔══██╗██║╚██╗ ██╔╝██╔══╝ ██╔══██║██║ ██║██║ ██║ ██║
1674██║ ██║██║██████╔╝███████╗ ██████╔╝██║ ██║██║ ╚████╔╝ ███████╗ ██║ ██║╚██████╔╝███████╗██████╔╝
1675╚═╝ ╚═╝╚═╝╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═══╝ ╚══════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═════╝
1676*/
1677function hideDriveHold(){
1678 console.log('drive hold')
1679 if ($('#driveHoldHide').length == 0){
1680 $('#sort-and-pagination button:eq(0)').after(`
1681 <button id="driveHoldHide" class="btn btn-default btn-sm ng-scope" tabindex="0">
1682 <span><b>Hide:</b> Drive Hold/Ready Tickets</span>
1683 </button>
1684 <button id="driveHoldShow" class="btn btn-default btn-sm ng-scope" tabindex="0" style="display:none;color:red">
1685 <span><b>Show:</b> Drive Hold/Ready Tickets</span>
1686 </button>
1687 <span id="countList"><div></div><span>`);
1688
1689 $('#driveHoldHide').unbind().on('click', function() {
1690 hideElement();
1691 });
1692 $('#driveHoldShow').unbind().on('click', function() {
1693 showElement();
1694 });
1695 }
1696 if ($('#driveHoldHide').is(":visible")){
1697 showElement();
1698 }else{
1699 hideElement();
1700 }
1701}
1702
1703function hideElement(){
1704 // Show all the tickets so that we can hide them again.
1705 $('search-result').show();
1706 var countList = 0;
1707 $('#driveHoldHide').hide();
1708 $('#driveHoldShow').show();
1709 $('search-result').each(function(){
1710 var headerTitle = $(this).find('.search-result-header div:eq(0) div:eq(2)').text().trim();
1711 if (headerTitle.indexOf('data-tech-drive-hold') > -1 || headerTitle.indexOf('data-tech-drive-ready') > -1){
1712 $(this).hide();
1713 }else{
1714 countList++;
1715 }
1716 });
1717 $('#countList').show().text(`Viewing: ${countList}`);
1718}
1719function showElement(){
1720 $('#driveHoldShow').hide();
1721 $('#driveHoldHide').show();
1722 /*$('search-result').each(function(){
1723 var headerTitle = $(this).find('.search-result-header div:eq(0) div:eq(2)').text().trim();
1724 if (headerTitle.indexOf('data-tech-drive-hold') > -1 || headerTitle.indexOf('data-tech-drive-ready') > -1){
1725 $(this).show();
1726 }
1727 });*/
1728 // Show all the tickets
1729 $('search-result').show();
1730 $('#countList').hide();
1731}
1732
1733/*
1734 ██████╗ ██████╗ ██╗ ██████╗ ██████╗ ██╗████████╗██╗ ██╗
1735 ██╔══██╗██╔══██╗██║██╔═══██╗██╔══██╗██║╚══██╔══╝╚██╗ ██╔╝
1736 ██████╔╝██████╔╝██║██║ ██║██████╔╝██║ ██║ ╚████╔╝
1737 ██╔═══╝ ██╔══██╗██║██║ ██║██╔══██╗██║ ██║ ╚██╔╝
1738 ██║ ██║ ██║██║╚██████╔╝██║ ██║██║ ██║ ██║
1739 ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
1740*/
1741
1742function priorityTickets(){
1743 var techNames = ['wired','sevan','mayor','oasis','vincenle','shonhilt','rugrat','jtoepfer','thebaron','jahlilar','huddchri','mylbooth'];
1744 var alias = $('.nav.navbar-nav.navbar-right .dropdown .dropdown-toggle .ng-binding').text().trim();
1745 for (var i = 0; i < techNames.length; i++) {
1746 //console.log(techNames[i],alias)
1747 if (techNames[i] == alias){
1748 // Loop for main QM view of tickets
1749 $('.timestamps').each(function(){
1750 // Split the div into two so that we can color just the created date
1751 var splitBoth = $(this).text().trim().split("|");
1752 // Hide the timestamps so that it can still be referenced when filtering the queue
1753 $(this).hide();
1754 // Remove the new timestamp and readd it as something was clicked and it could be the filtering
1755 $(this).parent().find('.timestampsNew').remove();
1756 $(this).parent().append(`<div class="timestampsNew ng-binding"><span>${splitBoth[0]}</span<|<span>${splitBoth[1]}</span>`);
1757 //$(this).html("<span>"+splitBoth[0]+"</span>|<span>"+splitBoth[1]+"</span>");
1758 var array = $(this).text().trim().split(' ');
1759 if ((array[1] >= 2 && array[2] == "months") || array[2].indexOf("year") > -1){
1760 $(this).parent().find('.timestampsNew span:eq(0)').css('color','green');
1761 }else{
1762 $(this).parent().find('.timestampsNew span:eq(0)').css('color','red');
1763 }
1764 });
1765 // Loop for when a ticket is selected in QM view
1766 $('filtered-result').each(function(){
1767 var array = $(this).find('div div:eq(3) div:last').text().trim().split(' ');
1768 if ((array[1] >= 2 && array[2] == "months") || array[2].indexOf("year") > -1){
1769 $(this).find('div div:eq(3) div:last').css('color','green');
1770 }else{
1771 $(this).find('div div:eq(3) div:last').css('color','red');
1772 }
1773 });
1774 // Loop for tickets in a batch
1775 $('tech-result').each(function(){
1776 var array = $(this).find('div div:eq(2) div:last').text().trim().split(' ');
1777 if ((array[1] >= 2 && array[2] == "months") || array[2].indexOf("year") > -1){
1778 $(this).find('div div:eq(2) div:last').css('color','green');
1779 }else{
1780 $(this).find('div div:eq(2) div:last').css('color','red');
1781 }
1782 });
1783 break;
1784 }
1785 }
1786}
1787
1788
1789
1790
1791/*
1792 ██████╗ ███╗ ██╗██╗ ██╗███╗ ██╗███████╗ ███████╗████████╗ █████╗ ████████╗██╗ ██╗███████╗
1793██╔═══██╗████╗ ██║██║ ██║████╗ ██║██╔════╝ ██╔════╝╚══██╔══╝██╔══██╗╚══██╔══╝██║ ██║██╔════╝
1794██║ ██║██╔██╗ ██║██║ ██║██╔██╗ ██║█████╗ ███████╗ ██║ ███████║ ██║ ██║ ██║███████╗
1795██║ ██║██║╚██╗██║██║ ██║██║╚██╗██║██╔══╝ ╚════██║ ██║ ██╔══██║ ██║ ██║ ██║╚════██║
1796╚██████╔╝██║ ╚████║███████╗██║██║ ╚████║███████╗ ███████║ ██║ ██║ ██║ ██║ ╚██████╔╝███████║
1797 ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝╚═╝ ╚═══╝╚══════╝ ╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
1798 */
1799function assignTechs() {
1800 // Loop through the aliases found on the page
1801 $('#team-members .team_member_section').each(function() {
1802 // Grab alias from page
1803 var alias = $(this).find('.team_member_properties div:eq(0)').text().trim();
1804 // Grab assigned tech from page
1805 var selectedTech = $(this).find('.fa.fa-certificate.fa-2x.assigned.ng-hide').length;
1806 var pattern = new RegExp('^pd[tx][0-9]+');
1807
1808 // Hide all techs that are not the primary/secondary group or the currently assigned tech
1809 if (!pattern.test(alias) && selectedTech != 0) {
1810 $(this).toggle();
1811 }
1812 });
1813}
1814
1815function onlineTechs() {
1816 $('#team-members assignment-individual').each(function() {
1817 var checkOnlineStatus = $(this).find('i[class="fa fa-circle offline"]').attr('title');
1818 console.log(checkOnlineStatus);
1819 if (checkOnlineStatus == "Offline") {
1820 $(this).toggle();
1821 }
1822 });
1823
1824 // Loop through the aliases found on the page
1825 /*$('#team-members .team_member_section').each(function() {
1826 var checkStyle = $(this).find('.assignment_panel div:eq(0)').attr('style');
1827 if (typeof checkStyle == typeof undefined && checkStyle !== false) {
1828 $(this).toggle();
1829 }
1830 });*/
1831}
1832
1833/* function onlineStatus() {
1834 var url = ['http://workready.aka.amazon.com/workready/data/PDXdco.list',
1835 'http://workready.aka.amazon.com/workready/data/PDXrack.list',
1836 'http://workready.aka.amazon.com/workready/data/PDXdecom.list'
1837 ];
1838
1839 for (var index in url) {
1840 console.log(url[index]);
1841 GM.xmlHttpRequest({
1842 method: "GET",
1843 //url: 'http://workready.aka.amazon.com/workready/data/PDXdco.list',
1844 url: url[index],
1845 headers: {
1846 "Content-Type": "text/xml"
1847 },
1848 onload: function(response) {
1849 checkStatus(response);
1850
1851 },
1852 onerror: function(response) {
1853 // Display a notice that check failed.
1854 console.log(response);
1855 }
1856 });
1857 }
1858}
1859
1860function checkStatus(response) {
1861 // Get todays date
1862 var d = new Date();
1863 var month = d.getMonth() + 1;
1864 var day = d.getDate();
1865 var year = d.getFullYear().toString().substr(2, 2);
1866 var today = (month < 10 ? '0' : '') + month + '-' + (day < 10 ? '0' : '') + day + '-' + year;
1867 // Get current time
1868 var hours = d.getHours();
1869 var minutes = d.getMinutes();
1870 var seconds = d.getSeconds();
1871 var time = (hours < 10 ? '0' : '') + hours + ':' + (minutes < 10 ? '0' : '') + minutes;
1872
1873 // Split the responce into a list
1874 var lines = response.responseText.split("\n");
1875 // Keep track of the online users
1876 var Techs = [];
1877 var cnt = 0;
1878
1879 // Loop through the response list and store only the techs that are online
1880 for (var i = 0; i < lines.length; i++) {
1881 // Split the date into an array
1882 var t = lines[i].split('--').pop().split(':');
1883 // Store the time from the list in the correct format
1884 var newTime = (t[0] < 10 ? '0' : '') + t[0] + ':' + (t[1] < 10 ? '0' : '') + t[1];
1885 // Find the difference between the current time and the list time (In minutes)
1886 var diff = (new Date("October 13, 1975 " + time) - new Date("October 13, 1975 " + newTime)) / 1000 / 60;
1887 // If the line contains todays date and is an hour old then they are online
1888 if (lines[i].indexOf(today) > -1 && diff <= 60) {
1889 Techs[cnt] = lines[i].split(' ', 1);
1890 //console.log(Techs[cnt])
1891 cnt++;
1892 }
1893 }
1894
1895 // Loop through the aliases found on the assignment page
1896 $('#team-members .team_member_section').each(function() {
1897 // Grab alias from page
1898 var alias = $(this).find('.team_member_properties div:eq(0)').text().trim();
1899 // Compare the alias with the online status of the tech
1900 for (var j = 0; j < cnt; j++) {
1901 if (Techs[j] == alias) {
1902 $(this).find('.assignment_panel div:eq(0)').css({
1903 'border-style': 'solid',
1904 'border-color': 'green',
1905 'border-width': '3px'
1906 });
1907 }
1908 }
1909 });
1910
1911 // Loop through the aliases found on the left menu
1912 $('facets-section[title="Assigned Individual"] .facet-list.facet-hover .facet-name.ng-binding.ng-scope').each(function() {
1913 alias = $(this).text().trim();
1914 // Compare the alias with the online status of the tech
1915 for (var j = 0; j < cnt; j++) {
1916 if (Techs[j] == alias) {
1917 $(this).css({
1918 'color': 'green'
1919 });
1920 }
1921 }
1922 });
1923} */
1924/*
1925 ██████╗ ██████╗ ███╗ ███╗███╗ ███╗██╗ ██╗███╗ ██╗██╗ ██████╗ █████╗ ████████╗██╗ ██████╗ ███╗ ██╗ ████████╗ █████╗ ██████╗
1926██╔════╝██╔═══██╗████╗ ████║████╗ ████║██║ ██║████╗ ██║██║██╔════╝██╔══██╗╚══██╔══╝██║██╔═══██╗████╗ ██║ ╚══██╔══╝██╔══██╗██╔══██╗
1927██║ ██║ ██║██╔████╔██║██╔████╔██║██║ ██║██╔██╗ ██║██║██║ ███████║ ██║ ██║██║ ██║██╔██╗ ██║ ██║ ███████║██████╔╝
1928██║ ██║ ██║██║╚██╔╝██║██║╚██╔╝██║██║ ██║██║╚██╗██║██║██║ ██╔══██║ ██║ ██║██║ ██║██║╚██╗██║ ██║ ██╔══██║██╔══██╗
1929╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚═╝ ██║╚██████╔╝██║ ╚████║██║╚██████╗██║ ██║ ██║ ██║╚██████╔╝██║ ╚████║ ██║ ██║ ██║██████╔╝
1930 ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═════╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝╚═════╝
1931 */
1932function communicationTab() {
1933 if ($('#showComm').length == 0) {
1934 $('#validate-ticket communication-entries').before('<br/><a href="#" id="showComm">Show Communication</a>');
1935 $('#validate-ticket communication-entries').hide();
1936 $('#showComm').unbind().on('click', function(event) {
1937 $('#validate-ticket communication-entries').toggle();
1938 });
1939 }
1940 // Color the correspondence
1941 var keywordObject = [{
1942 keyword: "Completed instruction:",
1943 color: "#80ff80"
1944 }, //green
1945 {
1946 keyword: "Ticket instructions:",
1947 color: "#8080ff"
1948 }, //blue
1949 {
1950 keyword: "Ticket instructions set to:",
1951 color: "#8080ff"
1952 },
1953 {
1954 keyword: "Asset:",
1955 color: "#ffc966"
1956 }, //orange
1957 {
1958 keyword: "The following parts were requested for site:",
1959 color: "#ffc966"
1960 }, //orange
1961 {
1962 keyword: "Data Tech has overridden the need for approval",
1963 color: "#ff8080"
1964 }, //red
1965 {
1966 keyword: "Previous work approvals for the host",
1967 color: "#ff8080"
1968 }, //red
1969 {
1970 keyword: "This ticket has not been resolved successfully, additional triage required.",
1971 color: "#ff8080"
1972 },
1973 {
1974 keyword: "Re-Opened this ticket as the last repair was unsuccessful.",
1975 color: " #e580ff"
1976 },
1977 {
1978 keyword: "+++ Reopening ticket, auto-assigning ticket to the lowest support order in the resolver group.",
1979 color: "#e580ff"
1980 },
1981 {
1982 keyword: "+++ Water Rule added this Correspondence:",
1983 color: "#ff8080"
1984 },
1985 {
1986 keyword: "*** Matched Water Rule:",
1987 color: "#ff8080"
1988 },
1989 {
1990 keyword: "Cancellation Reason:",
1991 color: "#ff8080"
1992 },
1993 {
1994 keyword: "** Location found , **",
1995 color: "#ff8080"
1996 },
1997 {
1998 keyword: "Issue resolved using QM Workflow.",
1999 color: "#e5ff80"
2000 },
2001 {
2002 keyword: "This ticket has not been resolved successfully, additional triage required",
2003 color: "#e5ff80"
2004 },
2005 {
2006 keyword: "## TicketNanny has automatically",
2007 color: "#ff8080"
2008 }
2009 ]; //red
2010
2011 // Create a border around the communications
2012 $('#communication-entries-section communication-entry').find('.verbose-communication-entry').css("border", "1px solid black");
2013
2014 // Loop through each entry
2015 $('#communication-entries-section communication-entry').each(function() {
2016 // Grab the first line of each section
2017 //var foundKeywordMin = $(this).find('.entry-min.ng-binding:eq(0)').text();
2018 var foundKeywordMin = $(this).find('.ng-binding.ng-scope').text().split(/\n/)[0];
2019 var foundKeywordMinSec = $(this).find('.ng-binding.ng-scope').text().split(/\n/)[1];
2020
2021 // Change the backgound color of all the entries
2022 for (var i = 0; i < keywordObject.length; i++) {
2023 if (foundKeywordMin.indexOf(keywordObject[i].keyword) >= 0) {
2024 $(this).find('.verbose-communication-entry').css('background-color', keywordObject[i].color);
2025 }
2026 }
2027 // Since TicketNany adds a blank line we need to just check it manually
2028 if (typeof foundKeywordMinSec != typeof undefined) {
2029 if (foundKeywordMinSec.indexOf(keywordObject[16].keyword) >= 0) {
2030 $(this).find('.verbose-communication-entry').css('background-color', keywordObject[16].color);
2031 }
2032 }
2033
2034 // Create a border around the communications
2035 //$(this).find('.verbose-communication-entry').css("border","1px solid black");
2036 //$(this).parent().css("border","1px solid black");
2037
2038 // Change the 'Show more' and 'Promote to summary' font color
2039 $(this).find('.verbose-communication-entry a').css({
2040 'color': 'black',
2041 'text-decoration': 'underline'
2042 });
2043
2044 // If foundKeyword is "Ticket instructions:" then bold the created font.
2045 /*if (foundKeywordMin.indexOf(keywordObject[1].keyword) >= 0 || foundKeywordMin.indexOf(keywordObject[2].keyword) >= 0 || foundKeywordMax.indexOf(keywordObject[1].keyword) >= 0 || foundKeywordMax.indexOf(keywordObject[2].keyword) >= 0){
2046 $('#communication-entries-section communication-entry #formatted-ticket-content').split(/\n/).each(function() {
2047 // Bold the created font to make it stand out
2048 if ($(this).text().indexOf('[created]') > -1){
2049 $(this).css('font-weight', 'bold');
2050 }
2051 // Remove the myday garbage at the bottom of each correspondence
2052 if ($(this).text().indexOf('updated by flx-autobot-myday-pdx on behalf of') > -1){
2053 $(this).hide();
2054 }
2055 });
2056 }*/
2057 // If foundKeyword is "Asset:" then add what part was replaced.
2058 if (foundKeywordMin.indexOf(keywordObject[3].keyword) >= 0) {
2059 var cnt = 0;
2060 var modelType = '';
2061 // Grab the index number from where it says replacement
2062 var index1 = foundKeywordMin.indexOf('Replacement');
2063 // Find the index of the colon that comes after, then add two to remove the space
2064 var beginning = foundKeywordMin.indexOf(': ', index1) + 2;
2065 // Find the index of the comma that comes after the serial, then subtract the beginning to get the length
2066 var ending = foundKeywordMin.indexOf(', ', beginning) - beginning;
2067 // Store the replaced serial number
2068 var replacedSerial = foundKeywordMin.substr(beginning, ending);
2069 // Loop through the list of replaced hardware and grab the model for each (Repair History)
2070 $('hardware-repairs tbody tr').each(function() {
2071 var replacementList = $(this).find('td:eq(1)').text().trim();
2072 //console.log("+" + replacementList + "+")
2073 if (replacementList == replacedSerial) {
2074 cnt++;
2075 modelType = $(this).find('td:eq(3)').text().trim();
2076 return;
2077 }
2078 });
2079 if (cnt > 0) {
2080 if (foundKeywordMin.substr(0, 1) != '[') {
2081 $(this).find('.ng-binding.ng-scope').prepend('[' + modelType + '] ');
2082 }
2083 }
2084 }
2085 // Add a format button to the heading of each correspondence --formatted-ticket-content
2086 if ($(this).find('.entry-header div:eq(0) i').length == 0){
2087 $(this).find('.entry-header div:eq(0)').append(`<a href="#"><i data-value="0" style="-webkit-text-stroke: 2px" class="fa fa-angle-right"></a>`);
2088 }
2089 });
2090 // Add a click action to the buttons
2091 $('#communication-entries-section communication-entry').each(function(){
2092 $(this).find('.entry-header div:eq(0) i').unbind().on('click', function() {
2093 // if the pre is not wrapped around the contents then set data to 0 and remove any pre's that exist
2094 if ($(this).closest('#log').find('pre #formatted-ticket-content').length == 0){
2095 $(this).data('value', "0");
2096 $(this).closest('#log').find('pre').remove();
2097 }
2098 if ($(this).data('value') == "0"){
2099 $(this).data('value', "1");
2100 $(this).closest('#log').find('#formatted-ticket-content').attr('style','font-size:11px').wrap('<pre/>');
2101 }else{
2102 $(this).data('value', "0");
2103 $(this).closest('#log').find('#formatted-ticket-content').attr('style','font-size:12px').unwrap('<pre/>');
2104 }
2105 });
2106 });
2107}
2108
2109/*
2110███████╗ █████╗ ███╗ ██╗ ██╗████████╗██╗ ██╗ ██████╗██╗ ██╗███████╗ ██████╗██╗ ██╗
2111██╔════╝ ██╔══██╗ ████╗ ██║ ██║╚══██╔══╝╚██╗ ██╔╝ ██╔════╝██║ ██║██╔════╝██╔════╝██║ ██╔╝
2112███████╗ ███████║ ██╔██╗ ██║ ██║ ██║ ╚████╔╝ ██║ ███████║█████╗ ██║ █████╔╝
2113╚════██║ ██╔══██║ ██║╚██╗██║ ██║ ██║ ╚██╔╝ ██║ ██╔══██║██╔══╝ ██║ ██╔═██╗
2114███████║ ██║ ██║ ██║ ╚████║ ██║ ██║ ██║ ╚██████╗██║ ██║███████╗╚██████╗██║ ██╗
2115╚══════╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═════╝╚═╝ ╚═╝
2116*/
2117
2118function findAssetTag() {
2119 // Make the asset tag on the sanity step clickable
2120 if ($('#states .ng-binding.ng-scope.active').text().trim() == "Complete Work" && $('#tickets .ng-binding.ng-scope.active').text().trim() == "Step 0" && $('#assetID').length ==0){
2121 $('.unselectable').removeClass('unselectable');
2122 }
2123}
2124
2125function findConsoleIP(){
2126 // Add console IP to sanity check page
2127 if ($('#states .ng-binding.ng-scope.active').text().trim() == "Complete Work" && $('#tickets .ng-binding.ng-scope.active').text().trim() == "Step 0" && $('#assetID').length ==0){
2128 // Pull the hardware ID
2129 var sanityHWID = $('#description div span:eq(0)').text().replace("[","").replace("]","").trim();
2130 if (sanityHWID != "" && $('#consoleIP').length == 0){
2131 GM.xmlHttpRequest({
2132 method: "GET",
2133 url: 'https://myday-website-pdx.amazon.com/hosts/'+sanityHWID,
2134 synchronous: false,
2135 headers: {
2136 "Content-Type": "application/json"
2137 },
2138 onload: function(response) {
2139 // Verify the request has finished
2140 if (response.readyState == "4") {
2141 // Check if the response is ready for processing
2142 if (response.status === 200) {
2143 // JSON is recieved. Parse it
2144 var jsonResponse = JSON.parse(response.responseText);
2145 // Grab the console IP
2146 var console_ip = jsonResponse.console.console_ip;
2147 var console_ok = jsonResponse.console.console_ok;
2148 $('#consoleIP').remove();
2149 if (!console_ip){
2150 var label = 'label-danger';
2151 }else if (console_ip && console_ok){
2152 var label = 'label-success';
2153 }else if (console_ip && !console_ok){
2154 var label = 'label-warning';
2155 }
2156 $('host-info .details.location').prepend(`<div id="consoleIP">
2157 <b>Console IP</b>
2158 <div class="ng-binding">
2159 <span class="label ${label} ng-binding" ng_show="console.console_ip && console.console_ok" aria-hidden="false">
2160 ${console_ip}
2161 </span>
2162 </div></div>`)
2163 }
2164 }
2165 },
2166 onerror: function(response) {
2167 // Display a notice that check failed.
2168 console.log(response);
2169 }
2170 });
2171 }
2172 }
2173}
2174
2175function countChar(){
2176 if ($('#countBroken').length == 0){
2177 var total = "";
2178 $('parts-repair input[ng_model="doRepairData.asset_id"]').parent().find('label').append('<b id=countAsset> (Char: 0/10)</b>');
2179 $('parts-repair input[ng_model="doRepairData.broken_serial_no"]').parent().find('label').append('<b id=countBroken> (Char: 0)</b>');
2180 $('parts-repair input[ng_model="doRepairData.replacement_serial_no"]').parent().find('label').append('<b id=countReplacement> (Char: 0)</b>');
2181
2182 //Asset ID
2183 $('parts-repair input[ng_model="doRepairData.asset_id"]').unbind().on('keyup', function() {
2184 $('#countAsset').text(" (Char: " + this.value.length + "/10)");
2185 if (this.value.length == 10){
2186 $('#countAsset').css('color','green');
2187 }else{
2188 $('#countAsset').css('color','black');
2189 }
2190 });
2191
2192 //Broken serial
2193 $('parts-repair input[ng_model="doRepairData.broken_serial_no"]').unbind().on('keyup', function() {
2194 if ($(this).val().substr(0,3).toUpperCase() == "PDX" || $(this).val().substr(0,3).toUpperCase() == "180"){
2195 total = "/12";
2196 }else if($(this).val().substr(0,2).toUpperCase() == "MJ"){
2197 total = "/17";
2198 }else{
2199 total = "";
2200 }
2201 $('#countBroken').text(" (Char: " + this.value.length + total + ")");
2202 if ($(this).val().indexOf('HFS128G32TNF-N3A0A BB') > -1){
2203 var newValue = $(this).val().replace('HFS128G32TNF-N3A0A BB','');
2204 $(this).val(newValue);
2205 }
2206 if ("/"+this.value.length == total){
2207 $('#countBroken').css('color','green');
2208 }else{
2209 $('#countBroken').css('color','black');
2210 }
2211 });
2212
2213 //Replacement serial
2214 $('parts-repair input[ng_model="doRepairData.replacement_serial_no"]').unbind().on('keyup', function() {
2215 if ($(this).val().substr(0,3).toUpperCase() == "PDX" ||$(this).val().substr(0,3).toUpperCase() == "180"){
2216 total = "/12";
2217 }else if($(this).val().substr(0,2).toUpperCase() == "MJ"){
2218 total = "/17";
2219 }else{
2220 total = "";
2221 }
2222 $('#countReplacement').text(" (Char: " + this.value.length + total + ")");
2223 if ("/"+this.value.length == total){
2224 $('#countReplacement').css('color','green');
2225 }else{
2226 $('#countReplacement').css('color','black');
2227 }
2228 });
2229 }
2230}
2231
2232/*
2233 ██████╗ ██████╗ ██████╗ ██╗ ██╗██████╗ ██████╗██╗ ██╗██████╗ ██████╗ ██████╗ █████╗ ██████╗ ██████╗
2234██╔════╝██╔═══██╗██╔══██╗╚██╗ ██╔╝╚════██╗██╔════╝██║ ██║██╔══██╗██╔══██╗██╔═══██╗██╔══██╗██╔══██╗██╔══██╗
2235██║ ██║ ██║██████╔╝ ╚████╔╝ █████╔╝██║ ██║ ██║██████╔╝██████╔╝██║ ██║███████║██████╔╝██║ ██║
2236██║ ██║ ██║██╔═══╝ ╚██╔╝ ██╔═══╝ ██║ ██║ ██║██╔═══╝ ██╔══██╗██║ ██║██╔══██║██╔══██╗██║ ██║
2237╚██████╗╚██████╔╝██║ ██║ ███████╗╚██████╗███████╗██║██║ ██████╔╝╚██████╔╝██║ ██║██║ ██║██████╔╝
2238 ╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝╚══════╝╚═╝╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝
2239*/
2240function Copy2Clipboard(thisVar, name, contents) {
2241 if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)) {
2242 var ffversion = new Number(RegExp.$1);
2243 if (ffversion >= 41) {
2244 console.log("You're using FF 41 or above. (" + ffversion + ")");
2245 // Enable copy to clip board
2246 //thisVar.next().html(contents + ' <a id="clip_'+name+'"><i class="fa fa-clipboard" data-clipboard-text="'+contents+'"></i></a>');
2247 thisVar.next().append(' <a id="clip_' + name + '"><i class="fa fa-clipboard" data-clipboard-text="' + contents + '"></i></a>');
2248 // Run this function when the user clicks the copy icon
2249 $('#clip_' + name).click(function() {
2250 // Only display "copied to clipboard" once
2251 if ($("#showClip_" + name).length == 0) {
2252 $(this).parent().append('<i id="showClip_' + name + '" style="color:green;font-size:12;font-weight:bold"> Copied to Clipboard</i>');
2253 setTimeout(function() {
2254 $('#showClip_' + name).remove();
2255 }, 3000);
2256 }
2257 });
2258 } else {
2259 console.log("You're using FF 40 or below. (" + ffversion + ")");
2260 }
2261 }
2262}
2263
2264
2265function checkForUpdates(){
2266 // Get the time to use in the GET method to pervent caching
2267 var randomTime = (new Date()).getTime();
2268 console.log('test')
2269 GM.xmlHttpRequest({
2270 method: "GET",
2271 url: "http://pdx-tools.pdx2.amazon.com:3000/mylbooth/MyDay_Tweaks_V3/raw/branch/master/MyDay_Tweaks_V3.user.js?time="+randomTime,
2272 headers: {
2273 "Content-Type": "text/xml"
2274 },
2275 cache: false,
2276 onload: function(response) {
2277 if (response.readyState == 4 && response.status == 200) {
2278 console.log('test1')
2279 var currentVersion = GM.info.script.version;
2280 var responseVersion = response.responseText.match(/version\s+([0-9]+.\d+)/);
2281 if (parseFloat(parseFloat(currentVersion).toFixed(2)) < parseFloat(parseFloat(responseVersion[1]).toFixed(2))) {
2282 //if (parseFloat(currentVersion) < parseFloat(responseVersion[1])) {
2283 $('.navbar').after(' \
2284 <div class="modal show" id="updateModal" role="dialog"> \
2285 <div class="modal-dialog modal-sm"> \
2286 <div class="modal-content"> \
2287 <div class="modal-header"> \
2288 <button type="button" class="close" data-dismiss="modal">×</button> \
2289 <h4 class="modal-title"> \
2290 Update Available<br /> \
2291 </h4> \
2292 </div> \
2293 <div class="modal-body" id="menu"> \
2294 <div id="Update"> \
2295 A new version (' + responseVersion[1] + ') of ' + GM.info.script.name + ' is available.<br/> \
2296 1) Install <a href="http://pdx-tools.pdx2.amazon.com:3000/mylbooth/MyDay_Tweaks_V3/raw/branch/master/MyDay_Tweaks_V3.user.js" style="color:#428bca">Update</a>.<br/> \
2297 2) <a onclick="window.location.href=this" style="color:#428bca">Refresh</a> MyDay \
2298 </div> \
2299 </div> \
2300 <div class="modal-footer"> \
2301 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> \
2302 </div> \
2303 </div> \
2304 </div> \
2305 </div> \
2306 </div> \
2307 ');
2308 $('#updateModal button[data-dismiss="modal"]').unbind().on('click', function(event) {
2309 $('#updateModal').removeClass('show')
2310 $('#updateModal').addClass('hide')
2311 })
2312 /*if (confirm('A new version (' + responseVersion[1] + ') of ' + GM.info.script.name + ' is available.\n\nPlease Update.')) {
2313 window.open("http://pdx-tools.pdx2.amazon.com:3000/mylbooth/MyDay_Tweaks_V3/raw/branch/master/MyDay_Tweaks_V3.user.js");
2314 }*/
2315 }
2316 }
2317 },
2318 onerror: function(e) {
2319 textArea = 'Error - Unable to post';
2320 console.error('**** error ', e);
2321 },
2322 onabort: function(e) {
2323 textArea = 'Error - Unable to post';
2324 console.error('**** abort ', e);
2325 },
2326 ontimeout: function(e) {
2327 textArea = 'Error - Unable to post';
2328 console.error('**** timeout ', e);
2329 }
2330 });
2331 console.log('test2')
2332}