highlight all labels with for=name in ?err=...

box-drawing
Ondřej Hruška 7 years ago
parent afd8c47a74
commit 172a890be2
  1. 9
      js/appcommon.js

@ -1,5 +1,5 @@
const $ = require('./lib/chibi') const $ = require('./lib/chibi')
const { mk, qs, cr } = require('./utils') const { mk, qs, qsa, cr } = require('./utils')
const modal = require('./modal') const modal = require('./modal')
const notify = require('./notif') const notify = require('./notif')
@ -93,10 +93,11 @@ $.ready(function () {
let errs = window.location.search.substr(errAt + 4).split(',') let errs = window.location.search.substr(errAt + 4).split(',')
let humanReadableErrors = [] let humanReadableErrors = []
errs.forEach(function (er) { errs.forEach(function (er) {
let lbl = qs('label[for="' + er + '"]') let lbls = qsa('label[for="' + er + '"]')
if (lbl) { for (let i = 0; i < lbls.length; i++) {
let lbl = lbls[i]
lbl.classList.add('error') lbl.classList.add('error')
humanReadableErrors.push(lbl.childNodes[0].textContent.trim().replace(/: ?$/, '')) if (i === 0) humanReadableErrors.push(lbl.childNodes[0].textContent.trim().replace(/: ?$/, ''))
} }
// else { // else {
// hres.push(er) // hres.push(er)

Loading…
Cancel
Save