driver_gen.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <?php
  2. include '../../auth.php';
  3. ?>
  4. <html>
  5. <head>
  6. <title>Module Driver Generator</title>
  7. <link rel="stylesheet" href="../script/tocas/tocas.css">
  8. <script src="../script/jquery.min.js"></script>
  9. </head>
  10. <body>
  11. <div class="ts container">
  12. <br><br>
  13. <h2>Home Dynamic System Module Driver Generator</h2>
  14. <p>This is a simple php script that use to generate driver template if you are developing a new module.<br>
  15. 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>
  16. <form class="ts form">
  17. <div class="ts dividing header">Module Information</div>
  18. <div class="field">
  19. <label>Module Identifier</label>
  20. <div class="one fields">
  21. <div class="field">
  22. <input type="text" placeholder="e.g. relay.std.hd.com.imuslab">
  23. </div>
  24. </div>
  25. </div>
  26. <div class="field">
  27. <details class="ts accordion" open>
  28. <summary>
  29. <i class="dropdown icon"></i> Standard HDS Functions Mapping
  30. </summary>
  31. <div class="content">
  32. <table class="ts table">
  33. <thead>
  34. <tr>
  35. <th>#</th>
  36. <th>HDS key path definitions</th>
  37. <th>Mapping functions variable</th>
  38. </tr>
  39. </thead>
  40. <tbody>
  41. <tr>
  42. <td>1</td>
  43. <td>/</td>
  44. <td>DETAIL</td>
  45. </tr>
  46. <tr>
  47. <td>2</td>
  48. <td>/info</td>
  49. <td>INFO</td>
  50. </tr>
  51. <tr>
  52. <td>3</td>
  53. <td>/status</td>
  54. <td>STATUS</td>
  55. </tr>
  56. <tr>
  57. <td>4</td>
  58. <td>/uuid</td>
  59. <td>UUID</td>
  60. </tr>
  61. <tr>
  62. <td>5</td>
  63. <td>/on</td>
  64. <td>ON</td>
  65. </tr>
  66. <tr>
  67. <td>6</td>
  68. <td>/off</td>
  69. <td>OFF</td>
  70. </tr>
  71. </tbody>
  72. <tfoot>
  73. <tr>
  74. <th colspan="3">** Functions above are necessary for standard HDS module.</th>
  75. </tr>
  76. </tfoot>
  77. </table>
  78. </div>
  79. </details>
  80. </div>
  81. <div class="field">
  82. <table class="ts table">
  83. <thead>
  84. <tr>
  85. <th>#</th>
  86. <th>Custom path calls</th>
  87. <th>Mapping functions</th>
  88. <th>Remove Function</th>
  89. </tr>
  90. </thead>
  91. <tbody id="methods">
  92. </tbody>
  93. <tfoot>
  94. <tr>
  95. <th colspan="3">** The count of functions are only for easy visibility purpose. The script works with some number missing in the middle.</th>
  96. </tr>
  97. </tfoot>
  98. </table>
  99. <a class="ts button" onClick="addline();">Add Line</a>
  100. </div>
  101. <button class="ts button">Generate</button>
  102. </form>
  103. </div>
  104. <br><br><br><br><br><br><br><br><br><br><br>
  105. <script>
  106. var template = '<tr id="list_%ID%"><td>%ID%</td><td>%PATH%</td><td>%MAPPINGFUNCTION%</td><td><a onClick="remove(%ID%);">Remove</a></td></tr>';
  107. var counter = 0;
  108. var paths = [];
  109. var functionsmap = [];
  110. function addline(){
  111. var path = "/test";
  112. var functionmap = "TEST";
  113. if (paths.includes(path) || functionsmap.includes(functionmap)){
  114. //This function already mapped
  115. alert("This function has been mapped");
  116. return;
  117. }
  118. var box = template.split("%ID%").join(counter);
  119. box = box.replace("%PATH%",path);
  120. box = box.replace("%MAPPINGFUNCTION%",functionmap);
  121. $("#methods").append(box)
  122. counter++;
  123. }
  124. function remove(id){
  125. $("#list_" + id).remove();
  126. }
  127. </script>
  128. </body>
  129. </html>