Merge pull request #324 from kijin/pr/redirect-after-board-write

#323 게시판에서 글이나 댓글을 작성 또는 삭제한 후 짧은 주소로 redirect하도록 변경
This commit is contained in:
Kijin Sung 2016-03-07 08:39:48 +09:00
commit f40ea2e05d
5 changed files with 72 additions and 48 deletions

View file

@ -377,6 +377,21 @@ function sendMailTo(to) {
location.href="mailto:"+to;
}
/**
* @brief url이동 (Rhymix 개선된 버전)
*/
function redirect(url) {
if (url === window.location.href || url.indexOf(window.location.href.replace(/#.+$/, "") + "#") === 0)
{
window.location.href = url;
window.location.reload();
}
else
{
window.location.href = url;
}
}
/**
* @brief url이동 (open_window 값이 N 아니면 새창으로 띄움)
**/
@ -394,7 +409,7 @@ function move_url(url, open_window) {
if(open_window) {
winopen(url);
} else {
location.href=url;
redirect(url);
}
return false;

View file

@ -102,9 +102,11 @@
}
// If the response contains a redirect URL, redirect immediately.
if (result.redirect_url) {
window.location = result.redirect_url.replace(/&/g, "&");
return null;
if (data.redirect_url) {
data.redirect_url = data.redirect_url.replace(/&/g, "&");
}
if (data.redirect_url && !$.isFunction(callback_success)) {
return redirect(data.redirect_url);
}
// If there was a success callback, call it.
@ -220,6 +222,14 @@
}
}
// If the response contains a redirect URL, redirect immediately.
if (data.redirect_url) {
data.redirect_url = data.redirect_url.replace(/&/g, "&");
}
if (data.redirect_url && !$.isFunction(callback_success)) {
return redirect(data.redirect_url);
}
// If there was a success callback, call it.
if($.isFunction(callback_success)) {
callback_success(data);