@@ -5,6 +5,8 @@ window.shark = window.shark || {};
5
5
window . shark . info = window . shark . info || { } ;
6
6
window . shark . screenshots = window . shark . screenshots || { } ;
7
7
8
+ var screenshot_counter = 0 ;
9
+
8
10
function goToLoadingScreen ( ) {
9
11
document . querySelector ( '.file-upload-screen' ) . style . display = 'none' ;
10
12
document . querySelector ( '.loading-screen' ) . style . display = 'initial' ;
@@ -246,6 +248,9 @@ function addScreenshot(screenshot) {
246
248
<button onclick='flipScreenshot("${ screenshot . id } ", axis="y")'>Horizontal Flip</button>
247
249
</span>
248
250
</div>
251
+ <div>
252
+ <button onclick='delete_screenshot("${ screenshot . id } ")'>Delete</button>
253
+ </div>
249
254
</div>
250
255
</div>
251
256
` ;
@@ -358,7 +363,10 @@ function takeVideoScreenshot(query, xPercent, yPercent, widthPercent, heightPerc
358
363
359
364
let id = randomHex ( ) ;
360
365
361
- let index_string = String ( Object . keys ( window . shark . screenshots ) . length ) . padStart ( 3 , '0' ) ;
366
+ // Get screenshot counter value and update counter.
367
+ let index_string = String ( screenshot_counter ) . padStart ( 3 , '0' ) ;
368
+ screenshot_counter += 1 ;
369
+
362
370
let name = window . shark . info [ 'video' ] . name + "_" + index_string ;
363
371
364
372
let time = undefined ;
@@ -396,6 +404,15 @@ function takeScreenshot(source, x, y, width, height, format = 'image/jpeg') {
396
404
return canvas . toDataURL ( format ) ;
397
405
}
398
406
407
+ // Delete a screenshot, it is no longer displayed or saved.
408
+ function delete_screenshot ( screenshot_id ) {
409
+ // Find screenshot area to remove.
410
+ let screenshot_area = document . querySelector ( `.screenshot[data-id="${ screenshot_id } "]` ) ;
411
+ screenshot_area . remove ( ) ;
412
+ // Update screenshots metadata to remove flipped image.
413
+ delete window . shark . screenshots [ screenshot_id ] ;
414
+ }
415
+
399
416
// Inputs don't have a timezone aware type.
400
417
// Instead we use datetime-local (which is always local).
401
418
// But to format to set it's input is a bit tricky to set (while getting the timezone correct).
0 commit comments