function vpb_multiple_file_uploader(vpb_configuration_settings) {
this.vpb_settings = vpb_configuration_settings;
this.vpb_files = "";
this.vpb_browsed_files = []
var self = this;
var vpb_msg = "Sorry, your browser does not support this application. Thank You!";
//Get all browsed file extensions
function vpb_file_ext(file) {
return (/[.]/.exec(file)) ? /[^.]+$/.exec(file.toLowerCase()) : '';
}
/* Display added files which are ready for upload */
//with their file types, names, size, date last modified along with an option to remove an unwanted file
vpb_multiple_file_uploader.prototype.vpb_show_added_files = function(vpb_value) {
this.vpb_files = vpb_value;
if (this.vpb_files.length > 0) {
var vpb_added_files_displayer = vpb_file_id = "";
for (var i = 0; i < this.vpb_files.length; i++) {
//Use the names of the files without their extensions as their ids
var files_name_without_extensions = this.vpb_files[i].name.substr(0, this.vpb_files[i].name.lastIndexOf('.')) || this.vpb_files[i].name;
vpb_file_id = files_name_without_extensions.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '');
var vpb_file_to_add = vpb_file_ext(this.vpb_files[i].name);
var vpb_class = $("#added_class").val();
var vpb_file_icon;
//Check and display File Size
var vpb_fileSize = (this.vpb_files[i].size / 1024);
if (vpb_fileSize / 1024 > 1) {
if (((vpb_fileSize / 1024) / 1024) > 1) {
vpb_fileSize = (Math.round(((vpb_fileSize / 1024) / 1024) * 100) / 100);
var vpb_actual_fileSize = vpb_fileSize + " GB";
} else {
vpb_fileSize = (Math.round((vpb_fileSize / 1024) * 100) / 100)
var vpb_actual_fileSize = vpb_fileSize + " MB";
}
} else {
vpb_fileSize = (Math.round(vpb_fileSize * 100) / 100)
var vpb_actual_fileSize = vpb_fileSize + " KB";
}
//Check and display the date that files were last modified
var vpb_date_last_modified = new Date(this.vpb_files[i].lastModifiedDate);
var dd = vpb_date_last_modified.getDate();
var mm = vpb_date_last_modified.getMonth() + 1;
var yyyy = vpb_date_last_modified.getFullYear();
var vpb_date_last_modified_file = dd + '/' + mm + '/' + yyyy;
//File Display Classes
if (vpb_class == 'vpb_blue') {
var new_classc = 'vpb_white';
} else {
var new_classc = 'vpb_blue';
}
if (typeof this.vpb_files[i] != undefined && this.vpb_files[i].name != "") {
//Check for the type of file browsed so as to represent each file with the appropriate file icon
if (vpb_file_to_add == "jpg" || vpb_file_to_add == "JPG" || vpb_file_to_add == "jpeg" || vpb_file_to_add == "JPEG" || vpb_file_to_add == "gif" || vpb_file_to_add == "GIF" || vpb_file_to_add == "png" || vpb_file_to_add == "PNG") {
vpb_file_icon = '';
} else if (vpb_file_to_add == "doc" || vpb_file_to_add == "docx" || vpb_file_to_add == "rtf" || vpb_file_to_add == "DOC" || vpb_file_to_add == "DOCX") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "pdf" || vpb_file_to_add == "PDF") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "txt" || vpb_file_to_add == "TXT" || vpb_file_to_add == "RTF") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "php") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "css") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "js") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "html" || vpb_file_to_add == "HTML" || vpb_file_to_add == "htm" || vpb_file_to_add == "HTM") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "setup") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "video") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "real") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "psd") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "fla") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "xls" || vpb_file_to_add == "xlsx") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "swf") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "eps") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "exe") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "binary") {
vpb_file_icon = '
';
} else if (vpb_file_to_add == "zip") {
vpb_file_icon = '
';
} else {
vpb_file_icon = '
';
}
var split = this.vpb_files[i].name.split('.');
var filename = split[0];
var extension = split[1];
if (filename.length > 15) {
filename = filename.substring(0, 10) + '[...]';
}
var result = filename + '.' + extension;
//Assign browsed files to a variable so as to later display them below
vpb_added_files_displayer += '