This repository has been archived by the owner on Oct 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.html
209 lines (202 loc) · 5.23 KB
/
core.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
<html>
<head>
<meta charset="UTF-8">
</head>
<body>
<style>
body {
padding: 0;
margin: 0;
font: 700 11px/14px "Helvetica Neue", Helvetica, Arial, sans-serif;
overflow: hidden
-webkit-font-smoothing: subpixel-antialiased;
}
.zhihu-btn {
height: 20px;
overflow: hidden
}
.zh-btn,
.zh-ico,
.zh-count{
float: left
}
.zh-btn,
.zh-count {
padding: 2px 5px 2px 4px;
color: #333;
text-decoration: none;
text-shadow: 0 1px 0 #fff;
white-space: nowrap;
cursor: pointer;
border-radius: 3px
}
.zh-btn {
background: #0d77e4;
background-color: #0e78e7;
background-image: -moz-linear-gradient(top,#0e7bef,#0d73da);
background-image: -ms-linear-gradient(top,#0e7bef,#0d73da);
background-image: -webkit-gradient(linear,0 0,0 100%,from(#0e7bef),to(#0d73da));
background-image: -webkit-linear-gradient(top,#0e7bef,#0d73da);
background-image: -o-linear-gradient(top,#0e7bef,#0d73da);
background-image: linear-gradient(top,#0e7bef,#0d73da);
background-repeat: repeat-x;
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0e7bef', endColorstr='#0d73da', GradientType=0);
color: #FFF;
text-align: center;
text-shadow: 0 1px 1px rgba(0,0,0,.12);
cursor: pointer;
border: 1px solid #045BB2;
border-radius: 4px;
box-shadow: 0 1px 2px rgba(0,0,0,.05),inset 0 1px 1px rgba(255,255,255,.15);
-webkit-transition: all .2s ease-in-out;
transition: all .2s ease-in-out;
outline: 0;
}
.zh-btn:active {
background: #096ED5;
background: -webkit-gradient(linear,left top,left bottom,from(#0e7ceb),to(#0c6fd3));
background: -moz-linear-gradient(top,#0e7ceb,#0c6fd3);
border: 1px solid #0659AC;
box-shadow: 0 1px 0 rgba(255,255,255,.06),inset 0 1px 2px rgba(0,0,0,.2);
}
.zh-count {
position: relative;
display: block;
margin-left: 4px;
background-color: #fafafa;
border: 1px solid #d4d4d4
}
.zh-count:focus,
.zh-count:hover {
color: #4183C4
}
.zh-count:after,
.zh-count:before {
content: '';
position: absolute;
display: inline-block;
width: 0;
height: 0;
border-color: transparent;
border-style: solid
}
.zh-count:before {
top: 50%;
left: -3px;
margin-top: -4px;
border-width: 4px 4px 4px 0;
border-right-color: #fafafa
}
.zh-ico {
width: 14px;
height: 14px;
margin-right: 4px;
box-shadow: inset 0 0 2px #0e78e7;
background-size: 100% 100%;
background-repeat: no-repeat
}
.zh-count:after {
top: 50%;
left: -4px;
z-index: -1;
margin-top: -5px;
border-width: 5px 5px 5px 0;
border-right-color: #d4d4d4
}
.zhihu-btn-large {
height: 30px
}
.zhihu-btn-large .zh-btn,
.zhihu-btn-large .zh-count {
padding: 3px 10px 3px 8px;
font-size: 16px;
line-height: 30px;
border-radius: 4px
}
.zhihu-btn-large .zh-ico {
width: 25px;
height: 25px;
margin-right: 0.5em;
margin-top: 2px;
}
.zhihu-btn-large .zh-count {
margin-left: 6px
}
.zhihu-btn-large .zh-count:before {
left: -5px;
margin-top: -6px;
border-width: 6px 6px 6px 0
}
.zhihu-btn-large .zh-count:after {
left: -6px;
margin-top: -7px;
border-width: 7px 7px 7px 0
}
</style>
<span class="zhihu-btn" id="container" style="display:none">
<a class="zh-btn" id="zh-btn" target="_blank">
<span class="zh-ico" id="zh-ico"></span>
<span class="zh-text" id="zh-text"></span>
</a>
<a class="zh-count" id="zh-count" target="_blank"></a>
</span>
<script>
var params = (function() {
var vars = [],
hash = [];
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}());
var container = document.getElementById('container')
counter = document.getElementById('zh-count'),
btn = document.getElementById('zh-btn'),
ico = document.getElementById('zh-ico'),
btn_text = document.getElementById('zh-text'),
head = document.getElementsByTagName('head')[0],
user = params.user,
isLarge = params.large;
function jsonp(path, cbName) {
var el = document.createElement('script');
el.src = path + '?callback=' + (cbName ? cbName : 'callback');
head.insertBefore(el, head.firstChild);
}
function hideContainer() {
container.style.display = 'none';
}
function showContainer() {
container.style.display = '';
}
function addCommas(n) {
return String(n).replace(/(\d)(?=(\d{3})+$)/g, '$1,');
}
function callback(obj) {
if (obj.message) {
// user is not found
hideContainer();
} else {
counter.innerHTML = addCommas(obj.followers);
btn_text.innerHTML = obj.name;
btn.href = obj.url;
ico.style.backgroundImage = "url('" + obj.avatar_url + "')";
counter.href = obj.url;
if (isLarge) {
// large button
container.className = container.className + ' zhihu-btn-large';
}
showContainer();
}
}
if (typeof user != 'undefined') {
jsonp('http://app-wwl.herokuapp.com/zhihu-api/users/' + user);
} else {
// hide button if user is not defined in URL
hideContainer();
}
</script>
</body>
</html>