Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

516 view variables #13725

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 67 additions & 128 deletions code/datums/datumvars.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,106 +43,45 @@
function updateSearch(){
var filter_text = document.getElementById('filter');
var filter = filter_text.value.toLowerCase();

if(event.keyCode == 13){ //Enter / return
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.style.backgroundColor == "#ffee88" )
{
alist = lis\[i\].getElementsByTagName("a")
if(alist.length > 0){
location.href=alist\[0\].href;
}
}
}catch(err) { }
}
return
}

if(event.keyCode == 38){ //Up arrow
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.style.backgroundColor == "#ffee88" )
{
if( (i-1) >= 0){
var li_new = lis\[i-1\];
li.style.backgroundColor = "white";
li_new.style.backgroundColor = "#ffee88";
return
}
}
}catch(err) { }
}
return
}

if(event.keyCode == 40){ //Down arrow
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.style.backgroundColor == "#ffee88" )
{
if( (i+1) < lis.length){
var li_new = lis\[i+1\];
li.style.backgroundColor = "white";
li_new.style.backgroundColor = "#ffee88";
return
}
}
}catch(err) { }
}
return
}
var vars_ol = document.getElementById("vars");

//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
vars_ol.innerHTML = complete_list
}

if(filter.value == ""){
if(filter === ""){
return;
}else{
var vars_ol = document.getElementById('vars');
var lis = vars_ol.getElementsByTagName("li");

var lis = Array.from(vars_ol.children);
var fragment = document.createDocumentFragment();
for ( var i = 0; i < lis.length; ++i )
{
try{
var li = lis\[i\];
if ( li.innerText.toLowerCase().indexOf(filter) == -1 )
var text = li.textContent.toLowerCase();

var aElements = li.getElementsByTagName('a');
for (var j = 0; j < aElements.length; j++)
{
var aText = aElements\[j\].textContent.trim().toLowerCase();
if (aText === 'e' || aText === 'c' || aText === 'm')
{
text = text.replace(aElements\[j\].textContent.toLowerCase(), '');
}
}
if ( text.indexOf(filter) !== -1 )
{
vars_ol.removeChild(li);
i--;
fragment.appendChild(li)
}
}catch(err) { }
}
}
var lis_new = vars_ol.getElementsByTagName("li");
for ( var j = 0; j < lis_new.length; ++j )
{
var li1 = lis\[j\];
if (j == 0){
li1.style.backgroundColor = "#ffee88";
}else{
li1.style.backgroundColor = "white";
}

vars_ol.innerHTML = '';
vars_ol.appendChild(fragment);
}
}



function selectTextField(){
var filter_text = document.getElementById('filter');
filter_text.focus();
Expand All @@ -161,7 +100,7 @@
}
</script> "}

body += "<body onload='selectTextField(); updateSearch()' onkeyup='updateSearch()'>"
body += "<body onload='selectTextField(); updateSearch()'>"

body += "<div align='center'><table width='100%'><tr><td width='50%'>"

Expand Down Expand Up @@ -232,72 +171,72 @@
"}


body += "<option value='?_src_=vars;mark_object=\ref[D]'>Mark Object</option>"
body += "<option value='byond://?_src_=vars;mark_object=\ref[D]'>Mark Object</option>"
if(ismob(D))
body += "<option value='?_src_=vars;mob_player_panel=\ref[D]'>Show player panel</option>"
body += "<option value='byond://?_src_=vars;mob_player_panel=\ref[D]'>Show player panel</option>"
if(istype(D, /atom/movable))
body += "<option value='?_src_=holder;adminplayerobservefollow=\ref[D]'>Follow</option>"
body += "<option value='byond://?_src_=holder;adminplayerobservefollow=\ref[D]'>Follow</option>"
else
var/atom/A = D
if(istype(A))
body += "<option value='?_src_=holder;adminplayerobservecoodjump=1;X=[A.x];Y=[A.y];Z=[A.z]'>Jump to</option>"
body += "<option value='byond://?_src_=holder;adminplayerobservecoodjump=1;X=[A.x];Y=[A.y];Z=[A.z]'>Jump to</option>"

body += "<option value>---</option>"

