Forked mumble-django project from https://bitbucket.org/Svedrin/mumble-django
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.

96 lines
2.9 KiB

  1. // kate: space-indent on; indent-width 4; replace-tabs on;
  2. Ext.namespace('Ext.ux');
  3. Ext.ux.MumbleChannelViewer = function( config ){
  4. Ext.apply( this, config );
  5. Ext.applyIf( this, {
  6. title: "Channel View",
  7. root: {
  8. text: "ohai",
  9. leaf: true
  10. }
  11. } );
  12. var conn = new Ext.data.Connection();
  13. conn.request({
  14. url: this.source_url,
  15. scope: this,
  16. success: function( resp, opt ){
  17. respdata = Ext.decode( resp.responseText );
  18. root = {
  19. text: respdata.name,
  20. id: "mumbroot",
  21. leaf: false,
  22. icon: '/static/mumble/mumble.16x16.png',
  23. children: [],
  24. };
  25. function populateNode( node, json ){
  26. subchan_users = 0;
  27. for( var i = 0; i < json.channels.length; i++ ){
  28. child = {
  29. text: json.channels[i].name,
  30. id: ("channel_" + json.channels[i].id),
  31. leaf: false,
  32. icon: '/static/mumble/channel.png',
  33. children: [],
  34. };
  35. node.children.push( child );
  36. subchan_users += populateNode( child, json.channels[i] );
  37. }
  38. for( var i = 0; i < json.users.length; i++ ){
  39. child = {
  40. text: json.users[i].name,
  41. id: ("user_" + json.users[i].id),
  42. leaf: true,
  43. icon: '/static/mumble/talking_off.png',
  44. };
  45. node.children.push( child );
  46. }
  47. if( json.id == 0 || json.users.length > 0 || subchan_users )
  48. node.expanded = true;
  49. return subchan_users + json.users.length;
  50. }
  51. populateNode( root, respdata.root );
  52. this.setRootNode( root );
  53. },
  54. failure: function( resp, opt ){
  55. alert("fail");
  56. },
  57. });
  58. Ext.ux.MumbleChannelViewer.superclass.constructor.call( this );
  59. }
  60. Ext.extend( Ext.ux.MumbleChannelViewer, Ext.tree.TreePanel, {
  61. } );
  62. Ext.reg( 'mumblechannelviewer', Ext.ux.MumbleChannelViewer );
  63. function render_mumble( divname, data_url ){
  64. var mainpanel = new Ext.Panel({
  65. renderTo: divname,
  66. height: 600,
  67. layout: "border",
  68. items: [{
  69. xtype: "mumblechannelviewer",
  70. region: "west",
  71. width: 350,
  72. split: true,
  73. source_url: data_url,
  74. }, {
  75. xtype: "tabpanel",
  76. region: "center",
  77. activeTab: 0,
  78. items: [{
  79. title: "fail",
  80. html: "fail",
  81. }, {
  82. title: "omg",
  83. html: "omg"
  84. }],
  85. }],
  86. });
  87. }