forked from bramp/js-sequence-diagrams
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.html
132 lines (96 loc) · 4.27 KB
/
client.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
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title></title>
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="https://canvg.googlecode.com/svn/trunk/rgbcolor.js"></script>
<script type="text/javascript" src="https://canvg.googlecode.com/svn/trunk/StackBlur.js"></script>
<script type="text/javascript" src="https://canvg.googlecode.com/svn/trunk/canvg.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/lodash.js/1.2.1/lodash.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="https://bramp.github.io/js-sequence-diagrams/sequence-diagram-min.js"></script>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
<script>
$(document).ready(function(){
$('#language').bind('input propertychange',_.throttle( function() {
try{
$('#diagram').empty();
var diagram = Diagram.parse($('#language').val());
diagram.drawSVG('diagram', {theme: 'simple'});
// Test canvg
var data = document.getElementById('diagram').childNodes[0]; //svg data
var s = new XMLSerializer();
var str = s.serializeToString(data); //convert SVG code to string
canvg(document.getElementById('canvas'), str); //drawing the svg on the canvas
var dataURL = document.getElementById('canvas').toDataURL("image/png");
document.getElementById('myImg').src = dataURL;
document.getElementById('downloadlink').src = dataURL;
var a = $("#downloadlink");
a.attr("download", "seq.png"); // TODO I could put title here
a.attr("href", dataURL);
$("#statustext").text("Status - OK");
}catch(exception){
$("#statustext").text("Status - Error.. "+exception.message);
}
}, 100));
});
function toggleText(){
$("#sequence-text-container-open").css("width:10px");
}
</script>
<style>
h1{
font-family:'Roboto';
font-weight:100;
}
#statusbar{
position: fixed;
z-index: 100;
bottom: 0;
width: 100%;
}
a.toggle-text{
font-size:18px;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-4" id="sequence-text-container-open">
<h1>Sequence Text</h1>
<textarea id="language" rows="20" cols="50">
Andrew->China: Says Hello
Note right of China: China thinks\nabout it
China-->Andrew: How are you?
Andrew->>China: I am good thanks!
Title: Here is a title
A->B: Normal line
B-->C: Dashed line
C->>D: Open arrow
D-->>A: Dashed open arrow
Note left of A: Note to the\n left of A
Note right of A: Note to the\n right of A
Note over A: Note over A
</textarea>
</div>
<div class="col-md-6"><h1>Preview</h1><div id="diagram"></div></div>
</div>
<div class="row" id="statusbar">
<div class="col-md-8">
<h1 id="statustext">Status - OK</h1>
<a style="display:none" id="downloadlink" href="">Download PNG</a></h1>
</div>
</div>
</div>
<canvas style="dislay:none" id="canvas" width="1000px" height="600px"></canvas>
<img style="dislay:none" id="myImg" src="" >
</body>
</html>