mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 10:12:45 +00:00
- A hacked together pseudo-ajax. I called it byjax (byond+ajax).
- Fixed a couple of nasty mech fabricator bugs. - Tweaked mecha status window. - Mecha equipment is now detachable (the command is in mecha "Equipment" menu). - Misc. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@1506 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
29
code/js/byjax.dm
Normal file
29
code/js/byjax.dm
Normal file
@@ -0,0 +1,29 @@
|
||||
//this function places received data into element with specified id.
|
||||
var/const/js_byjax = {"
|
||||
function replaceContent(id,content) {
|
||||
var parent = document.getElementById(id);
|
||||
if(typeof(parent)!=='undefined' && parent!=null){
|
||||
parent.innerHTML = content?content:'';
|
||||
}
|
||||
}
|
||||
"}
|
||||
|
||||
/*
|
||||
sends data to control_id:replaceContent
|
||||
|
||||
receiver - mob
|
||||
control_id - window id (for windows opened with browse(), it'll be "windowname.browser")
|
||||
target_element - HTML element id
|
||||
new_content - HTML content
|
||||
callback - js function that will be called after the data is sent //TODO: move callback processing to js
|
||||
callback_args - arguments for callback function
|
||||
|
||||
Be sure to include required js functions in your page, or it'll raise an exception.
|
||||
*/
|
||||
proc/send_byjax(receiver, control_id, target_element, new_content=null, callback=null, list/callback_args=null)
|
||||
if(receiver && target_element && control_id) // && winexists(receiver, control_id))
|
||||
receiver << output(list2params(list(target_element, new_content)),"[control_id]:replaceContent")
|
||||
if(callback)
|
||||
receiver << output(istype(callback_args)?list2params(callback_args):"","[control_id]:[callback]")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user