Changeset 1073
- Timestamp:
- 02/15/13 14:46:51 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-htmlmonitor/src/main/js/autoquest-htmlmonitor.js
r1069 r1073 72 72 //{ "tag": "bdo", "actions": [ ] }, 73 73 //{ "tag": "blockquote", "actions": [ ] }, 74 { "tag": "body", "actions": [ "onbeforeunload", 75 "onload", 76 "onunload", 77 //"onerror", 78 "onscroll", 74 { "tag": "body", "actions": [ "onclick", 79 75 "onpagehide", 80 76 "onpageshow", 77 "onscroll", 81 78 "onundo" ] }, 82 79 { "tag": "button", "actions": [ "onclick", … … 206 203 var autoquestDoLog = false; 207 204 208 /*var matchedTags = ["A", "ABBR", "ACRONYM", "ADDRESS", "AREA", "B", "BIG", "BLOCKQUOTE", "BODY",209 "BUTTON", "CAPTION", "CENTER", "CITE", "CODE", "COL", "COLGROUP", "DD", "DEL",210 "DFN", "DIR", "DIV", "DL", "DT", "EM", "FIELDSET", "FORM", "H1", "H2", "H3",211 "H4", "H5", "H6", "HR", "I", "IMG", "INPUT", "INS", "KBD", "LABEL", "LEGEND",212 "LI", "LINK", "MAP", "MENU", "NOFRAMES", "NOSCRIPT", "OBJECT", "OL",213 "OPTGROUP", "OPTION", "P", "PRE", "Q", "S", "SAMP", "SELECT", "SMALL", "SPAN",214 "STRIKE", "STRONG", "SUB", "SUP", "TABLE", "TBODY", "TD", "TEXTAREA", "TFOOT",215 "TH", "THEAD", "TR", "TT", "U", "UL", "VAR"];*/216 /*var actions = ['onclick', 'ondblclick', 'onkeypress', 'onkeydown', 'onkeyup',217 'onmouseout' , 'onmousemove' ,'onfocus','onscroll']; // edit*/218 219 205 /** 220 206 * stores the structure of the GUI of the current page … … 254 240 autoquestGUIModel = 255 241 addEventHandlingAndGetJSONRepresentation(document.documentElement, ""); 242 243 addDefaultEventHandling(); 256 244 257 245 // recall sending data each 100 seconds to ensure, that for browser windows staying … … 394 382 var tagName = getTagName(node); 395 383 var action; 396 var parameters;397 384 var i; 398 385 var k; … … 408 395 } 409 396 else { 410 parameters = { action : action, path : nodePath}; 411 if (jQuery(node).on) { 412 jQuery(node).on(action.substring(2), parameters, handleJQueryEvent); 413 } 414 else { 415 jQuery(node).bind(action.substring(2), parameters, handleJQueryEvent); 416 } 397 registerEventHandler(node, nodePath, action); 417 398 } 418 399 } … … 423 404 /** 424 405 * adapts the event handling attributed provided by the action parameter so that it calls 425 * the {@link #handleEvent(node, action, path, even )} function in the case the event occurs.406 * the {@link #handleEvent(node, action, path, event)} function in the case the event occurs. 426 407 * Either the method creates an appropriate onxxx attribute on the node if there is none, or it 427 408 * adds a call to the function as first thing called by the onxxx attribute. 428 409 * 429 410 * @param node the node of the DOM structure that shall be equipped with event handling 430 * @param nodePath the path to node within the DOM-structure of the HTML-site411 * @param nodePath the path to the node within the DOM-structure of the HTML-site 431 412 * @param action the event for which event handling shall be enabled 432 413 */ … … 443 424 node.setAttribute(action, value + ' ' + oldValue); 444 425 } 426 } 427 } 428 429 /** 430 * registers an event handler using jQuery for the provided action on the given object so that it 431 * calls the {@link #handleJQueryEvent(event)} function in the case the event occurs. 432 * 433 * @param node the node of the DOM structure that shall be equipped with event handling 434 * @param nodePath the path to the node within the DOM-structure of the HTML-site 435 * @param action the event for which event handling shall be enabled 436 */ 437 function registerEventHandler(node, nodePath, action) { 438 var parameters = { action : action, path : nodePath}; 439 if (jQuery(node).on) { 440 jQuery(node).on(action.substring(2), parameters, handleJQueryEvent); 441 } 442 else { 443 jQuery(node).bind(action.substring(2), parameters, handleJQueryEvent); 444 } 445 } 446 447 /** 448 * adds default event handling functionality for receiving load, unload, and other document 449 * relevant events. The registration for events is done depending on the availability of jQuery. 450 * If jQuery is available and must therefore be used, then the registration is done on the window 451 * object. Otherwise, the appropriate attributes of the document's body tag are changed 452 */ 453 function addDefaultEventHandling() { 454 var body; 455 456 if (typeof jQuery === 'undefined') { 457 body = document.getElementsByTagName("body").item(0); 458 adaptEventHandlingAttribute(body, "/html[0]/body[0]", "onbeforeunload"); 459 adaptEventHandlingAttribute(body, "/html[0]/body[0]", "onload"); 460 adaptEventHandlingAttribute(body, "/html[0]/body[0]", "onunload"); 461 //adaptEventHandlingAttribute(body, "/html[0]/body[0]", "onerror"); 462 } 463 else { 464 registerEventHandler(window, "/html[0]/body[0]", "onbeforeunload"); 465 registerEventHandler(window, "/html[0]/body[0]", "onload"); 466 registerEventHandler(window, "/html[0]/body[0]", "onunload"); 467 //registerEventHandler(body, "/html[0]/body[0]", "onerror"); 445 468 } 446 469 } … … 626 649 for (i = 0; i < node.parentNode.childNodes.length; i++) { 627 650 if (node.parentNode.childNodes[i].tagName === node.tagName) { 628 index++;629 651 // if === also returns true if the nodes are not identical but only equal, 630 652 // this may fail. … … 632 654 break; 633 655 } 656 index++; 634 657 } 635 658 }
Note: See TracChangeset
for help on using the changeset viewer.