if(ismob(D))
body += "<option value='?_src_=vars;give_spell=\ref[D]'>Give Spell</option>"
body += "<option value='?_src_=vars;give_disease2=\ref[D]'>Give Disease</option>"
body += "<option value='?_src_=vars;give_religion=\ref[D]'>Give Religion</option>"
body += "<option value='byond://?_src_=vars;give_spell=\ref[D]'>Give Spell</option>"
body += "<option value='byond://?_src_=vars;give_disease2=\ref[D]'>Give Disease</option>"
body += "<option value='byond://?_src_=vars;give_religion=\ref[D]'>Give Religion</option>"
if(isliving(D))
body += "<option value='?_src_=vars;give_status_effect=\ref[D]'>Give Status Effect</option>"
body += "<option value='?_src_=vars;give_disease=\ref[D]'>Give TG-style Disease</option>"
body += "<option value='?_src_=vars;godmode=\ref[D]'>Toggle Godmode</option>"
body += "<option value='?_src_=vars;build_mode=\ref[D]'>Toggle Build Mode</option>"
body += "<option value='byond://?_src_=vars;give_status_effect=\ref[D]'>Give Status Effect</option>"
body += "<option value='byond://?_src_=vars;give_disease=\ref[D]'>Give TG-style Disease</option>"
body += "<option value='byond://?_src_=vars;godmode=\ref[D]'>Toggle Godmode</option>"
body += "<option value='byond://?_src_=vars;build_mode=\ref[D]'>Toggle Build Mode</option>"

body += "<option value='?_src_=vars;ninja=\ref[D]'>Make Space Ninja</option>"
body += "<option value='byond://?_src_=vars;ninja=\ref[D]'>Make Space Ninja</option>"

body += "<option value='?_src_=vars;direct_control=\ref[D]'>Assume Direct Control</option>"
body += "<option value='?_src_=vars;drop_everything=\ref[D]'>Drop Everything</option>"
body += "<option value='byond://?_src_=vars;direct_control=\ref[D]'>Assume Direct Control</option>"
body += "<option value='byond://?_src_=vars;drop_everything=\ref[D]'>Drop Everything</option>"

body += "<option value='?_src_=vars;regenerateicons=\ref[D]'>Regenerate Icons</option>"
body += "<option value='?_src_=vars;addlanguage=\ref[D]'>Add Language</option>"
body += "<option value='?_src_=vars;remlanguage=\ref[D]'>Remove Language</option>"
body += "<option value='byond://?_src_=vars;regenerateicons=\ref[D]'>Regenerate Icons</option>"
body += "<option value='byond://?_src_=vars;addlanguage=\ref[D]'>Add Language</option>"
body += "<option value='byond://?_src_=vars;remlanguage=\ref[D]'>Remove Language</option>"
if(ishuman(D) || istype(D, /mob/dead/new_player))
body += "<option value='?_src_=vars;give_quality=\ref[D]'>Give Quality</option>"
body += "<option value='byond://?_src_=vars;give_quality=\ref[D]'>Give Quality</option>"

