Slider w/Multiple FileReader

by Hybridx24

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<button id="_uploadImages" class="btn btn-primary">Upload Images</button>

<form id="_imagesForm" action="" method="post">
<input id="_imagesInput" type="file" style="display:none" multiple>
</form>

<div id="_displayImages">
    <div class="slider">
        <ul id="frames" class="frames">

        </ul>
    </div>
</div>

CSS

* {
    margin: 0;
    padding: 0;
    /*transition*/
    -webkit-transition: all 1s ease;
    -moz-transition: all 1s ease;
    -o-transition: all 1s ease;
    transition: all 1s ease;
}
body {
    padding:30px;
}
/* Slider */
.slider {
    height: 250px;
    left: 50%;
    margin: -125px -225px;
    position: absolute;
    top: 48%;
    width: 450px;
    /*box-shadow*/
    -webkit-box-shadow: 0 0 5px #000;
    -moz-box-shadow: 0 0 5px #000;
    box-shadow: 0 0 5px #000;
}
.slider .frames {
    height: 250px;
    position: relative;
	list-style-type: none;
}
.slider .frames .slide {
    height: 250px;
    list-style: none;
    position: absolute;
    width: 450px;
}
.slider .slide:target { z-index: 100 }
.slider .frames .slide img {
    height: 250px;
    width: 450px;
}
.slider .frames .slide nav a {
    background: hsla(0,0%,0%,.75);
    color: #fff;
    font-size: 16px;
    line-height: 50px;
    margin-top: -25px;
    opacity: 0;
    position: absolute;
    text-align: center;
    text-decoration: none;
    top: 50%;
    width: 50px;
    visibility: hidden;
    z-index: 10;
}
.slider:hover .frames .slide nav a {
    opacity: 1;
    visibility: visible;
}
.slider .frames .slide nav .prev {
    /*border-radius*/
    -webkit-border-radius: 0 25px 25px 0;
    -moz-border-radius: 0 25px 25px 0;
    border-radius: 0 25px 25px 0;
    left: 0;
}
.slider .frames .slide nav .next {
    /*border-radius*/
    -webkit-border-radius: 25px 0 0 25px;
    -moz-border-radius: 25px 0 0 25px;
    border-radius: 25px 0 0 25px;
    right: 0;
}
.slider .frames .slide nav a:hover { background: #000 }
.slider .quicknav {
    bottom: 0;
    font-size: 0;
    opacity: 0;
    position: absolute;
    text-align: center;
    width: 100%;
    z-index: 100;
}
.slider:hover .quicknav { opacity: .9 }
.slider .quicknav li { display: inline-block }
.slider .quicknav a {
    background: hsla(0,0%,100%,.9);
    border: 1px solid hsla(0,0%,0%,.9);
    /*border-radius*/
    -webkit-border-radius:...

JavaScript

$('#_uploadImages').click(function() {
	$('#_imagesInput').click();
});

$('#_imagesInput').on('change', function() {
	handleFileSelect();
});

function handleFileSelect() {
    //Check File API support
    if (window.File && window.FileList && window.FileReader) {

        var files = event.target.files; //FileList object
        var output = document.getElementById("frames");
		var arrFilesCount = [];
                
        for (var i = 0; i < files.length; i++) {
            arrFilesCount.push(i);
            var file = files[i];

            //Only pics
            if (!file.type.match('image')) continue;

            var picReader = new FileReader();
            picReader.addEventListener("load", function (event) {
                var picFile = event.target;

                console.log(event);

				current_i = arrFilesCount.shift();
				prev_i = current_i - 1;
				next_i = current_i + 1;
                
                if(prev_i < 0) {
                    prev_i = 0
                }
                //if(arrFilesCount.length < 1) {
                //	next_i = 0
                //}

                output.innerHTML = output.innerHTML + '<li id="slide-' + current_i + '" class="slide">' + "<img src='" + picFile.result + "'" + "title=''/>" + '<nav>' + '<a class="prev" href="#slide-' + prev_i + '">&larr;</a>' + '<a class="next" href="#slide-' + next_i + '">&rarr;</a>' + '</nav>' + '<li>';  // TODO: Enter Title
                
            });
            //Read the image
            picReader.readAsDataURL(file);
        }
		output.innerHTML = output.innerHTML + '<li class="quicknav">' + '<ul>' + '<li><a href="#slide-0"></a></li>' + '<li><a href="#slide-1"></a></li>' + '<li><a href="#slide-2"></a></li>' + '</ul>' + '</li>'
    } else {
        console.log("Your browser does not support File API");
    }
}