Index: lams_central/web/includes/javascript/upload.js =================================================================== RCS file: /usr/local/cvsroot/lams_central/web/includes/javascript/Attic/upload.js,v diff -u -r1.1.2.1 -r1.1.2.2 --- lams_central/web/includes/javascript/upload.js 27 Feb 2017 09:57:59 -0000 1.1.2.1 +++ lams_central/web/includes/javascript/upload.js 28 Feb 2017 11:27:11 -0000 1.1.2.2 @@ -1,10 +1,10 @@ // LAMS Helper methods to validate file upload // returns true if not an executable, shows error message if not valid -function validateShowErrorNotExecutable(file, errorMessage, showFilename, exeListStr) { - clearFileError(); +function validateShowErrorNotExecutable(file, errorMessage, showFilename, exeListStr, errDivId) { + clearFileError(errDivId); if ( ! validateNotExecutable( file, exeListStr) ) { - showFileError(showFilename ? filename + ": " + errorMessage: errorMessage); + showFileError(showFilename ? file.name + ": " + errorMessage: errorMessage, errDivId); return false; } return true; @@ -33,11 +33,11 @@ } // returns false if not an image type, shows error message if not valid -function validateShowErrorImageType(file, errorMessage, showFilename, exeTypes) { +function validateShowErrorImageType(file, errorMessage, showFilename, errDivId) { // Check the file type. - clearFileError(); + clearFileError(errDivId); if (file.type != 'image/png' && file.type != 'image/jpg' && file.type != 'image/gif' && file.type != 'image/jpeg' ) { - showFileError(showFilename ? file.name + ": " + errorMessage: errorMessage); + showFileError(showFilename ? file.value + ": " + errorMessage: errorMessage, errDivId); return false; } return true; @@ -47,10 +47,10 @@ // maxSize: maximum size allowed in bytes // rawErrorMessage: message text from I18N files. Must contain '{0}' which will be replaced by the size and the units // e.g. 'Uploaded file exceeded maximum size: {0}' -function validateShowErrorFileSize(file, maxSize, errorMessage, showFilename) { +function validateShowErrorFileSize(file, maxSize, errorMessage, showFilename, errDivId) { if ( file.size > maxSize ) { var updatedErrorMessage = errorMessage.replace('{0}', formatBytesForMessage(maxSize) ) - showFileError(showFilename ? file.name + ": " + updatedErrorMessage: updatedErrorMessage); + showFileError(showFilename ? file.value + ": " + updatedErrorMessage: updatedErrorMessage, errDivId); return false; } return true; @@ -79,13 +79,19 @@ return parseFloat(sizeinBytes).toFixed(1) + unit; } -function clearFileError() { - var errDiv = $("#file-error-msg"); +function clearFileError(errDivId) { + if ( ! errDivId || errDivId.length == 0 ) { + errDivId = 'file-error-msg'; + } + var errDiv = $('#'+errDivId); errDiv.empty(); errDiv.css( "display", "none" ); } -function showFileError(error) { - var errDiv = $("#file-error-msg"); +function showFileError(error, errDivId) { + if ( ! errDivId || errDivId.length == 0 ) { + errDivId = 'file-error-msg'; + } + var errDiv = $('#'+errDivId); if ( errDiv.size() > 0 ) { errDiv.append(error); errDiv.css( "display", "block" );