Index: /issm/trunk-jpl/src/m/mesh/triangle.js
===================================================================
--- /issm/trunk-jpl/src/m/mesh/triangle.js	(revision 19715)
+++ /issm/trunk-jpl/src/m/mesh/triangle.js	(revision 19716)
@@ -54,5 +54,5 @@
 	//Now, build the connectivity tables for this mesh.
 	md.mesh.vertexconnectivity=NodeConnectivity(md.mesh.elements,md.mesh.numberofvertices);
-	//md.mesh.elementconnectivity=ElementConnectivity(md.mesh.elements,md.mesh.vertexconnectivity);	
+	md.mesh.elementconnectivity=ElementConnectivity(md.mesh.elements,md.mesh.vertexconnectivity);	
 
 }
Index: /issm/trunk-jpl/src/wrappers/ElementConnectivity/ElementConnectivity.h
===================================================================
--- /issm/trunk-jpl/src/wrappers/ElementConnectivity/ElementConnectivity.h	(revision 19715)
+++ /issm/trunk-jpl/src/wrappers/ElementConnectivity/ElementConnectivity.h	(revision 19716)
@@ -45,4 +45,14 @@
 #endif
 
+#ifdef _HAVE_JAVASCRIPT_MODULES_
+/* serial input macros: */
+#define ELEMENTS         elementsin, nelsin,3
+#define NODECONNECTIVITY nodeconnectivityin, nodsin, widthin
+/* serial output macros: */
+#define ELEMENTCONNECTIVITY pelementconnectivity,NULL,NULL
+#undef WRAPPER
+#define WRAPPER(modulename) extern "C" { int  ElementConnectivityModule(double** pelementconnectivity, int* elementsin, int* nodeconnectivityin, int nelsin, int nodsin, int widthin)
+#endif
+
 /* serial arg counts: */
 #undef NLHS
Index: /issm/trunk-jpl/src/wrappers/ElementConnectivity/ElementConnectivity.js
===================================================================
--- /issm/trunk-jpl/src/wrappers/ElementConnectivity/ElementConnectivity.js	(revision 19716)
+++ /issm/trunk-jpl/src/wrappers/ElementConnectivity/ElementConnectivity.js	(revision 19716)
@@ -0,0 +1,45 @@
+function ElementConnectivity(elementsin,nodeconnectivityin){
+/*ElementConnectivity 
+	   usage: var md.mesh.elementconnectivity= ElementConnectivity(md.mesh.elements,md.mesh.vertexconnectivity);
+*/
+
+	//Dynamic allocations: {{{
+	//Retrieve elements and allocate on Module heap: 
+	
+	//input
+	nel=elementsin.length;
+	nods=nodeconnectivityin.length;
+	width=nodeconnectivityin[0].length;
+	
+	var delements=new Int32Array(MatrixToList(elementsin)); var nelements=delements.length * delements.BYTES_PER_ELEMENT;
+	var delementsPtr= Module._malloc(nelements); var elementsHeap = new Uint8Array(Module.HEAPU8.buffer,delementsPtr,nelements);
+	elementsHeap.set(new Uint8Array(delements.buffer)); var elements=elementsHeap.byteOffset;
+	
+	var dnodeconnectivity=new Int32Array(MatrixToList(nodeconnectivityin)); var nnodeconnectivity=dnodeconnectivity.length * dnodeconnectivity.BYTES_PER_ELEMENT;
+	var dnodeconnectivityPtr= Module._malloc(nnodeconnectivity); var nodeconnectivityHeap = new Uint8Array(Module.HEAPU8.buffer,dnodeconnectivityPtr,nnodeconnectivity);
+	nodeconnectivityHeap.set(new Uint8Array(dnodeconnectivity.buffer)); var nodeconnectivity=nodeconnectivityHeap.byteOffset;
+
+	//output
+	var connectivitylinear,connectivity;
+	var pconnectivity= Module._malloc(4); 
+	//}}}
+
+	//Declare ElementConnectivity module: 
+	ElementConnectivityModule = Module.cwrap('ElementConnectivityModule','number',['number','number','number','number','number','number']);
+	
+	//Call ElementConnectivity module: 
+	ElementConnectivityModule(pconnectivity,elements, nodeconnectivity, nel, nods, width);
+	
+	/*Dynamic copying from heap: {{{*/
+	//recover mesh: 
+	var connectivityptr = Module.getValue(pconnectivity,'i32');
+	connectivitylinear = Module.HEAPF64.slice(connectivityptr /8, connectivityptr/8 + nel*3);
+	connectivity = ListToMatrix(connectivitylinear,3);
+	/*}}}*/
+
+	/*Free ressources: */
+	Module._free(pconnectivity); 
+	Module._free(connectivitylinear); 
+
+	return connectivity;
+}
Index: /issm/trunk-jpl/src/wrappers/NodeConnectivity/NodeConnectivity.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/NodeConnectivity/NodeConnectivity.cpp	(revision 19715)
+++ /issm/trunk-jpl/src/wrappers/NodeConnectivity/NodeConnectivity.cpp	(revision 19716)
@@ -10,5 +10,5 @@
 	_printf0_("\n");
 }/*}}}*/
