summaryrefslogtreecommitdiff
path: root/data/js
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2016-07-31 09:29:07 +0200
committerYorhel <git@yorhel.nl>2016-07-31 09:29:09 +0200
commita8a9a2a12d95e0a443f4b768698d50f4fc4e8fff (patch)
tree28e03e636c2860fefd032be1aec693de23720c03 /data/js
parentf3c877ba7257c024219fd7f79724f726f6d1a63d (diff)
vnstaff.js: Show error message when staff is credited multiple times
The backend does this validation as well, but if that validation fails it will show an unhelpful "Malformed JSON" error. This JS message should be more helpful.
Diffstat (limited to 'data/js')
-rw-r--r--data/js/vnstaff.js21
1 files changed, 20 insertions, 1 deletions
diff --git a/data/js/vnstaff.js b/data/js/vnstaff.js
index 0d963c53..60a30b80 100644
--- a/data/js/vnstaff.js
+++ b/data/js/vnstaff.js
@@ -13,7 +13,7 @@ function vnsLoad() {
}
vnsEmpty();
- onSubmit(byName(byId('maincontent'), 'form')[0], vnsSerialize);
+ onSubmit(byName(byId('maincontent'), 'form')[0], vnsCheckAndSerialize);
// dropdown search
dsInit(byId('credit_input'), '/xml/staff.xml?q=', function(item, tr) {
@@ -84,6 +84,25 @@ function vnsSerialize() {
return true;
}
+function vnsCheckAndSerialize() {
+ var l = byName(byId('credits_tbl'), 'tr');
+ var tbl = {};
+ for (var i = 0; i < l.length; i++) {
+ if(l[i].id == 'credits_tr_none')
+ continue;
+ var aid = byName(byClass(l[i], 'tc_name')[0], 'input')[0];
+ var name = byName(byClass(l[i], 'tc_name')[0], 'a')[0];
+ var role = byName(byClass(l[i], 'tc_role')[0], 'select')[0];
+ var idx = aid.value + ' ' + role.value;
+ if(tbl[idx]) {
+ alert("Invalid input in staff listing: '" + name.innerText + "' is credited multiple times with '" + role.options[role.selectedIndex].value + "'.");
+ return false;
+ }
+ tbl[idx] = 1;
+ }
+ return vnsSerialize();
+}
+
function vnsDel() {
var tr = this;
while (tr.nodeName.toLowerCase() != 'tr')