summaryrefslogtreecommitdiff
path: root/js/pomf.js
diff options
context:
space:
mode:
authorJuuso Lapinlampi <wub@partyvan.eu>2015-09-27 16:42:53 +0200
committerJuuso Lapinlampi <wub@partyvan.eu>2015-09-27 16:47:15 +0200
commitf5ebff0cdd9ef99d536ef4a9f7c45706152153fa (patch)
treef66ae1d34c3e3d7fe45efac2a97a61723c2058e7 /js/pomf.js
parent28915a6f561a5295935a619c415df0721df7d4ba (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.
Diffstat (limited to 'js/pomf.js')
-rw-r--r--js/pomf.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/js/pomf.js b/js/pomf.js
index 2cea939..bdd3174 100644
--- a/js/pomf.js
+++ b/js/pomf.js
@@ -106,10 +106,12 @@ $(function() {
var totalName = $('.file-name', totalRow);
+ var UPLOAD_ERR_MAX_SIZE = 'onii-chan y-your upload is t-too big&hellip;';
+ 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&hellip;');
+ 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&hellip;');
+ 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();