Fix unnecessary redirect on comment insertion in some skins

This commit is contained in:
Kijin Sung 2016-03-04 15:07:03 +09:00
parent 54fc1da600
commit 006474cb98
2 changed files with 63 additions and 34 deletions

View file

@ -104,6 +104,8 @@
// If the response contains a redirect URL, redirect immediately. // If the response contains a redirect URL, redirect immediately.
if (data.redirect_url) { if (data.redirect_url) {
data.redirect_url = data.redirect_url.replace(/&/g, "&"); data.redirect_url = data.redirect_url.replace(/&/g, "&");
}
if (data.redirect_url && !$.isFunction(callback_success)) {
if (data.redirect_url.indexOf(window.location.href.replace(/#.+$/, "") + "#") === 0) if (data.redirect_url.indexOf(window.location.href.replace(/#.+$/, "") + "#") === 0)
{ {
window.location = data.redirect_url; window.location = data.redirect_url;
@ -232,6 +234,8 @@
// If the response contains a redirect URL, redirect immediately. // If the response contains a redirect URL, redirect immediately.
if (data.redirect_url) { if (data.redirect_url) {
data.redirect_url = data.redirect_url.replace(/&/g, "&"); data.redirect_url = data.redirect_url.replace(/&/g, "&");
}
if (data.redirect_url && !$.isFunction(callback_success)) {
if (data.redirect_url.indexOf(window.location.href.replace(/#.+$/, "") + "#") === 0) if (data.redirect_url.indexOf(window.location.href.replace(/#.+$/, "") + "#") === 0)
{ {
window.location = data.redirect_url; window.location = data.redirect_url;

View file

@ -13,19 +13,21 @@ function completeDocumentInserted(ret_obj)
var document_srl = ret_obj.document_srl; var document_srl = ret_obj.document_srl;
var category_srl = ret_obj.category_srl; var category_srl = ret_obj.category_srl;
//alert(message); if (ret_obj.redirect_url) {
location.href = ret_obj.redirect_url;
var url; } else {
if(!document_srl) var url;
{ if(!document_srl)
url = current_url.setQuery('mid',mid).setQuery('act',''); {
url = current_url.setQuery('mid',mid).setQuery('act','');
}
else
{
url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
}
if(category_srl) url = url.setQuery('category',category_srl);
location.href = url;
} }
else
{
url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
}
if(category_srl) url = url.setQuery('category',category_srl);
location.href = url;
} }
/* delete the document */ /* delete the document */
@ -38,9 +40,6 @@ function completeDeleteDocument(ret_obj)
var url = current_url.setQuery('mid',mid).setQuery('act','').setQuery('document_srl',''); var url = current_url.setQuery('mid',mid).setQuery('act','').setQuery('document_srl','');
if(page) url = url.setQuery('page',page); if(page) url = url.setQuery('page',page);
//alert(message);
location.href = url; location.href = url;
} }
@ -75,13 +74,21 @@ function completeInsertComment(ret_obj)
var mid = ret_obj.mid; var mid = ret_obj.mid;
var document_srl = ret_obj.document_srl; var document_srl = ret_obj.document_srl;
var comment_srl = ret_obj.comment_srl; var comment_srl = ret_obj.comment_srl;
if (ret_obj.redirect_url) {
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act',''); if (ret_obj.redirect_url.indexOf(window.location.href.replace(/#.+$/, "") + "#") === 0)
if(comment_srl) url = url.setQuery('rnd',comment_srl)+"#comment_"+comment_srl; {
window.location = ret_obj.redirect_url;
//alert(message); window.location.reload();
}
location.href = url; else
{
window.location = ret_obj.redirect_url;
}
} else {
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
if (comment_srl) url = url.setQuery('rnd',comment_srl)+"#comment_"+comment_srl;
window.location.href = url;
}
} }
/* delete the comment */ /* delete the comment */
@ -93,12 +100,21 @@ function completeDeleteComment(ret_obj)
var document_srl = ret_obj.document_srl; var document_srl = ret_obj.document_srl;
var page = ret_obj.page; var page = ret_obj.page;
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act',''); if (ret_obj.redirect_url) {
if(page) url = url.setQuery('page',page); if (ret_obj.redirect_url.indexOf(window.location.href.replace(/#.+$/, "") + "#") === 0)
{
//alert(message); window.location = ret_obj.redirect_url;
window.location.reload();
location.href = url; }
else
{
window.location = ret_obj.redirect_url;
}
} else {
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
if (page) url = url.setQuery('page',page);
window.location.href = url;
}
} }
/* delete the trackback */ /* delete the trackback */
@ -110,12 +126,21 @@ function completeDeleteTrackback(ret_obj)
var document_srl = ret_obj.document_srl; var document_srl = ret_obj.document_srl;
var page = ret_obj.page; var page = ret_obj.page;
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act',''); if (ret_obj.redirect_url) {
if(page) url = url.setQuery('page',page); if (ret_obj.redirect_url.indexOf(window.location.href.replace(/#.+$/, "") + "#") === 0)
{
//alert(message); window.location = ret_obj.redirect_url;
window.location.reload();
location.href = url; }
else
{
window.location = ret_obj.redirect_url;
}
} else {
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
if (page) url = url.setQuery('page',page);
window.location.href = url;
}
} }
/* change category */ /* change category */