Skip to content

Commit

Permalink
Improve hotfixes page, various tooltip fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Marlamin committed Sep 19, 2020
1 parent 81370fe commit 8233863
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 48 deletions.
6 changes: 4 additions & 2 deletions css/style.css
Expand Up @@ -353,7 +353,8 @@ footer p{

/* Tooltips */
.wt-tooltip{
display: none;
display: none;
z-index: 5;
}
.tooltip-icon{
clear: both;
Expand All @@ -380,7 +381,8 @@ footer p{
background: rgba(17, 17, 34, 0.90);
color: white;
margin-left: 4px;
font: normal 12px/1.5 Verdana,sans-serif;
font: normal 12px/1.5 Verdana,sans-serif;
z-index: 10;
}

.tooltip-desc h2{
Expand Down
4 changes: 4 additions & 0 deletions dbc/css/dbc.css
Expand Up @@ -123,4 +123,8 @@ thead input { width: 100% }
max-height: 200px;
overflow-x: hidden;
min-width: 700px;
}

.diffTable tr td{
padding: 2px;
}
90 changes: 61 additions & 29 deletions dbc/hotfixes.php
Expand Up @@ -116,9 +116,9 @@
"targets": 4,
"render": function ( data, type, full, meta ) {
if(full[4] == 1){
return "Valid";
return "<i class='fa fa-check'></i> Valid";
}else{
return "Invalidated (" + full[4] + ")";
return "<i class='fa fa-trash'></i> Invalidated (" + full[4] + ")";
}
}
},
Expand Down Expand Up @@ -150,48 +150,80 @@ function getAddendum(dbc, col, value){
return addendum;
}

function richValue(dbc, col, val, build, fk){
let returnedValue = "";
let displayValue = val;

if(flagMap.has(dbc.toLowerCase() + "." + col)){
displayValue = "0x" + Number(val).toString(16);
}

if (fk == "FileData::ID"){
returnedValue = "<a style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' data-toggle='modal' data-target='#moreInfoModal' onclick='fillModal(" + val + ")'>" + val + "</a>";
} else if (fk == "SoundEntries::ID" && parseInt(build[0]) > 6){
returnedValue = "<a style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' onclick='openFKModal(" + val + ", \"SoundKit::ID\", \"" + build + "\")'>" + val + "</a>";
} else if (fk == "Item::ID" && val > 0){
returnedValue = "<a data-build='" + build + "' data-tooltip='item' data-id='" + val + "' ontouchstart='showTooltip(this)' ontouchend='hideTooltip(this)' onmouseover='showTooltip(this)' onmouseout='hideTooltip(this)' style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' onclick='openFKModal(" + val + ", \"" + fk + "\", \"" + build + "\")'>" + val + "</a>";
} else if (fk == "Spell::ID" || fk == "SpellName::ID" && val > 0){
returnedValue = "<a data-build='" + build + "' data-tooltip='spell' data-id='" + val + "' ontouchstart='showTooltip(this)' ontouchend='hideTooltip(this)' onmouseover='showTooltip(this)' onmouseout='hideTooltip(this)' style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' onclick='openFKModal(" + val + ", \"" + fk + "\", \"" + build + "\")'>" + val + "</a>";
} else if (fk == "Creature::ID" && val > 0){
returnedValue = "<a data-build='" + build + "' data-tooltip='creature' data-id='" + val + "' ontouchstart='showTooltip(this)' ontouchend='hideTooltip(this)' onmouseover='showTooltip(this)' onmouseout='hideTooltip(this)' style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' onclick='openFKModal(" + val + ", \"" + fk + "\", \"" + build + "\")'>" + val + "</a>";
} else if (fk == "QuestV2::ID" && val > 0){
returnedValue = "<a data-build='" + build + "' data-tooltip='quest' data-id='" + val + "' ontouchstart='showTooltip(this)' ontouchend='hideTooltip(this)' onmouseover='showTooltip(this)' onmouseout='hideTooltip(this)' style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' onclick='openFKModal(" + val + ", \"" + fk + "\", \"" + build + "\")'>" + val + "</a>";
} else if (fk !== undefined && val > 0){
returnedValue = "<a data-build='" + build + "' data-tooltip='fk' data-id='" + val + "' data-fk='" + fk + "' ontouchstart='showTooltip(this)' ontouchend='hideTooltip(this)' onmouseover='showTooltip(this)' onmouseout='hideTooltip(this)' style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' onclick='openFKModal(" + val + ", \"" + fk + "\", \"" + build + "\")'>" + val + "</a>";
} else{
returnedValue = displayValue;
}

if(enumMap.has(dbc.toLowerCase() + "." + col)){
if(val in enumMap.get(dbc.toLowerCase() + "." + col)){
returnedValue += " (" + enumMap.get(dbc.toLowerCase() + "." + col)[val] + ")";
}else{
returnedValue += " (unknown)";
}
}

if(flagMap.has(dbc.toLowerCase() + "." + col)){
let usedFlags = getFlagDescriptions(dbc.toLowerCase(), col, val);
usedFlags.forEach(function (flag) {
returnedValue += " (" + flag[0] + ": " + flag[1] + ")";
});
}

return returnedValue;
}

function showRowDiff(dbc, build, recordID){
var headerReq = fetch("/dbc/api/header/" + dbc.toLowerCase() + "?build=" + build).then(data => data.json());
var beforeReq = fetch("/dbc/hotfix_api.php?cacheproxy=1&dbc=" + dbc.toLowerCase() + "&build=" + build + "&col=ID&val=" + recordID + "&useHotfixes=false&calcOffset=false").then(data => data.json());
var afterReq = fetch("/dbc/hotfix_api.php?cacheproxy=1&dbc=" + dbc.toLowerCase() + "&build=" + build + "&col=ID&val=" + recordID + "&useHotfixes=true&calcOffset=false").then(data => data.json());

Promise.all([beforeReq, afterReq])
Promise.all([headerReq, beforeReq, afterReq])
.then(json => {
const before = json[0].values;
const after = json[1].values;
const header = json[0];
const before = json[1].values;
const after = json[2].values;

let changes = "<table>";
let changes = "<table class='diffTable'>";

if(Object.keys(before).length == 0){
Object.keys(after).forEach(function (key) {
let addendum = getAddendum(dbc, key, after[key]);
let displayedValue = after[key];
if(flagMap.has(dbc.toLowerCase() + "." + key)){
displayedValue = "0x" + Number(after[key]).toString(16);
}
changes += "<tr><td>"+ key + "</td><td><ins class='diff-added'>"+ displayedValue + addendum + "</ins></td></tr>";
const displayedValue = richValue(dbc, key, after[key], build, header.fks[key]);
changes += "<tr><td><i style='color: green;' class='fa fa-plus-circle'></i> <b>" + key + "</b></td><td>" + displayedValue + "</td></tr>";
});
} else if(Object.keys(after).length == 0){
Object.keys(before).forEach(function (key) {
let addendum = getAddendum(dbc, key, before[key]);
let displayedValue = before[key];
if(flagMap.has(dbc.toLowerCase() + "." + key)){
displayedValue = "0x" + Number(before[key]).toString(16);
}
changes += "<tr><td>"+ key + "</td><td><del class='diff-removed'>"+ displayedValue + addendum + "</del></td></tr>";
const displayedValue = richValue(dbc, key, before[key], build, header.fks[key]);
changes += "<tr><td><i style='color: red;' class='fa fa-minus-circle'></i> <b>" + key + "</b></td><td>" + displayedValue + "</td></tr>";
});
}else{
Object.keys(before).forEach(function (key) {
if(before[key] != after[key]){
if (!isNaN(before[key]) && !isNaN(after[key])) {
let addendumBefore = getAddendum(dbc, key, before[key]);
let addendumAfter = getAddendum(dbc, key, after[key]);
let displayedValBefore = before[key];
let displayedValAfter = after[key];
if(flagMap.has(dbc.toLowerCase() + "." + key)){
displayedValBefore = "0x" + Number(before[key]).toString(16);
displayedValAfter = "0x" + Number(after[key]).toString(16);
}
changes += "<tr><td>" + key + "</td><td><del class='diff-removed'>" + displayedValBefore + addendumBefore + "</del> &rarr; <ins class='diff-added'>" + displayedValAfter + addendumAfter + "</ins></td></tr>";
let displayedValBefore = richValue(dbc, key, before[key], build, header.fks[key]);
let displayedValAfter = richValue(dbc, key, after[key], build, header.fks[key]);
changes += "<tr><td><i style='color: orange' class='fa fa-pencil-square'></i> <b>" + key + "</b></td><td>" + displayedValBefore + " &rarr; " + displayedValAfter + "</td></tr>";
} else {
var dmp = new diff_match_patch();
var dmp_diff = dmp.diff_main(before[key], after[key]);
Expand All @@ -205,8 +237,8 @@ function showRowDiff(dbc, build, recordID){

changes += "</table>";

if(changes == "<table></table>"){
changes = "No changes detected (<a href='#' data-toggle='modal' data-target='#fkModal' onclick='openFKModal(" + recordID + ", \"" + dbc.toLowerCase() + "::ID" + "\", \"" + build + "\")'>view record</a>)";
if(changes == "<table class='diffTable'></table>"){
changes = "No changes found (<a href='#' data-toggle='modal' data-target='#fkModal' onclick='openFKModal(" + recordID + ", \"" + dbc.toLowerCase() + "::ID" + "\", \"" + build + "\")'>view record</a>)";
}

var resultHolder = document.getElementById("resultHolder-" + dbc + "-" + build + "-" + recordID);
Expand Down
2 changes: 1 addition & 1 deletion dbc/index.php
Expand Up @@ -477,7 +477,7 @@ function loadTable(){
let idHeader = 0;

$.ajax({
"url": "/dbc/api/header/" + apiArgs,
"url": "/dbc/api/header/" + currentParams["dbc"] + "/?build=" + currentParams["build"],
"success": function(json) {
if(json['error'] != null){
if(json['error'] == "No valid definition found for this layouthash or build!"){
Expand Down
6 changes: 4 additions & 2 deletions dbc/js/dbc.js
Expand Up @@ -86,9 +86,11 @@ function openFKModal(value, location, build){
} else if (headerjson.fks[key] == "SoundEntries::ID" && parseInt(build[0]) > 6){
$("#fktable").append("<tr><td>" + key + "</td><td><a style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' onclick='openFKModal(" + val + ", \"SoundKit::ID\", \"" + build + "\")'>" + val + "</a></td></tr>");
} else if (headerjson.fks[key] == "Item::ID" && val > 0){
$("#fktable").append("<tr><td>" + key + "</td><td><a data-tooltip='item' data-id='" + val + "' ontouchstart='showTooltip(this)' ontouchend='hideTooltip(this)' onmouseover='showTooltip(this)' onmouseout='hideTooltip(this)' style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' onclick='openFKModal(" + val + ", \"" + headerjson.fks[key] + "\", \"" + build + "\")'>" + val + "</a></td></tr>");
$("#fktable").append("<tr><td>" + key + "</td><td><a data-build='" + build + "' data-tooltip='item' data-id='" + val + "' ontouchstart='showTooltip(this)' ontouchend='hideTooltip(this)' onmouseover='showTooltip(this)' onmouseout='hideTooltip(this)' style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' onclick='openFKModal(" + val + ", \"" + headerjson.fks[key] + "\", \"" + build + "\")'>" + val + "</a></td></tr>");
} else if (headerjson.fks[key] == "Spell::ID" || headerjson.fks[key] == "SpellName::ID" && val > 0){
$("#fktable").append("<tr><td>" + key + "</td><td><a data-build='" + build + "' data-tooltip='spell' data-id='" + val + "' ontouchstart='showTooltip(this)' ontouchend='hideTooltip(this)' onmouseover='showTooltip(this)' onmouseout='hideTooltip(this)' style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' onclick='openFKModal(" + val + ", \"" + headerjson.fks[key] + "\", \"" + build + "\")'>" + val + "</a></td></tr>");
} else {
$("#fktable").append("<tr><td>" + key + "</td><td><a data-tooltip='fk' data-id='" + val + "' data-fk='" + headerjson.fks[key] + "' ontouchstart='showTooltip(this)' ontouchend='hideTooltip(this)' onmouseover='showTooltip(this)' onmouseout='hideTooltip(this)' style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' onclick='openFKModal(" + val + ", \"" + headerjson.fks[key] + "\", \"" + build + "\")'>" + val + "</a></td></tr>");
$("#fktable").append("<tr><td>" + key + "</td><td><a data-build='" + build + "' data-tooltip='fk' data-id='" + val + "' data-fk='" + headerjson.fks[key] + "' ontouchstart='showTooltip(this)' ontouchend='hideTooltip(this)' onmouseover='showTooltip(this)' onmouseout='hideTooltip(this)' style='padding-top: 0px; padding-bottom: 0px; cursor: pointer; border-bottom: 1px dotted;' onclick='openFKModal(" + val + ", \"" + headerjson.fks[key] + "\", \"" + build + "\")'>" + val + "</a></td></tr>");
}

var cleanDBname = headerjson.fks[key].split('::')[0].toLowerCase();
Expand Down
12 changes: 6 additions & 6 deletions dbc/js/enums.js
Expand Up @@ -394,16 +394,16 @@ const criteriaAdditionalCondition = {
const itemStatType = {
0: 'MANA',
1: 'HEALTH',
// 2: 'UNUSED',
2: 'ENDURANCE',
3: 'AGILITY',
4: 'STRENGTH',
5: 'INTELLECT',
6: 'SPIRIT', // Removed in 7.3.0
6: 'SPIRIT_UNUSED', // Removed in 7.3.0
7: 'STAMINA',
// 8: 'UNUSED',
// 9: 'UNUSED',
// 10: 'UNUSED',
// 11: 'UNUSED',
8: 'ENERGY',
9: 'RAGE',
10: 'FOCUS',
11: 'WEAPON_SKILL_RATING_OBSOLETE',
12: 'DEFENSE_SKILL_RATING',
13: 'DODGE_RATING',
14: 'PARRY_RATING',
Expand Down
10 changes: 6 additions & 4 deletions dbc/scripts/updateHotfixes.php
Expand Up @@ -20,13 +20,13 @@
$filesToProcess = [];

foreach ($files as $file) {
if (empty($argv[1]) && filemtime($file) < strtotime("-1 hour")) {
if (empty($argv[1]) && filemtime($file) < strtotime("-2 hours")) {
continue;
}

$md5 = md5_file($file);
if (in_array($md5, $processedMD5s)) {
// echo "[Hotfix updater] [".date("Y-m-d H:i:s")."] Skipping already processed DBCache ". $file . " (" . $md5 . ")\n";
// echo "[Hotfix updater] [" . date("Y-m-d H:i:s") . "] Skipping already processed DBCache " . $file . " (" . $md5 . ")\n";
continue;
}

Expand Down Expand Up @@ -126,6 +126,8 @@
echo "[Hotfix updater] [" . date("Y-m-d H:i:s") . "] Reloaded TACT keys\n";
}

$insertMD5->execute([$md5]);
echo "[Hotfix updater] [" . date("Y-m-d H:i:s") . "] Inserted " . $md5 . " as processed cache\n";
if (!in_array($md5, $processedMD5s)) {
$insertMD5->execute([$md5]);
echo "[Hotfix updater] [" . date("Y-m-d H:i:s") . "] Inserted " . $md5 . " as processed cache\n";
}
}
13 changes: 9 additions & 4 deletions js/tooltips.js
Expand Up @@ -28,6 +28,8 @@ function showTooltip(el){
const tooltipDiv = document.createElement("div");
tooltipDiv.innerHTML = tooltipHTML;
tooltipDiv.style.position = "absolute";
// tooltipDiv.style.position.top = el.getBoundingClientRect().top + el.ownerDocument.defaultView.pageYOffset;
// tooltipDiv.style.position.left = el.getBoundingClientRect().left + el.ownerDocument.defaultView.pageXOffset;
tooltipDiv.style.zIndex = 5;
tooltipDiv.style.display = "block";
tooltipDiv.style.marginLeft = tooltipMarginLeft + "px";
Expand All @@ -49,7 +51,7 @@ function showTooltip(el){
generateQuestTooltip(tooltipTargetValue, tooltipDiv);
} else if (tooltipType == 'fk'){
if ((el.dataset.fk == "Map::ID" || tooltipTargetValue != 0) && tooltipTargetValue != -1){
generateFKTooltip(el.dataset.fk, tooltipTargetValue, tooltipDiv);
generateFKTooltip(el.dataset.fk, tooltipTargetValue, tooltipDiv, localBuild);
} else {
hideTooltip(el);
}
Expand Down Expand Up @@ -313,10 +315,13 @@ function generateSpellTooltip(id, tooltip, build)
return;
}

console.log(data);

const calcData = data[0];

if (calcData["name"] == null){
calcData["name"] = "Unknown spell";
calcData["description"] = "It is possible this spell was added through hotfixes or is entirely unavailable in the client.";
}

tooltipDesc.innerHTML = "<h2>" + calcData["name"] + "</h2>";
if (calcData["description"] != null){
tooltipDesc.innerHTML += "<p class='yellow'>" + calcData["description"].replace("\n", "<br><br>");
Expand All @@ -328,7 +333,7 @@ function generateSpellTooltip(id, tooltip, build)
});
}

function generateFKTooltip(targetFK, value, tooltip)
function generateFKTooltip(targetFK, value, tooltip, build)
{
console.log("Generating foreign key tooltip for " + value);

Expand Down

0 comments on commit 8233863

Please sign in to comment.