Skip to content
This repository has been archived by the owner on Dec 24, 2020. It is now read-only.

Initialize config programmatically skipping machine.xml, XSL and CSS #64

Open
mihailik opened this issue May 22, 2018 · 1 comment
Open

Comments

@mihailik
Copy link
Contributor

It would be great if embedPCx86 could be fired with some extra parameters, to avoid the whole roundtrip fetching/parsing/resolving/transforming machine.xml and XSL (and CSS too).

For example a JS function is passed instead of sXMLFile argument, and PCx86 logic would call into it skipping whole processXML and the rest.




I think I got a general idea how the logic works there, except still very hazy about binding HTML elements to components.

Maybe you can direct me towards relevant parts of the code, and I can try to implement such a shortcut JS functionality?

@jeffpar
Copy link
Owner

jeffpar commented May 22, 2018

Would that save much? Every machine XML file refers in turn to ROM images (and usually 1 or more disk images) that must be preloaded before the machine can be allowed to start. How are you envisioning those resources being stored and supplied to embedXXX()?

The XML serves two purposes: defining component appearance and defining component initialization properties. Using an XSL file, each XML component tag is transformed into a set of HTML tags -- usually just DIVs -- that collectively describe the machine's appearance. For each component, one of the DIVs is usually what I consider the "object" DIV -- ie, a DIV with a class suffix "-object" and a data-value attribute containing all the parameters used to initialize an object of the appropriate class.

See the static init() function in any of the component class files; they're all very similar. The init() function calls getComponentParms() to extract the data-value attributes from the object DIV, passes them to the component's constructor, and then calls bindComponentControls() with the new object and the DIV. That function looks through all the DIV's child elements that have a "-binding" class and calls the object's setBinding() function. At a minimum, setBinding() will simply record the HTML control (button, list, or whatever) and add whatever onclick, onchange, etc, handlers it needs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants