ID:147218
 
Is there a way to add a box "[x]" next to the complaint so an administrator that has handled the problem can erase it?

This because I see when adding to the complaints list, it says Complaints = "(the rest of the coding)"

This is so admins dont handle the same problem twice.

var/Complaints
var/Complaintslen

mob/verb/Access_List() // !!!!Add ability to erase a complaint off of list!!!!
if(src.key == "RainZero")
src << browse("[Complaints]","window=complaints")

mob/verb/File_Complaint(T as text)
Complaints = "[Complaints][html_encode(T)] - <i>[html_encode(src.name)]</i><br>"
Complaintslen+=1
sleep(5)
usr << "Thank you for filing your complaint. Administrators currently have [Complaintslen] report\s to respond to before yours. You will be contacted as soon as possible."
The easiest way would be to store all the complaints in a list.

var/list/complaints=list()
client/Topic(href, href_list)
if("deletecomplaint" in href_list)
if("id" in href_list)
complaints-=complaints[text2num(href_list["id"])]
src<<"That complaint has been removed."
mob/verb/Access_List()
if(usr.key == "RainZero")
var/HTML
for(var/i=1,i<=complaints.len,i++)
HTML+="[complaints[i]]<a href=?deletecomplaint&id=[i]>\[x\]</a><br><br>"
usr<<browse(HTML,"window=complaints")
mob/verb/FileComplaint(T as text)
complaints+="[html_encode(T)] - <i>[html_encode(usr.name)]</i><br>"
sleep(5)
usr << "Thank you for filing your complaint. Administrators currently have [complaints.len-1] report\s to respond to before yours. You will be contacted as soon as possible."


I also fixed a few small problems. FileComplaint(T) is invalid. It should be FileComplaint(T as text) Also, it's perfectly fine to use usr inside of verbs to capture the player's key.
In response to HavenMaster
Can you break down some of the more complicated areas for me? Like the href. I understand its html but why is it implemented into this coding?
In response to ZLegend
I'll break it all down bit by bit for you.

var/list/complaints=list() //defines the complaints list
client/Topic(href, href_list) //this is what is called when a link is pressed
if("deletecomplaint" in href_list) //it checks if 'deletecomplaint' is in the URL that was clicked
if("id" in href_list) //it does the same for 'id'
complaints-=complaints[text2num(href_list["id"])] //it gets rid of the complaint that was clicked
src<<"That complaint has been removed." //it tells you
mob/verb/Access_List()
if(usr.key == "RainZero") //checks if your key is 'RainZero'
var/HTML //this is what the user will be shown
for(var/i=1,i<=complaints.len,i++) //a for statement that will loop as many times as complaints.len is
HTML+="[complaints[i]]<a href=?deletecomplaint&id=[i]>\[x\]</a><br><br>" //adds that complaint to HTML
usr<<browse(HTML,"window=complaints") //you browse HTML
mob/verb/FileComplaint(T as text)
complaints+="[html_encode(T)] - <i>[html_encode(src.name)]</i><br>" //adds your complaint to the list
sleep(5)
usr << "Thank you for filing your complaint. Administrators currently have [complaints.len] report\s to respond to before yours. You will be contacted as soon as possible."


I hope that helps.
In response to HavenMaster
Is there a way to refresh the window after deleting a post so the new list can be viewed imediately?

In response to ZLegend
Yes.

client/Topic(href, href_list)
if("deletecomplaint" in href_list)
if("id" in href_list)
complaints-=complaints[text2num(href_list["id"])]
src<<"That complaint has been removed."
src<<browse(null,"window=complaints")
var/HTML
for(var/i=1,i<=complaints.len,i++)
HTML+="[complaints[i]]<a href=?deletecomplaint&id=[i]>\[x\]</a><br><br>"
src<<browse(HTML,"window=complaints")
var
list/Complaints=list()
list/Administraters=list("RainZero")

mob/verb/Access_List()
if(Administraters.Find(src.key))
var
Comp
for(var/i in Complaints)
Comp+=i
src<<browse(Comp,"window=pop_up")

mob/verb/File_Complaint(T as message)
Complaints+="<table border=1><tr><td>Complaint written by [html_decode(src.name)]<table border=1 width=99%>[html_encode(T)] -<a href=?Action=Delete;Post=[Complaints.len+1]>Delete</a>"
if(Complaints.len>1)src<<"Thank you for filing your complaint. Administrators currently have [Complaints.len] reports to respond to before yours. You will be contacted as soon as possible."
else if(Complaints.len==1)src<<"Thank you for filling your complaint. Administrators will review your report as soon as possible."

client/Topic(href,href_list[])
switch(href_list["Action"]=="Delete")
if(Administraters.Find(usr.key))
var/PostID=text2num(href_list["Post"])
var/i
for(var/I in Complaints)
i++
if(i==PostID)Complaints-=I

There probably are errors in that, I just whiped it up. If there are, please tell me.
<EDIT>I see Haven has all ready helped, his looks to be cleaner. Perhaps you shouldn't refer to this then. =/
In response to HavenMaster
im just wondering. Why does it display [0] and then when i remove one post. It displays [x]
In response to ZLegend
If you use this:
client/Topic(href, href_list)
if("deletecomplaint" in href_list)
if("id" in href_list)
complaints-=complaints[text2num(href_list["id"])]
src<<"That complaint has been removed."
src<<browse(null,"window=complaints")
var/HTML
for(var/i=1,i<=complaints.len,i++)
HTML+="[complaints[i]]<a href=?deletecomplaint&id=[i]>\[x\]</a><br><br>"
src<<browse(HTML,"window=complaints")
mob/verb/Access_List()
if(usr.key == "RainZero") //checks if your key is 'RainZero'
var/HTML //this is what the user will be shown
for(var/i=1,i<=complaints.len,i++) //a for statement that will loop as many times as complaints.len is
HTML+="[complaints[i]]<a href=?deletecomplaint&id=[i]>\[x\]</a><br><br>" //adds that complaint to HTML
usr<<browse(HTML,"window=complaints") //you browse HTML
mob/verb/FileComplaint(T as text)
complaints+="[html_encode(T)] - <i>[html_encode(src.name)]</i><br>" //adds your complaint to the list
sleep(5)
usr << "Thank you for filing your complaint. Administrators currently have [complaints.len-1] report\s to respond to before yours. You will be contacted as soon as possible."


You shouldn't run into any problems. I didn't.
In response to ZLegend
[x] needs to be \[x\] - I corrected myself after seeing that mistake a few seconds after I posted.
In response to HavenMaster
o ok. I really appreciate your help. Now I can understand what Topic is better used for.