https://www.byond.com/developer/Shadowdarke/sd_Alert
if(usr&&usr.client&&usr.client != target)
return
response = params["clk"]
proc/Display(message,title,list/buttons,default,unfocus,size,table,style,select,flags)
if(istext(buttons)) buttons = list(buttons)
src.keyboard_support=buttons.Copy()
if(!default) default = buttons[1]
if(!(flags & SD_ALERT_NOVALIDATE)) validation = buttons.Copy()
//validation = buttons.Copy()
var/html = {"<head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"><title>[title]</title>[style]<script>\
var clen=[buttons.len];var cpos=1;function c(x) {document.location.href='BYOND://?src=\ref[src];'+x;}"}
if(target.mob.keyboardhelper)
html+={"function e(event) {
if(event.keyCode==112||event.keyCode==49){
c(\"clk=[buttons[min(1,buttons.len)]]\");
}
else if(event.keyCode==113||event.keyCode==50){
c(\"clk=[buttons[min(2,buttons.len)]]\");
}
else if(event.keyCode==114||event.keyCode==51){
c(\"clk=[buttons[min(3,buttons.len)]]\");
}
else if(event.keyCode==115||event.keyCode==52){
c(\"clk=[buttons[min(4,buttons.len)]]\");
}
else if(event.keyCode==116||event.keyCode==53){
c(\"clk=[buttons[min(5,buttons.len)]]\");
}
else if(event.keyCode==117||event.keyCode==54){
c(\"clk=[buttons[min(6,buttons.len)]]\");
}
else if(event.keyCode==118||event.keyCode==55){
c(\"clk=[buttons[min(7,buttons.len)]]\");
}
else if(event.keyCode==119||event.keyCode==56){
c(\"clk=[buttons[min(8,buttons.len)]]\");
}
else if(event.keyCode==120||event.keyCode==57){
c(\"clk=[buttons[min(9,buttons.len)]]\");
}
else if(event.keyCode==121){
c(\"clk=[buttons[min(10,buttons.len)]]\");
}
else if(event.keyCode==122){
c(\"clk=[buttons[min(11,buttons.len)]]\");
}
else if(event.keyCode==123||event.keyCode==48){
c(\"clk=[buttons[buttons.len]]\");
}
else if(event.keyCode==38){
if(cpos==0){cpos=1;}
cpos--;
if(cpos<1){cpos=clen;}
if(document.getElementById(\"choice\"+cpos.toString())){document.getElementById(\"choice\"+cpos.toString()).focus();}
}
else if(event.keyCode==40)
cpos++;
if(cpos>clen){cpos=1;}
if(document.getElementById(\"choice\"+cpos.toString())){document.getElementById(\"choice\"+cpos.toString()).focus();}
else if(event.keyCode==13){
c('clk='+document.getElementById(\"choice\"+cpos.toString()));
event.preventDefault();
}
}"}
if(!unfocus&&target.mob.keyboardhelper)
html+={"this.focus();cpos=[buttons.Find(default)];"}
if(target.mob.keyboardhelper)
html+={"</script></head><body onkeydown=e(event) onLoad=\
[(flags&SD_ALERT_SCROLL)?"":]document.getElementById(\"choice[buttons.Find(default)]\").focus();><table [table]><tr>\
<td>[message]</td></tr><tr><th>"}
else
html+={"</script></head><body onLoad=\
[(flags&SD_ALERT_SCROLL)?"":]><table [table]><tr>\
<td>[message]</td></tr><tr><th>"}
if(select || (flags & SD_ALERT_SELECT_MULTI)) // select style choices
html += {"<FORM ID=fcs ACTION='BYOND://?' METHOD=GET>\
<INPUT TYPE=HIDDEN NAME=src VALUE='\ref[src]'>
<SELECT NAME=clk SIZE=[select]\
[(flags & SD_ALERT_SELECT_MULTI)?" MULTIPLE":""]>"}
for(var/b in buttons)
html += "<OPTION[(b == default)?" SELECTED":""]>\
[html_encode(b)]</OPTION>"
html += "</SELECT><BR><INPUT TYPE=SUBMIT VALUE=Submit></FORM>"
else if(flags & SD_ALERT_LINKS) // text link style
for(var/i=1;i<=buttons.len;++i)
var/b=buttons[i]
var/list/L = list()
L["clk"] = b
var/html_string=list2params(L)
var/focus
//if(b == default) focus = " ID=fcs"
html += "<A[focus] id=\"choice[i]\" href=\"javascript:void(0);\" onClick=\"c('[html_string]')\">[b]</A>\
<BR>"
else // button style choices
for(var/b in buttons)
var/list/L = list()
L["clk"] = b
var/html_string=list2params(L)
var/focus
if(b == default) focus = " ID=fcs"
html += "<INPUT[focus] TYPE=button VALUE='[html_encode(b)]' \
onClick=\"c('[html_string]')\"> "
html += "</th></tr></table></body>"
if(target.connection=="web")
target << browse(html,"window=\ref[src];size=[size];can_close=0")
else
winclone(target,"fancyfix","\ref[src]")
winset(target,"\ref[src]","title=[title];size=[size];pos=[target.resolution_width/2.5],[target.resolution_height/3]")
target << browse(html,"window=\ref[src].fancytest;size=[size];can_close=0")
//world << "Called with size [size]"
winset(target,null,"\ref[src].macro=macro")
winshow(target,"\ref[src]",1)
proc/Response(default)
var/validated
while(!validated)
while(target && !response) // wait for a response
sleep(2)
if(response && validation)
if(istype(response, /list))
var/list/L = response - validation
if(L.len) response = null
else validated = 1
else if(response in validation) validated = 1
else response=null
else validated = 1
spawn(2) del(src)
if(!target||!src)
return default
return response
Problem description:
Trying to make sdAlert work with a list of mobs. The basic BYOND input window supports this. I want sdAlert to support this too. What do I do?
Bear in mind sd_Alert is a very old library, so there's probably a much better way to do this now.