Changeset 1823 for trunk/autoquest-htmlmonitor/src/main/js
- Timestamp:
- 11/13/14 15:25:23 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-htmlmonitor/src/main/js/autoquest-htmlmonitor.js
r1807 r1823 228 228 //{ "tag": "section", "actions": [ ] }, 229 229 { "tag": "select", "actions": [ "onchange", 230 "onfocus" ] }, 230 "onfocus", 231 "onscroll" ] }, 231 232 { "tag": "small", "actions": [ "onclick" ] }, 232 233 //{ "tag": "source", "actions": [ ] }, … … 303 304 addDefaultEventHandling(); 304 305 306 // the onload event is already fired and lost. So pretend it to happen. 307 handleEvent(document.getElementsByTagName("body").item(0), "onload", 308 "/html[0]/body[0]", null); 309 305 310 // recall sending data each 100 seconds to ensure, that for browser windows staying 306 311 // open the data will be send, as well. … … 588 593 var eventType; 589 594 var eventObj = null; 595 var preceedingScrollEventObj = null; 590 596 var tagName; 591 597 var unmonitored; 598 var x1, x2; 599 var y1, y2; 592 600 593 601 if (!autoquestDestination) { … … 603 611 if ((eventType === "onkeydown") && (node === document.body)) { 604 612 // do not handle key downs on the body which are other than tabs (keycode 9) 605 if ( event.keyCode !== 9) {613 if ((event.keyCode !== 9) && (event.keyCode !== 13)) { 606 614 return; 607 615 } … … 613 621 eventObj = autoquestRecordedEvents[autoquestRecordedEvents.length - 1]; 614 622 615 if ((eventObj.type === event Name) && (eventObj.nodePath.indexOf(nodePath) === 0)) {623 if ((eventObj.type === eventType) && (eventObj.nodePath.indexOf(nodePath) === 0)) { 616 624 // the event is of the same type. 617 625 if (eventObj.nodePath.length > nodePath.length) { … … 623 631 } 624 632 else if (eventType !== "onscroll") { 625 // we have the same event on the same element. If it is an onscroll, we should633 // we have the same event on the same element. If it is an onscroll, we may 626 634 // reuse it. But it is not an onscroll. So we ignore the existing event. 627 635 eventObj = null; 636 } 637 else { 638 // we have a repeated onscroll. Check, if the scrolling direction can be determined 639 // and if it changed. If so created a new object. If not, stick to the existing one. 640 if (autoquestRecordedEvents.length > 1) { 641 preceedingScrollEventObj = 642 autoquestRecordedEvents[autoquestRecordedEvents.length - 2]; 643 644 if (preceedingScrollEventObj.type !== eventType) { 645 preceedingScrollEventObj = null; 646 } 647 } 648 649 if (preceedingScrollEventObj != null) { 650 x1 = preceedingScrollEventObj.scrollPosition[0] - eventObj.scrollPosition[0]; 651 x2 = eventObj.scrollPosition[0] - getScrollCoordinates(node)[0]; 652 y1 = preceedingScrollEventObj.scrollPosition[1] - eventObj.scrollPosition[1]; 653 y2 = eventObj.scrollPosition[1] - getScrollCoordinates(node)[1]; 654 655 if ((((x1 >= 0) && (x2 >= 0)) || ((x1 <= 0) && (x2 <= 0))) && 656 (((y1 >= 0) && (y2 >= 0)) || ((y1 <= 0) && (y2 <= 0)))) 657 { 658 // The new scrolling is a continuation of the previous scrolling --> reuse 659 // previous object 660 } 661 else { 662 eventObj = null; 663 } 664 } 665 else { 666 // we cannot determine the preceeding scroll direction, so we have to store the 667 // new event 668 eventObj = null; 669 } 628 670 } 629 671 } … … 821 863 */ 822 864 function getScrollCoordinates(node) { 823 if ( node.scrollLeft || node.scrollTop) {865 if (typeof node.scrollLeft !== 'undefined') { 824 866 return [node.scrollLeft, node.scrollTop]; 825 867 } 826 else if ((node === window) && window.pageYOffset) {868 else if ((node === window) && (typeof window.pageXOffset !== 'undefined')) { 827 869 return [window.pageXOffset, window.pageYOffset]; 828 870 } 829 else if ((node == document) || (node == document.body) || (node == document.documentElement)) { 830 if (document.body && (document.body.scrollLeft || document.body.scrollTop)) { 871 else if ((node === document) || (node === document.body) || 872 (node === document.documentElement)) 873 { 874 if ((typeof document.body !== 'undefined') && 875 (typeof document.body.scrollLeft !== 'undefined')) 876 { 831 877 return [document.body.scrollLeft, document.body.scrollTop]; 832 878 } 833 else if ( document.documentElement&&834 ( document.documentElement.scrollLeft || document.documentElement.scrollTop))879 else if ((typeof document.documentElement !== 'undefined') && 880 (typeof document.documentElement.scrollLeft !== 'undefined')) 835 881 { 836 882 return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
Note: See TracChangeset
for help on using the changeset viewer.