Makes browser datum use asset cache (#20847)

* Makes browser datum use asset cache

This should shave one or two round trips off of the lag for player preferences window, since it was sending the css for browser datums every load.

* Fix improper casing
This commit is contained in:
Kyle Spier-Swenson
2016-10-09 15:28:29 -07:00
committed by oranges
parent 1efebaf096
commit 06a826dd18

View File

@@ -40,9 +40,11 @@
/datum/browser/proc/add_stylesheet(name, file) /datum/browser/proc/add_stylesheet(name, file)
stylesheets[name] = file stylesheets[name] = file
register_asset("[ckey(name)].css", file)
/datum/browser/proc/add_script(name, file) /datum/browser/proc/add_script(name, file)
scripts[name] = file scripts[name] = file
register_asset("[ckey(name)].js", file)
/datum/browser/proc/set_content(ncontent) /datum/browser/proc/set_content(ncontent)
content = ncontent content = ncontent
@@ -54,13 +56,9 @@
var/key var/key
var/filename var/filename
for (key in stylesheets) for (key in stylesheets)
filename = "[ckey(key)].css"
user << browse_rsc(stylesheets[key], filename)
head_content += "<link rel='stylesheet' type='text/css' href='[filename]'>" head_content += "<link rel='stylesheet' type='text/css' href='[filename]'>"
for (key in scripts) for (key in scripts)
filename = "[ckey(key)].js"
user << browse_rsc(scripts[key], filename)
head_content += "<script type='text/javascript' src='[filename]'></script>" head_content += "<script type='text/javascript' src='[filename]'></script>"
var/title_attributes = "class='uiTitle'" var/title_attributes = "class='uiTitle'"
@@ -98,6 +96,10 @@
var/window_size = "" var/window_size = ""
if (width && height) if (width && height)
window_size = "size=[width]x[height];" window_size = "size=[width]x[height];"
if (stylesheets.len)
send_asset_list(user, stylesheets, verify=FALSE)
if (scripts.len)
send_asset_list(user, scripts, verify=FALSE)
user << browse(get_content(), "window=[window_id];[window_size][window_options]") user << browse(get_content(), "window=[window_id];[window_size][window_options]")
if (use_onclose) if (use_onclose)
spawn(0) spawn(0)