diff options
| author | Juuso Lapinlampi <wub@partyvan.eu> | 2015-09-27 16:42:53 +0200 |
|---|---|---|
| committer | Juuso Lapinlampi <wub@partyvan.eu> | 2015-09-27 16:47:15 +0200 |
| commit | f5ebff0cdd9ef99d536ef4a9f7c45706152153fa (patch) | |
| tree | f66ae1d34c3e3d7fe45efac2a97a61723c2058e7 | |
| parent | 28915a6f561a5295935a619c415df0721df7d4ba (diff) | |
Replace copy-pasted pomf.js errors with constants
Introduces client-side UPLOAD_ERR_MAX_SIZE and UPLOAD_ERR_FAILED
constants.
This reduces code duplication, which means less code smell.
| -rw-r--r-- | js/pomf.js | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -106,10 +106,12 @@ $(function() { var totalName = $('.file-name', totalRow); + var UPLOAD_ERR_MAX_SIZE = 'onii-chan y-your upload is t-too big…'; + var UPLOAD_ERR_FAILED = 'Something went wrong; try again later.'; + if (files.size > MAX_SIZE) { uploadFiles.addClass('error'); - - totalName.html('onii-chan y-your upload is t-too big…'); + totalName.html(UPLOAD_ERR_MAX_SIZE); return; } @@ -143,7 +145,7 @@ $(function() { var res = JSON.parse(res); if (!res.success) { uploadFiles.addClass('error'); - totalName.text('Something went wrong; try again later.'); + totalName.text(UPLOAD_ERR_FAILED); break; } eachRow(res.files, function(row, file, files) { @@ -160,11 +162,11 @@ $(function() { break; case 413: uploadFiles.addClass('error completed'); - totalName.html('onii-chan, y-your upload is t-too big…'); + totalName.html(UPLOAD_ERR_MAX_SIZE); break; default: uploadFiles.addClass('error completed'); - totalName.text('Something went wrong; try again later.'); + totalName.text(UPLOAD_ERR_FAILED); } }); up.upload(); |
