<s> def addWindowCloseListener ( listener ) : <EOL> closingListeners . append ( listener ) <EOL> def addWindowResizeListener ( listener ) : <EOL> resizeListeners . append ( listener ) <EOL> def getTitle ( ) : <EOL> return JS ( '<STR_LIT>' ) <EOL> def getLocation ( ) : <EOL> global location <EOL> if not location : <EOL> location = Location . Location ( wnd ( ) . location ) <EOL> return location <EOL> def setLocation ( url ) : <EOL> w = JS ( '<STR_LIT>' ) <EOL> w . location = url <EOL> def getClientHeight ( ) : <EOL> return JS ( '<STR_LIT>' ) <EOL> def getClientWidth ( ) : <EOL> return JS ( '<STR_LIT>' ) <EOL> def setOnError ( onError ) : <EOL> if ( not callable ( onError ) ) : <EOL> raise TypeError ( "<STR_LIT>" ) <EOL> JS ( """<STR_LIT>""" ) <EOL> def fireClosingImpl ( ) : <EOL> ret = None <EOL> for listener in closingListeners : <EOL> msg = listener . onWindowClosing ( ) <EOL> if ret is None : <EOL> ret = msg <EOL> return ret <EOL> def fireResizedAndCatch ( handler ) : <EOL> pass <EOL> def fireResizedImpl ( ) : <EOL> for listener in resizeListeners : <EOL> listener . onWindowResized ( getClientWidth ( ) , getClientHeight ( ) ) <EOL> def onClosed ( ) : <EOL> fireClosedImpl ( ) <EOL> def onClosing ( ) : <EOL> fireClosingImpl ( ) <EOL> def onResize ( ) : <EOL> fireResizedImpl ( ) <EOL> def fireClosedAndCatch ( handler ) : <EOL> pass <EOL> def fireClosedImpl ( ) : <EOL> for listener in closingListeners : <EOL> listener . onWindowClosed ( ) <EOL> def fireClosingAndCatch ( handler ) : <EOL> pass <EOL> def resize ( width , height ) : <EOL> wnd ( ) . resizeTo ( width , height ) <EOL> def onError ( msg , url , linenumber ) : <EOL> dialog = doc ( ) . createElement ( "<STR_LIT>" ) <EOL> dialog . className = '<STR_LIT>' <EOL> tracestr = sys . trackstackstr ( JS ( "<STR_LIT>" ) ) <EOL> tracestr = tracestr . replace ( "<STR_LIT:\n>" , "<STR_LIT>" ) <EOL> dialog . innerHTML = """<STR_LIT>""" % ( msg , linenumber , tracestr ) <EOL> doc ( ) . body . appendChild ( dialog ) <EOL> return True <EOL> def alert ( msg ) : <EOL> wnd ( ) . alert ( msg ) <EOL> def confirm ( msg ) : <EOL> return wnd ( ) . confirm ( msg ) <EOL> def prompt ( msg , defaultReply = "<STR_LIT>" ) : <EOL> return wnd ( ) . prompt ( msg , defaultReply ) <EOL> def init_listeners ( ) : <EOL> global closingListeners <EOL> global resizeListeners <EOL> if not closingListeners : <EOL> closingListeners = [ ] <EOL> if not resizeListeners : <EOL> resizeListeners = [ ] <EOL> def init ( ) : <EOL> global sys <EOL> import sys <EOL> init_listeners ( ) <EOL> JS ( """<STR_LIT>""" ) <EOL> setOnError ( onError ) </s>
