Stat panel fixes (Not done)

This commit is contained in:
QuoteFox
2021-02-28 03:58:07 +00:00
parent fed22c003f
commit 74fd8d8f13
13 changed files with 74 additions and 61 deletions
+25 -18
View File
@@ -9,8 +9,8 @@
body {
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: 12px !important;
margin: 5px !important;
padding: 2px !important;
margin: 0 !important;
padding: 0 !important;
}
body.dark {
background-color: #131313;
@@ -19,11 +19,18 @@ body.dark {
#menu {
background-color: white;
position: fixed;
padding: 7px;
width: 100%;
}
.dark #menu {
background-color: #131313;
}
#statcontent {
padding: 0 7px 7px 7px;
}
a {
color: black;
text-decoration: none
@@ -142,6 +149,7 @@ li a:hover:not(.active) {
</head>
<body>
<ul id="menu" class="button-container"></ul>
<div id="under_menu"></div>
<div id="statcontent"></div>
<script>
// Polyfills and compatibility ------------------------------------------------
@@ -220,6 +228,7 @@ var permanent_tabs = []; // tabs that won't be cleared by wipes
var turfcontents = [];
var turfname = "";
var menu = document.querySelector('#menu');
var under_menu = document.querySelector('#under_menu');
function createStatusTab(name) {
if(document.getElementById(name) || name.trim() == "")
@@ -227,7 +236,10 @@ function createStatusTab(name) {
if(!verb_tabs.includes(name) && !permanent_tabs.includes(name))
return;
var B = document.createElement("BUTTON");
B.onclick = function() {tab_change(name)};
B.onclick = function() {
tab_change(name);
this.blur();
};
B.id = name;
B[textContentKey] = name;
B.className = "button";
@@ -241,6 +253,7 @@ function createStatusTab(name) {
}
//END ORDERING
menu.appendChild(B);
under_menu.style.height = menu.clientHeight + 'px';
}
function removeStatusTab(name) {
@@ -252,10 +265,15 @@ function removeStatusTab(name) {
}
}
menu.removeChild(document.getElementById(name));
under_menu.style.height = menu.clientHeight + 'px';
if(document.getElementById(name)) // repeat for duplicates
removeStatusTab(name);
}
window.onresize = function () {
under_menu.style.height = menu.clientHeight + 'px';
}
function addPermanentTab(name) {
if(!permanent_tabs.includes(name))
permanent_tabs.push(name);
@@ -276,21 +294,7 @@ function checkStatusTab() {
if(!verb_tabs.includes(menu.children[i].id) && !permanent_tabs.includes(menu.children[i].id))
removeStatusTab(menu.children[i].id);
}
function add_verb(v) {
var to_add = JSON.parse(v);
var cat = "";
cat = to_add[0];
if(verb_tabs.includes(cat)){ // we have the category already
verbs.push(to_add); // add it to verb list and we done
} else if(cat.trim() != "") { // we don't have the category
verb_tabs.push(cat);
verbs.push(to_add); // add verb
createStatusTab(cat); // create the category
}
if(current_tab == cat) {
draw_verbs(cat); // redraw if we added a verb to the tab we're currently in
}
}
function remove_verb(v) {
var verb_to_remove = v; // to_remove = [verb:category, verb:name]
for(var i = verbs.length - 1; i >= 0; i--){
@@ -345,6 +349,9 @@ function add_verb_list(v) {
for(var i = 0; i < to_add.length; i++) {
var part = to_add[i];
if(verb_tabs.includes(part[0])){
if(verbs.includes(part)){
continue;
}
verbs.push(part);
if(current_tab == part[0]) {
draw_verbs(part[0]); // redraw if we added a verb to the tab we're currently in