forked from yuezhongxin/MessageManager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommon.js
More file actions
73 lines (63 loc) · 1.99 KB
/
common.js
File metadata and controls
73 lines (63 loc) · 1.99 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
function getPassportHost() {
var hostname = location.hostname;
var suffix = hostname.substring(hostname.lastIndexOf("."));
return 'http://passport.cnblogs' + suffix;
}
function login() {User
location.href = getPassportHost() + "/login.aspx?ReturnUrl=" + location.href;
return false;
}
function login2(anchor) {
var url = encodeURIComponent(location.href + "#" + anchor);
location.href = getPassportHost() + "/login.aspx?ReturnUrl=" + url;
return false;
}
function register() {
location.href = getPassportHost() + "/register.aspx?ReturnUrl=" + location.href;
return false;
}
function logout() {
if (confirm('确定要退出吗?')) {
location.href = getPassportHost() + "/logout.aspx?ReturnUrl=" + location.href;
}
return false;
}
var ajaxRequest = {};
ajaxRequest.type = 'post';
ajaxRequest.dataType = 'json';
ajaxRequest.contentType = 'application/json; charset=utf8';
function getHostPostfix() {
var hostname = location.hostname;
hostname = hostname.substring(hostname.lastIndexOf("."), hostname.length);
return hostname;
}
function GetUserInfo() {
var prefixUrl = 'http://passport.cnblogs' + getHostPostfix();
$.ajax({
url: prefixUrl + '/account/LoginInfo',
dataType: 'jsonp',
success: function (data) {
$("#login_area").html(data);
var spacerUserId = parseInt($("#current_spaceId").html());
if (spacerUserId > 0) {
$.ajax({
url: prefixUrl + '/account/NewMsgCount',
data: 'spaceUserId=' + spacerUserId,
dataType: 'jsonp',
success: function (data) {
if (data) {
$("#msg_count").html('(' + data + ')').show();
}
}
});
}
}
});
}
function GetNewMsgCount() {
}
if (typeof (jQuery) != 'undefined') {
$(function () {
GetNewMsgCount();
});
}