#!/bin/sh
# Throwaway. Counts every English string this branch removed in the HTML the
# server sent to a Thai reader. Every line must read 0.
DIR=${1:-tmp/chrome/narin}

check() {
  needle=$1
  shift
  total=0
  hits=""
  for f in "$@"; do
    n=$(grep -o -F "$needle" "$DIR/$f.html" 2>/dev/null | wc -l | tr -d ' ')
    total=$((total + n))
    [ "$n" != "0" ] && hits="$hits $f:$n"
  done
  printf '%-40s %-3s %s\n' "$needle" "$total" "$hits"
}

ALL="tasks review positions admin_people team"

echo "== data-table chrome, all five screens =="
check "Previous"                          $ALL
check ">Next<"                            $ALL
check "Page 1 of"                         $ALL
check " selected"                         $ALL
check "Select everything on this page"    $ALL
check "Sort by "                          $ALL
check ">Columns"                          $ALL
check "No result. Clear a filter"         $ALL

echo
echo "== sidebar footer and rail, all five screens =="
check "all departments"                   $ALL
check "no department"                     $ALL
check "No position<"                      $ALL
check "Toggle Sidebar"                    $ALL

echo
echo "== the deleted department switcher, all five screens =="
check "Quality Control"                   $ALL
check ">Maintenance<"                     $ALL
check ">Logistics<"                       $ALL
check ">Production<"                      $ALL
check ">Human Resources<"                 $ALL
check ">All departments<"                 $ALL

echo
echo "== the positions screen =="
check "positions, "                       positions
check "with nobody in them"               positions
check " of 217 positions"                 positions
check "No position matches"               positions
check "Search positions and holders"      positions
check "Clear the search"                  positions
check "All departments"                   positions
check "Filter by department"              positions
check "No department of that name"        positions
check "Vacant only"                       positions
check ">Position<"                        positions
check ">Department<"                      positions
check ">Held by<"                         positions
check ">Duties<"                          positions
check ">Nobody<"                          positions
check " more</span>"                      positions
check " off</span>"                       positions
check "Actions for "                      positions
check "Open the position"                 positions
check "Change holder"                     positions
check "Assign somebody"                   positions
check "Copy duties to another position"   positions
