<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Q Light Controller Plus - RGBScript Development Tool</title>
<style>
  .readonly {
    background-color: lightgrey;
    border: solid 0px;
  }
  body {
    background: #373737;
    color: #f9f8f0;
    font-family: Arial;
  }
  h2 {
    background: #aaa;
    color: #333;
    padding: 10px;
  }
  .box {
    padding: 10px;
    display: inline-block;
    vertical-align:top;
    min-width: 200px;
  }
  input[type=button] {
    background-color: #7497b6;
    border: none;
    color: white;
    padding: 5px 10px;
    text-decoration: none;
    margin: 4px 2px;
    font-size: 16px;
    cursor: pointer;
  }
  input[type=button]:hover {
    background-color: #8db8dd;
  }
</style>
<script type="text/javascript" src="devtool/devtool.js"></script>
</head>
<body onLoad="devtool.loadAlgoFile()">

<h1>Q Light Controller Plus - RGB Script Development Tool</h1>

<div>
<h2>Instructions</h2>
<p>
To use this tool, you must first set the filename of the script you intend to test/debug
(including the .js extension) in the 'filename' field. Then hit 'Reload' to load it.
To make your algorithm object accessible to this tool, you must create a global variable
within your algorithm file called <b>testAlgo</b>, which then actually contains your algorithm
object i.e. the object that provides rgbMap() and rgbMapStepCount() functions. Now you're ready to load
this file with your browser and see your first results.
</p>

<p>
If you see what you expect to see in the <b>Algorithm Properties</b> section below,
you'll know your script has been evaluated successfully. Next, put some values to the
<b>Width</b> and <b>Height</b> boxes in the <b>Grid Size</b> section and see if your
script calculates the <b>rgbMapStepCount(width, height)</b> result correctly.
If everything is OK, you should already see your RGB script running through frames.
To inspect individual frames, stop the script and hit the previous and next buttons.
</p>

<b>
For troubleshooting purposes, I would suggest using some good JavaScript development
tools for your browser. Mozilla FireFox has a built-in Web Console behind <i>Tools -> Web
Developer</i> which is very useful in hunting errors within the JavaScript code.
Google Chrome has one as well, that you can access with F12 or with <i>More Tools -> Developer Tools (Ctrl+Shift+I)</i>
</b>
</div>

<div class="box">
<h2>Algorithm Specification</h2>
<form>
<table id="definitions">
 <tr>
  <td>filename</td>
  <td><input type="text" size="12" id="filename" value="Enter filename here." onChange="devtool.onFilenameUpdated(this.value)"/></td>
 </tr>
 <tr>
  <td>apiVersion</td>
  <td><input type="text" readonly="readonly" class="readonly" size="3" id="apiversion"/></td>
 </tr>
 <tr>
  <td>name</td>
  <td><input type="text" readonly="readonly" class="readonly" id="name"/></td>
 </tr>
 <tr>
  <td>author</td>
  <td><input type="text" readonly="readonly" class="readonly" id="author"/></td>
 </tr>
 <tr>
  <td>acceptColors</td>
  <td><input type="text" readonly="readonly" class="readonly" id="acceptColors"/></td>
 </tr>
 <tr>
  <td colspan="2">
   <input type="button" value="Reload" onClick="location.reload()"/>
  </td>
 </tr>
</table>
</form>

<h2>Grid Size</h2>
<form>
<table>
 <tr>
  <td>Width</td>
  <td><input type="number" min="1" id="gridwidth" value="15" size="4" style="width: 8em;" required onChange="devtool.onGridSizeUpdated()"/></td>
 </tr>
 <tr>
  <td>Height</td>
  <td><input type="number" min="1" id="gridheight" value="15" size="4" style="width: 8em;" required onChange="devtool.onGridSizeUpdated()"/></td>
 </tr>
 <tr>
  <td>Size</td>
  <td><input type="number" min="1" max="20" id="gridsize" value="20" size="4" style="width: 8em;" required onChange="devtool.onGridSizeUpdated()"/></td>
 </tr>
</table>
</form>

</div>

<div class="box">
<form id="pixelColorChooser">
<h2>Pixel colors</h2>
<table id="colorChooserTable">
</table>
</form>

<h2>Algorithm Properties</h2>
<form>
<table id="properties">
</table>
</form>

<h2>Algorithm Functions</h2>
<form>
<table>
 <tr>
  <td>rgbMapStepCount(width, height)</td>
  <td><input TYPE="text" readonly="readonly" class="readonly" size="3" id="stepCount"/></td>
 </tr>
</table>
</form>

<form>
<table>
 <tr>
  <td>rgbMap(width, height, rgb, <b>step</b>)
   <input type="number" min="0" id="currentStep" onChange="devtool.writeCurrentStep()"/>
  </td>
 </tr>
 <tr>
  <td>
   <span>
    <input type="button" value="Previous" onClick="devtool.previousStep()"/>
    <input type="button" value="Next" onClick="devtool.nextStep()"/>
   </span>
   <span>
    <input type="button" value="Start test" onClick="devtool.startTest(1)"/>
    <input type="button" value="Stop test" onClick="devtool.stopTest()"/>
    <input type="button" value="Start reversed" onClick="devtool.startTest(-1)"/>
   </span>
  </td>
 </tr>
 <tr>
  <td>
   Alternate: <input type="checkbox" id="alternate" onChange="devtool.onAlternateChanged()"/>
  </td>
 </tr>
 <tr>
  <td>
   Speed (ms): <input type="number" min="1" id="speed" value="500" size="4" style="width: 8em;" onChange="devtool.onSpeedChanged()"/>
  </td>
 </tr>
</table>
</form>

</div>

<div class="box">
<h2>Preview</h2>
<table id="map">
</table>
</div>

<hr/>
This file is licensed under the Apache 2.0 license. Copyright &copy; Heikki Junnila, Massimo Callegari, APIv2 & APIv3 integration: Hans-Jürgen Tappe.

</body>
</html>