-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
59 lines (53 loc) · 2.15 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>feature-configurator</title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script src="https://cdn.rawgit.com/vanderlee/tristate/master/jquery.tristate.js"></script>
<script src="bundle.js"></script>
<script>
$(function() {
$("button").click(function() {
try {
var xml = $.parseXML($("textarea").val().trim());
window.app = new Configurator(new Model(new XmlModel(xml)), {
target: $(".configurator"),
renderer: {
renderAround: function(fn) {
var html = "<p>This configuration is " + (this.configuration.isValid() ? "valid" : "invalid") +
" and " + (this.configuration.isComplete() ? "complete" : "incomplete") + ".</p>";
html += fn();
html += '<button class="export" ' + (this.configuration.isComplete() ? "" : "disabled") + '>Export Configuration</button>';
return html;
},
afterRender: function() {
var self = this;
$(".export").click(function() {
$("pre").empty().text(self.configuration.serialize());
});
}
}
});
} catch (e) {
alert(e);
}
});
});
</script>
<style>
body { font-family: Arial; }
ul { list-style-type: none; user-select: none; }
pre { white-space: pre-wrap; word-break: keep-all; }
input[type=text] { margin-left: 8px; height: 0.95em; }
</style>
</head>
<body>
<div>
<textarea cols="100" rows="10"></textarea>
</div>
<button>Load Model</button>
<div class="configurator"></div>
<pre></pre>
</body>
</html>