diff --git a/config/development.json b/config/development.json index 34c4c849..e91061d3 100644 --- a/config/development.json +++ b/config/development.json @@ -7,7 +7,7 @@ }, "Database": { "MySqlConnectionUri": "none", - "DownloadDirectory": "/home/lbry/Downloads/" + "DownloadDirectory": "C:\\Users\\Bones\\Downloads\\lbry\\" }, "Logging": { "LogLevel": "silly" diff --git a/public/assets/js/generalFunctions.js b/public/assets/js/generalFunctions.js index 521e26fc..0556f0c5 100644 --- a/public/assets/js/generalFunctions.js +++ b/public/assets/js/generalFunctions.js @@ -17,7 +17,6 @@ function toggleSection(event){ } } -// create a progress animation function createProgressBar(element, size){ var x = 1; var adder = 1; @@ -54,4 +53,27 @@ function dataURItoBlob(dataURI) { } return new Blob([ia], {type:mimeString}); -} \ No newline at end of file +} + +function showError(elementId, errorMsg) { + var errorDisplay = document.getElementById(elementId); + errorDisplay.hidden = false; + errorDisplay.innerText = errorMsg; +} + +// Create new error objects, that prototypically inherit from the Error constructor +function FileError(message) { + this.name = 'FileError'; + this.message = message || 'Default Message'; + this.stack = (new Error()).stack; +} +FileError.prototype = Object.create(Error.prototype); +FileError.prototype.constructor = FileError; + +function NameError(message) { + this.name = 'NameError'; + this.message = message || 'Default Message'; + this.stack = (new Error()).stack; +} +NameError.prototype = Object.create(Error.prototype); +NameError.prototype.constructor = NameError; \ No newline at end of file diff --git a/public/assets/js/index.js b/public/assets/js/index.js index 81b1d9ee..e7e99d5e 100644 --- a/public/assets/js/index.js +++ b/public/assets/js/index.js @@ -11,7 +11,13 @@ function publishSelectedImage(event) { try { validateSubmission(stagedFiles, name); } catch (error) { - alert(error.message); + if (error.name === 'FileError'){ + showError('input-error-file-selection', error.message); + } else if (error.name === 'NameError') { + showError('input-error-claim-name', error.message); + } else { + showError('input-error-publish-submit', error.message); + } return; } // make sure the name is available then start the upload @@ -20,7 +26,7 @@ function publishSelectedImage(event) { uploader.submitFiles(stagedFiles); //note: must pass the file as part of an array. }) .catch(function(error) { - alert(error); + showError('input-error-claim-name', error); }) }; diff --git a/public/assets/js/memeFodder-publish.js b/public/assets/js/memeFodder-publish.js index 67c13597..191063de 100644 --- a/public/assets/js/memeFodder-publish.js +++ b/public/assets/js/memeFodder-publish.js @@ -47,19 +47,4 @@ socket.on('publish-complete', function(msg){ publishResults += '
'; // update publish area document.getElementById('publish-active-area').innerHTML = publishResults; - // update the link holder - document.getElementById('direct-link-holder').innerText = 'https://spee.ch' + directUrl; - // enable copy-to-clipboard - var copyBtn = document.querySelector('.copy-button'); - copyBtn.addEventListener('click', function(event) { - // select the text - var text = document.getElementById('direct-link-holder'); - text.select(); - try { - var successful = document.execCommand('copy'); - var msg = successful ? 'successful' : 'unsuccessful'; - } catch (err) { - alert('Oops, unable to copy'); - } - }); }); \ No newline at end of file diff --git a/public/assets/js/publishFunctions.js b/public/assets/js/publishFunctions.js index 67fcbf09..b93a4f55 100644 --- a/public/assets/js/publishFunctions.js +++ b/public/assets/js/publishFunctions.js @@ -29,16 +29,16 @@ function validateFile(file) { function validateSubmission(stagedFiles, name){ // make sure only 1 file was selected if (!stagedFiles) { - throw new Error("Please select a file"); + throw new FileError("Please select a file"); } else if (stagedFiles.length > 1) { - throw new Error("Only one file is allowed at a time"); + throw new FileError("Only one file is allowed at a time"); } // validate 'name' field var invalidCharacters = /[^A-Za-z0-9,-]/.exec(name); if (invalidCharacters) { - throw new Error(invalidCharacters + ' is not allowed. A-Z, a-z, 0-9, and "-" only.'); + throw new NameError(invalidCharacters + ' is not allowed. A-Z, a-z, 0-9, and "-" only.'); } else if (name.length < 1) { - throw new Error("You must enter a name for your claim"); + throw new NameError("You must enter a name for your claim"); } } @@ -77,7 +77,7 @@ function previewAndStageFile(selectedFile){ try { validateFile(selectedFile); } catch (error) { - alert(error.message); + showError('input-error-file-selection', error.message); return; } // set the preview @@ -145,10 +145,10 @@ function stageAndPublish(file) { var invalidCharacters = /[^A-Za-z0-9,-]/.exec(name); // validate 'name' if (invalidCharacters) { - alert(invalidCharacters + ' is not allowed. A-Z, a-z, 0-9, "_" and "-" only.'); + showError('input-error-claim-name', invalidCharacters + ' is not allowed. A-Z, a-z, 0-9, "_" and "-" only.'); return; } else if (name.length < 1) { - alert("You must enter a name for your claim"); + showError('input-error-claim-name', 'You must enter a name for your claim'); return; } // stage files @@ -157,7 +157,7 @@ function stageAndPublish(file) { if (stagedFiles) { // make sure only 1 file was selected if (stagedFiles.length < 1) { - alert("A file is needed"); + showError('input-error-file-selection', 'A file is needed'); return; } // make sure the content type is acceptable @@ -169,10 +169,10 @@ function stageAndPublish(file) { uploader.submitFiles(stagedFiles); break; default: - alert("Only .png, .jpeg, .gif, and .mp4 files are currently supported"); + showError('input-error-publish-submit', 'Only .png, .jpeg, .gif, and .mp4 files are currently supported'); break; } } else { - alert("Please select a file"); + showError('input-error-file-selection', 'Please select a file'); } } \ No newline at end of file diff --git a/views/partials/assetInfo.handlebars b/views/partials/assetInfo.handlebars index 986718ce..7ad1bace 100644 --- a/views/partials/assetInfo.handlebars +++ b/views/partials/assetInfo.handlebars @@ -6,8 +6,9 @@