| ︙ | | | ︙ | |
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
) || 20,
chunkFetch: {
/* Default callack handlers for Diff.fetchArtifactChunk(),
unless overridden by options passeed to that function. */
beforesend: function(){},
aftersend: function(){},
onerror: function(e){
F.toast.error("XHR error: ",e.message);
}
}
}
};
/**
Uses the /jchunk AJAX route to fetch specific lines of a given
artifact. The argument must be an Object suitable for passing as
|
|
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
) || 20,
chunkFetch: {
/* Default callack handlers for Diff.fetchArtifactChunk(),
unless overridden by options passeed to that function. */
beforesend: function(){},
aftersend: function(){},
onerror: function(e){
console.error("XHR error: ",e);
}
}
}
};
/**
Uses the /jchunk AJAX route to fetch specific lines of a given
artifact. The argument must be an Object suitable for passing as
|
| ︙ | | | ︙ | |
136
137
138
139
140
141
142
143
144
145
146
147
148
149
|
};
D.clearElement(tr);
this.e.td = D.addClass(
/* Holder for our UI controls */
D.attr(D.td(tr), 'colspan', this.isSplit ? 5 : 4),
'chunkctrl'
);
this.e.btnWrapper = D.div();
D.append(this.e.td, this.e.btnWrapper);
/**
Depending on various factors, we need one or more of:
- A single button to load the initial chunk incrementally
|
>
|
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
};
D.clearElement(tr);
this.e.td = D.addClass(
/* Holder for our UI controls */
D.attr(D.td(tr), 'colspan', this.isSplit ? 5 : 4),
'chunkctrl'
);
this.e.msgWidget = D.addClass(D.span(), 'hidden');
this.e.btnWrapper = D.div();
D.append(this.e.td, this.e.btnWrapper);
/**
Depending on various factors, we need one or more of:
- A single button to load the initial chunk incrementally
|
| ︙ | | | ︙ | |
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
btnUp = this.createButton(this.FetchType.NextUp);
}
}
//this.e.btnUp = btnUp;
//this.e.btnDown = btnDown;
if(btnDown) D.append(this.e.btnWrapper, btnDown);
if(btnUp) D.append(this.e.btnWrapper, btnUp);
/* For debugging only... */
this.e.posState = D.span();
D.append(this.e.btnWrapper, this.e.posState);
this.updatePosDebug();
};
ChunkLoadControls.prototype = {
|
>
|
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
btnUp = this.createButton(this.FetchType.NextUp);
}
}
//this.e.btnUp = btnUp;
//this.e.btnDown = btnDown;
if(btnDown) D.append(this.e.btnWrapper, btnDown);
if(btnUp) D.append(this.e.btnWrapper, btnUp);
D.append(this.e.btnWrapper, this.e.msgWidget);
/* For debugging only... */
this.e.posState = D.span();
D.append(this.e.btnWrapper, this.e.posState);
this.updatePosDebug();
};
ChunkLoadControls.prototype = {
|
| ︙ | | | ︙ | |
293
294
295
296
297
298
299
300
301
302
303
304
305
306
|
urlParam/*from fetchChunk()*/,
lines/*response lines*/){
if(!lines.length){
/* No more data to load */
this.destroy();
return this;
}
//console.debug("Loaded line range ",
//urlParam.from,"-",urlParam.to, "fetchType ",fetchType);
const lineno = [],
trPrev = this.e.tr.previousElementSibling,
trNext = this.e.tr.nextElementSibling,
doAppend = (
!!trPrev && fetchType>=this.FetchType.FillGap
|
>
|
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
|
urlParam/*from fetchChunk()*/,
lines/*response lines*/){
if(!lines.length){
/* No more data to load */
this.destroy();
return this;
}
this.msg(false);
//console.debug("Loaded line range ",
//urlParam.from,"-",urlParam.to, "fetchType ",fetchType);
const lineno = [],
trPrev = this.e.tr.previousElementSibling,
trNext = this.e.tr.nextElementSibling,
doAppend = (
!!trPrev && fetchType>=this.FetchType.FillGap
|
| ︙ | | | ︙ | |
452
453
454
455
456
457
458
459
460
461
462
463
464
465
|
}
Diff.checkTableWidth(true);
return this;
}else{
throw new Error("Unexpected 'fetchType' value.");
}
},
/**
Fetches and inserts a line chunk. fetchType is:
this.FetchType.NextUp = upwards from next chunk (this.pos.next)
this.FetchType.FillGap = the whole gap between this.pos.prev
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
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
|
}
Diff.checkTableWidth(true);
return this;
}else{
throw new Error("Unexpected 'fetchType' value.");
}
},
/**
Sets this widget's message to the given text. If the message
represents an error, the first argument must be truthy, else it
must be falsy. Returns this object.
*/
msg: function(isError,txt){
if(txt){
if(isError) D.addClass(this.e.msgWidget, 'error');
else D.removeClass(this.e.msgWidget, 'error');
D.append(
D.removeClass(D.clearElement(this.e.msgWidget), 'hidden'),
txt);
}else{
D.addClass(D.clearElement(this.e.msgWidget), 'hidden');
}
return this;
},
/**
Fetches and inserts a line chunk. fetchType is:
this.FetchType.NextUp = upwards from next chunk (this.pos.next)
this.FetchType.FillGap = the whole gap between this.pos.prev
|
| ︙ | | | ︙ | |
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
|
a warning. Returns this object.
*/
fetchChunk: function(fetchType){
/* Forewarning, this is a bit confusing: when fetching the
previous lines, we're doing so on behalf of the *next* diff
chunk (this.pos.next), and vice versa. */
if(this.$isFetching){
F.toast.warning("Cannot load chunk while a load is pending.");
return this;
}
if(fetchType===this.FetchType.NextUp && !this.pos.next
|| fetchType===this.FetchType.PrevDown && !this.pos.prev){
console.error("Attempt to fetch diff lines but don't have any.");
return this;
}
const fOpt = {
urlParams:{
name: this.fileHash, from: 0, to: 0
},
aftersend: ()=>delete this.$isFetching,
onload: (list)=>this.injectResponse(fetchType,up,list)
};
|
|
<
>
|
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
|
a warning. Returns this object.
*/
fetchChunk: function(fetchType){
/* Forewarning, this is a bit confusing: when fetching the
previous lines, we're doing so on behalf of the *next* diff
chunk (this.pos.next), and vice versa. */
if(this.$isFetching){
return this.msg(true,"Cannot load chunk while a load is pending.");
}
if(fetchType===this.FetchType.NextUp && !this.pos.next
|| fetchType===this.FetchType.PrevDown && !this.pos.prev){
console.error("Attempt to fetch diff lines but don't have any.");
return this;
}
this.msg(false,"Fetching diff chunk...");
const fOpt = {
urlParams:{
name: this.fileHash, from: 0, to: 0
},
aftersend: ()=>delete this.$isFetching,
onload: (list)=>this.injectResponse(fetchType,up,list)
};
|
| ︙ | | | ︙ | |
526
527
528
529
530
531
532
533
534
535
536
537
538
539
|
if( this.pos.prev && this.pos.prev.endLhs >= up.from ){
up.from = this.pos.prev.endLhs + 1;
fetchType = this.FetchType.FillGap;
}
}
this.$isFetching = true;
//console.debug("fetchChunk(",fetchType,")",up);
Diff.fetchArtifactChunk(fOpt);
return this;
}
};
/**
Adds context-loading buttons to one or more tables. The argument
|
>
|
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
|
if( this.pos.prev && this.pos.prev.endLhs >= up.from ){
up.from = this.pos.prev.endLhs + 1;
fetchType = this.FetchType.FillGap;
}
}
this.$isFetching = true;
//console.debug("fetchChunk(",fetchType,")",up);
fOpt.onerror = (err)=>this.msg(true,err.message);
Diff.fetchArtifactChunk(fOpt);
return this;
}
};
/**
Adds context-loading buttons to one or more tables. The argument
|
| ︙ | | | ︙ | |