/datum/nanoui var/mob/user var/atom/movable/src_object var/title var/ui_key var/window_id // window_id is used as the window name for browse and onclose var/width = 0 var/height = 0 var/atom/ref = null var/on_close_logic = 1 var/window_options = "focus=0;can_close=1;can_minimize=1;can_maximize=0;can_resize=1;titlebar=1;" // window option is set using window_id var/list/stylesheets = list() var/list/scripts = list() var/templates[0] var/title_image var/head_elements var/body_elements var/head_content = "" var/content = "
" // the #mainTemplate div will contain the compiled "main" template html var/list/initial_data[0] var/is_auto_updating = 0 var/status = 2 /datum/nanoui/New(nuser, nsrc_object, nui_key, ntemplate, ntitle = 0, nwidth = 0, nheight = 0, var/atom/nref = null) user = nuser src_object = nsrc_object ui_key = nui_key window_id = "[ui_key]\ref[src_object]" add_template("main", ntemplate) if (ntitle) title = ntitle if (nwidth) width = nwidth if (nheight) height = nheight if (nref) ref = nref add_common_assets() /datum/nanoui/proc/add_common_assets() add_script("libraries.min.js") // The jQuery library add_script("nano_update.js") // The NanoUpdate JS, this is used to receive updates and apply them. add_script("nano_config.js") // The NanoUpdate JS, this is used to receive updates and apply them. add_script("nano_base_helpers.js") // The NanoBaseHelpers JS, this is used to set up template helpers which are common to all templates add_stylesheet("shared.css") // this CSS sheet is common to all UIs add_stylesheet("icons.css") // this CSS sheet is common to all UIs /datum/nanoui/proc/set_status(state) if (state != status) status = state push_data(list(), 1) // Update the UI else status = state /datum/nanoui/proc/set_auto_update(state = 1) is_auto_updating = state /datum/nanoui/proc/set_initial_data(data) initial_data = modify_data(data) /datum/nanoui/proc/add_head_content(nhead_content) head_content = nhead_content /datum/nanoui/proc/set_window_options(nwindow_options) window_options = nwindow_options /datum/nanoui/proc/set_title_image(ntitle_image) //title_image = ntitle_image /datum/nanoui/proc/add_stylesheet(file) stylesheets.Add(file) /datum/nanoui/proc/add_script(file) scripts.Add(file) /datum/nanoui/proc/add_template(name, file) templates[name] = file /datum/nanoui/proc/set_content(ncontent) content = ncontent /datum/nanoui/proc/add_content(ncontent) content += ncontent /datum/nanoui/proc/use_on_close_logic(nsetting) on_close_logic = nsetting /datum/nanoui/proc/get_header() for (var/filename in stylesheets) head_content += "" var/title_attributes = "id='uiTitle'" if (title_image) title_attributes = "id='uiTitle icon' style='background-image: url([title_image]);'" var/templatel_data[0] for (var/key in templates) templatel_data[key] = templates[key]; var/template_data_json = "{}" // An empty JSON object if (templatel_data.len > 0) template_data_json = list2json(templatel_data) var/initial_data_json = "{}" // An empty JSON object if (initial_data.len > 0) initial_data_json = list2json(initial_data) var/url_parameters_json = list2json(list("src" = "\ref[src_object]")) return {" [head_content]