body += "<option value='?_src_=vars;addverb=\ref[D]'>Add Verb</option>"
body += "<option value='?_src_=vars;remverb=\ref[D]'>Remove Verb</option>"
body += "<option value='?_src_=vars;setckey=\ref[D]'>Set Client</option>"
body += "<option value='byond://?_src_=vars;addverb=\ref[D]'>Add Verb</option>"
body += "<option value='byond://?_src_=vars;remverb=\ref[D]'>Remove Verb</option>"
body += "<option value='byond://?_src_=vars;setckey=\ref[D]'>Set Client</option>"
if(isAI(D))
body += "<option value>---</option>"
body += "<option value='?_src_=vars;allowmoving=\ref[D]'>Allow Moving</option>"
body += "<option value='byond://?_src_=vars;allowmoving=\ref[D]'>Allow Moving</option>"
if(ishuman(D))
body += "<option value>---</option>"
body += "<option value='?_src_=vars;setspecies=\ref[D]'>Set Species</option>"
body += "<option value='?_src_=vars;makeai=\ref[D]'>Make AI</option>"
body += "<option value='?_src_=vars;makerobot=\ref[D]'>Make cyborg</option>"
body += "<option value='?_src_=vars;makemonkey=\ref[D]'>Make monkey</option>"
body += "<option value='?_src_=vars;makealien=\ref[D]'>Make alien</option>"
body += "<option value='?_src_=vars;makeslime=\ref[D]'>Make slime</option>"
body += "<option value='?_src_=vars;makezombie=\ref[D]'>Make zombie</option>"
body += "<option value='byond://?_src_=vars;setspecies=\ref[D]'>Set Species</option>"
body += "<option value='byond://?_src_=vars;makeai=\ref[D]'>Make AI</option>"
body += "<option value='byond://?_src_=vars;makerobot=\ref[D]'>Make cyborg</option>"
body += "<option value='byond://?_src_=vars;makemonkey=\ref[D]'>Make monkey</option>"
body += "<option value='byond://?_src_=vars;makealien=\ref[D]'>Make alien</option>"
body += "<option value='byond://?_src_=vars;makeslime=\ref[D]'>Make slime</option>"
body += "<option value='byond://?_src_=vars;makezombie=\ref[D]'>Make zombie</option>"
body += "<option value>---</option>"
body += "<option value='?_src_=vars;gib=\ref[D]'>Gib</option>"
body += "<option value='?_src_=vars;dust=\ref[D]'>Turn to dust</option>"
body += "<option value='byond://?_src_=vars;gib=\ref[D]'>Gib</option>"
body += "<option value='byond://?_src_=vars;dust=\ref[D]'>Turn to dust</option>"
if(isatom(D))
body += "<option value='?_src_=vars;delthis=\ref[D]'>Delete this object</option>"
body += "<option value='?_src_=vars;edit_filters=\ref[D]'>Edit Filters</option>"
body += "<option value='?_src_=vars;edit_particles=\ref[D]'>Edit Particles</option>"
body += "<option value='?_src_=vars;update_icon=\ref[D]'>Update icon</option>"
body += "<option value='byond://?_src_=vars;delthis=\ref[D]'>Delete this object</option>"
body += "<option value='byond://?_src_=vars;edit_filters=\ref[D]'>Edit Filters</option>"
body += "<option value='byond://?_src_=vars;edit_particles=\ref[D]'>Edit Particles</option>"
body += "<option value='byond://?_src_=vars;update_icon=\ref[D]'>Update icon</option>"
if(isobj(D))
body += "<option value='?_src_=vars;delall=\ref[D]'>Delete all of type</option>"
body += "<option value='byond://?_src_=vars;delall=\ref[D]'>Delete all of type</option>"
if(isobj(D) || ismob(D) || isturf(D))
body += "<option value='?_src_=vars;explode=\ref[D]'>Trigger explosion</option>"
body += "<option value='?_src_=vars;emp=\ref[D]'>Trigger EM pulse</option>"
body += "<option value='byond://?_src_=vars;explode=\ref[D]'>Trigger explosion</option>"
body += "<option value='byond://?_src_=vars;emp=\ref[D]'>Trigger EM pulse</option>"
if(istype(D, /datum/reagents))
body += "<option value='?_src_=vars;action=addreag;reagents=\ref[D]'>Add reagent</option>"
body += "<option value='?_src_=vars;action=remreag;reagents=\ref[D]'>Remove reagent</option>"
body += "<option value='?_src_=vars;action=isoreag;reagents=\ref[D]'>Isolate reagent</option>"
body += "<option value='?_src_=vars;action=clearreags;reagents=\ref[D]'>Clear reagents</option>"
body += "<option value='byond://?_src_=vars;action=addreag;reagents=\ref[D]'>Add reagent</option>"
body += "<option value='byond://?_src_=vars;action=remreag;reagents=\ref[D]'>Remove reagent</option>"
body += "<option value='byond://?_src_=vars;action=isoreag;reagents=\ref[D]'>Isolate reagent</option>"
body += "<option value='byond://?_src_=vars;action=clearreags;reagents=\ref[D]'>Clear reagents</option>"

body += "</select></form>"

Expand All @@ -307,7 +246,7 @@
body += "<b>C</b> - Change, asks you for the var type first.<br>"
body += "<b>M</b> - Mass modify: changes this variable for all objects of this type.</font><br>"

body += "<hr><table width='100%'><tr><td width='20%'><div align='center'><b>Search:</b></div></td><td width='80%'><input type='text' id='filter' name='filter_text' value='[last_search]' style='width:100%;'></td></tr></table><hr>"
body += "<hr><table width='100%'><tr><td width='20%'><div align='center'><b>Search:</b></div></td><td width='80%'><input type='text' id='filter' name='filter_text' value='[last_search]' style='width:100%;' oninput='updateSearch()'></td></tr></table><hr>"

body += "<ol id='vars'>"

Expand All @@ -324,7 +263,7 @@

body += "</ol>"

var/html = "<html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>"
var/html = "<!DOCTYPE html><html><head><meta http-equiv='Content-Type' content='text/html; charset=utf-8'>"
if (title)
html += "<title>[title]</title>"
html += {"<style>
Expand Down Expand Up @@ -359,7 +298,7 @@ body
var/html = ""

if(DA)
html += "<li style='backgroundColor:white'>(<a href='byond://?_src_=vars;datumedit=\ref[DA];varnameedit=[name]'>E</a>) (<a href='byond://?_src_=vars;datumchange=\ref[DA];varnamechange=[name]'>C</a>) (<a href='byond://?_src_=vars;datummass=\ref[DA];varnamemass=[name]'>M</a>) "
html += "<li>(<a href='byond://?_src_=vars;datumedit=\ref[DA];varnameedit=[name]'>E</a>) (<a href='byond://?_src_=vars;datumchange=\ref[DA];varnamechange=[name]'>C</a>) (<a href='byond://?_src_=vars;datummass=\ref[DA];varnamemass=[name]'>M</a>) "
else
html += "<li>"

Expand Down
Loading