diff --git a/code/datums/datumvars.dm b/code/datums/datumvars.dm index fa6044d15cc0..d18626364b53 100644 --- a/code/datums/datumvars.dm +++ b/code/datums/datumvars.dm @@ -261,6 +261,15 @@ font-family: "Courier New", monospace; font-size: 8pt; } + .var { + display: none; + } + .var.visible { + display: list-item; + } + .var.selected { + background-color: "#ffee88"; + }
@@ -301,13 +310,15 @@ { try{ var li = lis\[i\]; - if(li.style.backgroundColor == "#ffee88") + if(li.className == "var visible" && li.style.backgroundColor == "#ffee88") { - if((i-1) >= 0){ - var li_new = lis\[i-1\]; - li.style.backgroundColor = "white"; - li_new.style.backgroundColor = "#ffee88"; - return + for(var j = i-1; j >= 0; --j) { + var li_new = lis\[j\]; + if(li_new.className == "var visible") { + li.style.backgroundColor = "white"; + li_new.style.backgroundColor = "#ffee88"; + return + } } } }catch(err) { } @@ -321,13 +332,15 @@ { try{ var li = lis\[i\]; - if(li.style.backgroundColor == "#ffee88") + if(li.className == "var visible" && li.style.backgroundColor == "#ffee88") { - if((i+1) < lis.length){ - var li_new = lis\[i+1\]; - li.style.backgroundColor = "white"; - li_new.style.backgroundColor = "#ffee88"; - return + for(var j = i+1; j < lis.length; ++j) { + var li_new = lis\[j\]; + if(li_new.className == "var visible") { + li.style.backgroundColor = "white"; + li_new.style.backgroundColor = "#ffee88"; + return + } } } }catch(err) { } @@ -335,38 +348,26 @@ return } - //This part here resets everything to how it was at the start so the filter is applied to the complete list. Screw efficiency, it's client-side anyway and it only looks through 200 or so variables at maximum anyway (mobs). - if(complete_list != null && complete_list != ""){ - var vars_ol1 = document.getElementById("vars"); - vars_ol1.innerHTML = complete_list - } document.cookie="[refid][cookieoffset]search="+encodeURIComponent(filter); - if(filter == ""){ - return; - }else{ - var vars_ol = document.getElementById('vars'); - var lis = vars_ol.getElementsByTagName("li"); - for(var i = 0; i < lis.length; ++i) - { - try{ - var li = lis\[i\]; - if(li.innerText.toLowerCase().indexOf(filter) == -1) - { - vars_ol.removeChild(li); - i--; - } - }catch(err) { } - } - } - var lis_new = vars_ol.getElementsByTagName("li"); - for(var j = 0; j < lis_new.length; ++j) + var vars_ol = document.getElementById('vars'); + var lis = vars_ol.getElementsByTagName("li"); + var first = true; + for(var i = 0; i < lis.length; ++i) { - var li1 = lis\[j\]; - if(j == 0){ - li1.style.backgroundColor = "#ffee88"; - }else{ - li1.style.backgroundColor = "white"; - } + try{ + var li = lis\[i\]; + li.style.backgroundColor = "white"; + if(li.innerText.toLowerCase().indexOf(filter) == -1) + { + li.className = "var"; + } else { + if(first) { + li.style.backgroundColor = "#ffee88"; + first = false; + } + li.className = "var visible"; + } + }catch(err) { } } } function selectTextField() { @@ -481,9 +482,9 @@ name = debug_list[name] // name is really the index until this line else value = debug_list[name] - header = "