-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
163 lines (152 loc) · 5.61 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>wallStickers</title>
<script src="js/jquery-3.1.1.min.js"></script>
<script src="js/jquery-ui.js"></script>
<link rel="stylesheet" href="css/index.css">
<link rel="stylesheet" href="css/jquery-ui.css">
</head>
<body>
<div id="box"></div>
<div id="addBox">
<textarea placeholder="请输入贴条内容" id="input_content"></textarea>
<input type="color" value="#A0C1FF" id="sticker_bg">
<button id="addSticker">addSticker</button>
</div>
<div id="searchSticker">
<input type="text" placeholder="请输入贴条编号" id="filter_content">
<button id="searchBtn">Search</button>
</div>
<script>
$(document).ready(function () {
var box=$('#box');
box.height(window.innerHeight);
StickersCount=1;
Stickers={
add:function (custorm_content,bgcolor) {
var s_div=document.createElement('div');
var s_title=document.createElement('h5');
var s_content=document.createElement('p');
var s_close=document.createElement('b');
s_div.id='d'+StickersCount;
s_div.className="stickers";
s_title.className='s_title';
s_content.className='s_content';
s_close.className='s_close';
s_title.innerHTML='第'+(StickersCount++)+'条 '+new Date().toLocaleDateString();
s_content.innerHTML=custorm_content;
s_close.innerHTML='×';
s_div.style.backgroundColor=bgcolor;
s_div.style.top=this.get_stickers_top();
s_div.style.left=this.get_stickers_left();
s_div.appendChild(s_title);
s_div.appendChild(s_content);
s_div.appendChild(s_close);
$('#box').append(s_div);
},
get_stickers_top:function () {
var s_top=0;
var box_height=parseInt(box.height());
s_top= Math.floor(Math.random()*(box_height+1))+'px';
return s_top
},
get_stickers_left:function () {
var s_left=0;
var box_width=parseInt(box.width());
s_left= Math.floor(Math.random()*(box_width+1))+'px';
return s_left
}
};
function addOneSticker() {
var input_content=$('#input_content');
var c_content=input_content.val();
if(!c_content){
input_content.focus();
return
}
var sticker_bg=$('#sticker_bg').val() || "#A0C1FF";
Stickers.add(c_content,sticker_bg);
}
$('#addSticker').click(addOneSticker);
box.on('mousedown','.stickers',function (event) {
var target=event.target;
if(target.className!="stickers"){
target=$(target).parents('.stickers');
}
console.log('mousedown',target);
target.css({
'cursor':'move',
'z-index':50000
});
var left = parseInt(getComputedStyle(target[0]).left);
var top = parseInt(getComputedStyle(target[0]).top);
var old_x=event.clientX;
var old_y=event.clientY;
var isDrag=true;
document.onmousemove=function (e) {
if(!isDrag){ return }
var current_x=e.clientX;
var current_y=e.clientY;
var x=current_x-old_x;
var y=current_y-old_y;
target.css({
top:top+y+'px',
left:left+x+'px'
});
};
document.onmouseup=function () {
isDrag=false;
target.css({
'cursor':'default',
'z-index':2
});
}
});
box.on('click','.s_close',function () {
$(this).parents('.stickers').remove();
});
$('#searchBtn').click(function () {
var filter_input=$('#filter_content');
var sticker_id=filter_input.val();
if(!sticker_id){
filter_input.focus();
return
}
var s_width=$('#d'+sticker_id).width();
var s_height=$('#d'+sticker_id).height();
$('#d'+sticker_id).css({
'top':'50%',
'left':'50%',
'margin-top':-s_height/2+'px',
'margin-left':-s_width/2+'px',
'z-index':100000
}).animate({
borderColor: "#f00",
left:'49%'
},200).animate({
borderColor: "#0402ff",
left:'51%'
},200).animate({
borderColor: "#f00",
left:'49%'
},200).animate({
borderColor: "#0402ff",
left:'51%'
},200).animate({
borderColor: "transparent",
left:'50%'
},200);
});
for(var i=0;i<100;i++){
var r=Math.floor(Math.random()*255);
var g=Math.floor(Math.random()*255);
var b=Math.floor(Math.random()*255);
var color='rgb('+r+','+g+','+b+')';
Stickers.add("北 峰 DMR 智 能 综 合 巡 查 指 挥 调 度 系 统",color);
}
});
</script>
</body>
</html>