| 🌟 | 現在、 鉄壁HSは通常HSと同じダメージになります。LMG及びDMR、チャージライフル、ハンマーポイント弾を除き、すべてのダメージ値が一致していることを確認しています。 |
「MediaWiki:Common.js」の版間の差分
ナビゲーションに移動
検索に移動
(tooltipの内容が勝手に型変換され正しくunescapeできないことがある問題の修正) |
(ダメージ表を均一の幅に保つJavaScriptの実装) |
||
| 38行目: | 38行目: | ||
} | } | ||
function updateWidth(classname) { | |||
var targetSelector = 'tr:first th:nth-child(2), tr:first td:nth-child(2)' | |||
// Reset the max width of each column in each table. | |||
$("." + classname).each(function(index, elem) { | |||
$(elem).find(targetSelector).first().width('') | |||
}); | |||
// Find the max width of each column across all tables. | |||
var col_width = 0 | |||
$("." + classname).each(function(index, elem) { | |||
col_width = Math.max( | |||
col_width, | |||
$(elem).find(targetSelector).first().width()) | |||
}); | |||
// Set each column in each table to the max width of that column across all tables. | |||
$("." + classname).each(function(index, elem) { | |||
$(elem).find(targetSelector).first().width(col_width) | |||
}); | |||
} | |||
var targetClassname = 'damagetable' | |||
$(window).resize(updateWidth.bind(null, targetClassname)); | |||
$(function(){ | $(function(){ | ||
tooltip = $("<div>", { id: 'tooltip' }).appendTo('body'); | tooltip = $("<div>", { id: 'tooltip' }).appendTo('body'); | ||
| 43行目: | 68行目: | ||
.mouseenter(showTooltip) | .mouseenter(showTooltip) | ||
.mouseleave(hideTooltip); | .mouseleave(hideTooltip); | ||
updateWidth(targetClassname); | |||
}); | }); | ||
2021年2月16日 (火) 09:47時点における版
/* ここにあるすべてのJavaScriptは、すべてのページ読み込みですべての利用者に対して読み込まれます */
var tooltip
function updatePosition(e) {
var obj = $(e.currentTarget)
var offset = obj.offset()
var y = offset.top + obj.outerHeight()
var maxY = $(window).scrollTop() + $(window).height() - $('#tooltip').outerHeight()
if (y > maxY) {
y = offset.top - obj.outerHeight()
}
tooltip
.css('left', Math.min(
$(window).width() - tooltip.outerWidth(),
Math.round(offset.left - 0.5 * (tooltip.outerWidth() - obj.outerWidth()))))
.css('top', y)
}
function unescapeHtml(html) {
return html
.replace(/"/g, '"')
.replace(/&/g, '&')
}
function showTooltip(e) {
var escaped = $(this).attr('data-tooltip')
var html = unescapeHtml(escaped)
tooltip
.css('display', 'block')
.html(html)
updatePosition(e)
$(this).mousemove(updatePosition)
}
function hideTooltip(e) {
tooltip.css('display', '')
$(this).off('mousemove')
}
function updateWidth(classname) {
var targetSelector = 'tr:first th:nth-child(2), tr:first td:nth-child(2)'
// Reset the max width of each column in each table.
$("." + classname).each(function(index, elem) {
$(elem).find(targetSelector).first().width('')
});
// Find the max width of each column across all tables.
var col_width = 0
$("." + classname).each(function(index, elem) {
col_width = Math.max(
col_width,
$(elem).find(targetSelector).first().width())
});
// Set each column in each table to the max width of that column across all tables.
$("." + classname).each(function(index, elem) {
$(elem).find(targetSelector).first().width(col_width)
});
}
var targetClassname = 'damagetable'
$(window).resize(updateWidth.bind(null, targetClassname));
$(function(){
tooltip = $("<div>", { id: 'tooltip' }).appendTo('body');
$('[data-tooltip]')
.mouseenter(showTooltip)
.mouseleave(hideTooltip);
updateWidth(targetClassname);
});