add rhymix_alert

This commit is contained in:
conory 2019-12-26 21:04:09 +09:00
parent 9e6005ccbc
commit 40e35a9451
4 changed files with 68 additions and 5 deletions

View file

@ -82,6 +82,38 @@
}
};
/**
* @brief display alert
*/
window.rhymix_alert = function(message, redirect_url, delay) {
if(!delay) {
delay = 2500;
}
if(!redirect_url) {
$('#rhymix_alert').text(message).show();
setTimeout(function() {
$('#rhymix_alert').fadeOut(1000, function() {
$(this).empty();
});
}, delay);
}
else if(isSameOrigin(location.href, redirect_url)) {
Cookies.set('rhymix_alert_message', message, { expires: 1 / 1440, path: '' });
Cookies.set('rhymix_alert_delay', delay, { expires: 1 / 1440, path: '' });
}
else {
alert(message);
}
};
$(document).ready(function() {
if(Cookies.get('rhymix_alert_message')) {
rhymix_alert(Cookies.get('rhymix_alert_message'), null, Cookies.get('rhymix_alert_delay'));
Cookies.remove('rhymix_alert_message', { path: '' });
Cookies.remove('rhymix_alert_delay', { path: '' });
}
});
/* Array for pending debug data */
window.rhymix_debug_pending_data = [];
@ -531,10 +563,7 @@ function sendMailTo(to) {
* @brief url이동 (Rhymix 개선된 버전)
*/
function redirect(url) {
var absolute_url = window.location.href;
var relative_url = window.location.pathname + window.location.search;
if (url === absolute_url || url.indexOf(absolute_url.replace(/#.+$/, "") + "#") === 0 ||
url === relative_url || url.indexOf(relative_url.replace(/#.+$/, "") + "#") === 0) {
if (isCurrentPageUrl(url)) {
window.location.href = url;
window.location.reload();
} else {
@ -542,6 +571,13 @@ function redirect(url) {
}
}
function isCurrentPageUrl(url) {
var absolute_url = window.location.href;
var relative_url = window.location.pathname + window.location.search;
return url === absolute_url || url.indexOf(absolute_url.replace(/#.+$/, "") + "#") === 0 ||
url === relative_url || url.indexOf(relative_url.replace(/#.+$/, "") + "#") === 0;
}
/**
* @brief url이동 (open_window 값이 N 아니면 새창으로 띄움)
**/