-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
132 lines (127 loc) · 4.44 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
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
132
<!DOCTYPE html>
<html lang="en">
<head>
<title>JS-Sequence-Diagramm</title>
<link href='http://fonts.googleapis.com/css?family=Love+Ya+Like+A+Sister' rel='stylesheet' type='text/css'>
<style type="text/css" media="screen">
body {
overflow:hidden;
}
#container {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: silver;
}
#menu {
position: absolute;
top: 0;
right: 0;
left: 0;
height: 60px;
background-color: silver;
font-family: 'Love Ya Like A Sister', cursive;
}
#menu h1 {
padding: 3px;
margin: 0px;
font-weight: bold;
font-size: 280%;
}
#menu h1 a {
float: right;
border: 1px solid grey;
border-radius: 10px;
font-size: 75%;
background-color: grey;
padding: 4px;
font-weight: normal;
text-decoration: none;
color: black;
box-shadow: 0px 0px 10px grey;
text-shadow: silver 1px 1px;
}
#main {
position: absolute;
top: 60px;
right: 0;
left: 0;
bottom: 40px;
background-color: white;
}
#statusbar {
position: absolute;
bottom: 0;
right: 0;
left: 0;
height: 40px;
background-color: silver;
font-family: 'Love Ya Like A Sister', cursive;
}
#statusbar p {
padding: 10px;
margin: 0px;
font-size: 120%;
}
#editor {
position: absolute;
top: 0;
left: 0;
bottom: 0;
width: 50%;
}
#diagram {
position: absolute;
top: 0;
right: 0;
bottom: 0;
width: 50%;
}
</style>
</head>
<body>
<div id="container">
<div id="menu">
<h1>JS-Sequence-Diagramm
<a id="saveLink" href="#" download="diagram.svg">Save Image</a></h1>
</div>
<div id="main">
<div id="editor"></div>
<div id="diagram"></div>
</div>
<div id="statusbar"></div>
</div>
<!-- JS libraries -->
<script src="ace/ace.js" type="text/javascript" charset="utf-8"></script>
<script src="raphael-min.js" type="text/javascript" charset="utf-8"></script>
<script src="underscore-min.js" type="text/javascript" charset="utf-8"></script>
<script src="sequence-diagram-min.js" type="text/javascript" charset="utf-8"></script>
<script>
var editor = ace.edit("editor");
editor.on('change', function() {
var statusmsg = '';
try {
document.getElementById('diagram').innerHTML = "";
var diagram = Diagram.parse(editor.getValue());
diagram.drawSVG("diagram", {theme: 'simple'});
var svg = document.getElementsByTagName('svg')[0];
var width = parseInt(svg.width.baseVal.value);
var height = parseInt(svg.height.baseVal.value);
var data = editor.getValue();
var xml = '<?xml version="1.0" encoding="utf-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"><svg xmlns="http://www.w3.org/2000/svg" width="' + width + '" height="' + height + '" xmlns:xlink="http://www.w3.org/1999/xlink"><source><![CDATA[' + data + ']]></source>' + svg.innerHTML + '</svg>';
document.getElementById('saveLink').href = "data:image/svg+xml," + encodeURIComponent(xml);
statusmsg = '<p>Diagramm sucessfully generated</p>';
} catch(err) {
statusmsg = '<p>Error while parsing the input</p>';
console.log(err);
}
document.getElementById('statusbar').innerHTML = statusmsg;
});
editor.setTheme("ace/theme/monokai");
editor.getSession().setMode("ace/mode/asciidoc");
editor.setValue("A->B: test()\nB-->A: TestReply()", -1);
</script>
</body>
</html>