-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathindex.html
More file actions
489 lines (389 loc) · 13.5 KB
/
index.html
File metadata and controls
489 lines (389 loc) · 13.5 KB
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
<html lang="en">
<head>
<style>
html {
height: 100%;
}
.grass {
margin: 0;
z-index: 999;
width: 100%;
position: fixed;
bottom: 0px;
}
body {
height: 100%;
background: url("http://preview.ibb.co/nHsvLF/page_background.png") no-repeat;
/* background-color: aqua;*/
background-size: cover;
}
.tree {
/* background: url("images/tree1.jpg") no-repeat;*/
}
.tree_img {
width: 100%;
height: 100%;
z-index: -1;
}
.leaf_test {
position: absolute;
top: 12%;
left: 12%;
height: 55%;
width: 60%;
}
.leaf_1 {
transform-origin: top;
background-image: url("http://image.ibb.co/kiJVnv/leaves_1.png");
}
.leaf_2 {
transform-origin: top;
background-image: url("http://image.ibb.co/kpofnv/leaves_2.png");
}
.leaf_3 {
transform-origin: top;
background-image: url("http://image.ibb.co/eXWpfF/leaves_3.png");
}
.leaf_group {
position: absolute;
display: inline-block;
width: 30%;
height: 30%;
background-repeat: no-repeat;
background-size: contain;
animation-name: growUp;
animation-duration: 0.5s;
-webkit-animation-fill-mode: forwards;
/* Chrome, Safari, Opera */
animation-fill-mode: forwards;
}
@keyframes growUp {
0% {
width: 0%;
height: 0%;
}
25% {
width: 5%;
height: 5%;
}
50% {
width: 12%;
height: 12%;
}
70% {
width: 23%;
height: 23%;
}
100% {
width: 30%;
height: 30%;
}
}
.leaf_group:hover {
cursor: pointer;
width: 35%;
height: 35%;
}
.text_on_leaf {
z-index: 999;
transform: rotate(180deg);
text-overflow: ellipsis;
overflow: hidden;
/* margin: 50% 20% 30% 20%;*/
margin: 25% auto auto 30%;
width: 50%;
height: 20%;
}
.name_on_leaf {
display: none;
}
.time_tag {
display: none;
}
#special_leaf_4 {
margin: 20% 20% 30% 20% !important;
}
.modal-content img {
position: absolute;
width: 100%;
height: 100%;
opacity: 0.4;
}
.user_input {
padding: 30px 10px;
margin-top: 2%;
z-index:1000;
}
textarea {
/* border-radius: 3px;*/
}
.counter {
display: inline;
float: right;
}
#wish_content {
width: 100%;
height: 75px;
}
#wisher_name {
max-width: 100%;
}
#make_wish {
float: right;
}
#modal_content {
width: 100%;
/* word-break: break-all;*/
word-wrap: break-word;
}
</style>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<script>
$(document).ready(function() {
//shuffle function for fake random
function shuffle(array) {
var currentIndex = array.length;
// var temporaryValue, randomIndex;
// While there remain elements to shuffle...
while (0 !== currentIndex) {
// Pick a remaining element...
var randomIndex = Math.floor(Math.random() * currentIndex);
currentIndex -= 1;
// And swap it with the current element.
var temporaryValue = array[currentIndex];
array[currentIndex] = array[randomIndex];
array[randomIndex] = temporaryValue;
}
return array;
}
//numbers arr for fake random
//var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23];
var arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23];
shuffle(arr);
//if one leaf has been clicked
$('body').on("click", ".leaf_group", lookWishDetails);
//see the wish detials
//note: get data from SharePoint, modfy here
//push data in modal
function lookWishDetails() {
//get the content of the leaf been clicked
var to_modal_content = $(this).find(".wish_on_leaf").text();
var to_modal_name = $(this).find(".name_on_leaf").text();
var to_modal_time = $(this).find(".time_tag").text();
//push data to modal
$("#modal_content").text(to_modal_content);
$("#modal_name").text(to_modal_name);
$("#modal_time").text(to_modal_time);
//show the modal
$("#myModal").modal();
};
//wish_data is a array of wish content
var wish_data = {};
// n is for the fake random position
var n = 0;
var WishNo = 0;
var WishText;
var NameText;
var TimeText;
//add the data from sharepoint
from_sharepoint();
//creat a leaf when click make a wish button
$("#make_wish").click(function() {
//check if has content, make sure no empty
if ($("#wish_content").val() && $("#wisher_name").val()) {
WishText = $("#wish_content").val();
console.log(WishText)
NameText = $("#wisher_name").val();
TimeText = new Date().toLocaleDateString('en-US');
prepare_data();
CreatALeaf(wish_data);
// after creat the leaf, reset the textarea for next wish
$("#wish_content").val('');
$("#wisher_name").val('');
$('.counter').text("200 / 200");
//make a magic sound
//new Audio("https://d1490khl9dq1ow.cloudfront.net/sfx/mp3preview/magic-spells-with-harp-and-chimes_GJiMErE_.mp3").play();
} else {
// if empty, alert the user
alert("Please enter your wishes and name in the typearea.");
}
});
//get data from sharepoint
function from_sharepoint() {
for (let i = 0; i < 20; i++) {
WishText = "wishwishwish";
console.log(WishText)
NameText = "namenamename";
TimeText = 'datedatedate';
prepare_data();
//CreatALeaf(wish_data);
}
}
//import data
function prepare_data() {
var Num = Math.floor(Math.random() * 3) + 1;
var FakeRandomTop = [24, 51, 89, 25, 53, 36, 80, 36, 50, 51, 41, 55, 72, 16, 80, 78, 34, 85, 71, 40, 96, 17, 87, 71];
var FakeRandomLeft = [6, 76, 37, 44, 32, 79, 55, 89, 54, -8, 29, 2, 48, 17, 86, 25, 56, 66, 6, 53, 57, 57, 35, 92];
var FakeRandomRotate = [131, 281, 48, 169, 92, 209, 195, 265, 237, 111, 138, 172, 149, 187, 312, 71, 220, 218, 91, 126, 289, 220, 156, 251];
// console.log("n=" + n)
// console.log("arr.n=" + arr[n])
// console.log(FakeRandomTop[arr[n]])
// console.log(FakeRandomLeft[arr[n]])
// console.log(FakeRandomRotate[arr[n]])
wish_data = {
wish: WishText,
name: NameText,
time: TimeText,
wish_num: WishNo,
num: Num,
top: FakeRandomTop[arr[n]],
left: FakeRandomLeft[arr[n]],
rotate: FakeRandomRotate[arr[n]]
}
WishNo += 1;
//use the number in arr to fake the random without duplication, so a position only has one leaf, in a loop
if (n < arr.length - 1) {
n += 1;
}
// if the arr has been run out once, reset the arr order and n
else if (n === arr.length - 1) {
shuffle(arr);
n = 0;
};
}
//creat a new leaf fucntion
function CreatALeaf(data) {
var txt1 = '<div data-rotate=' + data.rotate + ' data-orig=' + data.rotate + ' id="wish_' + data.wish_num + '" class="leaf_group leaf_' + data.num + '" style="top:' + data.top + '%; left:' + data.left + '%; transform:rotate(' + data.rotate + 'deg)"><p class="text_on_leaf wish_on_leaf">' + data.wish + '</p><p class="text_on_leaf name_on_leaf">' + data.name + '</p><p class="text_on_leaf time_tag">' + data.time + '</p></div>';
$(".leaf_test").append(txt1);
}
//character remain in the text area
$('#wish_content').keyup(function() {
var postlength = $(this).val().length;
var charactersLeft = 200 - postlength;
$('.counter').text(charactersLeft + " / 200");
});
// set the interval between two wind
var BreezeAll = setInterval(BreezeLeft, 4800);
//breeze animation - rotate function
function BreezeLeft() {
var handle_1 = 0;
var blow_handle = setInterval(function() {
//change the 25 to any number if wanna change the movement distance
if (handle_1 < 25) {
for (let i = 0; i < WishNo; i++) {
var css_id = '#wish_' + i;
//check the deg of each leaf, the deg of wind is 250deg to 70deg, change the number to change the deg of wind
if ($(css_id).data("orig") > 110 && $(css_id).data("orig") <= 340) {
//change 0.5 to any number to change the step
var RotateValue = $(css_id).data("rotate") + 0.5;
} else {
var RotateValue = $(css_id).data("rotate") - 0.5;
}
var cssValue = "rotate(" + RotateValue + "deg)"
$(css_id).css("transform", cssValue);
$(css_id).data("rotate", RotateValue)
};
handle_1 += 1;
} else {
clearInterval(blow_handle);
FallBack();
}
//change the 60 to any number to change the blow duration
}, 60)
}
//leaves falls back
function FallBack() {
var handle_2 = 0;
var fall_handle = setInterval(function() {
if (handle_2 < 25) {
for (let i = 0; i < WishNo; i++) {
var css_id = '#wish_' + i;
if ($(css_id).data("orig") > 110 && $(css_id).data("orig") <= 340) {
var RotateValue = $(css_id).data("rotate") - 0.5;
} else {
var RotateValue = $(css_id).data("rotate") + 0.5;
}
var cssValue = "rotate(" + RotateValue + "deg)"
$(css_id).css("transform", cssValue);
$(css_id).data("rotate", RotateValue)
};
handle_2 += 1;
} else {
clearInterval(fall_handle);
}
}, 50)
}
});
</script>
</head>
<body>
<div class="for_position" style=" display:table;
height:100%; width:100%">
<div class="container-fluid" style="vertical-align: middle;
display: table-cell;">
<!--empty div for position arrangement-->
<div class="col-lg-2"></div>
<!--the tree frame-->
<div class="col-xs-12 col-sm-8 col-md-7 col-lg-5 tree">
<img src="http://image.ibb.co/mwmBua/tree.png" class="tree_img" />
<!--the leaf group frame-->
<!--定位树枝, 不能去掉-->
<div class="leaf_test">
<!--example of leaf templete--
<div id="wish_0" class="leaf_group leaf_1" >
<p class="text_on_leaf wish_on_leaf"> </p>
<p class="text_on_leaf name_on_leaf"></p>
<p class="text_on_leaf time_tag"></p>
</div>
end of one leaf templete-->
</div>
<!--end of leaf group frame-->
<!--modal pack-->
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog modal-sm">
<!-- Modal content-->
<div class="modal-content">
<img src="http://image.ibb.co/gpRY7v/wish_background.jpg" />
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<p id="modal_content"></p>
<p id="modal_name"></p>
<p id="modal_time"></p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" style="position:relative; background: none">Close</button>
</div>
</div>
</div>
</div>
<!--end of modal pack-->
</div>
<!--end of tree frame-->
<div class="user_input col-xs-12 col-sm-4 col-md-5 col-lg-4 " style="max-width: 500px">
What's your wish:
<br>
<textarea id="wish_content" type="text" name="wish_content" maxlength="200" rows="7" placeholder="Type your wish here" autofocus></textarea>
<p class="counter">200 / 200</p>
<br>
<br> Your name:
<br>
<textarea id="wisher_name" type="text" name="wisher_name" maxlength="20" placeholder="Enter your name"></textarea>
<br>
<br>
<button class="btn btn-default" id="make_wish" type="button">Make a wish</button>
</div>
<!--empty div for position arrangement-->
<div class="col-lg-1"></div>
</div>
</div>
<div class="grass">
<img src="http://image.ibb.co/cjgBua/front_grass.png" style="width:100%; height: 50px" />
</div>
</body>
</html>