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.

78 lines
2.7 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: gettext("Channel Viewer"),
  7. root: {
  8. text: gettext("Loading..."),
  9. leaf: true
  10. },
  11. buttons: [{
  12. text: gettext("Refresh"),
  13. handler: this.refresh,
  14. scope: this
  15. }],
  16. } );
  17. Ext.ux.MumbleChannelViewer.superclass.constructor.call( this );
  18. this.refresh();
  19. }
  20. Ext.extend( Ext.ux.MumbleChannelViewer, Ext.tree.TreePanel, {
  21. refresh: function(){
  22. var conn = new Ext.data.Connection();
  23. conn.request({
  24. url: this.source_url,
  25. scope: this,
  26. success: function( resp, opt ){
  27. var respdata = Ext.decode( resp.responseText );
  28. var root = {
  29. text: respdata.name,
  30. id: "mumbroot",
  31. leaf: false,
  32. icon: '/static/mumble/mumble.16x16.png',
  33. children: [],
  34. };
  35. function populateNode( node, json ){
  36. var subchan_users = 0;
  37. for( var i = 0; i < json.channels.length; i++ ){
  38. var child = {
  39. text: json.channels[i].name,
  40. id: ("channel_" + json.channels[i].id),
  41. leaf: true,
  42. icon: '/static/mumble/channel.png',
  43. children: [],
  44. };
  45. node.leaf = false;
  46. node.children.push( child );
  47. subchan_users += populateNode( child, json.channels[i] );
  48. }
  49. for( var i = 0; i < json.users.length; i++ ){
  50. var child = {
  51. text: json.users[i].name,
  52. id: ("user_" + json.users[i].id),
  53. leaf: true,
  54. icon: '/static/mumble/talking_off.png',
  55. };
  56. node.leaf = false;
  57. node.children.push( child );
  58. }
  59. if( json.id == 0 || json.users.length > 0 || subchan_users )
  60. node.expanded = true;
  61. return subchan_users + json.users.length;
  62. }
  63. populateNode( root, respdata.root );
  64. this.setRootNode( root );
  65. },
  66. failure: function( resp, opt ){
  67. alert("fail");
  68. },
  69. });
  70. },
  71. } );
  72. Ext.reg( 'mumblechannelviewer', Ext.ux.MumbleChannelViewer );