| 1 | <%
|
|---|
| 2 | /******************************/
|
|---|
| 3 | /* server side AJAJ functions */
|
|---|
| 4 | libinclude("server_call.js");
|
|---|
| 5 |
|
|---|
| 6 | /* this is a call that the client js code can make - it just adds
|
|---|
| 7 | some more elements to the passed object, then returns the object */
|
|---|
| 8 | function testfunc(x) {
|
|---|
| 9 | var sys = sys_init();
|
|---|
| 10 | x.nttime = sys.nttime();
|
|---|
| 11 | x.timestring = sys.httptime(x.nttime);
|
|---|
| 12 | return x;
|
|---|
| 13 | }
|
|---|
| 14 |
|
|---|
| 15 | /* register a call for clients to make */
|
|---|
| 16 | var call = servCallObj();
|
|---|
| 17 | call.add('testfunc', testfunc);
|
|---|
| 18 |
|
|---|
| 19 | /* run the function that was asked for */
|
|---|
| 20 | call.run();
|
|---|
| 21 |
|
|---|
| 22 | /***********************/
|
|---|
| 23 | /* now the main page */
|
|---|
| 24 | page_header("columns", "ESP qooxdoo test", "esptest");
|
|---|
| 25 | %>
|
|---|
| 26 |
|
|---|
| 27 | <script type="text/javascript" src="/scripting/client/encoder.js"></script>
|
|---|
| 28 | <script type="text/javascript" src="/scripting/client/call.js"></script>
|
|---|
| 29 |
|
|---|
| 30 | <h1>Samba4 qooxdoo test</h1>
|
|---|
| 31 |
|
|---|
| 32 | <script type="text/javascript">
|
|---|
| 33 |
|
|---|
| 34 | window.application.main = function()
|
|---|
| 35 | {
|
|---|
| 36 | var inlineWidget = new QxInline;
|
|---|
| 37 | var fieldSet = new QxFieldSet("thefieldset");
|
|---|
| 38 |
|
|---|
| 39 | with(fieldSet)
|
|---|
| 40 | {
|
|---|
| 41 | setWidth("40%");
|
|---|
| 42 | setMinHeight(400);
|
|---|
| 43 | setBottom(48);
|
|---|
| 44 | setMinWidth(500);
|
|---|
| 45 | };
|
|---|
| 46 |
|
|---|
| 47 | var gl = new QxGridLayout("auto,auto,auto,auto,auto", "100%");
|
|---|
| 48 | gl.setEdge(0);
|
|---|
| 49 | gl.setCellPaddingTop(3);
|
|---|
| 50 | gl.setCellPaddingBottom(3);
|
|---|
| 51 |
|
|---|
| 52 | inlineWidget.add(fieldSet);
|
|---|
| 53 |
|
|---|
| 54 | var d = this.getClientWindow().getDocument();
|
|---|
| 55 |
|
|---|
| 56 | var stopit = 0;
|
|---|
| 57 | var shared = new Object();
|
|---|
| 58 |
|
|---|
| 59 | function callback(o) {
|
|---|
| 60 | shared = o;
|
|---|
| 61 | var r = "Response:\\n";
|
|---|
| 62 | for (var i in shared) {
|
|---|
| 63 | r = r + "\\t" + i + " : " + shared[i] + "\\n";
|
|---|
| 64 | }
|
|---|
| 65 | ta.setText(r);
|
|---|
| 66 | if (shared.start_time == 0) {
|
|---|
| 67 | shared.start_time = shared.nttime;
|
|---|
| 68 | }
|
|---|
| 69 | shared.time_diff = shared.nttime - shared.start_time;
|
|---|
| 70 | shared.rate = shared.counter / (shared.time_diff * 0.0000001);
|
|---|
| 71 | shared.counter++;
|
|---|
| 72 | if (stopit == 0) {
|
|---|
| 73 | server_call_url("@@request.REQUEST_URI", 'testfunc', callback, shared);
|
|---|
| 74 | }
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | function start_call() {
|
|---|
| 78 | srv_printf("Starting calls ... (stopit=%d)\\n", stopit);
|
|---|
| 79 | stopit = 0;
|
|---|
| 80 | shared.counter = 0;
|
|---|
| 81 | shared.start_time = 0;
|
|---|
| 82 | server_call_url("@@request.REQUEST_URI", 'testfunc', callback, shared);
|
|---|
| 83 | };
|
|---|
| 84 |
|
|---|
| 85 | function stop_call() {
|
|---|
| 86 | srv_printf("Stopping calls\\n");
|
|---|
| 87 | stopit = 1;
|
|---|
| 88 | };
|
|---|
| 89 |
|
|---|
| 90 | function myButton(name, label, call) {
|
|---|
| 91 | var b = new QxButton(label);
|
|---|
| 92 | b.setWidth("25%");
|
|---|
| 93 | b.addEventListener("click", call);
|
|---|
| 94 | return b;
|
|---|
| 95 | };
|
|---|
| 96 |
|
|---|
| 97 | function myCheckBox(label, name, value) {
|
|---|
| 98 | var w = new QxCheckBox(label, value, name, value);
|
|---|
| 99 | w.setWidth("100%");
|
|---|
| 100 | return w;
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | var c1 = myCheckBox("Enable The Server", 'checkbox1', false);
|
|---|
| 104 | var c2 = myCheckBox("Another Server", 'checkbox2', true);
|
|---|
| 105 | var t3 = new QxTextField("hello");
|
|---|
| 106 | var b1 = myButton("send", "Make Call", start_call);
|
|---|
| 107 | var b2 = myButton("stop", "Stop Call", stop_call);
|
|---|
| 108 | var ta = new QxTextArea;
|
|---|
| 109 | ta.setText("initial text");
|
|---|
| 110 | ta.setWidth("80%");
|
|---|
| 111 | ta.setHeight(150);
|
|---|
| 112 | ta.setVerticalAlign("top");
|
|---|
| 113 |
|
|---|
| 114 | gl.add(c1, { row : 1, col : 1 });
|
|---|
| 115 | gl.add(c2, { row : 2, col : 1 });
|
|---|
| 116 | gl.add(t3, { row : 3, col : 1, scaleHorizontal: true });
|
|---|
| 117 | gl.add(b1, { row : 4, col : 1 });
|
|---|
| 118 | gl.add(ta, { row : 5, col : 1 });
|
|---|
| 119 | gl.add(b2, { row : 6, col : 1 });
|
|---|
| 120 |
|
|---|
| 121 | fieldSet.add(gl);
|
|---|
| 122 |
|
|---|
| 123 | inlineWidget.add(fieldSet);
|
|---|
| 124 |
|
|---|
| 125 | d.add(inlineWidget, "canvas");
|
|---|
| 126 | };
|
|---|
| 127 |
|
|---|
| 128 | </script>
|
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 | <div id="canvas" style="overflow:hidden;position:static;margin-top:38px;margin-left:10px;margin-right:700px;width:700px"></div>
|
|---|
| 132 |
|
|---|
| 133 | <% page_footer(); %>
|
|---|