view vendor/jcalderonzumba/mink-phantomjs-driver/src/Resources/Script/is_checked.js.twig @ 19:fa3358dc1485 tip

Add ndrum files
author Chris Cannam
date Wed, 28 Aug 2019 13:14:47 +0100
parents 4c8ae668cc8c
children
line wrap: on
line source
{% autoescape 'js' %}
(function (xpath) {
  function getElement(xpath, within) {
    var result;
    if (within === null || within === undefined) {
      within = document;
    }
    result = document.evaluate(xpath, within, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
    if (result.snapshotLength !== 1) {
      return null;
    }
    return result.snapshotItem(0);
  }

  var node = getElement(xpath);

  if (node === null) {
    return null;
  }

  if(node.tagName.toLowerCase() != "input"){
    return null;
  }

  if(node.type.toLowerCase() != "checkbox" && node.type.toLowerCase() != "radio"){
    return null;
  }

  return node.checked;
}('{{ xpath }}'));
{% endautoescape %}