index.html 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <html>
  2. <head>
  3. <title>System Setting</title>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
  6. <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
  7. <script type="text/javascript" src="../../script/jquery.min.js"></script>
  8. <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
  9. <script type="text/javascript" src="../../script/ao_module.js"></script>
  10. <style>
  11. html{
  12. overflow:hidden;
  13. height:100%;
  14. }
  15. body{
  16. background-color:#fcfcfc;
  17. overflow:hidden !important;
  18. height:100%;
  19. }
  20. #mainSideMenuDimmer{
  21. width:100%;
  22. height:100%;
  23. position:fixed;
  24. top:0px;
  25. left:0px;
  26. background-color: rgba(26,26,26,0.3);
  27. z-index:99;
  28. }
  29. #mainSideMenu{
  30. z-index:100;
  31. }
  32. #settingContentLoader{
  33. overflow-x: hidden;
  34. overflow-y:auto;
  35. height: calc(100% - 60px);
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div id="mainSideMenu" class="ui left fixed vertical menu">
  41. <div class="item">
  42. <img class="ui image" src="img/banner.png">
  43. </div>
  44. </div>
  45. <div id="mainSideMenuDimmer" onclick="hideToolBar();"></div>
  46. <div class="ui top attached tabular menu" style="overflow-x:auto;overflow-y:hidden;">
  47. <a id="toolbarBtn" class="item" onclick="showToolBar();">
  48. <i class="content icon"></i>
  49. </a>
  50. <div class="right menu">
  51. <!--
  52. <div class="item">
  53. <div class="ui transparent icon input">
  54. <input id="searchInput" type="text" placeholder="Search Settings..." onkeydown="if (event.which == 13){ search(); }">
  55. <i class="search link icon" onclick="search();"></i>
  56. </div>
  57. </div>
  58. -->
  59. </div>
  60. </div>
  61. <div id="settingContentLoader" class="ui bottom attached segment">
  62. </div>
  63. </div>
  64. <script>
  65. var currentSettingModuleList = [];
  66. var loadViaSystemSetting = true; //Check for this parameter to see if launching in Setting Interface
  67. var loadToPage = undefined; //Load setting page directly to the given tab, passed in via window hash
  68. if (window.location.hash.length > 0){
  69. var hashObject = window.location.hash.substr(1);
  70. hashObject = JSON.parse(decodeURIComponent(hashObject));
  71. if (typeof(hashObject.group) != 'undefined' && typeof(hashObject.name) != 'undefined'){
  72. loadToPage = hashObject;
  73. }
  74. }
  75. //Initiation Functions
  76. initMainSideMenu();
  77. hideToolBar();
  78. if (loadToPage == undefined){
  79. initSettingGroup("Info");
  80. }else{
  81. initSettingGroup(loadToPage.group, function(settingList){
  82. let reversedList = JSON.parse(JSON.stringify(settingList)).reverse();
  83. for (var i = 0; i < settingList.length; i++){
  84. var settingTab = settingList[i];
  85. if (settingTab.Name == loadToPage.name){
  86. //This is the tab we are looking for
  87. initSettingModules(i - 1);
  88. }
  89. }
  90. });
  91. }
  92. function initMainSideMenu(){
  93. $.get("../../system/setting/list",function(data){
  94. for (var i =0; i < data.length; i++){
  95. var settingGroupName = data[i].Name;
  96. var groupUUID = data[i].Group;
  97. var iconPath = "../../" + data[i].IconPath;
  98. var toolTip = data[i].Desc;
  99. $("#mainSideMenu").append(`<a class="item" group="${groupUUID}" title="${toolTip}" style="padding:4px;" onclick="menuClicked(this);"><img class="ui middle aligned mini image" src="${iconPath}" style="padding: 2px;"></img> ${settingGroupName}</a>`);
  100. }
  101. });
  102. }
  103. function initSettingGroup(group, callback=undefined){
  104. $.get("../../system/setting/list?listGroup=" + group,function(data){
  105. if (data.error !== undefined){
  106. console.log(data.error);
  107. }else{
  108. currentSettingModuleList = data;
  109. initSettingModuleTabs();
  110. initSettingModules(0);
  111. if (callback != undefined){
  112. callback(data);
  113. }
  114. }
  115. });
  116. }
  117. function menuClicked(object){
  118. var group=$(object).attr("group");
  119. initSettingGroup(group);
  120. hideToolBar();
  121. }
  122. //Initiate the setting modules tabs
  123. function initSettingModuleTabs(){
  124. $(".settingTab").remove();
  125. var moduleListInReverse = currentSettingModuleList.reverse();
  126. for (var i =0; i < moduleListInReverse.length; i ++){
  127. var thisModuleInfo = moduleListInReverse[i];
  128. var stringifyModuleInfo = encodeURIComponent(JSON.stringify(thisModuleInfo));
  129. $("#toolbarBtn").after(`<a class="item settingTab" moduleInfo="${stringifyModuleInfo}" title="${thisModuleInfo.Desc}" onclick="loadSettingModuleFromTab(this);">${thisModuleInfo.Name}</a>`);
  130. }
  131. }
  132. function initSettingModules(index){
  133. var targetObject = $(".settingTab")[index];
  134. $(".settingTab.active").removeClass("active");
  135. if (targetObject !== undefined){
  136. //Select this object
  137. $(targetObject).addClass("active");
  138. //Load this object into the tab
  139. var settingModuleInfo = JSON.parse(decodeURIComponent($(targetObject).attr("moduleInfo")));
  140. var settingStartDir = settingModuleInfo.StartDir;
  141. $("#settingContentLoader").html("");
  142. $("#settingContentLoader").load("../../" + settingStartDir, function(){
  143. injectIMEToLoadedConetentFrame();
  144. });
  145. }
  146. }
  147. function loadSettingModuleFromTab(object){
  148. targetObject = $(object);
  149. $(".settingTab.active").removeClass("active");
  150. if (targetObject !== undefined){
  151. //Select this object
  152. $(targetObject).addClass("active");
  153. //Load this object into the tab
  154. var settingModuleInfo = JSON.parse(decodeURIComponent($(targetObject).attr("moduleInfo")));
  155. var settingStartDir = settingModuleInfo.StartDir;
  156. $("#settingContentLoader").html("");
  157. $("#settingContentLoader").load("../../" + settingStartDir, function(){
  158. injectIMEToLoadedConetentFrame();
  159. });
  160. }
  161. }
  162. function injectIMEToLoadedConetentFrame(){
  163. //Inject IME listener into the loaded content window
  164. var inputFields = document.getElementById("settingContentLoader").querySelectorAll("input,textarea");
  165. for (var i = 0; i < inputFields.length; i++){
  166. if ($(inputFields[i]).attr("type") != undefined){
  167. var thisType = $(inputFields[i]).attr("type");
  168. if (thisType == "text" || thisType =="search" || thisType =="url"){
  169. //Supported types of input
  170. if (ao_module_virtualDesktop){
  171. ao_module_bindCustomIMEEvents(inputFields[i]);
  172. }
  173. console.log(inputFields[i]);
  174. }else{
  175. //Not supported type of inputs
  176. }
  177. }else{
  178. //text area
  179. if (ao_module_virtualDesktop){
  180. ao_module_bindCustomIMEEvents(inputFields[i]);
  181. }
  182. }
  183. }
  184. }
  185. function hideToolBar(){
  186. $("#mainSideMenuDimmer").fadeOut('fast');
  187. $("#mainSideMenu").animate({left: -1 * $("#mainSideMenu").width()},300);
  188. }
  189. function showToolBar(){
  190. $("#mainSideMenuDimmer").fadeIn('fast');
  191. $("#mainSideMenu").animate({left: "0px"},300);
  192. }
  193. function search(){
  194. var keyword = $("#searchInput").val();
  195. alert(keyword);
  196. }
  197. </script>
  198. </body>
  199. </html>