svn commit: samba r9135 - in branches/SAMBA_4_0/swat/esptest: .

tridge at samba.org tridge at samba.org
Fri Aug 5 19:16:50 GMT 2005


Author: tridge
Date: 2005-08-05 19:16:49 +0000 (Fri, 05 Aug 2005)
New Revision: 9135

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=9135

Log:
added a sample page that demonstrates using AJAJ to make remote calls
that update an object


Added:
   branches/SAMBA_4_0/swat/esptest/qooxdoo.esp
   branches/SAMBA_4_0/swat/esptest/remote.esp


Changeset:
Added: branches/SAMBA_4_0/swat/esptest/qooxdoo.esp
===================================================================
--- branches/SAMBA_4_0/swat/esptest/qooxdoo.esp	2005-08-05 19:16:13 UTC (rev 9134)
+++ branches/SAMBA_4_0/swat/esptest/qooxdoo.esp	2005-08-05 19:16:49 UTC (rev 9135)
@@ -0,0 +1,117 @@
+<% 
+  page_header("columns", "ESP qooxdoo test", "esptest"); 
+
+  libinclude("encoder.js");
+
+  var thispage = request.REQUEST_URI;
+%>
+
+<script type="text/javascript" src="/scripting/client/encoder.js"></script>
+<script type="text/javascript" src="/scripting/client/call.js"></script>
+
+<h1>Samba4 qooxdoo test</h1>
+
+  <script type="text/javascript">
+
+  window.application.main = function()
+  {
+    var inlineWidget = new QxInline;
+    var fieldSet = new QxFieldSet("thefieldset");
+
+    with(fieldSet)
+    {
+	    setWidth("40%");
+	    setMinHeight(400);
+	    setBottom(48);
+	    setMinWidth(700);
+    };
+
+    var gl = new QxGridLayout("auto,auto,auto,auto,auto", "100%");
+    gl.setEdge(0);
+    gl.setCellPaddingTop(3);
+    gl.setCellPaddingBottom(3);
+
+    inlineWidget.add(fieldSet);
+
+    var d = this.getClientWindow().getDocument();
+
+    function myCheckBox(label, name, value) {
+	    var w = new QxCheckBox(label, value, name, value);
+	    w.setWidth("100%");
+	    return w;
+    }
+
+    function myTextField(name, value) {
+	    var w = new QxTextField(value);
+	    return w;
+    }
+
+    var stopit = 0;
+    var shared = new Object();
+    shared.counter = 0;
+
+    function callback(o) {
+	    shared = o;
+	    var r = "Response:\\n";
+	    for (var i in shared) {
+		    r = r + "\\t" + i + " : " + shared[i] + "\\n";
+	    }
+	    ta.setText(r);
+	    shared.counter++;
+	    if (stopit == 0) {
+		    server_call('remote.esp', 'testfunc', callback, shared);
+	    }
+    }
+
+    function start_call() { 
+	    server_call('remote.esp', 'printf', null, 
+			"Starting calls ... (stopit=%d)\\n", stopit);
+	    stopit = 0;
+	    server_call('remote.esp', 'testfunc', callback, shared);
+    };
+
+    function stop_call() { 
+	    server_call('remote.esp', 'printf', null, "Stopping calls\\n");
+	    stopit = 1;
+    };
+
+    function myButton(name, label, call) {
+        var b = new QxButton(label);
+	b.setWidth("25%");
+	b.setVerticalAlign("top");
+	b.name = name;
+	b.addEventListener("click", call);
+	return b;
+    };
+
+    var c1 = myCheckBox("Enable The Server", 'checkbox1', false);
+    var c2 = myCheckBox("Another Server", 'checkbox2', true);
+    var t3 = myTextField("mytext", "hello");
+    var b1 = myButton("send", "Make Call", start_call);
+    var b2 = myButton("stop", "Stop Call", stop_call);
+    var ta = new QxTextArea;
+    ta.setText("initial text");
+    ta.setWidth("80%");
+    ta.setHeight(150);
+    ta.setVerticalAlign("top");
+
+    gl.add(c1, { row : 1, col : 1 });
+    gl.add(c2, { row : 2, col : 1 });
+    gl.add(t3, { row : 3, col : 1, scaleHorizontal: true });
+    gl.add(b1, { row : 4, col : 1 });
+    gl.add(ta, { row : 5, col : 1 });
+    gl.add(b2, { row : 6, col : 1 });
+
+    fieldSet.add(gl);
+
+    inlineWidget.add(fieldSet);
+
+    d.add(inlineWidget, "canvas");
+  };
+
+  </script>
+
+
+ <div id="canvas" style="overflow:hidden;position:static;margin-top:38px;margin-left:10px;margin-right:700px;width:700px"></div>
+
+<% page_footer() %>

Added: branches/SAMBA_4_0/swat/esptest/remote.esp
===================================================================
--- branches/SAMBA_4_0/swat/esptest/remote.esp	2005-08-05 19:16:13 UTC (rev 9134)
+++ branches/SAMBA_4_0/swat/esptest/remote.esp	2005-08-05 19:16:49 UTC (rev 9135)
@@ -0,0 +1,19 @@
+<%
+libinclude("server_call.js");
+
+/* this is a call that the client js code can make - it just adds
+   some more elements to the passed object, then returns the object */
+function testfunc(x) {
+	var sys = sys_init();
+	x.nttime = sys.nttime();
+	x.timestring = sys.httptime(x.nttime);
+	return x;
+}
+
+/* register a call for clients to make */
+var call = servCallObj();
+call.add('testfunc', testfunc);
+
+/* run the function that was asked for */
+call.run();
+%>



More information about the samba-cvs mailing list