-
Notifications
You must be signed in to change notification settings - Fork 25
/
index.html
193 lines (186 loc) · 7.3 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Circular Slides Generator - impress.js</title>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.0/css/bootstrap.min.css">
<link href='http://fonts.googleapis.com/css?family=Amaranth:400,700' rel='stylesheet' type='text/css'>
<style>
body {
background-image: url(//wmh.github.io/circular-slides-generator/static/img/noise.png);
}
h1 {
font-size: 82px;
font-family: 'Amaranth', sans-serif;
text-shadow: 0px 3px 3px #666;
margin-top: 0;
}
h2 {
font-family: 'Amaranth', sans-serif;
}
</style>
</head>
<body>
<div class="container">
<h1>Circular Slides Generator</h1>
<p class="lead">Generates circular slides for Impress.js presentations.</p>
<form class="form-horizontal" role="form">
<div class="form-group">
<label for="pages" class="col-md-2 control-label">How Many Slides</label>
<div class="col-md-2">
<input type="text" class="form-control" id="pages" value="10">
</div>
</div>
<div class="form-group">
<label for="origin-x" class="col-md-2 control-label">Origin</label>
<div class="col-md-2 input-group">
<span class="input-group-addon">X</span>
<input type="text" class="form-control" id="origin-x" value="0">
</div>
<div class="col-md-2 input-group">
<span class="input-group-addon">Y</span>
<input type="text" class="form-control" id="origin-y" value="0">
</div>
</div>
<div class="form-group">
<label for="size-x" class="col-md-2 control-label">Slide Size</label>
<div class="col-md-2 input-group">
<span class="input-group-addon">W</span>
<input type="text" class="form-control" id="size-w" value="800">
</div>
<div class="col-md-2 input-group">
<span class="input-group-addon">H</span>
<input type="text" class="form-control" id="size-h" value="600">
</div>
</div>
<div class="form-group">
<label for="spacing" class="col-md-2 control-label">Slide Spacing</label>
<div class="col-md-2">
<input type="text" class="form-control" id="spacing" value="-50">
</div>
</div>
<div class="form-group">
<label class="col-md-2 control-label">Options</label>
<div class="col-md-4">
<div class="checkbox">
<input type="checkbox" checked="checked" id="cover-page">
<label for="cover-page">Add cover page</label>
</div>
<div class="checkbox">
<input type="checkbox" checked="checked" id="credit-page">
<label for="credit-page">Include credit page</label>
</div>
<div class="checkbox">
<input type="checkbox" id="reverse">
<label for="reverse">Reverse (anti-clockwise)</label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-4">
<button type="submit" id="generate" class="btn btn-primary"><span class="glyphicon glyphicon-cog"></span> Generate</button>
<button type="submit" id="preview" class="btn btn-success"><span class="glyphicon glyphicon-play"></span> Preview</button>
</div>
</div>
<div class="form-group">
<label for="codes" class="col-md-2 control-label">Codes</label>
<div class="col-md-10">
<textarea id="codes" class="form-control" rows="6"></textarea>
</div>
</div>
</form>
<div id="notice">
<h2>Notice</h2>
<p>If you want to browse this template locally from the file system, you have to save impress.js as local file too.</p>
</div>
<div id="credits">
<h2>Credits</h2>
<ul>
<li>
<a href="http://bartaz.github.io/impress.js" target="_blank">impress.js</a> - Bartek Szopka
</li>
<li>
<a href="http://wmh.github.io/circular-slides-generator" target="_blank">Circular Slides Generator</a> - Hunter Wu
</li>
</ul>
</div>
</div>
<a href="https://github.com/wmh/circular-slides-generator"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_gray_6d6d6d.png" alt="Fork me on GitHub"></a>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function () {
// load template
var template = '';
$.get('template.html', function (data) {
template = data;
}, 'html');
function getSlideCodes() {
var pages = Math.max($('#pages').val() * 1, 3),
originX = $('#origin-x').val() * 1,
originY = $('#origin-y').val() * 1,
sizeW = $('#size-w').val() * 1,
sizeH = $('#size-h').val() * 1,
spacing = $('#spacing').val() * 1,
offsetX = parseInt(originX - sizeW / 2, 10),
offsetY = parseInt(originY - sizeH / 2, 10),
c = (sizeH + spacing) * pages,
r = parseInt(c / 2 / Math.PI + sizeW / 2, 10),
overviewScale = Math.ceil((r * 2 + Math.max(sizeW, sizeH)) / Math.min(sizeW, sizeH)),
coverPage = $('#cover-page').is(':checked'),
coverPageScale = 1,
creditPage = $('#credit-page').is(':checked'),
reverse = $('#reverse').is(':checked'),
de = 0,
deStep = (reverse ? -1 : 1) * (360 / pages),
page, ra, x, y, codes = '';
if (coverPage) {
coverPageScale = r / Math.max(sizeW, sizeH) * 0.7;
codes += '<div class="step slide" data-x="'+ (originX - parseInt(sizeW / 2, 10)) +'" data-y="' + (originY - parseInt(sizeH / 2, 10)) + '" data-rotate="0" data-scale="'+ coverPageScale +'"><q>My Slides</q></div>' + "\n";
}
for (page = 1; page <= pages; ++page) {
de = deStep * (page - 1);
rotate = de;
ra = (360 - de) * Math.PI / 180;
x = parseInt(offsetX + Math.cos(ra) * r, 10);
y = parseInt(offsetY - Math.sin(ra) * r, 10);
if (page < pages) {
codes += '<div class="step slide" data-x="'+ x +'" data-y="' + y + '" data-rotate="'+ rotate +'" data-scale="1"><q>Slide '+ page +'</q></div>' + "\n";
} else {
codes += '<div class="step slide credits" data-x="'+ x +'" data-y="' + y + '" data-rotate="'+ rotate +'" data-scale="1">'+ $('#credits').html() +'</div>' + "\n";
}
}
codes += '<div class="step" data-x="'+ originX +'" data-y="'+ originY +'" data-scale="'+ overviewScale +'"></div>';
return codes;
}
$('#generate').click(function (e) {
e.preventDefault();
var sizeW = $('#size-w').val() * 1,
sizeH = $('#size-h').val() * 1;
$('#codes').val(template
.replace('width: 800px;', 'width: '+ sizeW +'px;')
.replace('height: 600px;', 'height: '+ sizeH +'px;')
.replace('<!--impressinit-->','<script>impress().init()<\/script>')
.replace('<!-- slides -->', getSlideCodes())
);
});
$('#preview').click(function (e) {
e.preventDefault();
if (window.previewWindow) {
window.previewWindow.close();
}
window.previewWindow = window.open('template.html');
$(window.previewWindow).load(function (e) {
var previewDoc = window.previewWindow.document,
slideRule = previewDoc.styleSheets[0].cssRules[2],
sizeW = $('#size-w').val() * 1,
sizeH = $('#size-h').val() * 1;
slideRule.style.width = sizeW + 'px';
slideRule.style.height = sizeH + 'px';
$(previewDoc).find('#impress').html(getSlideCodes());
window.previewWindow.impress().init();
});
});
});
</script>
</body>
</html>