mirror of
				https://github.com/RetroShare/RetroShare.git
				synced 2025-10-30 22:29:00 -04:00 
			
		
		
		
	webui: adding counting feature for menu
This commit is contained in:
		
							parent
							
								
									2e41c373b5
								
							
						
					
					
						commit
						b6bb69df7a
					
				
					 3 changed files with 30 additions and 3 deletions
				
			
		|  | @ -16,6 +16,13 @@ function buildmenu(menu, tagname, runstate, ignore){ | |||
|         && (menu.path === undefined || !menu.path.contains(":")) | ||||
|         && (menu.show === undefined || menu.show) | ||||
|     )  { | ||||
|         var name = menu.name; | ||||
|         if (menu.counter != undefined && menu.counterfnkt != undefined) { | ||||
|             var data=rs(menu.counter); | ||||
|             if (data != undefined) { | ||||
|                 name += " (" + menu.counterfnkt(data) + ")"; | ||||
|             } | ||||
|         } | ||||
|         if (menu.action === undefined) { | ||||
|             return m(tagname , { | ||||
|                 onclick: function(){ | ||||
|  | @ -23,9 +30,9 @@ function buildmenu(menu, tagname, runstate, ignore){ | |||
|                         menu.path != undefined ? menu.path : "/" + menu.name | ||||
|                     ) | ||||
|                 } | ||||
|             }, menu.name); | ||||
|             }, name); | ||||
|         } else { | ||||
|             return m(tagname, {onclick: function(){menu.action(rs,m)}}, menu.name); | ||||
|             return m(tagname, {onclick: function(){menu.action(rs,m)}}, name); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -11,6 +11,22 @@ module.exports = {  nodes: [ | |||
| 	{ | ||||
| 		name: "peers", | ||||
| 		runstate: "running_ok.*", | ||||
| 		counter: "peers", | ||||
| 		counterfnkt: function(data){ | ||||
| 		    var onlinecount = 0; | ||||
| 		    data.map(function(peer) { | ||||
| 		        var is_online = false; | ||||
| 		        peer.locations.map(function (location){ | ||||
| 		            if (location.is_online) { | ||||
| 		                is_online=true; | ||||
| 		            } | ||||
| 		        }); | ||||
| 		        if (is_online) { | ||||
| 		            onlinecount +=1; | ||||
| 		        } | ||||
| 		    }); | ||||
| 		    return onlinecount + "/" + data.length; | ||||
| 		} | ||||
| 	}, | ||||
| 	{ | ||||
| 	    name: "addpeer", | ||||
|  | @ -29,6 +45,10 @@ module.exports = {  nodes: [ | |||
| 	{ | ||||
| 		name: "downloads", | ||||
| 		runstate: "running_ok.*", | ||||
| 		counter: "transfers/downloads", | ||||
| 		counterfnkt: function(data){ | ||||
| 		    return data.length; | ||||
| 		} | ||||
| 	}, | ||||
| 	{ | ||||
| 		name: "chat", | ||||
|  |  | |||
|  | @ -5,7 +5,7 @@ var rs = require("retroshare"); | |||
| 
 | ||||
| module.exports = {view: function(){ | ||||
|     var peers = rs("peers"); | ||||
|     console.log("peers:" + peers); | ||||
|     //console.log("peers:" + peers);
 | ||||
| 
 | ||||
|     //waiting for peerlist ...
 | ||||
|     if(peers === undefined){ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 zeners
						zeners