author | greg |
Fri, 23 Oct 2009 15:41:48 +0200 | |
changeset 427 | 7ac746c07ff2 |
parent 381 | 5c0f34a9ab00 |
permissions | -rw-r--r-- |
371 | 1 |
// import Nevow.Athena |
2 |
// import Divmod.Base |
|
3 |
||
4 |
function updateAttr(id, param, value) { |
|
5 |
Nevow.Athena.Widget.fromAthenaID(1).callRemote('HMIexec', 'setattr', id, param, value); |
|
6 |
} |
|
7 |
||
381
5c0f34a9ab00
Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents:
371
diff
changeset
|
8 |
var svguiWidgets = new Array(); |
371 | 9 |
|
10 |
var currentObject = null; |
|
11 |
function setCurrentObject(obj) { |
|
12 |
currentObject = obj; |
|
13 |
} |
|
14 |
function isCurrentObject(obj) { |
|
15 |
return currentObject == obj; |
|
16 |
} |
|
17 |
||
18 |
function getSVGElementById(id) { |
|
19 |
return document.getElementById(id); |
|
20 |
} |
|
21 |
||
22 |
function blockSVGElementDrag(element) { |
|
23 |
element.addEventListener("draggesture", function(event){event.stopPropagation()}, true); |
|
24 |
} |
|
25 |
||
26 |
LiveSVGPage.LiveSVGWidget = Nevow.Athena.Widget.subclass('LiveSVGPage.LiveSVGWidget'); |
|
27 |
LiveSVGPage.LiveSVGWidget.methods( |
|
381
5c0f34a9ab00
Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents:
371
diff
changeset
|
28 |
|
371 | 29 |
function handleEvent(self, evt) { |
30 |
if (currentObject != null) { |
|
31 |
currentObject.handleEvent(evt); |
|
32 |
} |
|
33 |
}, |
|
34 |
||
35 |
function receiveData(self, data){ |
|
36 |
dataReceived = json_parse(data); |
|
381
5c0f34a9ab00
Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents:
371
diff
changeset
|
37 |
gadget = svguiWidgets[dataReceived.id] |
5c0f34a9ab00
Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents:
371
diff
changeset
|
38 |
if (gadget) { |
5c0f34a9ab00
Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents:
371
diff
changeset
|
39 |
gadget.updateValues(json_parse(dataReceived.kwargs)); |
5c0f34a9ab00
Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents:
371
diff
changeset
|
40 |
} |
371 | 41 |
//console.log("OBJET : " + dataReceived.back_id + " STATE : " + newState); |
42 |
}, |
|
43 |
||
44 |
function init(self, arg1){ |
|
45 |
//console.log("Object received : " + arg1); |
|
46 |
for (ind in arg1) { |
|
47 |
gad = json_parse(arg1[ind]); |
|
48 |
args = json_parse(gad.kwargs); |
|
381
5c0f34a9ab00
Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents:
371
diff
changeset
|
49 |
gadget = new svguilib[gad.__class__](self, gad.id, args); |
5c0f34a9ab00
Improving support for svgui, separating setting end getting attributes functions from creating function.
laurent
parents:
371
diff
changeset
|
50 |
svguiWidgets[gadget.id]=gadget; |
371 | 51 |
//console.log('GADGET :' + gadget); |
52 |
} |
|
53 |
var elements = document.getElementsByTagName("svg"); |
|
54 |
for (var i = 0; i < elements.length; i++) { |
|
55 |
elements[i].addEventListener("mouseup", self, false); |
|
56 |
} |
|
57 |
//console.log("SVGUIWIDGETS : " + svguiWidgets); |
|
58 |
} |
|
59 |
); |