Web Interface For Lite Argus Control modules
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.4 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. Ext.onReady(function(){
  8. Ext.Direct.addProvider(
  9. Ext.app.REMOTING_API,
  10. {
  11. type:'polling',
  12. url: 'php/poll.php'
  13. }
  14. );
  15. var out = new Ext.form.DisplayField({
  16. cls: 'x-form-text',
  17. id: 'out'
  18. });
  19. var text = new Ext.form.TextField({
  20. width: 300,
  21. emptyText: 'Echo input'
  22. });
  23. var call = new Ext.Button({
  24. text: 'Echo',
  25. handler: function(){
  26. TestAction.doEcho(text.getValue(), function(result, e){
  27. var t = e.getTransaction();
  28. out.append(String.format('<p><b>Successful call to {0}.{1} with response:</b><xmp>{2}</xmp></p>',
  29. t.action, t.method, Ext.encode(result)));
  30. out.el.scroll('b', 100000, true);
  31. });
  32. }
  33. });
  34. var num = new Ext.form.TextField({
  35. width: 80,
  36. emptyText: 'Multiply x 8',
  37. style: 'text-align:left;'
  38. });
  39. var multiply = new Ext.Button({
  40. text: 'Multiply',
  41. handler: function(){
  42. TestAction.multiply(num.getValue(), function(result, e){
  43. var t = e.getTransaction();
  44. if(e.status){
  45. out.append(String.format('<p><b>Successful call to {0}.{1} with response:</b><xmp>{2}</xmp></p>',
  46. t.action, t.method, Ext.encode(result)));
  47. }else{
  48. out.append(String.format('<p><b>Call to {0}.{1} failed with message:</b><xmp>{2}</xmp></p>',
  49. t.action, t.method, e.message));
  50. }
  51. out.el.scroll('b', 100000, true);
  52. });
  53. }
  54. });
  55. text.on('specialkey', function(t, e){
  56. if(e.getKey() == e.ENTER){
  57. call.handler();
  58. }
  59. });
  60. num.on('specialkey', function(t, e){
  61. if(e.getKey() == e.ENTER){
  62. multiply.handler();
  63. }
  64. });
  65. var p = new Ext.Panel({
  66. title: 'Remote Call Log',
  67. //frame:true,
  68. width: 600,
  69. height: 300,
  70. layout:'fit',
  71. items: [out],
  72. bbar: [text, call, '-', num, multiply]
  73. }).render(Ext.getBody());
  74. Ext.Direct.on('message', function(e){
  75. out.append(String.format('<p><i>{0}</i></p>', e.data));
  76. out.el.scroll('b', 100000, true);
  77. });
  78. });