From 40e35a945107467673479db33d5364cb0e478bce Mon Sep 17 00:00:00 2001 From: conory Date: Thu, 26 Dec 2019 21:04:09 +0900 Subject: [PATCH 1/5] add rhymix_alert --- common/css/rhymix.less | 18 ++++++++++++++ common/js/common.js | 44 +++++++++++++++++++++++++++++++---- common/js/xml_handler.js | 10 +++++++- common/tpl/common_layout.html | 1 + 4 files changed, 68 insertions(+), 5 deletions(-) diff --git a/common/css/rhymix.less b/common/css/rhymix.less index 22ff2d8f1..15f312c80 100644 --- a/common/css/rhymix.less +++ b/common/css/rhymix.less @@ -157,6 +157,24 @@ a img { background: #333 url("../../common/img/msg.loading.gif") no-repeat center 15px; } +/* alert */ +#rhymix_alert { + display: none; + position: fixed; + left: 50%; + bottom: 20%; + width: 350px; + background-color: #000; + color: #fff; + font-size: 16px; + text-align: center; + opacity: 0.6; + padding: 12px 20px; + border-radius: 10px; + transform: translateX(-50%); + z-index: 999999999; +} + /* Debug */ #rhymix_debug_button { display: none; diff --git a/common/js/common.js b/common/js/common.js index e435d1f4e..6d90a3166 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -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 가 아니면 새창으로 띄움) **/ diff --git a/common/js/xml_handler.js b/common/js/xml_handler.js index 47ff8bc2b..2468142d8 100644 --- a/common/js/xml_handler.js +++ b/common/js/xml_handler.js @@ -376,7 +376,15 @@ if (callback_success && window[callback_success] && $.isFunction(window[callback_success])) { callback_success = window[callback_success]; } else { - callback_success = null; + callback_success = function(data) { + if (data['message'] === 'success') { + return; + } + rhymix_alert(data['message'], data['redirect_url']); + if (data['redirect_url']) { + redirect(data.redirect_url); + } + }; } var callback_error = form.data('callback-error'); if (callback_error && window[callback_error] && $.isFunction(window[callback_error])) { diff --git a/common/tpl/common_layout.html b/common/tpl/common_layout.html index 43bd43d4d..3e7d26f59 100644 --- a/common/tpl/common_layout.html +++ b/common/tpl/common_layout.html @@ -72,6 +72,7 @@
{$lang->msg_call_server}
+
From b3068758eff0576c21bdd12847184b10c1127c31 Mon Sep 17 00:00:00 2001 From: conory Date: Thu, 26 Dec 2019 23:36:44 +0900 Subject: [PATCH 2/5] for unit test --- common/js/xml_handler.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/js/xml_handler.js b/common/js/xml_handler.js index 2468142d8..3e3a08f3f 100644 --- a/common/js/xml_handler.js +++ b/common/js/xml_handler.js @@ -377,11 +377,11 @@ callback_success = window[callback_success]; } else { callback_success = function(data) { - if (data['message'] === 'success') { + if (data.message === 'success') { return; } - rhymix_alert(data['message'], data['redirect_url']); - if (data['redirect_url']) { + rhymix_alert(data.message, data.redirect_url); + if (data.redirect_url) { redirect(data.redirect_url); } }; From 36aa4abb0cd0a24b5604587f7e87eef63b22e9df Mon Sep 17 00:00:00 2001 From: conory Date: Fri, 27 Dec 2019 11:11:15 +0900 Subject: [PATCH 3/5] close when click --- common/js/common.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/common/js/common.js b/common/js/common.js index 6d90a3166..b7cbdf891 100644 --- a/common/js/common.js +++ b/common/js/common.js @@ -82,6 +82,15 @@ } }; + window.rhymix_alert_close = function() { + if($('#rhymix_alert').is(':hidden')) { + return; + } + $('#rhymix_alert').fadeOut(500, function() { + $(this).empty(); + }); + }; + /** * @brief display alert */ @@ -91,11 +100,7 @@ } if(!redirect_url) { $('#rhymix_alert').text(message).show(); - setTimeout(function() { - $('#rhymix_alert').fadeOut(1000, function() { - $(this).empty(); - }); - }, delay); + setTimeout(rhymix_alert_close, delay); } else if(isSameOrigin(location.href, redirect_url)) { Cookies.set('rhymix_alert_message', message, { expires: 1 / 1440, path: '' }); @@ -112,6 +117,7 @@ Cookies.remove('rhymix_alert_message', { path: '' }); Cookies.remove('rhymix_alert_delay', { path: '' }); } + $('#rhymix_alert').click(rhymix_alert_close); }); /* Array for pending debug data */ From 9bf9f6266a80aca1c62f9712c2037237902b87b3 Mon Sep 17 00:00:00 2001 From: conory Date: Fri, 27 Dec 2019 22:00:20 +0900 Subject: [PATCH 4/5] adjust size --- common/css/rhymix.less | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/css/rhymix.less b/common/css/rhymix.less index 15f312c80..0405da1ed 100644 --- a/common/css/rhymix.less +++ b/common/css/rhymix.less @@ -163,7 +163,8 @@ a img { position: fixed; left: 50%; bottom: 20%; - width: 350px; + min-width: 250px; + max-width: 500px; background-color: #000; color: #fff; font-size: 16px; From 945ecb2da4b528975a663e26748e0fd6ae3c64da Mon Sep 17 00:00:00 2001 From: conory Date: Sat, 28 Dec 2019 00:06:22 +0900 Subject: [PATCH 5/5] for dark background --- common/css/rhymix.less | 1 + 1 file changed, 1 insertion(+) diff --git a/common/css/rhymix.less b/common/css/rhymix.less index 0405da1ed..240ed9001 100644 --- a/common/css/rhymix.less +++ b/common/css/rhymix.less @@ -171,6 +171,7 @@ a img { text-align: center; opacity: 0.6; padding: 12px 20px; + border: 1px solid #fff; border-radius: 10px; transform: translateX(-50%); z-index: 999999999;