forked from cnodejs/conf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,229 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
$(function () { | ||
var hiddenID = $("#id"); | ||
var newsNode = $("#title"); | ||
var fieldset = $("#news"); | ||
var contentBox = $("#content"); | ||
|
||
$(".container").on("click", 'td a.edit', function (event) { | ||
var that = $(event.currentTarget); | ||
var tr = that.closest("tr"); | ||
var id = tr.data("id"); | ||
if (!id) { | ||
return false; | ||
} | ||
$.ajax("/admin/view_news", { | ||
type: 'GET', | ||
dataType: 'json', | ||
data: { | ||
"id": id | ||
}, | ||
success: function (res) { | ||
var news = res.news; | ||
hiddenID.val(news._id); | ||
contentBox.val(news.content); | ||
newsNode.val(news.title); | ||
$("#submit").text("更新").attr("edit", "1").attr("_id", id); | ||
newsNode.focus(); | ||
}, | ||
error: function (xhr, status) { | ||
if (xhr.status === 401) { | ||
alert("请先登录"); | ||
location.href = "/oauth?blogtype=weibo"; | ||
} else { | ||
alert("服务器错误,请稍候再试"); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
$(".container").on("click", 'td a.remove', function (event) { | ||
var that = $(event.currentTarget); | ||
var tr = that.closest("tr"); | ||
var id = tr.data("id"); | ||
if (!id) { | ||
return false; | ||
} | ||
$.ajax("/admin/del_news", { | ||
type: 'DELETE', | ||
dataType: 'json', | ||
data: { | ||
"id": id, | ||
"_csrf": csrf | ||
}, | ||
success: function (res) { | ||
location.reload(); | ||
}, | ||
error: function (xhr, status) { | ||
if (xhr.status === 401) { | ||
alert("请先登录"); | ||
location.href = "/oauth?blogtype=weibo"; | ||
} else { | ||
alert("服务器错误,请稍候再试"); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
$(".container").on("click", '#submit', function (event) { | ||
var title = newsNode.val(); | ||
var content = contentBox.val(); | ||
var that = $(event.currentTarget); | ||
if (that.attr("edit") !== "1") { | ||
$.ajax("/admin/add_news", { | ||
type: 'POST', | ||
dataType: 'json', | ||
data: { | ||
"title": title, | ||
"content": content, | ||
"_csrf": csrf | ||
}, | ||
success: function (res) { | ||
location.reload(); | ||
}, | ||
error: function (xhr, status) { | ||
if (xhr.status === 401) { | ||
alert("请先登录"); | ||
location.href = "/oauth?blogtype=weibo"; | ||
} else { | ||
alert("服务器错误,请稍候再试"); | ||
} | ||
} | ||
}); | ||
} else { | ||
var id = that.attr("_id"); | ||
$.ajax("/admin/edit_news", { | ||
type: 'POST', | ||
dataType: 'json', | ||
data: { | ||
"id": id, | ||
"title": title, | ||
"content": content, | ||
"_csrf": csrf | ||
}, | ||
success: function (res) { | ||
location.reload(); | ||
}, | ||
error: function (xhr, status) { | ||
if (xhr.status === 401) { | ||
alert("请先登录"); | ||
location.href = "/oauth?blogtype=weibo"; | ||
} else { | ||
alert("服务器错误,请稍候再试"); | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
newsNode.bind("input", function () { | ||
fieldset.removeClass("error"); | ||
}); | ||
$('.dropdown-toggle').dropdown(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
$(function () { | ||
var hiddenID = $("#id"); | ||
var newsNode = $("#title"); | ||
var fieldset = $("#news"); | ||
var contentBox = $("#content"); | ||
var signBox = $("#sign"); | ||
|
||
$(".container").on("click", 'td a.edit', function (event) { | ||
var that = $(event.currentTarget); | ||
var tr = that.closest("tr"); | ||
var id = tr.data("id"); | ||
if (!id) { | ||
return false; | ||
} | ||
$.ajax("/admin/view_page", { | ||
type: 'GET', | ||
dataType: 'json', | ||
data: { | ||
"id": id | ||
}, | ||
success: function (res) { | ||
var news = res.news; | ||
hiddenID.val(news._id); | ||
contentBox.val(news.content); | ||
newsNode.val(news.title); | ||
$("#submit").text("更新").attr("edit", "1").attr("_id", id); | ||
newsNode.focus(); | ||
}, | ||
error: function (xhr, status) { | ||
if (xhr.status === 401) { | ||
alert("请先登录"); | ||
location.href = "/oauth?blogtype=weibo"; | ||
} else { | ||
alert("服务器错误,请稍候再试"); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
$(".container").on("click", 'td a.remove', function (event) { | ||
var that = $(event.currentTarget); | ||
var tr = that.closest("tr"); | ||
var id = tr.data("id"); | ||
if (!id) { | ||
return false; | ||
} | ||
$.ajax("/admin/del_page", { | ||
type: 'DELETE', | ||
dataType: 'json', | ||
data: { | ||
"id": id, | ||
"_csrf": csrf | ||
}, | ||
success: function (res) { | ||
location.reload(); | ||
}, | ||
error: function (xhr, status) { | ||
if (xhr.status === 401) { | ||
alert("请先登录"); | ||
location.href = "/oauth?blogtype=weibo"; | ||
} else { | ||
alert("服务器错误,请稍候再试"); | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
$(".container").on("click", '#submit', function (event) { | ||
var title = newsNode.val(); | ||
var content = contentBox.val(); | ||
var sign = signBox.val(); | ||
var that = $(event.currentTarget); | ||
if (that.attr("edit") !== "1") { | ||
$.ajax("/admin/add_page", { | ||
type: 'POST', | ||
dataType: 'json', | ||
data: { | ||
"title": title, | ||
"content": content, | ||
"sign": sign, | ||
"_csrf": csrf | ||
}, | ||
success: function (res) { | ||
location.reload(); | ||
}, | ||
error: function (xhr, status) { | ||
if (xhr.status === 401) { | ||
alert("请先登录"); | ||
location.href = "/oauth?blogtype=weibo"; | ||
} else { | ||
alert("服务器错误,请稍候再试"); | ||
} | ||
} | ||
}); | ||
} else { | ||
var id = that.attr("_id"); | ||
$.ajax("/admin/edit_page", { | ||
type: 'POST', | ||
dataType: 'json', | ||
data: { | ||
"id": id, | ||
"title": title, | ||
"content": content, | ||
"sign": sign, | ||
"_csrf": csrf | ||
}, | ||
success: function (res) { | ||
location.reload(); | ||
}, | ||
error: function (xhr, status) { | ||
if (xhr.status === 401) { | ||
alert("请先登录"); | ||
location.href = "/oauth?blogtype=weibo"; | ||
} else { | ||
alert("服务器错误,请稍候再试"); | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
newsNode.bind("input", function () { | ||
fieldset.removeClass("error"); | ||
}); | ||
$('.dropdown-toggle').dropdown(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var config = {}; | ||
config.db = 'localhost/conf';//'82ml7vofpf1m8:898jowidte3@127.0.0.1:20088/4EU96oUTS0cD'; | ||
config.weibo = { | ||
appkey: '3065857112', | ||
secret: '0e303661ff8fc05e0747d60c0c1e3cf6' | ||
}; | ||
config.github = { | ||
appkey: '97db48307671a31aa0d2',//'ddd8ea44faa7c6e87c13', | ||
secret: '0c67119d0c8aecc9238c23670ea30b4497c5ef85'//'aa11b699e70229144d0e575ff8b05196b52b7070' | ||
}; | ||
config.tqq = { | ||
appkey: '801196847', | ||
secret: '8805aceeab82e8df0583751f98b8f4bf' | ||
}; | ||
config.admins = ["http://weibo.com/shyvo", "https://github.com/iwillwen"]; | ||
module.exports = config; |
Oops, something went wrong.