I have a simple web page that loads a list of topics from a file "dsdx_doc.txt". This file contains html code to organize text into divisions with id's, and event callbacks for onmouseover, onmouseout, and onclick. Here's a snippet:
- Code: Select all
<div id="doc_intro" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">Introduction to the DSDX Library</div>
<div id="doc_about" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">About the DSDX Library</div>
<div id="doc_using" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">Using the DSDX Library</div>
<ul>
<li id="doc_using_register" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">Registering and Unregistering the COM renderers</li>
<li id="doc_using_create" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">Creating and Destroying the renderers</li>
<li id="doc_using_query" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">Querying the target renderers</li>
<li id="doc_using_require" onclick="LoadContent(this);" onmouseover="HighlightContent(this);" onmouseout="UnhighlightContent(this);">Requirements for stable video rendering</li>
</ul>
The page is also responsible for loading a body of text related to the topic selected. For instance, if the heading "Using the DSDX Library" is selected (as seen in above code), then the page would load the content related, namely a description on using the library.
The "onclick" event handler calls the function LoadContent(), passing the element it is being called from as argument (or "this"). Internally, the element's id is extracted and is used to determine the file from which to load contents.
- Code: Select all
function LoadContent(srcDiv) {
var destDiv = document.getElementById("contents");
var id = srcDiv.getAttribute("id"); //id extracted from srcDiv
var fileName = "dsdx_" + id + ".txt"; //file name figured
LoadXml(fileName, destDiv);
}
In other words, if the division of id "
doc_using" is selected, the file "dsdx_
doc_using.txt" is retrieved for processing.
The contents of the requested file are written to another part of the page, under the element with id "contents". The files generally carry just html, such as "dsdx_doc_using.txt":
- Code: Select all
<h1>Using the DSDX Library</h1>
<p>This section describes in detail the steps required to use the DSDX Library in an application.</p>
<p>There are nine steps to using the library within an application. They are:</p>
<ol>
<li>Register the library with the system</li>
<li>Create an instance of the renderer</li>
<li>Connect the renderer to a filter graph and run the graph</li>
<li>Present the media samples</li>
<li>Use the target resources in the app</li>
<li>Repeat steps 4 and 5 for the duration of the app</li>
<li>Close the filter graph</li>
<li>Destroy the instance of the renderer</li>
<li>Unregister the library with the system</li>
</ol>
<p>The following articles detail these processes more specifically.</p>
<p>Registering and Unregistering the COM renderers</p>
<p>Creating and Destroying the Renderers</p>
<p>Querying the Target Renderers</p>
<p>Requirements for Stable Video Rendering</p>