summaryrefslogtreecommitdiffstats
path: root/src/html/js/emuchooser.js
blob: 78fbd4f885a41f811e7565f1c9823fad9d526103 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
var activeEntry = "";

var about = function() {
	if (activeEntry != "") {
		$("#" + activeEntry).toggleClass("selected");
	}
	activeEntry = "";

	$("#content").html(emuchooser.getAbout());
	return false;
};

var help = function() {
	if (activeEntry != "") {
		$("#" + activeEntry).toggleClass("selected");
	}
	activeEntry = "";

	$("#content").html(emuchooser.getHelp());
	var foo = emuchooser.getList();
};

var run = function() {
	if (activeEntry != "") {
		id = parseInt(activeEntry.substring(5));
		emuchooser.run(id);
	}
}

var handleListClick = function (e) {
	id = parseInt(e.srcElement.id.substring(5));
	if (activeEntry != "") {
		$("#" + activeEntry).toggleClass("selected");
	}
	$("#" + e.srcElement.id).toggleClass("selected");
	activeEntry = e.srcElement.id;
	$("#content").html(emuchooser.getDetails(id));
};

var renderList = function () {
	var foo = emuchooser.getList();
	$.each(foo, function(i,item) {
		$("#emulist").append('<li id="item_'+ item.id +'" class="list '+ item.icon + '">' + item.title + '</li>');
		$('#item_' + item.id).click(handleListClick);
	});
};


var init = function() {
	renderList();
	$("button").button();
	$("#content").html(emuchooser.getWelcome());
	$("#about").click(about);
	$("#help").click(help);
	$("#start").click(run);
	
};