{"size": 1616, "ext": "js", "max_stars_repo_path": "qisimah/resources/assets/js/mobx/sidebar.js", "max_stars_repo_name": "qisimah/web", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "qisimah/resources/assets/js/mobx/sidebar.js", "max_issues_repo_name": "qisimah/web", "max_issues_repo_issues_event_min_datetime": "2017-12-27T11:21:49.000Z", "max_issues_repo_issues_event_max_datetime": "2018-02-17T03:14:25.000Z", "max_forks_repo_path": "qisimah/resources/assets/js/mobx/sidebar.js", "max_forks_repo_name": "qisimah/web", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": 15, "max_forks_count": null, "avg_line_length": 42.5263157895, "max_line_length": 117, "alphanum_fraction": 0.5544554455}
$(document).ready(function () {
    $('#txtProPic').change(function () {
        var file = document.getElementById('txtProPic');
        var user = {};
        var storage = firebase.storage();
        var axiosrequest = axios.create({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="token"]').attr('content')
            }
        });

        user.id = $('#txtProPic').attr('data-user');
        var fileStorage = storage.ref(user.id+ '.' + file.files[0].type.split('/')[1]);

        var uploading = fileStorage.put(file.files[0]);

        swal('relax', 'Silent upload in progress, your picture change when successful', 'info');

        uploading.on('state_changed', function (snapShot) {
            // Observe state change events such as progress, pause, and resume
            // Get task progress, including the number of bytes uploaded and the total number of bytes to be uploaded
            var progressBar = Math.round((snapShot.bytesTransferred / snapShot.totalBytes) * 100);

            $(document).ready(function () {
                $('#divProPic').attr('data-percent', progressBar);
            });
        }, function (error) {
            return console.log(error);
        }, function () {
            user.img = uploading.snapshot.downloadURL;
            axiosrequest.post('/user/'+user.id+'/update', user).then(function (response) {
                $('#imgProPic').attr('src', user.img);
            }).catch(function (error) {
                swal('iesh', 'Sorry, updating your profile failed. Please try again later', 'error');
            });
        });
    });
});