<s> from pyjamas . Timer import Timer <EOL> from __pyjamas__ import doc , JS <EOL> from pyjamas import DOM <EOL> frameId = <NUM_LIT:0> <EOL> class Feed : <EOL> def __init__ ( self , url , callback ) : <EOL> global frameId <EOL> frame = DOM . createElement ( "<STR_LIT>" ) <EOL> frameid = "<STR_LIT>" % frameId <EOL> frameId += <NUM_LIT:1> <EOL> DOM . setAttribute ( frame , "<STR_LIT:id>" , frameid ) <EOL> DOM . setAttribute ( frame , "<STR_LIT:src>" , url ) <EOL> self . frameId = frameId <EOL> self . frame = frame <EOL> self . timer = Timer ( notify = self ) <EOL> doc ( ) . parent . body . appendChild ( frame ) <EOL> self . callback = callback <EOL> self . timer . scheduleRepeating ( <NUM_LIT:100> ) <EOL> def getFrameTxt ( self ) : <EOL> return str ( self . frame . contentWindow . document . body . innerHTML ) <EOL> def onTimer ( self , * args ) : <EOL> txt = self . getFrameTxt ( ) <EOL> if txt == '<STR_LIT>' : <EOL> return <EOL> self . callback ( self , txt ) <EOL> self . timer . cancel ( ) </s>
