From 172a890be27476586a54296d6584300ad5bf1888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 23 Sep 2017 01:23:50 +0200 Subject: [PATCH] highlight all labels with for=name in ?err=... --- js/appcommon.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/js/appcommon.js b/js/appcommon.js index 4eaa827..26f8733 100644 --- a/js/appcommon.js +++ b/js/appcommon.js @@ -1,5 +1,5 @@ const $ = require('./lib/chibi') -const { mk, qs, cr } = require('./utils') +const { mk, qs, qsa, cr } = require('./utils') const modal = require('./modal') const notify = require('./notif') @@ -93,10 +93,11 @@ $.ready(function () { let errs = window.location.search.substr(errAt + 4).split(',') let humanReadableErrors = [] errs.forEach(function (er) { - let lbl = qs('label[for="' + er + '"]') - if (lbl) { + let lbls = qsa('label[for="' + er + '"]') + for (let i = 0; i < lbls.length; i++) { + let lbl = lbls[i] lbl.classList.add('error') - humanReadableErrors.push(lbl.childNodes[0].textContent.trim().replace(/: ?$/, '')) + if (i === 0) humanReadableErrors.push(lbl.childNodes[0].textContent.trim().replace(/: ?$/, '')) } // else { // hres.push(er)