index.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="apple-mobile-web-app-capable" content="yes" />
  5. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  6. <meta charset="UTF-8">
  7. <meta name="theme-color" content="#4b75ff">
  8. <link rel="stylesheet" href="../script/semantic/semantic.min.css">
  9. <script src="../script/jquery.min.js"></script>
  10. <script src="../script/ao_module.js"></script>
  11. <script src="../script/semantic/semantic.min.js"></script>
  12. <script type="application/javascript" src="../script/clipboard.min.js"></script>
  13. <title>ARZ Serverless</title>
  14. <style>
  15. body{
  16. background-color:white;
  17. }
  18. /* Tooltip container */
  19. .tooltip {
  20. position: relative;
  21. display: inline-block;
  22. border-bottom: 1px dotted black; /* If you want dots under the hoverable text */
  23. }
  24. /* Tooltip text */
  25. .tooltip .tooltiptext {
  26. visibility: hidden;
  27. width: 120px;
  28. background-color: #555;
  29. color: #fff;
  30. text-align: center;
  31. padding: 5px 0;
  32. border-radius: 6px;
  33. /* Position the tooltip text */
  34. position: absolute;
  35. z-index: 1;
  36. bottom: 125%;
  37. left: 50%;
  38. margin-left: -60px;
  39. /* Fade in tooltip */
  40. opacity: 0;
  41. transition: opacity 0.3s;
  42. }
  43. /* Tooltip arrow */
  44. .tooltip .tooltiptext::after {
  45. content: "";
  46. position: absolute;
  47. top: 100%;
  48. left: 50%;
  49. margin-left: -5px;
  50. border-width: 5px;
  51. border-style: solid;
  52. border-color: #555 transparent transparent transparent;
  53. }
  54. </style>
  55. </head>
  56. <body>
  57. <div class="ui container" style="height: 100% !important;">
  58. <div>
  59. <br>
  60. <h1 class="ui header">
  61. <span id="normalStatus">ARZ Serverless</span>
  62. <div class="sub header">
  63. You can run our own AGI script without login by setting up the configuration below
  64. </div>
  65. </h1>
  66. </div>
  67. <div class="ui divider"></div>
  68. <div id="deleteSuceed" style="display:none;" class="ui green inverted segment"><i class="checkmark icon"></i>Deleted</div>
  69. <div>
  70. <table class="ui celled table">
  71. <thead>
  72. <tr>
  73. <th>UUID (access token)</th>
  74. <th>AGI Path</th>
  75. <th>Action</th>
  76. </tr>
  77. </thead>
  78. <tbody id="records">
  79. </tbody>
  80. </table>
  81. <div style="width: 100%" align="center">
  82. <div class="ui breadcrumb" id="pageIndexs">
  83. </div>
  84. </div>
  85. </div>
  86. <div class="ui divider"></div>
  87. <div id="updateSuceed" style="display:none;" class="ui green inverted segment"><i class="checkmark icon"></i>Added</div>
  88. <h4>Select AGI script Location</h4>
  89. <div class="ui action fluid input">
  90. <input id="agiPath" type="text" placeholder="Select Location" readonly="true">
  91. <button class="ui black button" onclick="openfileselector();"><i class="folder open icon"></i> Open</button>
  92. </div>
  93. <br>
  94. <button class="ui positive button" onclick="add();">Add</button>
  95. <br><br>
  96. </div>
  97. <script>
  98. $.getJSON( "/api/ajgi/listExt", function( data ) {
  99. $.each( data, function( key, val ) {
  100. appendTable(key, val.path);
  101. });
  102. if(Object.keys(data).length == 0) {
  103. $("#records").append(`<tr id="zeroRec"><td>0 record returned.</td></tr>`);
  104. }
  105. });
  106. function openfileselector(){
  107. ao_module_openFileSelector(fileLoader, "user:/", "file",false, {filter:["agi"]});
  108. }
  109. function fileLoader(filedata){
  110. for (var i=0; i < filedata.length; i++){
  111. var filename = filedata[i].filename;
  112. var filepath = filedata[i].filepath;
  113. $("#agiPath").val(filepath);
  114. }
  115. }
  116. function add() {
  117. var path = $("#agiPath").val();
  118. $.getJSON( "/api/ajgi/addExt?path=" + path, function( data ) {
  119. if(data.error == undefined) {
  120. $("#updateSuceed").slideDown("fast").delay(3000).slideUp("fast");
  121. appendTable(data, path);
  122. }else{
  123. alert(data.error);
  124. }
  125. });
  126. }
  127. function delRecord(element) {
  128. $.getJSON( "/api/ajgi/rmExt?uuid=" + $(element).attr("uuid"), function( data ) {
  129. if(data == "OK") {
  130. $("#deleteSuceed").slideDown("fast").delay(3000).slideUp("fast");
  131. }else{
  132. alert(data.error);
  133. }
  134. });
  135. $(element).parent().parent().remove().slideUp("fast");
  136. if($("#records").html().trim() == '') {
  137. $("#records").append(`<tr id="zeroRec"><td>0 record returned.</td></tr>`);
  138. }
  139. }
  140. var tokenAccessPath = location.protocol + "//" + window.location.host + "/api/remote/";
  141. new ClipboardJS('.copyURL', {
  142. text: function(trigger) {
  143. var token = $(trigger).attr("token");
  144. var url = tokenAccessPath + token;
  145. console.log( $(trigger).find(".tooltiptext"));
  146. $(trigger).find(".tooltiptext").css({
  147. "visibility": "visible",
  148. "opacity": 1,
  149. });
  150. setTimeout(function(){
  151. $(trigger).find(".tooltiptext").css({
  152. "visibility": "hidden",
  153. "opacity": 0,
  154. });
  155. }, 3000);
  156. return url;
  157. }
  158. });
  159. function generateClipboardText(uuid) {
  160. return `
  161. <div>
  162. <div class="content" style="font-family: monospace;">
  163. ${uuid} <a style="margin-left: 12px; font-family: Arial;" token="${uuid}" class="copyURL tooltip">
  164. <i class="copy icon"></i> Copy
  165. <span class="tooltiptext"><i class="checkmark icon"></i> Copied</span>
  166. </a>
  167. </div>
  168. </div>
  169. `;
  170. }
  171. function appendTable(uuid, path) {
  172. $("#zeroRec").remove().slideUp("fast");
  173. $("#records").append(`<tr>
  174. <td>` + generateClipboardText(uuid) +`</td>
  175. <td>` + path + `</td>
  176. <td>
  177. <button class="ui icon negative button" uuid="` + uuid + `" onclick="delRecord(this)">
  178. <i class="close icon"></i>
  179. </button>
  180. </td>
  181. </tr>`);
  182. }
  183. </script>
  184. </body>
  185. </html>