Skip to content

Commit

Permalink
highlight all labels with for=name in ?err=...
Browse files Browse the repository at this point in the history
  • Loading branch information
MightyPork committed Sep 22, 2017
1 parent afd8c47 commit 172a890
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions js/appcommon.js
Original file line number Diff line number Diff line change
@@ -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')

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 172a890

Please sign in to comment.