-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
210 lines (177 loc) · 4.06 KB
/
content.js
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
/**
* Created by Gaplo917 on 2/5/15.
*/
var hkepcWidget;
var forumDisplay;
var viewThread;
var pm;
$(function(){
var start = new Date().getTime();
// SetUp the base model for later user, wrapped by function is eliminate init time
hkepcWidget = {
// Pagination Button
pageButton: function () {
return $('.pages a, .pageback a');
},
// 公告 http://www.hkepc.com/forum/
announcement: function () {
return $('#ann');
},
group: function () {
return $('#mainIndex .group');
},
mainPortal: function () {
return $('#mainPortal, #mainIndex, #mainPoll, #mainUpdates');
},
// Quick reply editor
quickEditor: {
topPanel: function () {
return $('.editor_tb');
},
content: function () {
return $('#f_post .txtarea');
},
postButton: function () {
return $('#fastpostsubmit');
}
},
// Main editor
editor: {
main: function () {
return $('.editorcontent');
},
titleInput: function () {
return $('.editorcontent input.txt');
},
contentInput: function () {
return $('.editorcontent textarea');
},
redundant: function () {
return $('.newediter');
},
showSourceCheckBox: function () {
return $('a.plugeditor');
}
},
countReadNumber: function () {
return $('.nums em');
},
footer: function () {
return $('#footer');
},
floatingPostEditor: {
container: function () {
return $('.m_c');
},
titleInput: function () {
return $('.m_c .txt');
},
contentInput: function () {
return $('.m_c .textarea');
}
},
bigButton: function () {
return $('.postbtn, .replybtn');
},
blockCode: function () {
return $('.blockcode');
}
};
forumDisplay = {
contentHeader: function () {
return $('.colplural, .colplural th, .colplural td, th.highlight, td.highlight');
},
// redundent pixel on ForumDisplay
threadBorder: function () {
return $('.threadtype');
}
};
viewThread = {
// 每個 Post 尾
adcontent: function () {
return $('.adcontent');
},
// 左邊 Panel
leftPostAuthor: function () {
return $('.mainbox td.postauthor');
},
// 回覆/發貼制 bg
topPanel: function () {
return $('.forumcontrol table td');
},
// 發表於 yyyy-m-dd hh:mm
postTimeStamp: function () {
return $('.posterinfo a, .posterinfo em');
},
//引用
quote: function () {
return $('.quote');
},
// Code Block
blockQuote: function () {
return $('.quote blockquote');
},
//相關文章
relatedPost: function () {
return $('.box h1');
},
//倒序看帖 / 樓層數目
postInfo: function () {
return $('.postinfo strong a ');
},
threadTitle: {
container: function () {
return $('#threadtitle');
},
text: function () {
return $('.postmessage h1, .postmessage h2');
}
},
postAction: {
container: function () {
return $('.postactions');
}
},
postTimeStampPanel: function () {
return $('.postcontent .postinfo .authorinfo');
},
// Threads subject
threads: function () {
return $('.datatable tr .subject a');
},
popUpUserInfo: {
container: function () {
return $('.popupmenu_popup.userinfopanel');
},
userStatus: function () {
return $('.popupmenu_popup.userinfopanel .popuserinfo > p > em');
}
}
};
pm = {
// PM 查看消息
readBtns: function () {
return $('.pm_list .more a');
}
};
console.log("init model time",new Date().getTime() -start );
});
function guidGenerator() {
var S4 = function() {
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
};
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
}
function hexToRgb(hex) {
// Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
hex = hex.replace(shorthandRegex, function(m, r, g, b) {
return r + r + g + g + b + b;
});
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}