Пример #1
0
def setCookie(name, value, expires, domain=None, path=None, secure=False):
    cookiestr = doc().props.cookie
    c = SimpleCookie(cookiestr)
    c[name] = value
    m = c[name]
    d = datetime.datetime.now() + datetime.timedelta(0, expires/1000)
    d = d.strftime("%a, %d %b %Y %H:%M:%S GMT")
    m['expires'] = '"%s"' % d
    if domain:
        m['domain'] = domain
    if path:
        m['path'] = path
    if secure:
        m['secure'] = ''

    c = c.output(header='').strip()
    print "set cookies", c

    doc().props.cookie = c

    return
    JS("""
    if (expires instanceof Date) expires = expires.getTime();
    if (pyjslib_isUndefined(domain)) domain = null;
    if (pyjslib_isUndefined(path)) path = null;
    if (pyjslib_isUndefined(secure)) secure = false;
    
    var today = new Date();
    var expiration = new Date();
    expiration.setTime(today.getTime() + expires)

    var c = encodeURIComponent(name) + '=' + encodeURIComponent(value);
    c += ';expires=' + expiration.toGMTString();

    if (domain)
        c += ';domain=' + domain;
    if (path)
        c += ';path=' + path;
    if (secure)
        c += ';secure';

    $doc.cookie = c;
    """)
Пример #2
0
def getAbsoluteTop(elem):
    top = 0
    while elem:
        top += elem.props.offset_top - elem.props.scroll_top;
        parent = elem.props.offset_parent;
        if parent and parent.props.tag_name == 'BODY' and \
            hasattr(elem, 'style') and \
            getStyleAttribute(elem, 'position') == 'absolute':
            break
        elem = parent
    
    return top + doc().props.body.props.scroll_top;
Пример #3
0
def getAbsoluteLeft(elem):
    left = 0
    while elem:
        left += elem.props.offset_left - elem.props.scroll_left;
        parent = elem.props.offset_parent;
        if parent and parent.props.tag_name == 'BODY' and \
            hasattr(elem, 'style') and \
            getStyleAttribute(elem, 'position') == 'absolute':
            break
        elem = parent
    
    return left + doc().props.body.props.scroll_left;
Пример #4
0
def _dispatchCapturedMouseoutEvent(evt):
    cap = getCaptureElement()
    if cap:
        print "cap", dir(evt), cap
        if not eventGetToElement(evt):
            print "synthesise", cap
            #When the mouse leaves the window during capture, release capture
            #and synthesize an 'onlosecapture' event.
            setCapture(None)
            if cap._listener:
                # this should be interesting...
                lcEvent = doc().create_event('UIEvent')
                lcEvent.init_ui_event('losecapture', False, False, wnd(), 0)
                dispatchEvent(lcEvent, cap, cap._listener);
Пример #5
0
def getCookie2(cookie_name):
    cookiestr = doc().props.cookie
    c = SimpleCookie(cookiestr)
    cs = c.get(cookie_name, None)
    print "getCookie2", cookiestr, "name", cookie_name, "val", cs
    if cs:
        return cs.value
    return None
    
    JS("""
    var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

    if ( results )
        return ( decodeURIComponent ( results[2] ) );
    else
        return null;

    """)
Пример #6
0
def setTitle(title):
    doc().props.title = title
Пример #7
0
def setMargin(size):
    doc().props.body.props.style.margin = size;
Пример #8
0
def getClientWidth():
    width = wnd().props.inner_width
    if width:
        return width
    return doc().props.body.props.client_width;
Пример #9
0
def getClientHeight():
    height = wnd().props.inner_height
    if height:
        return height
    return doc().props.body.props.client_height;
Пример #10
0
def enableScrolling(enable):
    doc().props.body.props.style.overflow = enable and 'auto' or 'hidden'
    JS("""
    $doc.body.style.overflow = enable ? 'auto' : 'hidden';
    """)
Пример #11
0
def enableScrolling(enable):
    doc().props.body.props.style.overflow = enable and 'auto' or 'hidden'
Пример #12
0
def getBodyElement():
	return doc().props.body
Пример #13
0
def setInnerText(elem, text):
    #Remove all children first.
    while elem.props.first_child:
        elem.remove_child(elem.props.first_child)
    elem.append_child(doc().create_text_node(text or ''))
Пример #14
0
def getElementById(id):
    """
    Return the element in the document's DOM tree with the given id.
    """
    return doc().get_element_by_id(id)
Пример #15
0
def createElement(tag):
    return doc().create_element(tag)
Пример #16
0
def get_crumbs():
    docCookie = doc().props.cookie
    c = SimpleCookie(docCookie)
    c = c.output(header='')
    return map(strip, c.split('\n'))