1 608
edições
Sem resumo de edição |
Sem resumo de edição |
||
| (2 revisões intermediárias pelo mesmo usuário não estão sendo mostradas) | |||
| Linha 4: | Linha 4: | ||
function roColorToHtml(text) { | function roColorToHtml(text) { | ||
var html = ""; | |||
var colorStack = false; | |||
.replace(/\n/g, "<br>") | |||
var parts = text.split(/\^([0-9A-Fa-f]{6})/); | |||
for (var i = 0; i < parts.length; i++) { | |||
if (i % 2 === 1) { | |||
if (colorStack) html += "</span>"; | |||
html += '<span style="color:#' + parts[i] + '">'; | |||
colorStack = true; | |||
} else { | |||
html += parts[i]; | |||
} | |||
} | |||
if (colorStack) html += "</span>"; | |||
return html | |||
.replace(/\\n/g, "<br>") | |||
.replace(/\n/g, "<br>"); | |||
} | } | ||
document.querySelectorAll(".mw-item").forEach(function (el) { | document.querySelectorAll(".mw-item").forEach(function (el) { | ||
| Linha 27: | Linha 45: | ||
tip.className = "item-tooltip"; | tip.className = "item-tooltip"; | ||
tip.innerHTML = | tip.innerHTML = | ||
'<div class="row">' + | |||
'<img class="icon" src="' + API + item.icon + '">' + | |||
'<div class="title">' + item.name + '</div>' + | |||
'</div>' + | |||
'<div class="text">' + | |||
roColorToHtml(item.description) + | |||
'</div>'; | |||
document.body.appendChild(tip); | document.body.appendChild(tip); | ||
var move = function (ev) { | var move = function (ev) { | ||
var x = ev.clientX + 20; | |||
var y = ev.clientY + 20; | |||
if (x + 280 > window.innerWidth) | |||
x = ev.clientX - 300; | |||
if (y + 120 > window.innerHeight) | |||
y = ev.clientY - 140; | |||
tip.style.left = x + "px"; | |||
tip.style.top = y + "px"; | |||
}; | }; | ||