resources/js/forms/uploadImage.js   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 18
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
c 0
b 0
f 0
dl 0
loc 18
rs 10
wmc 3
mnd 0
bc 0
fnc 3
bpm 0
cpm 1
noi 0
1
$(document).ready(function () {
2
3
    // When an image is chosen, replace the "Choose a file" label
4
    $('.custom-file-input').on('change',function () {
5
        // Get the file name
6
        let filePath = $(this).val();
7
        let fileName = filePath.replace(/^.*[\\\/]/, '');
8
9
        // Replace the "Choose a file" label
10
        $('.selectedFile').html(fileName);
11
    })
12
13
    // Delete an already uploaded image
14
    $('.deleteImage').on('click',function () {
15
        $(this).parent().parent().children('span').children("input[type='hidden']").val("true");
16
        $("img.uploadedImage").remove();
17
    })
18
});
19