123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139 |
- <?php
- include '../../auth.php';
- ?>
- <html>
- <head>
- <title>Module Driver Generator</title>
- <link rel="stylesheet" href="../script/tocas/tocas.css">
- <script src="../script/jquery.min.js"></script>
- </head>
- <body>
- <div class="ts container">
- <br><br>
- <h2>Home Dynamic System Module Driver Generator</h2>
- <p>This is a simple php script that use to generate driver template if you are developing a new module.<br>
- This script cannot help you to write all your codes but it can help in a way that you are given with the most basic to start with.</p>
- <form class="ts form">
- <div class="ts dividing header">Module Information</div>
- <div class="field">
- <label>Module Identifier</label>
- <div class="one fields">
- <div class="field">
- <input type="text" placeholder="e.g. relay.std.hd.com.imuslab">
- </div>
- </div>
- </div>
- <div class="field">
- <details class="ts accordion" open>
- <summary>
- <i class="dropdown icon"></i> Standard HDS Functions Mapping
- </summary>
- <div class="content">
- <table class="ts table">
- <thead>
- <tr>
- <th>#</th>
- <th>HDS key path definitions</th>
- <th>Mapping functions variable</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>1</td>
- <td>/</td>
- <td>DETAIL</td>
- </tr>
- <tr>
- <td>2</td>
- <td>/info</td>
- <td>INFO</td>
- </tr>
- <tr>
- <td>3</td>
- <td>/status</td>
- <td>STATUS</td>
- </tr>
- <tr>
- <td>4</td>
- <td>/uuid</td>
- <td>UUID</td>
- </tr>
- <tr>
- <td>5</td>
- <td>/on</td>
- <td>ON</td>
- </tr>
- <tr>
- <td>6</td>
- <td>/off</td>
- <td>OFF</td>
- </tr>
- </tbody>
- <tfoot>
- <tr>
- <th colspan="3">** Functions above are necessary for standard HDS module.</th>
- </tr>
- </tfoot>
- </table>
- </div>
- </details>
- </div>
-
- <div class="field">
- <table class="ts table">
- <thead>
- <tr>
- <th>#</th>
- <th>Custom path calls</th>
- <th>Mapping functions</th>
- <th>Remove Function</th>
- </tr>
- </thead>
- <tbody id="methods">
-
- </tbody>
- <tfoot>
- <tr>
- <th colspan="3">** The count of functions are only for easy visibility purpose. The script works with some number missing in the middle.</th>
- </tr>
- </tfoot>
- </table>
- <a class="ts button" onClick="addline();">Add Line</a>
- </div>
-
- <button class="ts button">Generate</button>
- </form>
- </div>
- <br><br><br><br><br><br><br><br><br><br><br>
- <script>
- var template = '<tr id="list_%ID%"><td>%ID%</td><td>%PATH%</td><td>%MAPPINGFUNCTION%</td><td><a onClick="remove(%ID%);">Remove</a></td></tr>';
- var counter = 0;
- var paths = [];
- var functionsmap = [];
- function addline(){
- var path = "/test";
- var functionmap = "TEST";
- if (paths.includes(path) || functionsmap.includes(functionmap)){
- //This function already mapped
- alert("This function has been mapped");
- return;
- }
- var box = template.split("%ID%").join(counter);
- box = box.replace("%PATH%",path);
- box = box.replace("%MAPPINGFUNCTION%",functionmap);
- $("#methods").append(box)
- counter++;
- }
- function remove(id){
- $("#list_" + id).remove();
- }
- </script>
- </body>
- </html>
|