Skip to content

Commit a3fc8c5

Browse files
committed
refactoring webAlertAndQuit
1 parent 0194621 commit a3fc8c5

1 file changed

Lines changed: 18 additions & 9 deletions

File tree

manager/includes/document.parser.class.inc.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function __construct()
203203

204204
$this->q = self::_getCleanQueryString();
205205
}
206-
206+
207207
final public function __clone()
208208
{
209209
}
@@ -3162,22 +3162,31 @@ public function getChildIds($id, $depth = 10, $children = array())
31623162
* @param string $msg Message to show
31633163
* @param string $url URL to redirect to
31643164
*/
3165-
public function webAlertAndQuit($msg, $url = "")
3165+
public function webAlertAndQuit($msg, $url = '')
31663166
{
31673167
global $modx_manager_charset;
3168-
if (substr(strtolower($url), 0, 11) == "javascript:") {
3169-
$fnc = substr($url, 11);
3170-
} elseif ($url) {
3171-
$fnc = "window.location.href='" . addslashes($url) . "';";
3172-
} else {
3173-
$fnc = "history.back(-1);";
3168+
switch (true) {
3169+
case (0 === stripos($url, 0, 'javascript:')):
3170+
$fnc = substr($url, 11);
3171+
break;
3172+
case $url === '#':
3173+
$fnc = '';
3174+
break;
3175+
case empty($url):
3176+
$fnc = 'history.back(-1);';
3177+
break;
3178+
default:
3179+
$fnc = "window.location.href='" . addslashes($url) . "';";
31743180
}
3181+
31753182
echo "<html><head>
31763183
<title>MODX :: Alert</title>
31773184
<meta http-equiv=\"Content-Type\" content=\"text/html; charset={$modx_manager_charset};\">
31783185
<script>
31793186
function __alertQuit() {
3180-
alert('" . addslashes($msg) . "');
3187+
var el = document.querySelector('p');
3188+
alert(el.innerHTML);
3189+
el.remove();
31813190
{$fnc}
31823191
}
31833192
window.setTimeout('__alertQuit();',100);

0 commit comments

Comments
 (0)