Use event listener instead of inline href

Using inline `href` to execute JavaScript in Firefox doesn't work.
This commit is contained in:
Pig Fang 2017-11-24 22:27:33 +08:00
parent 88f7fe6850
commit 09ccae26c4
8 changed files with 32 additions and 32 deletions

View File

@ -75,18 +75,18 @@ function initUsersTable() {
if (data === 2) {
if (row.permission === 1) {
adminOption = `<li class="divider"></li>
<li><a id="admin-${row.uid}" data="admin" href="javascript:changeAdminStatus(${row.uid});">${trans('admin.unsetAdmin')}</a></li>`;
<li><a id="admin-${row.uid}" data="admin" style="cursor: pointer" onclick="changeAdminStatus(${row.uid});">${trans('admin.unsetAdmin')}</a></li>`;
} else {
adminOption = `<li class="divider"></li>
<li><a id="admin-${row.uid}" data="normal" href="javascript:changeAdminStatus(${row.uid});">${trans('admin.setAdmin')}</a></li>`;
<li><a id="admin-${row.uid}" data="normal" style="cursor: pointer" onclick="changeAdminStatus(${row.uid});">${trans('admin.setAdmin')}</a></li>`;
}
}
if (row.permission === -1) {
bannedOption = `<li class="divider"></li>
<li><a id="ban-${row.uid}" data="banned" href="javascript:changeBanStatus(${row.uid});">${trans('admin.unban')}</a></li>`;
<li><a id="ban-${row.uid}" data="banned" style="cursor: pointer" onclick="changeBanStatus(${row.uid});">${trans('admin.unban')}</a></li>`;
} else {
bannedOption = `<li class="divider"></li>
<li><a id="ban-${row.uid}" data="normal" href="javascript:changeBanStatus(${row.uid});">${trans('admin.ban')}</a></li>`;
<li><a id="ban-${row.uid}" data="normal" style="cursor: pointer" onclick="changeBanStatus(${row.uid});">${trans('admin.ban')}</a></li>`;
}
}
@ -96,7 +96,7 @@ function initUsersTable() {
<a class="btn btn-danger btn-sm" disabled="disabled" data-toggle="tooltip" data-placement="bottom" title="${trans('admin.cannotDeleteSuperAdmin')}">${trans('admin.deleteUser')}</a>`;
} else {
deleteUserButton = `
<a class="btn btn-danger btn-sm" href="javascript:deleteUserAccount(${row.uid});">${trans('admin.deleteUser')}</a>`;
<a class="btn btn-danger btn-sm" style="cursor: pointer" onclick="deleteUserAccount(${row.uid});">${trans('admin.deleteUser')}</a>`;
}
} else {
if (row.permission === 1 || row.permission === 2) {
@ -104,7 +104,7 @@ function initUsersTable() {
<a class="btn btn-danger btn-sm" disabled="disabled" data-toggle="tooltip" data-placement="bottom" title="${trans('admin.cannotDeleteAdmin')}">${trans('admin.deleteUser')}</a>`;
} else {
deleteUserButton = `
<a class="btn btn-danger btn-sm" href="javascript:deleteUserAccount(${row.uid});">${trans('admin.deleteUser')}</a>`;
<a class="btn btn-danger btn-sm" style="cursor: pointer" onclick="deleteUserAccount(${row.uid});">${trans('admin.deleteUser')}</a>`;
}
}
@ -113,9 +113,9 @@ function initUsersTable() {
<button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
${trans('admin.operationsTitle')} <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="javascript:changeUserEmail(${row.uid});">${trans('admin.changeEmail')}</a></li>
<li><a href="javascript:changeUserNickName(${row.uid});">${trans('admin.changeNickName')}</a></li>
<li><a href="javascript:changeUserPwd(${row.uid});">${trans('admin.changePassword')}</a></li>
<li><a style="cursor: pointer" onclick="changeUserEmail(${row.uid});">${trans('admin.changeEmail')}</a></li>
<li><a style="cursor: pointer" onclick="changeUserNickName(${row.uid});">${trans('admin.changeNickName')}</a></li>
<li><a style="cursor: pointer" onclick="changeUserPwd(${row.uid});">${trans('admin.changePassword')}</a></li>
${adminOption}${bannedOption}
</ul>
</div>
@ -197,12 +197,12 @@ function initPlayersTable() {
<button type="button" class="btn btn-sm btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
${trans('admin.operationsTitle')} <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="javascript:changeTexture(${row.pid}, '${row.player_name}');">${trans('admin.changeTexture')}</a></li>
<li><a href="javascript:changePlayerName(${row.pid}, '${row.player_name}');">${trans('admin.changePlayerName')}</a></li>
<li><a href="javascript:changeOwner(${row.pid});">${trans('admin.changeOwner')}</a></li>
<li><a style="cursor: pointer" onclick="changeTexture(${row.pid}, '${row.player_name}');">${trans('admin.changeTexture')}</a></li>
<li><a style="cursor: pointer" onclick="changePlayerName(${row.pid}, '${row.player_name}');">${trans('admin.changePlayerName')}</a></li>
<li><a style="cursor: pointer" onclick="changeOwner(${row.pid});">${trans('admin.changeOwner')}</a></li>
</ul>
</div>
<a class="btn btn-danger btn-sm" href="javascript:deletePlayer(${row.pid});">${trans('admin.deletePlayer')}</a>`;
<a class="btn btn-danger btn-sm" style="cursor: pointer" onclick="deletePlayer(${row.pid});">${trans('admin.deletePlayer')}</a>`;
}
}
]
@ -250,10 +250,10 @@ function initPluginsTable() {
let switchEnableButton, configViewButton, deletePluginButton;
if (data.enabled) {
switchEnableButton = `
<a class="btn btn-warning btn-sm" href="javascript:disablePlugin('${row.name}');">${trans('admin.disablePlugin')}</a>`;
<a class="btn btn-warning btn-sm" style="cursor: pointer" onclick="disablePlugin('${row.name}');">${trans('admin.disablePlugin')}</a>`;
} else {
switchEnableButton = `
<a class="btn btn-primary btn-sm" href="javascript:enablePlugin('${row.name}');">${trans('admin.enablePlugin')}</a>`;
<a class="btn btn-primary btn-sm" style="cursor: pointer" onclick="enablePlugin('${row.name}');">${trans('admin.enablePlugin')}</a>`;
}
if (data.enabled && data.hasConfigView) {
configViewButton = `
@ -263,7 +263,7 @@ function initPluginsTable() {
<a class="btn btn-default btn-sm" disabled="disabled" title="${trans('admin.noPluginConfigNotice')}" data-toggle="tooltip" data-placement="top">${trans('admin.configurePlugin')}</a>`;
}
deletePluginButton = `
<a class="btn btn-danger btn-sm" href="javascript:deletePlugin('${row.name}');">${trans('admin.deletePlugin')}</a>`;
<a class="btn btn-danger btn-sm" style="cursor: pointer" onclick="deletePlugin('${row.name}');">${trans('admin.deletePlugin')}</a>`;
return switchEnableButton + configViewButton + deletePluginButton;
}
}

View File

@ -97,9 +97,9 @@ function renderClosetItemComponent(item) {
<span title="${trans('general.more')}" class="more" data-toggle="dropdown" aria-haspopup="true" id="more-button"><i class="fa fa-cog"></i></span>
<ul class="dropup dropdown-menu" aria-labelledby="more-button">
<li><a href="javascript:renameClosetItem(${item.tid}, '${item.name}');">${trans('user.renameItem')}</a></li>
<li><a href="javascript:removeFromCloset(${item.tid});">${trans('user.removeItem')}</a></li>
<li><a href="javascript:setAsAvatar(${item.tid});">${trans('user.setAsAvatar')}</a></li>
<li><a onclick="renameClosetItem(${item.tid}, '${item.name}');">${trans('user.renameItem')}</a></li>
<li><a onclick="removeFromCloset(${item.tid});">${trans('user.removeItem')}</a></li>
<li><a onclick="setAsAvatar(${item.tid});">${trans('user.setAsAvatar')}</a></li>
</ul>
</div>
</div>`;

View File

@ -88,7 +88,7 @@
@endif
</div><!-- /.box-body -->
<div class="box-footer">
<a class="btn btn-primary" id="update-button" {!! !$info['new_version_available'] ? 'disabled="disabled"' : 'href="javascript:downloadUpdates();"' !!}>{{ trans('admin.update.info.button') }}</a>
<a class="btn btn-primary" id="update-button" {!! !$info['new_version_available'] ? 'disabled="disabled"' : 'onclick="downloadUpdates();"' !!}>{{ trans('admin.update.info.button') }}</a>
{!! trans('admin.update.info.check-github', ['url' => 'https://github.com/printempw/blessing-skin-server/releases']) !!}
</div>
</div>

View File

@ -9,10 +9,10 @@
<div class="box-footer">
@if ($texture->public == "1")
<a href="javascript:changePrivacy({{ $texture->tid }});" class="btn btn-warning">{{ trans('skinlib.privacy.set-as-private') }}</a>
<a onclick="changePrivacy({{ $texture->tid }});" class="btn btn-warning">{{ trans('skinlib.privacy.set-as-private') }}</a>
@else
<a href="javascript:changePrivacy({{ $texture->tid }});" class="btn btn-warning">{{ trans('skinlib.privacy.set-as-public') }}</a>
<a onclick="changePrivacy({{ $texture->tid }});" class="btn btn-warning">{{ trans('skinlib.privacy.set-as-public') }}</a>
@endif
<a href="javascript:deleteTexture({{ $texture->tid }});" class="btn btn-danger pull-right">{{ trans('skinlib.show.delete-texture') }}</a>
<a onclick="deleteTexture({{ $texture->tid }});" class="btn btn-danger pull-right">{{ trans('skinlib.show.delete-texture') }}</a>
</div><!-- /.box-footer -->
</div><!-- /.box -->

View File

@ -26,9 +26,9 @@
@else
@if ($user->getCloset()->has($texture->tid))
<a href="javascript:removeFromCloset({{ $texture->tid }});" id="{{ $texture->tid }}" class="btn btn-primary pull-right">{{ trans('skinlib.item.remove-from-closet') }}</a>
<a onclick="removeFromCloset({{ $texture->tid }});" id="{{ $texture->tid }}" class="btn btn-primary pull-right">{{ trans('skinlib.item.remove-from-closet') }}</a>
@else
<a href="javascript:addToCloset({{ $texture->tid }});" id="{{ $texture->tid }}" class="btn btn-primary pull-right">{{ trans('skinlib.item.add-to-closet') }}</a>
<a onclick="addToCloset({{ $texture->tid }});" id="{{ $texture->tid }}" class="btn btn-primary pull-right">{{ trans('skinlib.item.add-to-closet') }}</a>
@endif
@endif
@ -51,7 +51,7 @@
<td id="name">{{ $texture->name }}
@if (!is_null($user) && ($texture->uploader == $user->uid || $user->isAdmin()))
<small>
<a href="javascript:changeTextureName({{ $texture->tid }}, '{{ $texture->name }}');">{{ trans('skinlib.show.edit-name') }}</a>
<a style="cursor: pointer" onclick="changeTextureName({{ $texture->tid }}, '{{ $texture->name }}');">{{ trans('skinlib.show.edit-name') }}</a>
</small>
@endif
</td>

View File

@ -83,7 +83,7 @@
</div>
<div class="modal-footer">
<a href="./player" class="btn btn-default pull-left">{{ trans('user.closet.use-as.add') }}</a>
<a href="javascript:setTexture();" class="btn btn-primary">{{ trans('general.submit') }}</a>
<a onclick="setTexture();" class="btn btn-primary">{{ trans('general.submit') }}</a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->

View File

@ -42,11 +42,11 @@
</select>
</td>
<td>
<a class="btn btn-default btn-sm" href="javascript:changePlayerName('{{ $player['pid'] }}', '{{ $player['player_name'] }}')">{{ trans('user.player.edit-pname') }}</a>
<a class="btn btn-default btn-sm" onclick="changePlayerName('{{ $player['pid'] }}', '{{ $player['player_name'] }}')">{{ trans('user.player.edit-pname') }}</a>
</td>
<td>
<a class="btn btn-warning btn-sm" href="javascript:clearTexture('{{ $player['pid'] }}');">{{ trans('user.player.delete-texture') }}</a>
<a class="btn btn-danger btn-sm" href="javascript:deletePlayer('{{ $player['pid'] }}');">{{ trans('user.player.delete-player') }}</a>
<a class="btn btn-warning btn-sm" onclick="clearTexture('{{ $player['pid'] }}');">{{ trans('user.player.delete-texture') }}</a>
<a class="btn btn-danger btn-sm" onclick="deletePlayer('{{ $player['pid'] }}');">{{ trans('user.player.delete-player') }}</a>
</td>
</tr>
@endforeach
@ -133,7 +133,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('general.close') }}</button>
<a href="javascript:addNewPlayer();" class="btn btn-primary">{{ trans('general.submit') }}</a>
<a onclick="addNewPlayer();" class="btn btn-primary">{{ trans('general.submit') }}</a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->

View File

@ -121,7 +121,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-outline" data-dismiss="modal">{{ trans('general.close') }}</button>
<a href="javascript:deleteAccount();" class="btn btn-outline">{{ trans('general.submit') }}</a>
<a onclick="deleteAccount();" class="btn btn-outline">{{ trans('general.submit') }}</a>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->