2 (function (xpath, check) {
3 function getPolterNode(xpath) {
4 var polterAgent = window.__poltergeist;
5 var ids = polterAgent.find("xpath", xpath, document);
6 return polterAgent.get(ids[0]);
9 var pNode = getPolterNode(xpath);
11 if (check && pNode.element.checked) {
12 //requested to check the element and is already check, do nothing.
16 if (!check && pNode.element.checked == false) {
17 //move along nothing to be done
21 if (check && pNode.element.checked == false) {
22 //we have to check the element, we will do so by triggering a click event so all change listeners are aware.
23 pNode.trigger("click");
24 pNode.element.checked = true;
27 if (!check && pNode.element.checked) {
28 //move along nothing to be done
29 pNode.trigger("click");
30 pNode.element.checked = false;
34 }('{{xpath}}', {{check}}));