182 lines
6.3 KiB
JavaScript
182 lines
6.3 KiB
JavaScript
![]() |
// ******************************************************************
|
||
|
// helper functions
|
||
|
// ******************************************************************
|
||
|
|
||
|
function escapeBackslashes(s)
|
||
|
{
|
||
|
return s.replace(/\\/g, '\\\\');
|
||
|
}
|
||
|
|
||
|
// ******************************************************************
|
||
|
// object Sample
|
||
|
// ******************************************************************
|
||
|
|
||
|
// **********************************************
|
||
|
// constructor
|
||
|
|
||
|
function Sample(sID, sDesc, sSlnPath, sSlnDesc, sScreenshot, sOutputPath, sWin32Launch, sXenonLaunch, sPS3Launch, sGenericLaunch)
|
||
|
{
|
||
|
// sampleID needs to be unique and a single word
|
||
|
this.sampleID = sID;
|
||
|
// sampleDesc can be any string describing the sample
|
||
|
this.sampleDesc = sDesc;
|
||
|
|
||
|
// solutionPath is the relative path to the solution file for this sample
|
||
|
this.solutionPath = sSlnPath;
|
||
|
// solutionDesc is a shorter form of the solution path for use in the link to the solution file
|
||
|
this.solutionDesc = sSlnDesc;
|
||
|
// screenshotName is the name of the screenshot file (the thumbnail name is generated by prepending "tn_" onto this name)
|
||
|
this.screenshotName = sScreenshot;
|
||
|
// outputPath is a the path to the output file
|
||
|
this.outputPath = sOutputPath;
|
||
|
// win32Launch is the full command to run when launching this sample on win32
|
||
|
this.win32Launch = sWin32Launch;
|
||
|
// xenonLaunch is the full command to run when launching this sample on xenon
|
||
|
this.xenonLaunch = sXenonLaunch;
|
||
|
// ps3Launch is the full command to run when launching this sample on ps3
|
||
|
this.ps3Launch = sPS3Launch;
|
||
|
// genericLaunch is a general command to run
|
||
|
this.genericLaunch = sGenericLaunch;
|
||
|
}
|
||
|
|
||
|
// **********************************************
|
||
|
// methods
|
||
|
|
||
|
Sample.prototype.generateHTML = function(sectionID)
|
||
|
{
|
||
|
// NOTE: since the text in the openSolution function call below is code, it needs to be escaped again
|
||
|
solution = '<span style="cursor: hand; text-decoration: underline; color: blue;" onClick="openSolution(\'' + escapeBackslashes(this.solutionPath) + '\'); return true;">' + this.solutionDesc + '</span>';
|
||
|
|
||
|
screenshot = (this.screenshotName == null) ? '<img src="screens/rockstar_symbol.JPG"/>' : '<a href="screens/' + this.screenshotName + '"><img src="screens/tn_' + this.screenshotName + '"/>';
|
||
|
|
||
|
output = (this.outputPath == null) ? 'N/A' : '<a href="output/' + this.outputPath + '">OUTPUT</a>';
|
||
|
|
||
|
// NOTE: since the text in the launch/run function calls below is code, it needs to be escaped again
|
||
|
launch = (this.win32Launch == null) ? '' : '<input type="button" value="Win32" onClick="launchSample(\'' + escapeBackslashes(this.win32Launch) + '\'); return true;" id="btn_win32_' + sectionID + '_' + this.sampleID + '"/><br/>';
|
||
|
launch += (this.xenonLaunch == null) ? '' : '<input type="button" value="XENON" onClick="launchSample(\'' + escapeBackslashes(this.xenonLaunch) + '\'); return true;" id="btn_xenon_' + sectionID + '_' + this.sampleID + '"/><br/>';
|
||
|
launch += (this.ps3Launch == null) ? '' : '<input type="button" value="PS3" onClick="launchSample(\'' + escapeBackslashes(this.ps3Launch) + '\'); return true;" id="btn_ps3_' + sectionID + '_' + this.sampleID + '"/><br/>';
|
||
|
launch += (this.genericLaunch == null) ? '' : '<input type="button" value="Run" onClick="justRunIt(\'' + escapeBackslashes(this.genericLaunch) + '\'); return true;" id="btn_gen_' + sectionID + '_' + this.sampleID + '"/><br/>';
|
||
|
if(launch == "")
|
||
|
launch = "N/A";
|
||
|
|
||
|
h = '<tr>\n' +
|
||
|
' <td>' + solution + '</td>\n' +
|
||
|
' <td>' + screenshot + '</td>\n' +
|
||
|
' <td>' + output + '</td>\n' +
|
||
|
' <td>' + this.sampleDesc + '</td>\n' +
|
||
|
' <td>' + launch + '</td>\n' +
|
||
|
'</tr>\n';
|
||
|
// uncomment this to get an alert dialog for each sample (there will be a lot of these!)
|
||
|
//window.alert(h);
|
||
|
|
||
|
return h;
|
||
|
}
|
||
|
|
||
|
// ******************************************************************
|
||
|
// object Section
|
||
|
// ******************************************************************
|
||
|
|
||
|
// **********************************************
|
||
|
// constructor
|
||
|
|
||
|
function Section(sID, sName)
|
||
|
{
|
||
|
// sectionID needs to be unique and a single word
|
||
|
this.sectionID = sID;
|
||
|
// sectionName can be any string
|
||
|
this.sectionName = sName;
|
||
|
this.samples = new Array();
|
||
|
}
|
||
|
|
||
|
// **********************************************
|
||
|
// methods
|
||
|
|
||
|
Section.prototype.appendSample = function(newSample)
|
||
|
{
|
||
|
if(newSample instanceof Sample)
|
||
|
{
|
||
|
this.samples.push(newSample);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
throw "invalid object passed to Section.appendSample";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Section.prototype.generateHeaderHTML = function()
|
||
|
{
|
||
|
return "<a href=\"#anchor_" + this.sectionID + "\"><b>" + this.sectionName + "</b></a><br>\n";
|
||
|
}
|
||
|
|
||
|
Section.prototype.generateHTML = function()
|
||
|
{
|
||
|
html = "";
|
||
|
for(i = 0; i < this.samples.length; i++)
|
||
|
{
|
||
|
html += this.samples[i].generateHTML(this.sectionID);
|
||
|
}
|
||
|
section = "<a name=\"anchor_" + this.sectionID + "\"><b>" + this.sectionName + "</b></a>\n<div id=\"section_" + this.sectionID + "\">" + this.tableHeader() + html + this.tableFooter() + "</div><br>\n";
|
||
|
// uncomment this to get an alert dialog for each section
|
||
|
//window.alert(section);
|
||
|
return section;
|
||
|
}
|
||
|
|
||
|
Section.prototype.tableHeader = function()
|
||
|
{
|
||
|
return "<table width=\"100%\" border=\"2\" ID=\"table_" + this.sectionID + "\">\n<tr><td width=\"30%\">SAMPLE</td><td width=\"10%\">SCREENSHOT</td><td width=\"10%\">OUTPUT</td><td width=\"40%\">Description</td><td width=\"10%\">LAUNCH</td></tr>\n";
|
||
|
}
|
||
|
|
||
|
Section.prototype.tableFooter = function()
|
||
|
{
|
||
|
return "</table>\n<a href=\"#Top\">Return to Top</a>\n";
|
||
|
}
|
||
|
|
||
|
// ******************************************************************
|
||
|
// object SectionContainer
|
||
|
// ******************************************************************
|
||
|
|
||
|
// **********************************************
|
||
|
// constructor
|
||
|
|
||
|
function SectionContainer()
|
||
|
{
|
||
|
this.sections = new Array();
|
||
|
}
|
||
|
|
||
|
// **********************************************
|
||
|
// methods
|
||
|
|
||
|
SectionContainer.prototype.appendSection = function(newSection)
|
||
|
{
|
||
|
if(newSection instanceof Section)
|
||
|
{
|
||
|
this.sections.push(newSection);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
throw "invalid object passed to SectionContainer.appendSection";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
SectionContainer.prototype.generateHTML = function()
|
||
|
{
|
||
|
var i;
|
||
|
var html = "";
|
||
|
for(i = 0; i < this.sections.length; i++)
|
||
|
{
|
||
|
html += this.sections[i].generateHTML();
|
||
|
}
|
||
|
return html;
|
||
|
}
|
||
|
|
||
|
SectionContainer.prototype.generateHeaderHTML = function()
|
||
|
{
|
||
|
var i;
|
||
|
var html = "";
|
||
|
for(i = 0; i < this.sections.length; i++)
|
||
|
{
|
||
|
html += this.sections[i].generateHeaderHTML();
|
||
|
}
|
||
|
return html;
|
||
|
}
|