-WRAPPER(NodeConnectivity, double** pconnectivity, int* pnods, int *pwidth, int* elementsin, int nelsin, int nodsin){
+WRAPPER(NodeConnectivity){
 
 	/*inputs: */
Index: /issm/trunk-jpl/src/wrappers/NodeConnectivity/NodeConnectivity.h
===================================================================
--- /issm/trunk-jpl/src/wrappers/NodeConnectivity/NodeConnectivity.h	(revision 19715)
+++ /issm/trunk-jpl/src/wrappers/NodeConnectivity/NodeConnectivity.h	(revision 19716)
@@ -22,7 +22,5 @@
 /*Header files: */
 #include "../bindings.h"
-#ifndef _HAVE_JAVASCRIPT_MODULES_
 #include "../../c/main/globals.h"
-#endif
 #include "../../c/toolkits/toolkits.h"
 #include "../../c/modules/modules.h"
@@ -53,4 +51,6 @@
 /* serial output macros: */
 #define CONNECTIVITY pconnectivity,pnods,pwidth
+#undef WRAPPER
+#define WRAPPER(modulename) extern "C" { int  NodeConnectivityModule(double** pconnectivity, int* pnods, int *pwidth, int* elementsin, int nelsin, int nodsin)
 #endif
 
Index: /issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.cpp
===================================================================
--- /issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.cpp	(revision 19715)
+++ /issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.cpp	(revision 19716)
@@ -14,7 +14,6 @@
 	_printf_("\n");
 }/*}}}*/
-WRAPPER(TriMesh,double** pindex, double** px, double** py, int* pnel, int* pnods, double** psegments, double** psegmentmarkers, int* pnsegs, double* domainx, double* domainy, int domainnods, double areain){
+WRAPPER(TriMesh){
 	
-
 	/*intermediary: */
 	double    area;
Index: /issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.h
===================================================================
--- /issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.h	(revision 19715)
+++ /issm/trunk-jpl/src/wrappers/TriMesh/TriMesh.h	(revision 19716)
@@ -71,4 +71,6 @@
 #define SEGMENTS          psegments,pnsegs
 #define SEGMENTMARKERLIST psegmentmarkers,pnsegs
+#undef WRAPPER
+#define WRAPPER(modulename) extern "C" { int  TriMeshModule(double** pindex, double** px, double** py, int* pnel, int* pnods, double** psegments, double** psegmentmarkers, int* pnsegs, double* domainx, double* domainy, int domainnods, double areain)
 #define _DO_NOT_LOAD_GLOBALS_//we only load globals for TriMeshModule.js, not other modules!
 #endif
Index: /issm/trunk-jpl/src/wrappers/javascript/Makefile.am
===================================================================
--- /issm/trunk-jpl/src/wrappers/javascript/Makefile.am	(revision 19715)
+++ /issm/trunk-jpl/src/wrappers/javascript/Makefile.am	(revision 19716)
@@ -9,5 +9,6 @@
 bin_SCRIPTS = 
 bin_SCRIPTS += ../TriMesh/TriMesh.js  \
-			   ../NodeConnectivity/NodeConnectivity.js
+			   ../NodeConnectivity/NodeConnectivity.js\
+			   ../ElementConnectivity/ElementConnectivity.js
 	
 #javascript io{{{
@@ -73,6 +74,8 @@
 
 IssmModule_SOURCES = ../TriMesh/TriMesh.cpp \
-					 ../NodeConnectivity/NodeConnectivity.cpp
-IssmModule_CXXFLAGS= -fPIC -D_DO_NOT_LOAD_GLOBALS_ --memory-init-file 0 $(AM_CXXFLAGS) $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) -s EXPORTED_FUNCTIONS="['_TriMeshModule','_NodeConnectivityModule']"  -s DISABLE_EXCEPTION_CATCHING=0
+					 ../NodeConnectivity/NodeConnectivity.cpp\
+					 ../ElementConnectivity/ElementConnectivity.cpp
+
+IssmModule_CXXFLAGS= -fPIC -D_DO_NOT_LOAD_GLOBALS_ --memory-init-file 0 $(AM_CXXFLAGS) $(CXXFLAGS) $(CXXOPTFLAGS) $(COPTFLAGS) -s EXPORTED_FUNCTIONS="['_TriMeshModule','_NodeConnectivityModule','_ElementConnectivityModule']"  -s DISABLE_EXCEPTION_CATCHING=0
 IssmModule_LDADD = ${deps} $(TRIANGLELIB) 
 #}}}
