
// Elements are shown in this order
var data = [
  {name: "youtube", desc: "YouTube", action="switch_display", url="youtube"}, 
	{name: "earth",   desc: "Earth",   action="switch_display", url="youtube"},
  {name: "doodles", desc: "Doodles", action="showDoodlesPage"}
];

var sendSwitchROSMessage = function(message) {
  
};

var showDoodlesPage = function() {

}

var createElementsList = function() {
	
	var ul = document.createElement('ul');
	for(var i = 0 ; i < data.length ; i++ ) {
		
		var name = data[i].name;
		var desc = data[i].desc;

		var li = document.createElement('li');
		
		var img = document.createElement('img');
		img.setAttribute('src', chrome.extension.getURL("images/" + name + '.jpg'));

    var span = document.createElement('span');
    span.innerText = desc;

		li.appendChild(img);
		li.appendChild(span);

		li.onclick = sendSwitchROSMessage(name);

		ul.appendChild(li);
	}

	return ul;

};

var initializeMoreFun = function() {

  var onclick = function() {
		document.getElementById("morefun_items").style.visibility='visible';
	};

  var s = document.createElement('div');
	s.id = "morefun";
  s.innerText = "More fun --ICON HERE--";
	s.onclick = onclick;
  document.body.appendChild(s);

	var d = document.createElement('div');
	d.id = "morefun_items";
	
	d.appendChild(createElementsList());
	d.style.visibility='hidden';
	console.log(d);
	document.body.appendChild(d);
};

initializeMoreFun();

@@ -47,87 +47,8 @@
 = %5B%0A
-  %7Bname: %22youtube%22, desc: %22YouTube%22, action=%22switch_display%22, url=%22youtube%22%7D, %0A
 %09%7Bna
@@ -191,62 +191,239 @@
 %5D;%0A%0A
-var sendSwitchROSMessage = function(message) %7B%0A  
+// Sends ROS message to display to change the browser's URL%0Avar sendSwitchROSMessage = function(url) %7B%0A%09// TODO invent some protocol message with url inside%0A  // TODO send proper message%0A%09// TODO add support at display's side
 %0A%7D;%0A%0A
+%0A
 var 
@@ -453,18 +453,131 @@
 ion() %7B%0A
+  // TODO: implement the doodles page%0A%09// TODO: add support for sending the ROS message to switch URL on display
 %0A%7D
+;
 %0A%0Avar cr
@@ -707,16 +707,18 @@
 ar name 
+  
 = data%5Bi
@@ -736,16 +736,18 @@
 ar desc 
+  
 = data%5Bi
@@ -749,24 +749,55 @@
 ata%5Bi%5D.desc;
+%0A%09%09var action = data%5Bi%5D.action;
 %0A%0A%09%09var li =
@@ -1073,24 +1073,56 @@
 ld(span);%0A%0A%09
+%09if (action == %22switch_display%22)
 %09li.onclick 
@@ -1144,20 +1144,86 @@
 Message(
-name
+url);%0A%09%09if (action == %22showDoodlesPage%22) li.onclick = showDoodlesPage(
 );%0A%0A%09%09ul

Add todo items