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.

76 lines
2.6 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. respdata = Ext.decode( resp.responseText );
  28. 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. subchan_users = 0;
  37. for( var i = 0; i < json.channels.length; i++ ){
  38. child = {
  39. text: json.channels[i].name,
  40. id: ("channel_" + json.channels[i].id),
  41. leaf: false,
  42. icon: '/static/mumble/channel.png',
  43. children: [],
  44. };
  45. node.children.push( child );
  46. subchan_users += populateNode( child, json.channels[i] );
  47. }
  48. for( var i = 0; i < json.users.length; i++ ){
  49. child = {
  50. text: json.users[i].name,
  51. id: ("user_" + json.users[i].id),
  52. leaf: true,
  53. icon: '/static/mumble/talking_off.png',
  54. };
  55. node.children.push( child );
  56. }
  57. if( json.id == 0 || json.users.length > 0 || subchan_users )
  58. node.expanded = true;
  59. return subchan_users + json.users.length;
  60. }
  61. populateNode( root, respdata.root );
  62. this.setRootNode( root );
  63. },
  64. failure: function( resp, opt ){
  65. alert("fail");
  66. },
  67. });
  68. },
  69. } );
  70. Ext.reg( 'mumblechannelviewer', Ext.ux.MumbleChannelViewer );