-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
338 lines (300 loc) · 11.2 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>活動花絮產生器</title>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<link rel="stylesheet" type="text/css" media="all" href="css/styles.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
</head>
<body>
<div class="loading2" style="width:100%;height:100vh;background:rgba(0,0,0,.5);color:#fff;text-align:center;display:none;position:fixed;top:0;left:0;z-index:999">
<img src="img/ellipsis.svg"><br>系統處理中...
</div>
<div class="row">
<div class="col-md-12" id="dragwrap">
<form id="upload" action="upload.php" method="POST" enctype="multipart/form-data">
<fieldset>
<input type="hidden" id="MAX_FILE_SIZE" name="MAX_FILE_SIZE" value="300000" />
<div>
<input type="file" id="fileselect" name="fileselect[]" multiple="multiple" />
<div id="filedrag">將電腦裡的圖片檔案拖放至此。<br>(圖片建議尺寸:寬 220 像素內,高 295 像素內)</div>
</div>
<div id="submitbutton">
<button type="submit">Upload Files</button>
</div>
</fieldset>
</form>
</div>
<div class="col-md-8 col-md-offset-4">
<div class="step2">
<div class="toolbar clearfix">
<div class="input-group quickfill">
<span class="input-group-addon" id="basic-addon1">通通填入文字:</span>
<input type="text" class="form-control" id="filtxt" placeholder="">
<div class="input-group-btn">
<button type="button" class="btn btn-warning dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
選擇字型 <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li>
<a href="#" class="btn_font1">王漢宗注音</a>
</li>
<li>
<a href="#" class="btn_font2">微軟正黑體</a>
</li>
</ul>
<button class="btn btn-primary btn_fill" type="button">執行 <span class="glyphicon glyphicon-circle-arrow-down"></span></button>
</div>
</div>
<div class="input-group foldername">
<span class="input-group-addon" id="basic-addon1">圖片資料夾路徑</span>
<input type="text" class="form-control" id="foldername" value="img/activity/" placeholder="此批圖片將放在哪個資料夾裡面?">
<!--<span class="input-group-btn">
<a href="javascript:void(0);" class="btn btn-success btn_html" onclick="clear()"><span class="glyphicon glyphicon-check"></span> 產生 html </a>
</span>-->
<div class="input-group-btn">
<button type="button" class="btn btn-success dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
產生 <span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a href="#" class="btn_html">HTML 程式碼片段</a></li>
<li><a href="#" class="btn_htmlfile">HTML 檔案</a></li>
<!-- <li><a href="#" class="btn_image2">圖片</a></li>-->
</ul>
</div>
</div>
<!-- /input-group -->
<div class="btn-group" style="margin-left:15px">
<a href="javascript:void(0);" class="btn btn-info btn_hidedel" onclick="hidedel()"><span class="glyphicon glyphicon-remove"></span> 顯示/隱藏刪除按鈕 </a>
<a href="javascript:void(0);" class="btn btn-danger btn_clear" onclick="clear()"><span class="glyphicon glyphicon-trash"></span> 全部清空 </a>
</div>
</div>
<ul id="photo" class="">
</ul>
</div>
</div>
</div>
<div class="modal fade" tabindex="-1" role="dialog" id="htmlcodemodal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title">產生 html</h4>
</div>
<div class="modal-body">
<textarea id="htmlcode_result"></textarea>
<div id="img_result"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">關閉</button>
<button type="button" class="btn btn-primary">返回修改</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
<div id="temp"></div>
<div class="alertbottom alert alert-warrnig">
<span id="msg">載入成功,請輸入要放在照片上的文字。</span>
<div class="loading"><img src="img/ellipsis.svg"></div>
</div>
<input type="hidden" id="startedit" value="0">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
<script src="js/filedrag.js"></script>
<script async="" src="js/Blob.js"></script>
<script async="" src="js/canvas-toBlob.js"></script>
<script async="" src="js/FileSaver.js"></script>
<script src="js/html2canvas.js"></script>
<script src="js/html2canvas.svg.js"></script>
<script>
$(window).bind('beforeunload', function () {
if ($('#startedit').val() == "1") return "是否確定關閉網頁?";
});
function addZero(i) {if (i < 10) {i = "0" + i;} return i;}
var currentdate = new Date();
var datetime = currentdate.getFullYear() + "" + (currentdate.getMonth()+1) + "" + currentdate.getDate();
var htmlpart1 = "", htmlpart2 = "";
$.ajax({
url: 'part1.txt',
async: false,
type: 'get',
dataType: 'text',
success: function (rest) {
htmlpart1 = rest;
$.ajax({
url: 'part2.txt',
async: false,
type: 'get',
dataType: 'text',
success: function (rest) {
htmlpart2 = rest;
}
});
}
});
//console.log(htmlpart1,htmlpart2)
$('.btn_clear').click(function(){
if(confirm('是否確認清空?')) {
location.href = location.href
}
});
function hidedel(){
$('#photo .del').toggle();
}
$('.btn_fill').click(function(){
var filltxt = $('#filtxt').val();
$('#photo .form-control').each(function(){
$(this).val(filltxt);
});
});
$('#photo').on('click', '.del', function(){
$(this).parent().remove()
});
$('#photo').on('click', '.form-control', function(){
//console.log($(this).val());
if ($(this).val() == "點此輸入文字") $(this).val('');
});
$('.btn_htmlfile').click(function(){
$('#temp').html();
$('#photo').clone().appendTo('#temp');
var foldername = $('#foldername').val();
$('#temp #photo').removeClass('ui-sortable');
$('#temp img').each(function(){
var thissrc = $(this).data('src');
$(this).attr('src', foldername+thissrc);
$(this).removeAttr( "data-src" );
});
$('#temp .form-control').each(function(){
var thistxt = $(this).val();
$(this).next().text(thistxt);
$(this).remove();
});
$('#temp .del').each(function(){
$(this).remove();
});
$('#temp li').each(function(){
$(this).removeClass('ui-sortable-handle');
});
var temphtml = $('#temp').html();
var filename = datetime;
var blob = new Blob([htmlpart1+temphtml+htmlpart2], {type: "text/html;charset=utf-8"});
saveAs(blob, filename+".html");
});
$('.btn_html').click(function(){
$('#temp').html();
$('#photo').clone().appendTo('#temp');
var foldername = $('#foldername').val();
$('#temp #photo').removeClass('ui-sortable');
$('#temp img').each(function(){
var thissrc = $(this).data('src');
$(this).attr('src', foldername+thissrc);
$(this).removeAttr( "data-src" );
});
$('#temp .form-control').each(function(){
var thistxt = $(this).val();
$(this).next().text(thistxt);
$(this).remove();
});
$('#temp .del').each(function(){
$(this).remove();
});
$('#temp li').each(function(){
$(this).removeClass('ui-sortable-handle');
});
var temphtml = $('#temp').html();
$('#htmlcode_result').siblings().hide();
$('#htmlcode_result').val(temphtml);
$('#htmlcodemodal').modal();
});
$(".btn_image2").on("click", function(event) {
$('.loading2').fadeIn();
$('#temp').html('');
$('#photo').clone().appendTo('#temp');
var foldername = $('#foldername').val();
$('#temp #photo').removeClass('ui-sortable');
$('#temp .form-control').each(function(){
var thistxt = $(this).val();
$(this).next().text(thistxt);
$(this).remove();
});
$('#temp .del').each(function(){
$(this).remove();
});
$('#temp li').each(function(){
$(this).removeClass('ui-sortable-handle');
});
var temphtml = $('#temp').get(0);
console.log('start render');
html2canvas([ document.getElementById('temp') ], {
allowTaint: true,
taintTest: false,
logging:true,
onrendered: function(canvas) {
//document.body.appendChild(canvas);
console.log('done');
$('.loading2').fadeOut();
$('#htmlcodemodal').modal();
document.getElementById('img_result').appendChild(canvas);
}
});
});
$('.btn_image').click(function(){
$('#temp').html();
$('#photo').clone().appendTo('#temp');
var foldername = $('#foldername').val();
$('#temp #photo').removeClass('ui-sortable');
// $('#temp img').each(function(){
// var thissrc = $(this).data('src');
// $(this).attr('src', foldername+thissrc);
// $(this).removeAttr( "data-src" );
// });
$('#temp .form-control').each(function(){
var thistxt = $(this).val();
$(this).next().text(thistxt);
$(this).remove();
});
$('#temp .del').each(function(){
$(this).remove();
});
$('#temp li').each(function(){
$(this).removeClass('ui-sortable-handle');
});
var temphtml = $('#temp').get(0);
html2canvas(temphtml, {
onrendered: function(canvas) {
theCanvas = canvas;
// canvas.toBlob(function(blob) {
// saveAs(blob, datetime + "png");
// });
var myImage = canvas.toDataURL("image/png");
window.open(myImage);
// var a = document.createElement('a');
// a.href = canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream");
// a.download = 'somefilename.jpg';
// a.click();
}
});
// temphtml.getContext('2d');
// window.open('', temphtml.toDataURL());
});
// 選擇字型
$('.btn_font1').click(function(){
//注音
$('#photo input').attr('class','');
$('#photo input').addClass('font1');
$('#photo input').addClass('form-control');
});
$('.btn_font2').click(function(){
//沒注音
$('#photo input').attr('class','');
$('#photo input').addClass('font2');
$('#photo input').addClass('form-control');
});
</script>
<!--
https://www.sitepoint.com/html5-javascript-open-dropped-files/
-->
</body>
</html>