laurent@371: // import Nevow.Athena laurent@371: // import Divmod.Base laurent@371: laurent@371: function updateAttr(id, param, value) { laurent@371: Nevow.Athena.Widget.fromAthenaID(1).callRemote('HMIexec', 'setattr', id, param, value); laurent@371: } laurent@371: laurent@381: var svguiWidgets = new Array(); laurent@371: laurent@371: var currentObject = null; laurent@371: function setCurrentObject(obj) { laurent@371: currentObject = obj; laurent@371: } laurent@371: function isCurrentObject(obj) { laurent@371: return currentObject == obj; laurent@371: } laurent@371: laurent@371: function getSVGElementById(id) { laurent@371: return document.getElementById(id); laurent@371: } laurent@371: laurent@371: function blockSVGElementDrag(element) { laurent@371: element.addEventListener("draggesture", function(event){event.stopPropagation()}, true); laurent@371: } laurent@371: laurent@371: LiveSVGPage.LiveSVGWidget = Nevow.Athena.Widget.subclass('LiveSVGPage.LiveSVGWidget'); laurent@371: LiveSVGPage.LiveSVGWidget.methods( laurent@381: laurent@371: function handleEvent(self, evt) { laurent@371: if (currentObject != null) { laurent@371: currentObject.handleEvent(evt); laurent@371: } laurent@371: }, laurent@371: laurent@371: function receiveData(self, data){ laurent@371: dataReceived = json_parse(data); laurent@381: gadget = svguiWidgets[dataReceived.id] laurent@381: if (gadget) { laurent@381: gadget.updateValues(json_parse(dataReceived.kwargs)); laurent@381: } laurent@371: //console.log("OBJET : " + dataReceived.back_id + " STATE : " + newState); laurent@371: }, laurent@371: laurent@371: function init(self, arg1){ laurent@371: //console.log("Object received : " + arg1); laurent@371: for (ind in arg1) { laurent@371: gad = json_parse(arg1[ind]); laurent@371: args = json_parse(gad.kwargs); laurent@381: gadget = new svguilib[gad.__class__](self, gad.id, args); laurent@381: svguiWidgets[gadget.id]=gadget; laurent@371: //console.log('GADGET :' + gadget); laurent@371: } laurent@371: var elements = document.getElementsByTagName("svg"); laurent@371: for (var i = 0; i < elements.length; i++) { laurent@371: elements[i].addEventListener("mouseup", self, false); laurent@371: } laurent@371: //console.log("SVGUIWIDGETS : " + svguiWidgets); laurent@371: } laurent@371: );