index.html 11 KB

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