-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
165 lines (142 loc) · 5.07 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="apple-mobile-web-app-title" content="呃嘀呻呐">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="http://tva2.sinaimg.cn/crop.0.0.180.180.180/71ad6815jw1e8qgp5bmzyj2050050aa8.jpg"/>
<title>A System</title>
<script type="text/javascript">
!function(){var e;e=function(e){return function(e,t){function i(){var t=r.getBoundingClientRect().width;t/m>540&&(t=540*m);var i=t/7.5;r.style.fontSize=i+"px",d.rem=e.rem=i}var a,n=e.document,r=n.documentElement,o=n.querySelector('meta[name="viewport"]'),l=n.querySelector('meta[name="flexible"]'),m=0,s=0,d=t.flexible||(t.flexible={});if(o){console.warn("将根据已有的meta标签来设置缩放比例");var c=o.getAttribute("content").match(/initial\-scale=([\d\.]+)/);c&&(s=parseFloat(c[1]),m=parseInt(1/s))}else if(l){var p=l.getAttribute("content");if(p){var u=p.match(/initial\-dpr=([\d\.]+)/),f=p.match(/maximum\-dpr=([\d\.]+)/);u&&(m=parseFloat(u[1]),s=parseFloat((1/m).toFixed(2))),f&&(m=parseFloat(f[1]),s=parseFloat((1/m).toFixed(2)))}}if(!m&&!s){var v=(e.navigator.appVersion.match(/android/gi),e.navigator.appVersion.match(/iphone/gi)),h=e.devicePixelRatio;m=v?h>=3&&(!m||m>=3)?3:h>=2&&(!m||m>=2)?2:1:1,s=1/m}if(r.setAttribute("data-dpr",m),!o)if(o=n.createElement("meta"),o.setAttribute("name","viewport"),o.setAttribute("content","initial-scale="+s+", maximum-scale="+s+", minimum-scale="+s+", user-scalable=no"),r.firstElementChild)r.firstElementChild.appendChild(o);else{var x=n.createElement("div");x.appendChild(o),n.write(x.innerHTML)}e.addEventListener("resize",function(){clearTimeout(a),a=setTimeout(i,300)},!1),e.addEventListener("pageshow",function(e){e.persisted&&(clearTimeout(a),a=setTimeout(i,300))},!1),"complete"===n.readyState?n.body.style.fontSize=12*m+"px":n.addEventListener("DOMContentLoaded",function(e){n.body.style.fontSize=12*m+"px"},!1),i(),d.dpr=e.dpr=m,d.refreshRem=i,d.rem2px=function(e){var t=parseFloat(e)*this.rem;return"string"==typeof e&&e.match(/rem$/)&&(t+="px"),t},d.px2rem=function(e){var t=parseFloat(e)/this.rem;return"string"==typeof e&&e.match(/px$/)&&(t+="rem"),t}}(window,window.lib||(window.lib={})),e}()}();
</script>
</head>
<body>
<style type="text/css">
*{
margin:0;
padding:0;
list-style:none;
}
@font-face {
font-family: 'stock-iconfont';
src: url('http://at.alicdn.com/t/font_1472547527_974682.ttf') format('truetype');
}
.stock-iconfont{
font-family: 'stock-iconfont'
}
html{
background: #f1f1f1;
}
.content{
width:7.5rem;
margin:0 auto;
}
h1{
font-size:0.3rem;
text-align: center;
padding:0.2rem 0;
}
table{
width:7.5rem;
text-align: center;
line-height: 0.3rem;
}
th,td{
border-top: solid 1px #ccc;
padding: 0.1rem 0;
}
tbody tr:last-child td{
border-bottom: solid 1px #ccc;
}
.add{
position: fixed;
bottom: 0.5rem;
right:0.5rem;
font-size: 0.60rem;
color:#333;
}
</style>
<div class="content">
<h1>
A System
</h1>
<table>
<thead>
<th>Name</th>
<th>Highest</th>
<th>Lowest</th>
<th>Current</th>
<th>Operate</th>
</thead>
<tbody id="J_Tbody">
</tbody>
</table>
<span class="add stock-iconfont J_Add">

</span>
</div>
<script type="text/javascript">
var followStocks = [
{
c:'sz000009',
b:10.50,
s:11.00
},{
c:'sz000502',
b:20.50,
s:21.00
}
];
try{
var localData = JSON.parse(localStorage.getItem('stock'));
if(localData&&localData.length){
followStocks = localData;
}
}catch(e){
}
function getData(){
var join = followStocks.map(function(v){
return v.c;
}).join(',') ;
var url = 'http://hq.sinajs.cn/list=' + join + ',sz' + +new Date()
var script = document.createElement('script');
script.src=url;
document.getElementsByTagName('head')[0].appendChild(script);
script.onload = function(){
var html = '';
for(var i = 0;i<followStocks.length;i++){
var item = window['hq_str_' + followStocks[i].c].split(',')
html += '<tr>' +
'<td>'+item[0]+'</td>' +
'<td>'+item[4]+'</td>' +
'<td>'+item[5]+'</td>' +
'<td>'+item[3]+'</td>' +
'<td data-index="'+i+'" class="stock-iconfont oper J_Delete"></td>'
'</tr>';
}
document.getElementById('J_Tbody').innerHTML = html;
}
}
getData();
window.addEventListener('touchstart',function(e){
var target = e.target;
var cls = target.classList;
if(cls.contains('J_Delete')){
var index = + target.getAttribute('data-index');
followStocks.splice(index,1);
getData();
localStorage.setItem('stock',JSON.stringify(followStocks));
}else if(cls.contains('J_Add')){
var value = prompt('添加','sz').trim();
if(value && value.indexOf('sz') >-1 || value.indexOf('sh') > -1){
followStocks.push({
c:value
});
getData();
localStorage.setItem('stock',JSON.stringify(followStocks));
}
}
},false);
</script>
</body>
</html>