<s> from muntjac . api import VerticalLayout , Label <EOL> class BrowserInformationExample ( VerticalLayout ) : <EOL> def __init__ ( self ) : <EOL> super ( BrowserInformationExample , self ) . __init__ ( ) <EOL> self . _populated = False <EOL> def attach ( self ) : <EOL> if self . _populated : <EOL> return <EOL> context = self . getApplication ( ) . getContext ( ) <EOL> webBrowser = context . getBrowser ( ) <EOL> browserText = self . getBrowserAndVersion ( webBrowser ) <EOL> browserText = browserText + '<STR_LIT>' + self . getOperatingSystem ( webBrowser ) <EOL> ipAddresslabel = Label ( "<STR_LIT>" <EOL> + webBrowser . getAddress ( ) + "<STR_LIT>" , Label . CONTENT_XHTML ) <EOL> browser = Label ( "<STR_LIT>" <EOL> + browserText + "<STR_LIT>" , Label . CONTENT_XHTML ) <EOL> screenSize = Label ( "<STR_LIT>" <EOL> + str ( webBrowser . getScreenWidth ( ) ) + "<STR_LIT:x>" <EOL> + str ( webBrowser . getScreenHeight ( ) ) + "<STR_LIT>" , <EOL> Label . CONTENT_XHTML ) <EOL> locale = Label ( "<STR_LIT>" <EOL> + str ( webBrowser . getLocale ( ) ) + "<STR_LIT>" , <EOL> Label . CONTENT_XHTML ) <EOL> self . addComponent ( ipAddresslabel ) <EOL> self . addComponent ( browser ) <EOL> self . addComponent ( screenSize ) <EOL> self . addComponent ( locale ) <EOL> self . _populated = True <EOL> def getTimeZoneInfoString ( self , webBrowser ) : <EOL> tzOffset = webBrowser . getTimezoneOffset ( ) <EOL> infoStr = '<STR_LIT>' % ( '<STR_LIT:->' if tzOffset < <NUM_LIT:0> else '<STR_LIT:+>' , abs ( self . tzoToHours ( tzOffset ) ) ) <EOL> if webBrowser . isDSTInEffect ( ) : <EOL> infoStr += '<STR_LIT>' % self . tzoToHours ( webBrowser . getDSTSavings ( ) ) <EOL> return infoStr + '<STR_LIT>' <EOL> @ classmethod <EOL> def tzoToHours ( cls , ms ) : <EOL> return ms / <NUM_LIT:1000> / <NUM_LIT> / <NUM_LIT> <EOL> def getOperatingSystem ( self , webBrowser ) : <EOL> if webBrowser . isWindows ( ) : <EOL> return '<STR_LIT>' <EOL> elif webBrowser . isMacOSX ( ) : <EOL> return '<STR_LIT>' <EOL> elif webBrowser . isLinux ( ) : <EOL> return '<STR_LIT>' <EOL> else : <EOL> return '<STR_LIT>' <EOL> def getBrowserAndVersion ( self , webBrowser ) : <EOL> if webBrowser . isChrome ( ) : <EOL> return ( '<STR_LIT>' + str ( webBrowser . getBrowserMajorVersion ( ) ) <EOL> + '<STR_LIT:.>' + str ( webBrowser . getBrowserMinorVersion ( ) ) ) <EOL> elif webBrowser . isOpera ( ) : <EOL> return ( '<STR_LIT>' + str ( webBrowser . getBrowserMajorVersion ( ) ) <EOL> + '<STR_LIT:.>' + str ( webBrowser . getBrowserMinorVersion ( ) ) ) <EOL> elif webBrowser . isFirefox ( ) : <EOL> return ( '<STR_LIT>' + str ( webBrowser . getBrowserMajorVersion ( ) ) <EOL> + '<STR_LIT:.>' + str ( webBrowser . getBrowserMinorVersion ( ) ) ) <EOL> elif webBrowser . isSafari ( ) : <EOL> return ( '<STR_LIT>' + str ( webBrowser . getBrowserMajorVersion ( ) ) <EOL> + '<STR_LIT:.>' + str ( webBrowser . getBrowserMinorVersion ( ) ) ) <EOL> elif webBrowser . isIE ( ) : <EOL> return ( '<STR_LIT>' <EOL> + str ( webBrowser . getBrowserMajorVersion ( ) ) ) <EOL> else : <EOL> return '<STR_LIT>' </s>
