~certify-web-dev/twisted/certify-trunk

« back to all changes in this revision

Viewing changes to twisted/web/woven/WebConduit2_mozilla.js

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-01-17 14:52:35 UTC
  • mfrom: (1.1.5 upstream) (2.1.2 etch)
  • Revision ID: james.westby@ubuntu.com-20070117145235-btmig6qfmqfen0om
Tags: 2.5.0-0ubuntu1
New upstream version, compatible with python2.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
var woven_eventQueue = []
 
2
woven_eventQueueBusy = 0
 
3
woven_clientSideEventNum = 0
 
4
woven_requestingEvent = 0
 
5
 
 
6
function woven_eventHandler(eventName, node) {
 
7
    var eventTarget = node.getAttribute('id')
 
8
    var additionalArguments = ''
 
9
    for (i = 2; i<arguments.length; i++) {
 
10
        additionalArguments += '&woven_clientSideEventArguments='
 
11
        additionalArguments += escape(eval(arguments[i]))
 
12
    }
 
13
    var source = '?woven_clientSideEventName=' + eventName + '&woven_clientSideEventTarget=' + eventTarget + additionalArguments + '&woven_clientSideEventNum=' + woven_clientSideEventNum
 
14
    woven_clientSideEventNum += 1
 
15
    
 
16
    woven_eventQueue.unshift(source)
 
17
    if (!woven_eventQueueBusy) {
 
18
        woven_sendTopEvent()
 
19
    }
 
20
    return false
 
21
}
 
22
 
 
23
function woven_sendTopEvent() {
 
24
    woven_eventQueueBusy = 1
 
25
    var url = woven_eventQueue.shift()
 
26
    var input = document.getElementById('woven_inputConduit')
 
27
    
 
28
    input.src = url
 
29
}
 
30
 
 
31
function woven_requestNextEvent() {
 
32
    var output = document.getElementById('woven_outputConduit')
 
33
 
 
34
    if (output) { output.src = '?woven_hookupOutputConduitToThisFrame=1&woven_clientSideEventNum=' + woven_clientSideEventNum.toString()}
 
35
}
 
36
 
 
37
function woven_clientToServerEventComplete() {
 
38
    woven_requestNextEvent()
 
39
 
 
40
    if (woven_eventQueue.length) {
 
41
        woven_sendTopEvent()
 
42
    } else {
 
43
        woven_eventQueueBusy = 0
 
44
    }
 
45
    var focus = document.getElementById('woven_firstResponder')
 
46
    focus.focus()
 
47
}
 
48
 
 
49
function woven_attemptFocus(theNode) {
 
50
    // focus the first input element in the new node
 
51
    if (theNode.tagName == 'INPUT') {
 
52
        theNode.focus()
 
53
        return 1
 
54
    } else {
 
55
/*         for (i=0; i<theNode.childNodes.length; i++) { */
 
56
/*             if(woven_attemptFocus(theNode.childNodes[i])) { */
 
57
/*                 return 1 */
 
58
/*             } */
 
59
/*         } */
 
60
        return 0
 
61
    }
 
62
}
 
63
 
 
64
function woven_replaceElement(theId, htmlStr) {
 
65
 
 
66
    var oldNode = document.getElementById(theId)
 
67
    var newNode = document.createElement('span')
 
68
    newNode.innerHTML = htmlStr
 
69
    oldNode.parentNode.replaceChild(newNode.firstChild, oldNode)
 
70
    //woven_attemptFocus(newNode)
 
71
    woven_requestNextEvent()
 
72
    //alert('blah')
 
73
}
 
74
 
 
75
function woven_appendChild(theId, htmlStr) {
 
76
    woven_requestNextEvent()
 
77
 
 
78
    var container = document.getElementById(theId)
 
79
    var newNode = document.createElement('span')
 
80
    newNode.innerHTML = htmlStr
 
81
    container.appendChild(newNode.firstChild)
 
82
}