-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
869 lines (833 loc) · 32.8 KB
/
Copy pathindex.html
File metadata and controls
869 lines (833 loc) · 32.8 KB
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
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8"/>
<title>Ticket Editor</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/starter-template/">
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<!-- Custom styles for this template -->
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/css/bootstrap-select.min.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap-select@1.13.9/dist/js/bootstrap-select.min.js"></script>
<style type="text/css">
div{
padding:8px;
}
label{
font-size:10pt;
}
.ticket {
color: #FFF;
text-align: center;
padding: 5px;
position: absolute;
cursor: default;
width: 250px;
border-radius: 5px;
}
.auto-resize{
width: 100%;
font-size:9pt;
}
.story-point{
border: 0px;
font-size:8pt;
color:darkslategray;
}
.color-dialog{
width:30px;
}
.ticketno{
float:left;
font-size:10pt;
margin-right:30px;
color:black;
}
.annotation{
font-size:10pt;
margin-left:10pt;
margin-right:1pt;
color:darkslategray;
}
body {
margin-left: 0px;
margin-top: 0px;
}
</style>
</head>
<body>
<script type="text/javascript">
$(document).ready(function(){
//create web socket
var ws = new WebSocket("ws://localhost:9999/");
//session and client id
var session_id = "default"
var client_id = 0;
//positions
var posX1 = 0;
var posY1 = 0;
var posX2 = 0;
var posY2 = 0;
var scrX = 0;
var scrY = 0;
var scrX2 = 0;
var scrY2 = 0;
var zindex = 0
//moving object
var moving = null;
//editimg object
var editing = null;
//ticket default color
var default_color = "#a8c6ff"
//default ticket_tag
var ticket_tag = "ABCD"
//web socket open
ws.onopen = function(message){
console.log(message.type);
};
//web socket message receive
ws.onmessage = function(message){
var data = $.parseJSON(message.data);
switch(data.method){
case "notifyClientID":
client_id = Number(data.client_id);
$('#sockStatus').css('color', 'green');
//connect method
session_id = prompt("Please enter Session ID", session_id);
var data = {
"method": "connect",
"client_id": client_id,
"session_id": session_id
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
break;
case "initTicket":
//add ticket
var newTextBoxDiv = $(document.createElement('div')).attr("id", 'TextBoxDiv' + data.ticket_id);
newTextBoxDiv.attr("class", 'ticket');
newTextBoxDiv.after().html(
'<button type="button" class="close" style="margin-top:-8px;">×</button>'
+ '<button type="button" class="btn btn-small export" style="float:left;margin-top:-5px;margin-left:-5px;font-size:8px;">Jira</button>'
+ '<textarea></textarea>'
+ '<text class="ticketno">#' + data.ticket_id + '</text>'
+ '<text class="annotation">Point:</text>'
+ '<select class="story-point">'
+ '<option hidden>-</option>'
+ '<option>0.3</option>'
+ '<option>0.5</option>'
+ '<option>1</option>'
+ '<option>1.5</option>'
+ '<option>2</option>'
+ '<option>3</option>'
+ '<option>4</option>'
+ '<option>5</option>'
+ '<option>8</option>'
+ '<option>13</option>'
+ '</select>'
+ '<text class="annotation">Color:</text>'
+ '<input class="color-dialog" type="color" value="' + data.color + '">');
//set textarea to readonly
var textarea = newTextBoxDiv.children("textarea");
textarea.attr("class", 'auto-resize');
textarea.attr('readonly',true);
newTextBoxDiv.appendTo("#TextBoxesGroup");
//set position
var parent = $("#TextBoxDiv" + data.ticket_id);
if(data.top != 0){
parent.css("top", Number(data.top));
}
if(data.left != 0){
parent.css("left", Number(data.left));
}
//set text
var textarea = parent.children('textarea.auto-resize');
var binary = atob(data.text);
var len = binary.length;
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = binary.charCodeAt(i);
}
text = (new TextDecoder).decode(bytes)
textarea.val(text);
var outerHeight = textarea.outerHeight();
var schrollHeight = textarea.prop('scrollHeight');
if (textarea.outerHeight() > textarea.prop('scrollHeight')){
textarea.height(1);
}
var height = textarea.height();
while (textarea.outerHeight() < textarea.prop('scrollHeight')){
height = height + 1;
textarea.height(height);
}
//set point
parent.children('select.story-point').val(data.point);
var totalpoints = 0;
$('select.story-point').each(function(i, elm){
if($(elm).val() != "-"){
totalpoints += Number($(elm).val());
}
});
totalpoints *= 10;
totalpoints = Math.round(totalpoints,2);
totalpoints /= 10;
$('#total-point').text('Total : ' + String(totalpoints));
//set color
parent.css('background', data.color);
parent.children('textarea.auto-resize').css('background', data.color);
parent.children('select.story-point').css('background', data.color);
parent.children('input.color-dialog').val(data.color);
//
if(data.fixed == true){
parent.children('button.close').text('');
parent.children('button.export').css('color', 'gray');
parent.children('button.export').removeClass('export');
}
break;
case "addTicket":
if(data.session_id != session_id){
break;
}
//add ticket
var newTextBoxDiv = $(document.createElement('div')).attr("id", 'TextBoxDiv' + data.ticket_id);
newTextBoxDiv.attr("class", 'ticket');
newTextBoxDiv.after().html(
'<button type="button" class="close" style="margin-top:-8px;">×</button>'
+ '<button type="button" class="btn btn-small export" style="float:left;margin-top:-5px;margin-left:-5px;font-size:8px;">Jira</button>'
+ '<textarea></textarea>'
+ '<text class="ticketno">#' + data.ticket_id + '</text>'
+ '<text class="annotation">Point:</text>'
+ '<select class="story-point" size="1">'
+ '<option hidden>-</option>'
+ '<option>0.3</option>'
+ '<option>0.5</option>'
+ '<option>1</option>'
+ '<option>1.5</option>'
+ '<option>2</option>'
+ '<option>3</option>'
+ '<option>4</option>'
+ '<option>5</option>'
+ '<option>8</option>'
+ '<option>13</option>'
+ '</select>'
+ '<text class="annotation">Color:</text>'
+ '<input class="color-dialog" type="color" value="' + data.color + '" style=”float:right”>');
//set textarea to readonly
var textarea = newTextBoxDiv.children("textarea");
textarea.attr("class", 'auto-resize');
textarea.attr('readonly',true);
newTextBoxDiv.appendTo("#TextBoxesGroup");
//set color
parent = $("#TextBoxDiv" + data.ticket_id);
parent.css('background', data.color);
parent.children('textarea.auto-resize').css('background', data.color);
parent.children('select.story-point').css('background', data.color);
parent.children('input.color-dialog').val(data.color);
//zindex
parent.css('position','absolute')
parent.css('zIndex', zindex);
break;
case "moveTicket":
if(data.session_id != session_id){
break;
}
if(data.client_id != client_id){
//set element position
var parent = $("#" + data.id);
parent.css("top", Number(data.top));
parent.css("left", Number(data.left));
}
break;
case "fixTicket":
if(data.session_id != session_id){
break;
}
if(data.client_id != client_id){
//set element position
var parent = $("#" + data.id);
parent.css("top", Number(data.top));
parent.css("left", Number(data.left));
}
break;
case "editTicket":
if(data.session_id != session_id){
break;
}
if(data.client_id != client_id){
var parent = $("#" + data.id);
var textarea = parent.children('textarea.auto-resize');
//set text
let binary = atob(data.text);
let len = binary.length;
let bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) {
bytes[i] = binary.charCodeAt(i);
}
text = (new TextDecoder).decode(bytes)
textarea.val(text);
var outerHeight = textarea.outerHeight();
var schrollHeight = textarea.prop('scrollHeight');
if (textarea.outerHeight() > textarea.prop('scrollHeight')){
textarea.height(1);
}
var height = textarea.height();
while (textarea.outerHeight() < textarea.prop('scrollHeight')){
height = height + 1;
textarea.height(height);
}
}
break;
case "deleteTicket":
if(data.session_id != session_id){
break;
}
var parent = $("#" + data.id);
parent.remove();
var totalpoints = 0;
$('select.story-point').each(function(i, elm){
if($(elm).val() != "-"){
totalpoints += Number($(elm).val());
}
});
totalpoints *= 10;
totalpoints = Math.round(totalpoints,2);
totalpoints /= 10;
$('#total-point').text('Total : ' + String(totalpoints));
break;
case "lockTicket":
if(data.session_id != session_id){
break;
}
switch(data.next){
case "editTicket":
if(data.result == "OK"){
var parent = $("#" + data.id);
editing = parent.children('textarea.auto-resize');
editing.attr('readonly', false);
editing.focus();
//editing.attr('selectionEnd', 0);
//editing.attr('selectionStart', 0);
}
break;
case "moveTicket":
if(data.result == "OK"){
if(data.client_id == client_id){
moving = $("#" + data.id);
//set element position
pos1 = moving.position();
posX1 = data.left - pos1.left;
posY1 = data.top - pos1.top;
//frame border
moving.css('border', 'solid 1px black');
//zindex
moving.css('position','absolute')
moving.css('zIndex', data.zindex);
} else {
//zindex
$("#" + data.id).css('position','absolute')
$("#" + data.id).css('zIndex', data.zindex);
}
zindex = data.zindex
}
break;
}
break;
case "setPoint":
if(data.session_id != session_id){
break;
}
if(data.client_id != client_id){
//set point
var parent = $("#" + data.id);
parent.children('select.story-point').val(data.point);
}
var totalpoints = 0;
$('select.story-point').each(function(i, elm){
if($(elm).val() != "-"){
totalpoints += Number($(elm).val());
}
});
totalpoints *= 10;
totalpoints = Math.round(totalpoints,2);
totalpoints /= 10;
$('#total-point').text('Total : ' + String(totalpoints));
break;
case "setColor":
if(data.session_id != session_id){
break;
}
if(data.client_id != client_id){
var parent = $("#TextBoxDiv" + data.ticket_id);
parent.css('background', data.color);
parent.children('textarea.auto-resize').css('background', data.color);
parent.children('select.story-point').css('background', data.color);
parent.children('input.color-dialog').val(data.color);
}
break;
case "exportToJira":
if(data.session_id != session_id){
break;
}
var parent = $("#TextBoxDiv" + data.ticket_id);
parent.children('button.close').text('');
parent.children('button.export').css('color', 'gray');
parent.children('button.export').removeClass('export');
break;
case "importFromJira":
if(data.session_id != session_id){
break;
}
//add ticket
var newTextBoxDiv = $(document.createElement('div')).attr("id", 'TextBoxDiv' + data.ticket_id);
newTextBoxDiv.attr("class", 'ticket');
newTextBoxDiv.after().html(
'<button type="button" class="close" style="margin-top:-8px;">×</button>'
+ '<button type="button" class="btn btn-small export" style="float:left;margin-top:-5px;margin-left:-5px;font-size:8px;">Jira</button>'
+ '<textarea></textarea>'
+ '<text class="ticketno">#' + data.ticket_id + '</text>'
+ '<text class="annotation">Point:</text>'
+ '<select class="story-point">'
+ '<option hidden>-</option>'
+ '<option>0.3</option>'
+ '<option>0.5</option>'
+ '<option>1</option>'
+ '<option>1.5</option>'
+ '<option>2</option>'
+ '<option>3</option>'
+ '<option>4</option>'
+ '<option>5</option>'
+ '<option>8</option>'
+ '<option>13</option>'
+ '</select>'
+ '<text class="annotation">Color:</text>'
+ '<input class="color-dialog" type="color" value="' + data.color + '">');
//set textarea to readonly
var textarea = newTextBoxDiv.children("textarea");
textarea.attr("class", 'auto-resize');
textarea.attr('readonly',true);
newTextBoxDiv.appendTo("#TextBoxesGroup");
//set position
var parent = $("#TextBoxDiv" + data.ticket_id);
if(data.top != 0){
parent.css("top", Number(data.top));
}
if(data.left != 0){
parent.css("left", Number(data.left));
}
//set text
var textarea = parent.children('textarea.auto-resize');
var binary = atob(data.text);
var len = binary.length;
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = binary.charCodeAt(i);
}
text = (new TextDecoder).decode(bytes)
textarea.val(text);
var outerHeight = textarea.outerHeight();
var schrollHeight = textarea.prop('scrollHeight');
if (textarea.outerHeight() > textarea.prop('scrollHeight')){
textarea.height(1);
}
var height = textarea.height();
while (textarea.outerHeight() < textarea.prop('scrollHeight')){
height = height + 1;
textarea.height(height);
}
//set point
parent.children('select.story-point').val(data.point);
var totalpoints = 0;
$('select.story-point').each(function(i, elm){
if($(elm).val() != "-"){
totalpoints += Number($(elm).val());
}
});
totalpoints *= 10;
totalpoints = Math.round(totalpoints,2);
totalpoints /= 10;
$('#total-point').text('Total : ' + String(totalpoints));
//set color
parent.css('background', data.color);
parent.children('textarea.auto-resize').css('background', data.color);
parent.children('select.story-point').css('background', data.color);
parent.children('input.color-dialog').val(data.color);
//
if(data.fixed == true){
parent.children('button.close').text('');
parent.children('button.export').css('color', 'gray');
parent.children('button.export').removeClass('export');
}
break;
}
}
//web socket close
ws.onclose = function(message){
$('#sockStatus').css('color', 'red');
console.log(message.type);
};
//click event (add)
$("#addButton").click(function () {
var data = {
"method": "addTicket",
"client_id": client_id,
"color": default_color
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
});
//click event (tag)
$("#tagButton").click(function () {
var map = {};
//get #tags
$('textarea.auto-resize').each(function(i, elm){
var point = $(elm).parent().children('select.story-point').val();
if(point != '-'){
tags = $(elm).val().match(/[##][A-Za-zA-Za-z一-鿆0-90-9ぁ-ヶヲ-゚ー._-]+/gm);
//alert(tags);
for (var key in tags) {
//alert(tag);
if(map[tags[key]]){
map[tags[key]] += Number(point);
} else {
map[tags[key]] = Number(point);
}
}
}
});
//sort map
var sorted = {};
var key = Object.keys(map);
key.sort();
for( var i = 0; i < key.length; i++ ) {
sorted[ key[i] ] = map[ key[i] ];
}
//output
var outtext = '';
for(var key in sorted){
outtext += (key + ' : ' + map[key] + '\n');
}
alert(outtext);
});
//click event (import)
$("#importButton").click(function () {
key = prompt("Please enter Jira ticket key to import (ex." + ticket_tag + "-0123)", ticket_tag + "-0123");
if(key != null){
var data = {
"method": "importFromJira",
"client_id": client_id,
"color": default_color,
"key": key
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
}
});
$(document).on('click','button.export', function(evt){
if(!confirm('Eexport this ticket to Jira?\n(This ticket can no longer be edited)')){
//cansel
return false;
}else{
//ok
var summary = '';
var description = '';
var parent = $(this).parent();
var data = {
"method": "exportToJira",
"client_id": client_id,
"id": parent.attr("id"),
"ticket_id": parent.attr("id").replace(/[^0-9]/g, ''),
"tag": ticket_tag,
"summary": summary,
"description": description
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
}
evt.stopPropagation();
});
//mouse move event
$(document).mousemove(function(evt2) {
//moving
if(moving) {
if((evt2.pageY - posY1) >= 70){
//specify element position using css
posX2 = evt2.pageX - posX1;
posY2 = evt2.pageY - posY1;
moving.css("left", posX2);
moving.css("top", posY2);
var data = {
"method": "moveTicket",
"client_id": client_id,
"id": moving.attr("id"),
"ticket_id": moving.attr("id").replace(/[^0-9]/g, ''),
"left": posX2,
"top": posY2
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
}
}
});
//scrolling event
$(window).scroll(function(evt2) {
//moving
if(moving) {
scrX = scrX2;
scrY = scrY2;
scrX2 = $(this).scrollLeft();
scrY2 = $(this).scrollTop();
scrXdiff = scrX2 - scrX;
scrYdiff = scrY2 - scrY;
//specify element position using css
posX2 = posX2 + scrXdiff;
posY2 = posY2 + scrYdiff;
moving.css("left", posX2);
moving.css("top", posY2);
var data = {
"method": "moveTicket",
"client_id": client_id,
"id": moving.attr("id"),
"ticket_id": moving.attr("id").replace(/[^0-9]/g, ''),
"left": posX2,
"top": posY2
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
}
});
//point click actions
$(document).on('click','select.story-point', function(evt){
evt.stopPropagation();
});
//change point actions
$(document).on('change','select.story-point', function(){
if(moving){
// require unlock
var data = {
"method": "releaseTicket",
"client_id": client_id,
"ticket_id": moving.attr("id").replace(/[^0-9]/g, '')
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
// fix posision
var data = {
"method": "fixTicket",
"client_id": client_id,
"id": moving.attr("id"),
"ticket_id": moving.attr("id").replace(/[^0-9]/g, ''),
"left": posX2,
"top": posY2
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
//frame border
moving.css('border', '');
moving = null
}
var data = {
"method": "setPoint",
"client_id": client_id,
"id": $(this).parent().attr("id"),
"ticket_id": $(this).parent().attr("id").replace(/[^0-9]/g, ''),
"point": $(this).val()
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
});
//delete ticket button click action
$(document).on('click','button.close', function(evt1){
// delete
var data = {
"method": "deleteTicket",
"client_id": client_id,
"id": $(this).parent().attr("id"),
"ticket_id": $(this).parent().attr("id").replace(/[^0-9]/g, ''),
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
});
//textarea click action
$(document).on('click','textarea.auto-resize', function(evt1){
if(editing){
// require unlock
var data = {
"method": "releaseTicket",
"client_id": client_id,
"ticket_id": editing.parent().attr("id").replace(/[^0-9]/g, '')
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
editing.attr('readonly', true);
editing = null;
}
// require lock
var data = {
"method": "lockTicket",
"client_id": client_id,
"id": $(this).parent().attr("id"),
"ticket_id": $(this).parent().attr("id").replace(/[^0-9]/g, ''),
"next": "editTicket"
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
evt1.stopPropagation();
});
//out of textarea click action
$(document).on('click',function(e) {
if(!$(e.target).closest('textarea.auto-resize').length) {
if(editing){
// require unlock
var data = {
"method": "releaseTicket",
"client_id": client_id,
"ticket_id": editing.parent().attr("id").replace(/[^0-9]/g, '')
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
editing.attr('readonly', true);
editing = null;
}
}
});
//ticket click action
$(document).on('click', 'div', function(evt1) {
var idname = $(this).attr("id");
var pattern = 'TextBoxDiv';
if(idname.indexOf(pattern)){
return
}
//not moving
if(moving == null) {
if(editing){
//require unlock
var data = {
"method": "releaseTicket",
"client_id": client_id,
"ticket_id": editing.parent().attr("id").replace(/[^0-9]/g, '')
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
editing.attr('readonly', true);
editing = null;
}
//require lock
var data = {
"method": "lockTicket",
"client_id": client_id,
"id": $(this).attr("id"),
"ticket_id": $(this).attr("id").replace(/[^0-9]/g, ''),
"next": "moveTicket",
"left": evt1.pageX,
"top": evt1.pageY
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
//moving
} else if(moving) {
//require unlock
var data = {
"method": "releaseTicket",
"client_id": client_id,
"ticket_id": moving.attr("id").replace(/[^0-9]/g, '')
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
//fix posision
var data = {
"method": "fixTicket",
"client_id": client_id,
"id": moving.attr("id"),
"ticket_id": moving.attr("id").replace(/[^0-9]/g, ''),
"left": posX2,
"top": posY2
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
//frame border
moving.css('border', '');
moving = null;
}
evt1.stopPropagation();
});
//textarea input action
$(document).on('change keyup keydown paste cut','textarea.auto-resize', function(){
var arr = (new TextEncoder).encode($(this).val());
let base64String = btoa(String.fromCharCode(...arr));
var data = {
"method": "editTicket",
"client_id": client_id,
"id": $(this).parent().attr('id'),
"ticket_id": $(this).parent().attr("id").replace(/[^0-9]/g, ''),
"text": base64String
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
if ($(this).outerHeight() > this.scrollHeight){
$(this).height(1);
}
var height = $(this).height();
while ($(this).outerHeight() < this.scrollHeight){
height = height + 1;
$(this).height(height);
}
});
//color change action
$(document).on("change",'input.color-dialog', function(evt1){
var color = $(this).val();
var parent = $(this).parent();
parent.css('background', color);
parent.children('textarea.auto-resize').css('background', color);
parent.children('select.story-point').css('background', color);
var data = {
"method": "setColor",
"client_id": client_id,
"id": $(this).parent().attr('id'),
"ticket_id": $(this).parent().attr("id").replace(/[^0-9]/g, ''),
"color": color
}
var jsonString = JSON.stringify(data);
ws.send(jsonString);
evt1.stopPropagation();
});
$(document).on("click",'input.color-dialog', function(evt1){
evt1.stopPropagation();
});
});
</script>
</head><body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#">Ticket Editor</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav1" aria-controls="navbarNav1" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-left" id="navbarNav1">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" style="width:50px;" id='addButton'>Add<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link" style="width:80px;" id='importButton'>Import<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link" style="width:60px;" id='tagButton'>#Tags<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" style="width:100px;" id="total-point"></a>
</li>
<li class="nav-item">
<a class="nav-link" style="width:40px;color:red;" id='sockStatus'>■<span class="sr-only">(current)</span></a>
</li>
</ul>
</div>
</nav>
<div id='TextBoxesGroup'>
</div>
</body>
</html>