<s> def get_listener ( item ) : <EOL> if item is None : <EOL> return None <EOL> return listeners . get ( item . uniqueID ) <EOL> def set_listener ( item , listener ) : <EOL> listeners [ item . uniqueID ] = listener <EOL> def init ( ) : <EOL> mf = get_main_frame ( ) <EOL> mf . _addWindowEventListener ( "<STR_LIT>" , browser_event_cb ) <EOL> mf . _addWindowEventListener ( "<STR_LIT>" , browser_event_cb ) <EOL> mf . _addWindowEventListener ( "<STR_LIT>" , browser_event_cb ) <EOL> mf . _addWindowEventListener ( "<STR_LIT>" , browser_event_cb ) <EOL> mf . _addWindowEventListener ( "<STR_LIT>" , browser_event_cb ) <EOL> mf . _addWindowEventListener ( "<STR_LIT>" , browser_event_cb ) <EOL> mf . _addWindowEventListener ( "<STR_LIT>" , browser_event_cb ) <EOL> mf . _addWindowEventListener ( "<STR_LIT>" , browser_event_cb ) <EOL> mf . _addWindowEventListener ( "<STR_LIT>" , browser_event_cb ) <EOL> mf . _addWindowEventListener ( "<STR_LIT>" , browser_event_cb ) <EOL> body = doc ( ) . body <EOL> mf . addEventListener ( body , "<STR_LIT>" , _dispatchEvent ) <EOL> mf . addEventListener ( body , "<STR_LIT>" , _dispatchEvent ) <EOL> mf . addEventListener ( body , "<STR_LIT>" , _dispatchEvent ) <EOL> mf . addEventListener ( body , "<STR_LIT>" , _dispatchEvent ) <EOL> mf . addEventListener ( body , "<STR_LIT>" , _dispatchEvent ) <EOL> mf . addEventListener ( body , "<STR_LIT>" , _dispatchEvent ) <EOL> mf . addEventListener ( body , "<STR_LIT>" , _dispatchEvent ) <EOL> mf . addEventListener ( body , "<STR_LIT>" , _dispatchEvent ) <EOL> mf . addEventListener ( body , "<STR_LIT>" , _dispatchEvent ) <EOL> mf . addEventListener ( body , "<STR_LIT>" , _dispatchEvent ) <EOL> mf . addEventListener ( body , "<STR_LIT>" , _dispatchEvent ) <EOL> mf . addEventListener ( body , "<STR_LIT>" , _dispatchEvent ) <EOL> def _dispatchEvent ( sender , event , useCap ) : <EOL> if event is None : <EOL> evt = wnd ( ) . event <EOL> else : <EOL> evt = event <EOL> if evt . returnValue is None : <EOL> evt . returnValue = True <EOL> if not previewEvent ( evt ) : <EOL> return <EOL> cap = getCaptureElement ( ) <EOL> listener = get_listener ( cap ) <EOL> if cap and ( listener is not None ) : <EOL> dispatchEvent ( evt , cap , listener ) <EOL> return <EOL> curElem = sender <EOL> while curElem and ( get_listener ( curElem ) is None ) : <EOL> curElem = curElem . parentElement <EOL> listener = get_listener ( curElem ) <EOL> if listener is not None : <EOL> dispatchEvent ( evt , curElem , listener ) <EOL> def buttonClick ( elem ) : <EOL> newEvent = doc ( ) . createEventObject ( ) <EOL> elem . fireEvent ( '<STR_LIT>' , newEvent ) <EOL> def compare ( elem1 , elem2 ) : <EOL> e1 = elem1 is not None <EOL> e2 = elem2 is not None <EOL> if not e1 and not r2 : <EOL> return True <EOL> elif not e1 or not e2 : <EOL> return False <EOL> return elem1 . uniqueID == elem2 . uniqueID <EOL> def createInputRadio ( group ) : <EOL> return doc ( ) . createElement ( "<STR_LIT>" + group + "<STR_LIT>" ) <EOL> def eventStopPropagation ( evt ) : <EOL> eventCancelBubble ( evt , True ) <EOL> def eventGetKeyCode ( evt ) : <EOL> if hasattr ( evt , "<STR_LIT>" ) : <EOL> return evt . which <EOL> if hasattr ( evt , "<STR_LIT>" ) : <EOL> return evt . keyCode <EOL> return <NUM_LIT:0> <EOL> def eventGetTarget ( evt ) : <EOL> return evt . srcElement <EOL> def eventGetToElement ( evt ) : <EOL> return getattr ( evt , "<STR_LIT>" , None ) <EOL> def eventGetType ( event ) : <EOL> etype = event . type <EOL> if etype == '<STR_LIT>' : <EOL> return '<STR_LIT:input>' <EOL> return etype <EOL> def eventPreventDefault ( evt ) : <EOL> evt . returnValue = False <EOL> def eventToString ( evt ) : <EOL> if hasattr ( evt , "<STR_LIT>" ) : <EOL> return evt . toString ( ) <EOL> return "<STR_LIT>" <EOL> def getAbsoluteLeft ( elem ) : <EOL> scrollLeft = doc ( ) . documentElement . scrollLeft <EOL> if scrollLeft == <NUM_LIT:0> : <EOL> scrollLeft = doc ( ) . body . scrollLeft <EOL> return ( elem . getBoundingClientRect ( ) . left + scrollLeft ) - <NUM_LIT:2> <EOL> def getAbsoluteTop ( elem ) : <EOL> scrollTop = doc ( ) . documentElement . scrollTop <EOL> if scrollTop == <NUM_LIT:0> : <EOL> scrollTop = doc ( ) . body . scrollTop <EOL> return ( elem . getBoundingClientRect ( ) . top + scrollTop ) - <NUM_LIT:2> <EOL> def getAttribute ( elem , attr ) : <EOL> return getattr ( elem , attr ) <EOL> def getElemAttribute ( elem , attr ) : <EOL> mf = get_main_frame ( ) <EOL> if not elem . hasAttribute ( attr ) : <EOL> return getattr ( elem , mf . mash_attrib ( attr ) ) <EOL> return elem . getAttribute ( attr ) <EOL> def getChild ( elem , index ) : <EOL> return elem . children . item ( index ) <EOL> def getChildCount ( elem ) : <EOL> return elem . children . length <EOL> def getChildIndex ( parent , child ) : <EOL> for i in range ( parent . children . length ) : <EOL> if child . uniqueID == parent . children . item ( i ) . uniqueID : <EOL> return i <EOL> return - <NUM_LIT:1> <EOL> def getFirstChild ( elem ) : <EOL> return elem . firstChild <EOL> def getInnerText ( elem ) : <EOL> return elem . innerText <EOL> def getNextSibling ( elem ) : <EOL> return elem . nextSibling <EOL> def getParent ( elem ) : <EOL> return elem . parentElement <EOL> def insertChild ( parent , child , index ) : <EOL> if index == parent . children . length : <EOL> parent . appendChild ( child ) <EOL> else : <EOL> parent . insertBefore ( child , parent . children . item ( index ) ) <EOL> def isOrHasChild ( parent , child ) : <EOL> if parent is None : <EOL> return False <EOL> while child is not None : <EOL> if parent . uniqueID == child . uniqueID : <EOL> return True <EOL> child = child . parentElement <EOL> return False <EOL> def releaseCapture ( elem ) : <EOL> global sCaptureElem <EOL> if sCaptureElem and compare ( elem , sCaptureElem ) : <EOL> sCaptureElem = None <EOL> elem . releaseCapture ( ) <EOL> def setCapture ( elem ) : <EOL> global sCaptureElem <EOL> sCaptureElem = elem <EOL> elem . setCapture ( ) <EOL> def setInnerText ( elem , text ) : <EOL> if not text : <EOL> text = '<STR_LIT>' <EOL> elem . innerText = text <EOL> def toString ( elem ) : <EOL> return elem . outerHTML <EOL> def setOptionText ( select , text , index ) : <EOL> option = select . options . item ( index ) <EOL> option . text = text <EOL> def insertListItem ( select , text , value , index ) : <EOL> newOption = doc ( ) . createElement ( "<STR_LIT>" ) <EOL> if index == - <NUM_LIT:1> : <EOL> select . add ( newOption ) <EOL> else : <EOL> select . add ( newOption , index ) <EOL> newOption . text = text <EOL> newOption . value = value <EOL> def eventGetMouseWheelVelocityY ( evt ) : <EOL> return round ( - evt . wheelDelta / <NUM_LIT> ) or <NUM_LIT:0.0> </s>
