-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtimmi-ess-fusion.user.js
1775 lines (1460 loc) · 76.8 KB
/
timmi-ess-fusion.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name Timmi ESS Fusion
// @namespace https://github.com/draganignjic/timmi-ess-fusion/
// @version 0.8.14
// @description Embed ESS Timesheet in Lucca Timmi
// @author Dragan Ignjic (Saferpay)
// @include /ZCA_TIMESHEET
// @include /sps.ilucca.ch/timmi
// @include /sap/
// @grant GM.getValue
// @grant GM.setValue
// @grant GM_addValueChangeListener
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment-with-locales.min.js
// @downloadURL https://raw.githubusercontent.com/draganignjic/timmi-ess-fusion/master/timmi-ess-fusion.user.js
// @updateURL https://raw.githubusercontent.com/draganignjic/timmi-ess-fusion/master/timmi-ess-fusion.user.js
// ==/UserScript==
(async () => {
let _updateUrl = "https://raw.githubusercontent.com/draganignjic/timmi-ess-fusion/master/timmi-ess-fusion.user.js";
let _essLoginUrl = "https://www.corp.worldline.com//irj/portal?NavigationTarget=navurl%3A%2F%2F84bc02facde559823f00891e66f3af77&atosStandaloneContent=yes&CurrentWindowId=WID1578481318556&supportInitialNavNodesFilter=true&filterViewIdList=%3BAtosEndUser%3B&PrevNavTarget=navurl%3A%2F%2F7eb1a7e6f0945a01676a229d623d6c8f&TarTitle=Timesheet%20entry&NavMode=10";
let _essLegacyLoginUrl = "https://www.corp.worldline.com/irj/portal?NavigationTarget=navurl%3A%2F%2F84bc02facde559823f00891e66f3af77&atosStandaloneContent=yes&CurrentWindowId=WID1580893319809&supportInitialNavNodesFilter=true&filterViewIdList=%3BAtosEndUser%3B&PrevNavTarget=navurl%3A%2F%2F7eb1a7e6f0945a01676a229d623d6c8f&TarTitle=Timesheet entry&NavMode=10";
let _essStartUrl = "https://perf.corp.worldline.com/sap(ZT16N2x3UWs5WFNRYU8xWHlDOU5fcU13LS1USHhuan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QMaXCCjXMyDpv0OKF1UM4nEs4o4RMldzD/lPDzoYP5AIyj2Sk/a8C+VqZcB4eVhe6/X1CONWI4xjHjxNGksw4+1uxQcvbsSDiHxAsZOy2U3s7v6UwIypwn2DXzc1QyGgzpUg72b1c/BzsSTmBc7BI7DxLhS8aQ1QNbrhJYnnExCW7EkDoLfqdd5BzPsGrE7g5eYHnGtq7Zco6d7xbkY/fEISQgb2lVDRLvwFxjd9KR83wfKmLS65gt9z0tzz1WydiIJ8Tul2cjrIaxSUnjLQ4+Q8zQ84fzg4qle7LO558njJn+194mr5Kz6EYuwo5VS84l+MLyDfH/sGajptqCCZawVJun52fiUrV0T2LrzDUYI4v9m6QJqabmP+0IfXOT0I2GAAAAAElFTkSuQmCC";
let _wbsLookupLink = 'https://confluence.worldline.com/display/SFRP/WBS+Lookup';
let _autmatixWbsLookupLink = "https://confluence.worldline.com/display/SFRP/Automatix+ESS"
let _faviconEmpty = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsIAAA7CARUoSoAAAAN9SURBVDhPhVRbTxNBFJ6ZbbeCaIioiKAmBgxovYD6YEAxiBTDJQFsxRA0+uqDJr7rkyb+Ai8PitGYIC03tV4iEYJIRETUeEFQC0FQQWICoaXd7vidlVWoTfzS0z23+c7MzjnLHQ6H4ICUkuHBCKQTyN6dnakmrUprg6mMf/XtevDoacCMESLXGWTRIMTvUGLy2kqkbYdkJSxfVTk3FgVMEGtkFVOPj1OZEMoJeL8aIpTj8YtsRowQuY6ESkUlIxQ49uUjZROT4fOQC4yJjY7CfXsoFklm8gjDA0SSGbZFpd1N+6d+XoRcgu7ninoiGpmJf45MINtVUbIB4QIm9evN3pYfkDHoN+BzOMuLM8y8fzZx8li1NX3D5iRFjV3DuQUi1iALIrJxlxnazORGT6O3jxbsLytar6hxvVj6BuQdePqkrg9JGR7UApODvS97v/GrNZd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kJggg==";
let _modernEssStartUrl = "https://www.corp.worldline.com/sap/ur?sap-ushell-config=headerless#Timesheet-entry";
let _modernEssLoginUrl = "https://www.corp.worldline.com/irj/portal?NavigationTarget=navurl%3A%2F%2Fbaff536bcf44bbeff1a64b8649c78372&NavMode=10";
let _lastEssActivitySignal = null;
if (scriptAlreadyExecuted()) {
// some users have it installed twice
return;
}
if (window.location.href.indexOf('/timmi') !== -1 && window.location.href.indexOf('/login') == -1 && window.location.href.indexOf('/timmi-absences') == -1) {
if (isInIframe()) {
// timmi has iframes which we don't want to run ess in
return;
}
await appendEss();
collectTimmiHours();
await listenForNewSession();
closeInactiveEss();
setTimeout(() => { window.location.reload(); }, 1000 * 60 * 15);
}
await sessionHandling();
if (window.location.href.indexOf('ZCA_TIMESHEET') !== -1) {
fixLayout();
addFillButtons();
formatDayTitles();
hideWeekend();
await addTimmiHours();
keepSessionOpen();
listenForTimmiHours();
showAddItem();
enableDotDecimalEntry();
enableEnterKeySave();
addTopRightLinks();
fixWbsOverviewLayout();
await addFavouritesFeature();
calculateDiffsOnChange();
addWeekButtons();
addEndOfMonthWarning();
sendActivitySignal();
}
if (window.location.href.indexOf('/sap/flp') !== -1 && window.location.href.indexOf('#Timesheet-entry') !== -1) {
listenForTimmiHoursModernEss();
keepSessionOpen();
sendActivitySignal();
changeShowWeekendDefault();
addEndOfMonthWarningModernEss();
addFillButtonsModernEss();
enableEnterKeySave();
makeModernEssCompact();
showUseFirefoxMessage();
}
function showUseFirefoxMessage() {
setTimeout(showUseFirefoxMessage, 500);
$('span:contains("incorrect SAP Fiori launchpad configuration or a missing role assignment")').text('Please use "old ESS" or the Firefox Browser');
}
function makeModernEssCompact() {
$('#shell-hdr').css('z-index', 0); // Enable week "<" and ">" buttons
if (!isInIframe()) {
return;
}
$('.jss34')
.css('margin-left', 'unset')
.css('max-width', 'unset');
// $('div').css('min-width', 0);
// $('footer span').css('word-break', 'break-word');
// $('span:contains("start by using one of the options.")').closest('div').hide();
// $('main > div > div > div > .MuiPaper-elevation1').css('width', '28%');
// $('span:contains("Add activity")').css('width', '80px');
// $('span:contains("Copy last week")').css('width', '80px');
// Make sure that WBS name not truncated. Sometimes there are wbs with similar name which only differ at the the end.
$('main div').css('overflow', 'visible');
setTimeout(makeModernEssCompact, 500);
}
function changeShowWeekendDefault() {
if (!getCookie('showWeekends')) {
setCookie('showWeekends', 'false;SameSite=None;Secure');
}
}
function scriptAlreadyExecuted() {
var duplicateExecutionId = 'timmi-ess-fusion-prevent-duplicate-execution';
if ($('#' + duplicateExecutionId).length != 0){
return true;
}
$('body').append($('<div id="' + duplicateExecutionId + '" style="display:none"></div>'));
return false;
}
function calculateDiffsOnChange() {
$('input').change(function(){
if (isWorkdayInputField($(this))){
$(this).css('font-weight','bold');
$(this).css('background-color','white');
$(this).attr('title','This value is not saved yet');
var fill = $(this).val() === '*';
if (fill){
$(this).val(0);
var cell = $(this);
setTimeout(function(){
fillCellWithDayDiff(cell);
calculateDiffForDay(cell);
}, 500);
}
calculateDiffForDay($(this));
}
});
}
function calculateDiffForDay(element) {
var id = element.attr('id');
var blurEvent = $('script[for="' + id + '"][event="onblur"]');
if (blurEvent.length === 1){
eval(blurEvent.html());
return;
}
var idSuffix = element.attr('id').split('.')[1];
var totalEssDayHours = 0;
var sameDayFields = $('input').filter(function(){return isWorkdayInputField($(this)) && $(this).attr('id').endsWith(idSuffix);});
sameDayFields.each(function(){
totalEssDayHours += parseFloat($(this).val().replace(',','.')) || 0;
});
$('input[id="timesheet_tsdurationdata[2].' + idSuffix + '"]').val(totalEssDayHours.toFixed(2).replace('.',','));
}
function fixWbsOverviewLayout() {
if (!isWbsOverviewDisplayed()){
return;
}
// fix child row sizing
$('.tier1 > span').click(function(){
$(this).closest('tr:visible').nextAll().each(function(){
if ($(this).css('display') === 'block'){
$(this).css('display','table-row');
}
});
});
$('.urTbsDiv').css('height','1%'); // firefox sizing issue
$('.urTbsDiv').css('background-color','white'); // firefox coloring
$('td').css('vertical-align','middle');
$('td, span').css('font-size', '16px');
$('td:not(:last-child),th:not(:last-child)').css('width', '1%');
$('td').css('padding', '0 5px');
$('th').css('padding', '5px');
$('td,th').css('white-space', 'nowrap');
$('#super').find('td,th').css('border', '1px solid gray');
$('.folder').css('display','inline-block'); // unfold/fold button sizing issue
// remove top row with employee and week info for more clean view
$('#TSFormWorklist').find('table').first().remove();
var topBackBtn = $('<a href="#" style="margin-bottom:20px;display:inline-block;padding:5px;">Back</a>');
setButtonStyle(topBackBtn);
topBackBtn.prependTo($('body'));
topBackBtn.click(function(){
$('#WLBackButton').click();
});
// add toggle view link
var showFilterBtn = $('<buton style="margin-bottom:5px;padding:5px;cursor:pointer;">Toggle Columns</button>');
setButtonStyle(showFilterBtn);
$('.app').prepend(showFilterBtn);
showFilterBtn.click(function(){
for(var i = 4; i < 15; i++){
if (i !== 12){
$('#super').find('th:nth-child(' + i + ')').toggle();
$('#super').find('td:nth-child(' + i + ')').toggle();
}
}
});
$('span:contains("Filter")').closest('tr').css('background-color', 'lightblue');
$('span:contains("Filter")').closest('td').css('padding', '5px');
$('#htmlb_group_1').css('width', '100px');
$('#LayoutListBox').width($('#s_wbscust').width());
$('.urTbsWhl').css('margin-bottom','20px');
$('#super').parent().css('background-color','');
// fix filter box
$('.urTbsWhl').css('background-color','rgba(0, 0, 0, 0)');
$('.urTbsWhl').css('border','none');
$('.urScrl').css('border','1px solid gray');
$('.urGrpBdyBox.urScrl').css('border-top','0');
$('.urGrpTtlBox').removeClass('urGrpTtlBox');
$('.urTbsCnt').css('padding','0');
$('.urGrpBdyBoxPd').css('padding','0');
$('.urGrpBdyBoxPd').find('td').css('border','none');
$('.urGrpBdyBoxPd').find('table').css('padding','10px');
$('.urGrpBdyBoxPd').find('input,select').css('width','250px');
$('#myworklist-cnt-0').css('height','');
// fix back and select links
$('.urBtnPaddingEmph')
.css('margin', '10px')
.css('padding','5px');
$('.urBtnPrevPadding')
.css('padding','5px')
.text('Back');
setButtonStyle($('.urBtnPrevPadding'));
setButtonStyle($('.urBtnPaddingEmph'));
$('.urBtnStd1PrevStep').removeClass('urBtnStd1PrevStep');
$('.urBtnEmph1').removeClass('urBtnEmph1');
// hide useless title
$('#myworklist-scrl').hide();
$('#myworklist-cnt-0').css('width','1%');
// hide empty and unused cells
$('#super').find('tr').first().remove();
for(var i = 4; i < 15; i++){
if (i !== 12){
$('#super').find('th:nth-child(' + i + ')').hide();
$('#super').find('td:nth-child(' + i + ')').hide();
}
}
$('th').css('background-color','lightblue');
// fix paging-buttons
setButtonStyle($('.urBtnSml'));
$('.urBtnSml').parent().css('padding','5px');
$('.urBtnSml').css('height','10px');
$('.urBtnSml').children().css('font-size','10px');
$('.urBtnPadding').css('line-height','10px');
// add paging buttons
var favPaging = $('.urBtnSml').closest('tr').clone();
favPaging.attr('id','favPaging');
var favPagingTbl = $('<table/>');
favPagingTbl.css('margin-bottom','10px');
favPagingTbl.append(favPaging);
$('.urTbsWhl').prepend(favPagingTbl);
// fix clicking in description field for firefox
var descField = $('[name=timesheet_search_wbsel]');
descField.attr('id','s_description');
descField.attr('onfocus',"sapUrMapi_InputField_focus('s_description',event)");
}
async function addFavouritesFeature() {
$('#worklistIcon').css('vertical-align','middle');
var favouriteBtn = $('<img style="width:20px;height:20px;vertical-align:middle;cursor:pointer;" src="' + _faviconFull + '"/>')
favouriteBtn.insertBefore($('#worklistIcon'));
favouriteBtn.click(function(){
$('#worklistIcon').click();
});
await refreshFavourites();
}
async function refreshFavourites() {
var itemTitleCell = null;
if ($('#TSFormWorklist').length == 1){
itemTitleCell = $('.tier1,.tier2').parent().next();
}
else{
itemTitleCell = $('img[title*="Delete"]').closest('tr').find('td[align="left"]:last');
}
itemTitleCell.css('white-space', 'nowrap');
itemTitleCell.css('vertical-align', 'middle');
$('.favicon').remove();
$('.favouriteTitle').remove();
$('.saveFavouriteBtn').remove();
$('.favouriteInputBox').remove();
itemTitleCell.each(async function(){
var favicon = $('<img class="favicon" style="width:20px;height:20px;margin-right:5px;vertical-align:middle"/>');
favicon.prependTo($(this));
var itemKey = $(this).prev().find('span').text();
var wbsTitle = $(this).find('span');
var savedFavouriteTitle = await getFavourite(itemKey);
if (savedFavouriteTitle){
favicon.attr('src', _faviconFull);
favicon.attr('title', 'Remove from favourites');
wbsTitle.hide();
var newTitle = $('<span class="favouriteTitle urTxtStd" style="white-space:nowrap;" title="' + wbsTitle.attr('title') + ' - ' + wbsTitle.text() + '" originalValue="' + wbsTitle.text() + '">' + savedFavouriteTitle + '</span>');
if (isWbsOverviewDisplayed()){
newTitle.css('font-size', '16px');
}
$(this).append(newTitle);
newTitle.prev('br').remove();
}
else {
wbsTitle.show();
favicon.attr('src', _faviconEmpty);
favicon.attr('title', 'Add to favourites');
}
favicon.css('cursor', 'pointer');
favicon.click(async function(){
if ($(this).attr('src') == _faviconFull){
deleteFavourite($(this).parent().prev().find('span').text());
await refreshFavourites();
}
else {
$(this).attr('src', _faviconFull);
var wbsTitle = $(this).next();
wbsTitle.hide();
var inputBox = $('<input type="text" class="urTxtStd favouriteInputBox" value="' + wbsTitle.text() + '" originalValue="' + wbsTitle.text() + '" title="' + wbsTitle.attr('title') + '" />');
$(this).parent().append(inputBox);
inputBox.blur(function(e) {
e.preventDefault();
$(this).next().click();
});
inputBox.keydown(function(e){
if(e.keyCode == 13){
e.preventDefault();
$(this).next().click();
}});
var existingSaveBtn = $('img[title*="Save"]');
var newSaveBtn = $('<a class="saveFavouriteBtn" style="margin-left:5px;font-size:10px;" href="#">Save</a>');
newSaveBtn.insertAfter(inputBox);
inputBox.select();
newSaveBtn.click(async function(){
saveFavourite($(this).parent().prev().find('span').text(), $(this).prev().val());
await refreshFavourites();
});
}
});
});
await addFavouritesOverview();
}
async function addFavouritesOverview(){
$('#favouritesTable').remove();
var favouritesTable = $('<table id="favouritesTable" style="border:1px solid gray;padding:10px;border-collapse: collapse;" cellspacing="0"></table>"');
favouritesTable.append($('<tr><td colspan="4" style="padding:5px;background-color:lightblue;vertical-align:middle;"><img style="width:15px;height:15px;vertical-align:middle;" src="' + _faviconFull + '"/> <span>Favourites</span></td></tr>'));
$('.urTbsDiv').empty();
$('.urTbsDiv').append(favouritesTable);
favouritesTable.hide();
$('.urTbsDiv').css('margin-bottom','20px');
var favFounds = {};
$('.urVt1').each(async function() {
var txt = $(this).text();
var savedFavouriteTitle = await getFavourite(txt);
if (savedFavouriteTitle && ! favFounds.hasOwnProperty(txt)) {
favFounds[txt] = true;
favouritesTable.show();
var favRow = $('<tr></tr>');
favRow.append($('<td style="vertical-align:middle"><a href="#" class="addFromFavouritesBtn" wbsKey="' + $(this).text() + '">Select</a></td>'));
var favicon = $('<img style="width:20px;height:20px;cursor:pointer;vertical-align:middle;" title="Delete item from favourites" wbsKey="' + $(this).text() + '" src="' + _faviconFull + '"/>');
favicon.click(async function(){
deleteFavourite($(this).attr('wbsKey'));
await refreshFavourites();
});
var titleCell = $('<td style="width:99%;vertical-align:middle;"> ' + savedFavouriteTitle + '</td>');
titleCell.prepend(favicon);
favRow.append(titleCell);
favRow.append($('<td>' + $(this).closest('td').next().find('.urVt1').text() + '</td>'));
favRow.append($('<td>' + $(this).text() + '</td>'));
favouritesTable.append(favRow);
favRow.children('td').css('border', '1px solid gray');
favRow.children('td').css('padding', '1px 10px');
favRow.children('td').css('white-space', 'nowrap');
favRow.find('.addFromFavouritesBtn').click(function(){
var wbsKey = $(this).attr('wbsKey');
$('input[type="checkbox"]').each(function(){
var isSelectedFavourite = false;
$(this).parent().find('span').each(function(){
if ($(this).text() === wbsKey){
isSelectedFavourite = true;
}
});
$(this).prop("checked", isSelectedFavourite);
});
$('#WLSelectButton').click();
});
}
setButtonStyle($('.addFromFavouritesBtn'));
$('.addFromFavouritesBtn').css('padding','1px 5px');
});
}
function deleteFavourite(key) {
GM.setValue('ess_favourite_' + key, '');
}
function saveFavourite(key, newTitle) {
GM.setValue('ess_favourite_' + key, newTitle);
}
async function getFavourite(key) {
return await GM.getValue('ess_favourite_' + key);
}
function isWorkdayInputField(element) {
if (!element.attr('id')){
return false;
}
if (element.attr('readonly')){
return false;
}
return element.attr('id').indexOf('.mondhours') !== -1
|| element.attr('id').indexOf('.tueshours') !== -1
|| element.attr('id').indexOf('.wedhours') !== -1
|| element.attr('id').indexOf('.thurhours') !== -1
|| element.attr('id').indexOf('.fridhours') !== -1
|| element.attr('id').indexOf('.sathours') !== -1
|| element.attr('id').indexOf('.sunhours') !== -1;
}
async function listenForNewSession(){
GM_addValueChangeListener('ess_sessionUrl', async function(name, old_value, newSession, remote) {
if (newSession) {
if (old_value) {
// just reload after login. avoid endless reloads.
return;
}
var essIframe = $('#essIframe');
essIframe.attr('src', (await getStartUrl()).replace('?', '?reload&'));
window.focus();
if (_loginWindow) {
_loginWindow.close();
}
}
});
}
async function sessionHandling() {
if (window.location.href.indexOf('ZCA_TIMESHEET') !== -1 || window.location.href.indexOf('/sap/') !== -1) {
$('body').append($('<div><img src="https://qa.saferpay.com/userscripts/timmi-ess-fusion-saferpay-logo.png?cachebusting=' + moment(new Date()).format("YYYY-MM-DD") + '"/></div>').hide());
if (areCookiesBlocked()) {
showAllowCookiesMessage();
window.parent.postMessage({
cookiesNeedtoBeActivated : true
}, '*');
}
if (isSessionTimedOut()) {
$('body').empty()
window.parent.postMessage({
loginRequired : true
}, '*');
}
else if (isTimeEntryDisplayed()) {
GM.setValue('ess_sessionUrl', window.location.href);
if (isLegacyTimeEntryDisplayed()) {
GM.setValue('legacyEss_sessionUrl', window.location.href);
}
// have to set additional properties on cookie so chrmoe does not block it in iframe
var sessionCookie = getCookie('SAP_SESSIONID_P01_360');
if (sessionCookie){
setCookie('SAP_SESSIONID_P01_360', sessionCookie+ ';SameSite=None;Secure');
}
var sessionCookie2 = getCookie('SAP_SESSIONID_FP1_360');
if (sessionCookie2){
setCookie('SAP_SESSIONID_FP1_360', sessionCookie2+ ';SameSite=None;Secure');
}
setCookie('CookiesAllowedTest_Lax','true;SameSite=Lax;Secure');
setCookie('CookiesAllowedTest_None','true;SameSite=None;Secure');
} else {
setTimeout(sessionHandling, 1000);
}
}
}
function areCookiesBlocked() {
setCookie('CookiesAllowedTest_Any','true;SameSite=None;Secure');
if (!document.cookie) {
// browser blocks ALL third party cookies
return true;
}
if (getCookie('CookiesAllowedTest_None') != 'true') {
// user did not login yet
return false;
}
return areThirdPartyCookiesBlocked();
}
function areThirdPartyCookiesBlocked() {
if (document.cookie.indexOf('SAP_SESSIONID') == -1) {
return true;
}
return false;
}
function showAllowCookiesMessage() {
var body = $('body');
body.empty();
body.css('padding','20px');
body.append($('<div style="padding-bottom:20px;">Your browser is blocking ESS Cookies. Please allow them:</div>'));
var isFirefox = typeof InstallTrigger !== 'undefined';
var isChrome = /Chrome/.test(navigator.userAgent) && /Google/.test(navigator.vendor);
if (isFirefox) {
body.append($('<img src="https://raw.githubusercontent.com/draganignjic/timmi-ess-fusion/master/images/timmi-ess-fusion-allow-cookies-firefox.png"/>'));
}
else if (isChrome) {
body.append($('<img src="https://raw.githubusercontent.com/draganignjic/timmi-ess-fusion/master/images/timmi-ess-fusion-allow-cookies-chrome.png"/>'));
}
}
let _loginWindow = null;
function openPopup(url, title, w, h) {
// Fixes dual-screen position Most browsers Firefox
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
const width = screen.width;
const height = screen.height;
const systemZoom = 1;
const left = (width - w - 50) / systemZoom + dualScreenLeft
const top = (height - h - 150) / systemZoom + dualScreenTop
const newWindow = window.open(url, title,`scrollbars=yes,width=${w / systemZoom},height=${h / systemZoom},top=${top},left=${left}`);
if (window.focus) newWindow.focus();
_loginWindow = newWindow;
}
function isWbsOverviewDisplayed() {
return $('#WLSelectButton').length == 1;
}
function isTimeEntryDisplayed() {
return isLegacyTimeEntryDisplayed() || isModernTimeEntryDisplayed();
}
function isModernTimeEntryDisplayed() {
return $('#sap-ui-static').length != 0;
}
function isLegacyTimeEntryDisplayed() {
return $('input[id="timesheet_tsdurationdata[2].mondhours"]').length != 0;
}
async function getStartUrl() {
var sessionUrl = await GM.getValue('ess_sessionUrl');
var startUrl = sessionUrl || _modernEssStartUrl;
if (startUrl.indexOf('ZCA_TIMESHEET') == -1) {
// need to redirect because other Url does not work when refreshing page
startUrl = _modernEssStartUrl;
}
return startUrl;
}
async function appendEss() {
if ($('.pageLayout-container-main-content').length == 0) {
setTimeout(appendEss, 1000);
return;
}
var essIframe = $('<iframe id="essIframe" maximized="false" src="' + await getStartUrl() + '"/>');
essIframe.hide();
$('.pageLayout-container-main-content').append(essIframe);
minimizeEssFrame();
appendHelpBox();
var loginBtn = $('<button id="loginBtn">ESS</button>');
$('body').append(loginBtn);
setButtonStyle(loginBtn);
loginBtn
.css('position','fixed')
.css('bottom','15px')
.css('right','340px')
.css('width','80px')
.css('height','20px')
.css('z-index','100')
.css('padding','0');
var oldLoginBtn = $('<button id="oldLoginBtn">old ESS</button>');
$('body').append(oldLoginBtn);
setButtonStyle(oldLoginBtn);
oldLoginBtn
.css('position','fixed')
.css('bottom','15px')
.css('right','440px')
.css('width','80px')
.css('height','20px')
.css('z-index','100')
.css('padding','0')
.css('background-color', 'lightgray')
.css('color', 'black');
oldLoginBtn.click(async function(e) {
if ($(this).text() == 'old ESS') {
GM.setValue('ess_sessionUrl','');
openPopup(_essLoginUrl + '&closeAfterLogin','ESS Login', 400, 750);
$(this).text('new ESS');
}
else {
GM.setValue('ess_sessionUrl','');
openPopup(_modernEssLoginUrl + '&closeAfterLogin','ESS Login', 400, 750);
$(this).text('old ESS');
}
});
loginBtn.click(async function(e) {
if (!isEssActive()) {
GM.setValue('ess_sessionUrl','');
openPopup(_modernEssLoginUrl + '&closeAfterLogin','ESS Login', 400, 750);
}
});
$(window).on('message', function (e) {
if (e.originalEvent.data.loginRequired) {
essIframe.hide();
}
if (e.originalEvent.data.essIsActive) {
essIframe.show();
_lastEssActivitySignal = new Date();
}
if (e.originalEvent.data.cookiesNeedtoBeActivated) {
essIframe.show();
}
});
}
function appendHelpBox() {
var helpBtn = $('<a href="javascript:void()">Help</a>');
helpBtn.click(function() {
$('#helpBox').toggle();
});
$('body').append(helpBtn);
helpBtn
.css('position','fixed')
.css('width','70px')
.css('bottom','14px')
.css('line-height','10px')
.css('right','540px')
.css('z-index','100')
.css('font-family','arial')
.css('font-size','14px')
.css('background-color', 'white')
.css('padding', '5px')
.css('border', '1px solid lightgray')
.css('border-radius', '5px')
.css('text-decoration', 'none')
.css('text-align', 'center');
var emailHiddenFromWebCrawler = 'c2lwOmRyYWdhbi5pZ25qaWNAd29ybGRsaW5lLmNvbQ==';
var helpBox = $(`<div id="helpBox">
<b>Login Problems</b><a id="closeHelpBtn" href="javascript:void();" style="float:right;text-decoration:none;">close</a><br>
If you cannot login try following:
<ul>
<li>Restart your Browser.</li>
<li>Activate third party cookies in your
<a href="https://raw.githubusercontent.com/draganignjic/timmi-ess-fusion/master/images/timmi-ess-fusion-allow-cookies-chrome.png" target="_blank">Chrome</a> or
<a href="https://raw.githubusercontent.com/draganignjic/timmi-ess-fusion/master/images/timmi-ess-fusion-allow-cookies-firefox.png" target="_blank">Firefox</a> setting.</li>
<li>Login into the <a href="https://www.corp.worldline.com" target="_blank">worldline portal</a> in another browser tab and then return here.</li>
<li>Update the Timmi ESS Script <a href="` + _updateUrl + `" target="_blank">here</a></li>
<li>Contact the Support in <a href="` + atob(emailHiddenFromWebCrawler) + `">MS Teams</a></li>
</ul>
<br>
</div>`);
$('body').append(helpBox);
helpBox
.css('background-color', 'white')
.css('border', '1px solid lightgray')
.css('border-radius', '10px')
.css('position', 'fixed')
.css('bottom', '50px')
.css('right', '220px')
.css('width', '550px')
.css('height', '200px')
.css('z-index', 1000)
.css('font-family', 'arial')
.css('font-size', '14px')
.css('padding', '10px');
helpBox.hide();
$('#closeHelpBtn').click(function() {
helpBox.hide();
});
// setTimeout(function() {
// if ($('#lucca-banner-avatar').css('background-image').indexOf('employees/929/picture') != -1) {
// var cheesyMessage = "RHJhZ2FuIGFuZCBMdW5hIGxvdmUgeW91";
// $('body').append('<div style="position:fixed;top:10px;left:50%;z-index:10000;font-family:arial;color:gray;">' + atob(cheesyMessage) + ' <span style="color:red;font-size:20px;font-style: normal">❤</span></div>');
// }
// }, 1000);
}
function isEssActive() {
return (_lastEssActivitySignal && (new Date() - _lastEssActivitySignal)/ 1000 < 1);
}
function closeInactiveEss() {
if (_lastEssActivitySignal && (new Date() - _lastEssActivitySignal)/ 1000 >= 10) {
$('#essIframe').hide();
$('#loginBtn').text('ESS');
}
setTimeout(closeInactiveEss, 1000);
}
function setButtonStyle(btn) {
btn
.css('display','inline-block')
.css('text-decoration','none')
.css('background-color','#66A3C7')
.css('border','1px solid gray')
.css('color','white')
.css('font-size','10px')
.css('font-family','arial')
.css('white-space','nowrap')
.css('padding','5px')
.css('border-radius','2px')
.css('veritcal-align','middle')
.css('text-align','center')
.css('border-radius','5px')
.css('cursor','pointer');
}
function minimizeEssFrame() {
var essIframe = $('#essIframe');
essIframe
.attr('maximized','false')
.css('z-index','100')
.css('border','1px solid lightgray')
.css('border-radius','10px')
.css('width','100%')
.css('height','600px');
$('#oldNewEssBtn').show();
}
function maximizeEssFrame() {
var essIframe = $('#essIframe');
essIframe
.attr('maximized','true')
.css('top', '50px')
.css('left', '50px')
.css('width', 'calc(100% - 55px)')
.css('height', 'calc(100% - 55px)')
.css('border', '1px solid gray');
}
function collectTimmiHours() {
setTimeout(collectTimmiHours, 500);
var dateText = $('tt-timesheet-picker span').eq(0).text()?.trim();
if (!dateText) {
return;
}
var month = moment(dateText, 'MMMM', $('html').attr('lang'));
$('tt-date-display').each(function() {
var dayNumber = $(this).find('span').eq(0).text().replace(/\D/g, '');
var day = month.set("date", dayNumber)
let totalHours = 0;
var hoursAndMinutes = $(this).parent().find('.timeProgress-time-text').find('span').eq(0).text();
if (hoursAndMinutes) {
const hoursAndMinutesRegex = new RegExp("([0-9]{1,2})[A-Za-z\. ]*?([0-9]{2})");
let matchGroups = hoursAndMinutes.match(hoursAndMinutesRegex);
var hours = parseInt(matchGroups[1]);
var minutes = matchGroups[2];
totalHours = hours + minutes / 60;
}
var essIframe = document.getElementById('essIframe');
if (essIframe) {
essIframe.contentWindow.postMessage({
day: day.format('YYYY-MM-DD'),
totalHours: totalHours
}, '*');
}
});
}
function getTimmiHoursForDay(dayRowElement, day) {
var totalHours = 0;
dayRowElement.find('.period').each(function() {
var inputs = $(this).find('input');
if (inputs.length === 4){
var startH = inputs.eq(0).val();
var startM = inputs.eq(1).val();
var endH = inputs.eq(2).val();
var endM = inputs.eq(3).val();
var start = moment(day.format('YYYY-MM-DD') + ' ' + startH + ':' + startM);
var end = moment(day.format('YYYY-MM-DD') + ' ' + endH + ':' + endM);
if (endH == 0 && endM == 0){
end = end.add(1, 'days');
}
var duration = moment.duration(end.diff(start));
totalHours += duration.asHours();
}
});
return totalHours;
}
function addTopRightLinks() {
var row = $('#employee_kostl_l').closest('tr');
row.css('white-space', 'nowrap');
var link = $('<td><a style="font-family:arial;font-size:12px;" href="' + self.location.href.replace('&closeAfterLogin','') + '" target="_top">Fullscreen</a></td>');
row.append(link);
var isSaferpayUser = row.find('span:contains("CH08804041")').length === 1;
if (isSaferpayUser){
// Add a confluence link at the top right for the wbs lookup
var wbsLink = $('<td style="text-align:right;width:100%;font-size:12px;padding-right:10px;"><a href="' + _wbsLookupLink + '" target="_blank">Saferpay WBS Lookup</a> - <a href="' + _autmatixWbsLookupLink + '" target="_blank">Automatix</a></td>');
row.append(wbsLink);
}
else if (row.find('span:contains("10270394")').length === 1) {
var cheesyMessage = "RHJhZ2FuIExvdmVzIFlvdQ==";
row.append('<td style="text-align:right;width:100%;font-size:15px;padding-right:10px;line-height:5px;font-style: italic;">' + atob(cheesyMessage) + ' <span style="color:red;font-size:20px;font-style: normal">❤</span></td>');
}
else {
var feedbackHelpLink = $('<td style="text-align:right;width:100%;font-size:12px;padding-right:10px;"><a hreF="mailto:timmi-ess-fusion@dragan.ch?subject=Timmi ESS Fusion - Feedback / Help">Feedback / Help</a></td>');
row.append(feedbackHelpLink);
}
}
function isSessionTimedOut(){
return ($('form[name="loginForm"]').length > 0
|| $('*:contains("Session not found")').length > 0
|| $('*:contains("Session does not exist")').length > 0
|| $('*:contains("Session timed out")').length > 0
|| $('*:contains("session is expired")').length > 0
|| $('*:contains("This logon is obsolete and deprecated")').length > 0
|| $('*:contains("Choose one of the available Identity Providers")').length > 0
|| $('*:contains("Service Not Available")').length > 0
|| $('*:contains("You logged of")').length > 0);
}
function enableEnterKeySave(){
$(document).on("keypress", "input", function(e){
if(e.which == 13){
if ($(this).attr('id') === 'timesheet_pperiod') {
$('#changePeriodButton').click();
}
else if (isWorkhourInputField($(this))){
if ($(this).val() === '*'){
var fillBtn = $(this).parent().find('.fillDayBtn');
setTimeout(function(){
fillBtn.click();
}, 500);
}
else {
$('#save').focus();
$('#save').click();
}
}
else if (isCommentField($(this))){
$('#save').focus();
$('#save').click();
}
}
});
}
function isCommentField(element){
var id = element.attr('id');
return id && id.startsWith('timesheet_tsdurationdata') && id.endsWith('shorttext');
}
function enableDotDecimalEntry(){
$(document).on('change', 'input', function() {
if (isWorkhourInputField($(this))){
$(this).val($(this).val().replace('.', ','));
}
});
}
function isWorkhourInputField(element){
var id = element.attr('id');
if (id && id.startsWith("timesheet_tsdurationdata") && id.endsWith("hours")) {
return true;
}
return elemnet.hasClass('MuiInputBase-input');
}
function fixLayout(){
$('head').append('<link _id="urstyle" rel="stylesheet" type="text/css" href="/sap/public/bc/bsp/Design2008/themes/sap_tradeshow/ur/ur_sf3.css?7.33.3.72.0">');
//fix overall size
$('table[cellspacing=10]').attr('cellspacing','2');
$('#refreshIcon').closest('table').parents().closest('table').css('height','1%');
$('#refreshIcon').parents('tr').css('height','1%');
$('#refreshIcon').css('margin-left','7px');
$('body > table').css('height','100%');
$('#htmlb_image_2').hide();
// vertical alignment
$('.urTxtStd').parent().removeAttr('valign');
$('#htmlb_image_1').closest('tr').find('td').css('line-height','20px');
$('#htmlb_image_1').closest('tr').find('td').css('padding-right','20px');