-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
512 lines (475 loc) · 18.3 KB
/
index.html
File metadata and controls
512 lines (475 loc) · 18.3 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
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
<!--
* @Description:
* @Version: 2.0
* @Autor: 葛璐豪
* @Date: 2020-08-21 14:59:16
* @LastEditors: Seven
* @LastEditTime: 2020-08-25 21:27:48
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>button</title>
<script src="d3.js"></script>
<style>
.text {
font-size: 10px;
}
#calendar {
margin-left: 200px;
border: solid 1px teal;
border-spacing: 0;
}
.table_td {
border: solid thin black;
padding: 10px;
}
#clock {
margin-left: 300px;
}
.hour {
color: red;
}
.min {
color: blue;
}
.ss {
color: chartreuse;
}
</style>
</head>
<body>
<p class = "button">点击它 点击它!</p>
<svg></svg>
<div>点击球场任意位置实现球的移动</div>
<div id="filed" onclick="change(event)"
style="position: relative; width:300px; height:200px; margin:0px; border:black solid thin">
<img src="ground.jpg" style="position: absolute; width:300px; height:200px; top:0px;left:0px; ">
<img id="ball" src="ball.jpg"
style="position: absolute; margin:0px; padding:0px;width:30px; height:30px; top:0px; left:0px ;transition: 1s all; ">
</div>
<button id="ele">display</button>
<div id="text">text</div>
<button onclick="zhedie(event)" style="outline:none">click me</button>
<ul id="menu">
<li>this </li>
<li>cd </li>
<li>as </li>
<li>aa </li>
</ul>
<!-- <button style = "position:absolute; top:40px;left:0px">on</button>
<button style = "position:absolute; top:40px;left:350px">down</button>-->
<div style="position: relative;padding:0px 40px ; margin:20px; width:340px;border:red solid medium;">
<button id="up" style="position:absolute; top:40px;left:0px">上</button>
<button id="down" style="position:absolute; top:40px;left:380px">下</button>
<div id="carousel" style="width: 320px; height:100px;margin:0px; padding:0px;overflow:hidden">
<ul id="pictureul" style="margin:0px;margin-left:0px; padding:0px;border:mediumaquamarine thin solid">
<li style="display: inline-block;"><img src="ball.jpg" style="width: 100px; height:100px"></li>
<li style="display: inline-block;"><img src="ground.jpg" style="width: 100px; height:100px"></li>
<li style="display: inline-block;"><img src="three.jpg" style="width: 100px; height:100px"></li>
<li style="display: inline-block;"><img src="four.jpg" style="width: 100px; height:100px"></li>
<li style="display: inline-block;"><img src="five.jpg" style="width: 100px; height:100px"></li>
<li style="display: inline-block;"><img src="six.jpg" style="width: 100px; height:100px"></li>
<li style="display: inline-block;"><img src="seven.jpg" style="width: 100px; height:100px"></li>
</ul>
<button style="display: inline-block;">click</button>
</div>
</div>
<!--上一天的-->
<ul id="container"></ul>
<table id="calendar"></table>
<div id="clock">
<span class="hour">hh</span>:<span class="min">mm</span>:<span class="sec">ss</span>
</div>
<table id="pai">
<thead>
<tr>
<th>Name</th>
<th>Surname</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr>
<td>John</td>
<td>Smith</td>
<td>10</td>
</tr>
<tr>
<td>Pete</td>
<td>Brown</td>
<td>15</td>
</tr>
<tr>
<td>Ann</td>
<td>Lee</td>
<td>5</td>
</tr>
<tr>
<td>...</td>
<td>...</td>
<td>...</td>
</tr>
</tbody>
</table>
<article class="pane" style="border:solid red thin;background-color:yellow">
<h1>a Explorer 9</h1>
<p>Windows Internet Explorer 9(简称 IE9)于 2011 年 3 月 14 日发布.....</p>
</article>
<article class="pane" style="border:solid red thin;background-color:yellow">
<h1>b Explorer 9</h1>
<p>Windows Internet Explorer 9(简称 IE9)于 2011 年 3 月 14 日发布.....</p>
</article>
<article class="pane" style="border:solid red thin;background-color:yellow">
<h1>c Explorer 9</h1>
<p>Windows Internet Explorer 9(简称 IE9)于 2011 年 3 月 14 日发布.....</p>
</article>
<script>
var dataset = [];
for (let i = 0; i < 50; ++i) {
let yRange = Math.random() * 100;
dataset.push(yRange);
}
var w = 1000;
var h = 200;
var svg = d3.select("body").select("svg")
.attr("width", w).attr("height", h);
var margin = {
top: 20,
bottom: 20,
left: 30,
right: 30 //rangeBands([margin.left,w-margin.right],0.05) --更改为d3.scaleBand().domain(d3.range(dataset.length)).rangeRound([margin.left, w-margin.right]).padding(0.1);
}
var xScale = d3.scaleBand().domain(d3.range(dataset.length)).rangeRound([margin.left, w - margin.right])
.padding(0.1);
var yScale = d3.scaleLinear().domain([0, d3.max(dataset)]).range([h - margin.bottom, margin.top]).nice();
svg.selectAll("rect").data(dataset).enter().append("rect")
.attr("x", (d, i) => {
return xScale(i)
})
.attr("y", (d) => {
return h - margin.bottom - yScale(d)
})
.attr("width", xScale.bandwidth)
.attr("height", (d) => {
return yScale(d)
})
.attr("fill", (d) => {
return `rgb(${d},0,0)`
});
svg.selectAll("text").data(dataset).enter().append("text").text((d) => {
return Math.round(d)
})
.attr("class", "text")
.attr("fill", "white").attr("x", (d, i) => {
return xScale(i) + xScale.bandwidth() / 2
})
.attr("y", (d) => {
return h - margin.bottom - yScale(d) + 15
})
.attr("text-anchor", "middle");
var aXis = d3.axisBottom(xScale).ticks(20);
var aYis = d3.axisLeft(yScale).ticks(5);
svg.append("g").attr("transform", `translate(0,${h-margin.bottom})`).call(aXis);
svg.append("g").attr("transform", `translate(${margin.left},0)`).call(aYis);
d3.select("body").select("p.button").on("click", () => {
for (let i = 0; i < 50; ++i) {
let yRange = Math.random() * 100;
dataset[i] = yRange;
}
//新版d3.easeLinear
svg.selectAll("rect").data(dataset).transition().duration(1000).ease(d3.easeBounce)
.attr("y", (d) => {
return h - margin.bottom - yScale(d)
})
.attr("height", (d) => {
return yScale(d)
}).attr("fill", (d) => {
return `rgb(0,${d},0)`
});
svg.selectAll("text").data(dataset).text((d) => {
return Math.round(d)
})
.attr("y", (d) => {
return h - margin.bottom - yScale(d) + 15
});
});
</script>
<script>
function display() {
let key = true;
return function () {
if (key) {
text.style.display = 'none';
ele.innerHTML = "none-display";
} else {
text.style.display = '';
ele.innerHTML = "display";
}
key = !key;
}
}
ele.onclick = display();
function change(event) {
let left = Math.round(event.clientX - filed.offsetLeft - filed.clientLeft - ball.clientWidth / 2);
let top = Math.round(event.clientY - filed.offsetTop - filed.clientTop - ball.clientHeight / 2);
if (left < 0) left = 0;
if (top < 0) top = 0;
if (left > filed.clientWidth - ball.clientWidth) left = filed.clientWidth - ball.clientWidth;
if (top > filed.clientHeight - ball.clientHeight) top = filed.clientHeight - ball.clientHeight;
ball.style.left = left + 'px';
ball.style.top = top + 'px';
}
var isAN = true;
function zhedie(event) {
if (isAN) {
menu.style.display = "none";
} else {
menu.style.display = "";
}
isAN = !isAN;
}
let paneAll = document.body.querySelectorAll(".pane");
for (let pane of paneAll) {
pane.insertAdjacentHTML("afterbegin", '<button class="remove-button" style = "float:right">[x]</button>');
}
let closeAll = document.body.querySelectorAll(".remove-button");
for (let close of closeAll) {
close.onclick = function () {
close.parentNode.remove();
}
}
var MAX_LI = pictureul.querySelectorAll("li").length;
up.onclick = function () {
if (parseInt(pictureul.style.marginLeft) + 315 <= 0) {
pictureul.style.marginLeft = parseInt(pictureul.style.marginLeft) + 315 + "px";
}
}
down.onclick = function () {
if (parseInt(pictureul.style.marginLeft) - 315 > -MAX_LI * 105) {
pictureul.style.marginLeft = parseInt(pictureul.style.marginLeft) - 315 + "px";
}
}
/////////////上一天
//列表树的建立
let data = {
"Fish": {
"trout": {},
"salmon": {}
},
"Tree": {
"Huge": {
"sequoia": {},
"oak": {}
},
"Flowering": {
"apple tree": {},
"magnolia": {}
}
}
};
/*
//第一种
<li>p
<ul>
</ul>
</li>
//第二种
<li>p</li>
*/
function createTree(container, data) {
for (let p in data) {
//创建当前节点
if (data[p] != null) { //非空就是个队列 <ul>finish<ul>tourish</ul>
let li = document.createElement("li");
li.prepend(p);
container.append(li);
let ul = document.createElement("ul");
li.append(ul);
createTree(ul, data[p]);
} else {
let li = document.createElement("li");
li.innerHTML = p;
container.append(li);
}
}
}
createTree(container, data); //树已创建
//下来标出后代数量 container
for (let ele of container.querySelectorAll("li")) {
ele.firstChild.data += ` 子节点 = ${ele.querySelectorAll("li").length}`;
}
//日历的建立
//日期建立
function createCalendar(calendar, year, month) {
let current_Date = new Date(year, month - 1, 1);
//标题建立
caption = document.createElement("caption");
caption.innerHTML = `${year}年${month}月 日历`;
calendar.append(caption);
//头建立
head = document.createElement("tr");
head.className = "tr";
head.innerHTML =
"<td><strong>MO</strong></td><td><strong>TU</strong></td><td><strong>WE</strong></td><td><strong>TH</strong></td><td><strong>FR</strong></td><td><strong>SA</strong></td><td><strong>SU</strong></td>";
calendar.append(head);
//获取一共多少天
let get_data = new Date(year, month, 0);
let All_days = get_data.getDate();
//6行建立
let tr = new Array;
for (let i = 0; i < 6; ++i) {
tr[i] = document.createElement("tr");
calendar.append(tr[i]);
}
//日期填充
let start_week = (current_Date.getDay() == 0 ? 7 : current_Date.getDay()) % 8;
//alert("start_week="+start_week);
for (let i = 1; i <= All_days; ++i) {
//第一行空的填充
//alert(i);
let td = document.createElement("td");
td.innerHTML = i;
if (i == 1) {
for (let kong = 1; kong < start_week; ++kong) {
let td_kong = document.createElement("td");
tr[0].append(td_kong);
}
tr[0].append(td);
} else {
tr[parseInt((start_week - 1) / 7)].append(td);
}
++start_week;
}
//处理最后一行的空行
if ((start_week - 1) % 7 != 0) {
for (let i = (start_week % 7 == 0 ? 7 : start_week % 7); i <= 7; ++i) {
let td = document.createElement("td");
tr[parseInt((start_week - 1) / 7)].append(td);
}
}
//贴近类
tr = calendar.querySelectorAll("tr");
for (let ever of tr) {
ever.className = "table_td";
}
td = calendar.querySelectorAll("td");
for (let ever of td) {
ever.className = "table_td";
}
}
//方法1:类
class xun {
constructor(value) {
this.month = value;
}
change(calendar, year) {
calendar.innerHTML = "";
createCalendar(calendar, year, this.month);
this.month++;
if (this.month == 13) {
this.month = 1;
}
}
}
let c = new xun(1);
setTimeout(function at() {
c.change(calendar, 2020);
setTimeout(at, 1000);
}, 1000);
//方法2:闭包
/*
function change() {
let month_time = 1;
return function () {
//alert(month_time);
calendar.innerHTML = "";
createCalendar(calendar, 2020, month_time);
month_time++;
if(month_time == 13){
month_time = 1;
}
setTimeout(fchange,1000);
}
}
let fchange = change();
fchange();
*/
//时钟
function times() {
let Current = new Date();
let hour = clock.querySelector(".hour");
let min = clock.querySelector(".min");
let sec = clock.querySelector(".sec");
hour.innerHTML = `${Current.getHours()}`;
min.innerHTML = `${Current.getMinutes()}`;
sec.innerHTML = `${Current.getSeconds()}`;
}
setInterval(times, 1000);
//排序
//方法1
/*
let sortedRows = Array.from(pai.tBodies[0].rows)
.sort((rowa,rowb)=>rowa.cells[0].innerHTML.localeCompare(rowb.cells[0].innerHTML));
pai.tBodies[0].append(...sortedRows);
*/
//方法2
let tbody = pai.querySelector("tbody");
let tr_arry = Array.from(tbody.querySelectorAll("tr"));
tr_arry.sort((rowa, rowb) => rowa.cells[0].innerHTML.localeCompare(rowb.cells[0].innerHTML));
tbody.append(...tr_arry);
//创建临时通知
let notion = document.createElement("div");
notion.className = "welcome";
notion.style.cssText = `position:absolute;
top:10px;
right:80px;
background-color:red;
text-align:center;
padding:5px;
`;
notion.innerHTML = "hello";
document.body.append(notion);
//闪烁通知
function atk(notion) {
let cnt = 1;
let booler = true;
return function lett() {
notion.innerHTML = `hello ${cnt}`;
if (booler) {
notion.style.display = "";
cnt++;
} else {
notion.style.display = "none";
}
booler = !booler;
setTimeout(lett, 1000);
}
}
setTimeout(atk(notion), 1000);
//放中间
ball.style.left = Math.round(ground.clientWidth / 2 - ball.clientWidth / 2) + 'px';
ball.style.top = Math.round(ground.clientHeight / 2 - ball.clientHeight / 2) + 'px';
// 获取元素的文档坐标
function getCoords(elem) {
let box = elem.getBoundingClientRect();
return {
top: box.top + window.pageYOffset,
right: box.right + window.pageXOffset,
bottom: box.bottom + window.pageYOffset,
left: box.left + window.pageXOffset
};
}
function createMessageUnder(elem, html) {
let message = document.createElement('div');
message.style.cssText = "position:fixed; color: red";
let coords = getCoords(elem);
message.style.left = coords.left + "px";
message.style.top = coords.bottom + "px";
message.innerHTML = html;
return message;
}
</script>
</body>
</html>