forked from maxlambertini/DiasporaClusterGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcluster-edit.html
131 lines (115 loc) · 4.02 KB
/
cluster-edit.html
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Diaspora Cluster Editor</title>
<link href='http://fonts.googleapis.com/css?family=Aldrich' rel='stylesheet' type='text/css'>
<link href="./css/diaspora.css" rel="stylesheet"/>
<script type="text/javascript" src="./scripts/jquery-1.9.0.js"></script>
<script type="text/javascript" src="./scripts/jcanvas.js"></script>
<script type="text/javascript" src="./scripts/knockout-2.3.0.js"></script>
<script type="text/javascript" src="./scripts/seedrandom.js"></script>
<script type="text/javascript" src="./scripts/dice.js"></script>
<script type="text/javascript" src="./scripts/cluster.js"></script>
</head>
<body>
<h1>Diaspora Cluster Editor</h1>
<button id="backButton" type="button">Back to Generator</button>
<hr />
<br />
<canvas id="clusterCanvas" width="500" height="250"></canvas>
<hr />
<div id="instructions">
<h2>Click a system to begin</h2>
Still a work in progress
</div>
<div id="systemBlock" data-bind="foreach: systems">
<div id="system" data-bind="attr: {id: $index }" >
<label for="systemName">System Name</label><input data-bind="value: name" type="text" id="systemName" /><br />
<label for="technology">Technology</label>
<select id="technology" data-bind="value: planet.technology">
<option>4</option>
<option>3</option>
<option>2</option>
<option>1</option>
<option>0</option>
<option>-1</option>
<option>-2</option>
<option>-3</option>
<option>-4</option>
</select><br />
<label for="environment">Environment</label>
<select id="environment" data-bind="value: planet.environment">
<option>4</option>
<option>3</option>
<option>2</option>
<option>1</option>
<option>0</option>
<option>-1</option>
<option>-2</option>
<option>-3</option>
<option>-4</option>
</select><br />
<label for="resources">Resources</label>
<select id="resources" data-bind="value: planet.resources">
<option>4</option>
<option>3</option>
<option>2</option>
<option>1</option>
<option>0</option>
<option>-1</option>
<option>-2</option>
<option>-3</option>
<option>-4</option>
</select><br />
<label for="aspect1">Aspect</label><input data-bind="value: aspect1" type="text" id="aspect1" /><br />
<label for="aspect2">Aspect</label><input data-bind="value: aspect2" type="text" id="aspect2" /><br />
</div>
</div>
<br />
<div id="clusterJSON"></div>
<hr />
<div id="koJSON"></div>
<script type="text/javascript">
var json;
if(window.location.hash) {
json = window.location.hash.substring(1); //Puts hash in variable, and removes the # character
} else {
json = "";
}
var ClusterEditModel = function(systems) {
var self = this;
self.systems = ko.observableArray(systems);
};
var cluster = new Cluster();
$(document).ready(function () {
var jsonCluster = json;
if (json != "") {
jsonCluster = decodeURIComponent(jsonCluster);
cluster.LoadFromJSON(jsonCluster);
cluster.Draw("#clusterCanvas");
var model = new ClusterEditModel(cluster.systems)
$("#koJSON").html(ko.toJSON(model));
ko.applyBindings(model);
}
$("#systemBlock").children("div").hide();
$( "select" ).change(function() {
cluster.Draw("#clusterCanvas");
$("#koJSON").html(ko.toJSON(model));
window.location.hash = encodeURIComponent($("#koJSON").html());
});
$( "input" ).change(function() {
cluster.Draw("#clusterCanvas");
$("#koJSON").html(ko.toJSON(model));
window.location.hash = encodeURIComponent($("#koJSON").html());
});
$("#backButton").click(function () {
window.location.href = "diaspora.html";
});
});
</script>
<div id="footer">
<a href="https://github.com/thecrazygm/DiasporaClusterGenerator">Get the Source Code Here</a>
</div>
</body>
</html>