<s> from __pyjamas__ import JS , doc , wnd <EOL> import pyjd <EOL> if pyjd . is_desktop : <EOL> from __pyjamas__ import get_main_frame <EOL> global historyToken <EOL> historyToken = '<STR_LIT>' <EOL> historyListeners = [ ] <EOL> """<STR_LIT>""" <EOL> def addHistoryListener ( listener ) : <EOL> historyListeners . append ( listener ) <EOL> def back ( ) : <EOL> wnd ( ) . history . back ( ) <EOL> def forward ( ) : <EOL> wnd ( ) . history . forward ( ) <EOL> def getToken ( ) : <EOL> global historyToken <EOL> return historyToken <EOL> def newItem ( ht ) : <EOL> print "<STR_LIT>" , ht <EOL> onHistoryChanged ( ht ) <EOL> return <EOL> JS ( """<STR_LIT>""" ) <EOL> def onHistoryChanged ( ht ) : <EOL> fireHistoryChangedImpl ( ht ) <EOL> def fireHistoryChangedAndCatch ( ) : <EOL> pass <EOL> def fireHistoryChangedImpl ( ht ) : <EOL> for listener in historyListeners : <EOL> listener . onHistoryChanged ( ht ) <EOL> def removeHistoryListener ( listener ) : <EOL> historyListeners . remove ( listener ) <EOL> def init ( ) : <EOL> print "<STR_LIT>" <EOL> global historyToken <EOL> historyToken = '<STR_LIT>' <EOL> onHistoryChanged ( historyToken ) <EOL> return <EOL> JS ( """<STR_LIT>""" ) <EOL> init ( ) </s>
