personalization.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta name="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. <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
  8. <script src="../../script/jquery.min.js"></script>
  9. <script src="../../script/semantic/semantic.min.js"></script>
  10. <script src="../../script/ao_module.js"></script>
  11. <style>
  12. .hidden{
  13. display:none;
  14. }
  15. .backgroundpreview{
  16. border: 1px solid #898989;
  17. }
  18. </style>
  19. </head>
  20. <body>
  21. <div class="ui tabular menu" style="position:fixed; top:0px; left:0px; width: 100%;">
  22. <div class="active item" data-tab="wallpaper">Wallpaper</div>
  23. <div class="item" data-tab="theme">Theme</div>
  24. <div class="item" data-tab="advance">Advance</div>
  25. </div>
  26. <div style="position:fixed; top: 42px; left:0px; width: 100%; height: calc(100% - 42px); overflow-y:auto;">
  27. <div class="ui active tab" data-tab="wallpaper">
  28. <!-- Wallpaper Functions -->
  29. <br>
  30. <div class="ui container">
  31. <h3 class="ui header">
  32. <i class="image outline icon"></i>
  33. <div class="content">
  34. Wallpapers
  35. <div class="sub header">Manage your desktop preferences</div>
  36. </div>
  37. </h3>
  38. <div class="ui divider"></div>
  39. <div class="ui grid">
  40. <div class="ten wide column">
  41. <img id="mainBackground" class="ui fluid image backgroundpreview" src="">
  42. </div>
  43. <div class="six wide column">
  44. </div>
  45. </div>
  46. <div class="ui divider"></div>
  47. <div id="backgroundPreviewList" class="ui grid">
  48. <div class="four wide column">
  49. <img class="ui fluid image backgroundpreview" src="">
  50. </div>
  51. <div class="four wide column">
  52. <img class="ui fluid image backgroundpreview" src="">
  53. </div>
  54. <div class="four wide column">
  55. <img class="ui fluid image backgroundpreview" src="">
  56. </div>
  57. <div class="four wide column">
  58. <img class="ui fluid image backgroundpreview" src="">
  59. </div>
  60. </div>
  61. <div class="ui divider"></div>
  62. <h4 class="ui header">
  63. Background Wallpaper
  64. <div class="sub header">Set your desktop background wallpaper theme.</div>
  65. </h4>
  66. <select id="wallpaperlist" class="ui fluid dropdown allowSelectDefaultThemes" onchange="handleBackgroundSelectionChange(this.value);">
  67. <option value="">Wallpaper Packs</option>
  68. </select>
  69. <small>This option will be disabled by default if you have set your "User Defined Wallpaper" in Advance tab.</small>
  70. <br> <br>
  71. <button class="ui small green right floated button allowSelectDefaultThemes" onclick="applyWallpaper();"><i class="checkmark icon"></i> Apply Wallpaper</button>
  72. <br><br><br>
  73. <div class="ui green segment" style="display:none" id="wallpaperChangeConfirm">
  74. <h4 class="ui header">
  75. <i class="checkmark green icon"></i>
  76. <div class="content">
  77. Wallpaper Updated
  78. <div class="sub header">You should be seeing your desktop wallpaper change in a moment.</div>
  79. </div>
  80. </h4>
  81. </div>
  82. <!-- Wallpaper change interval-->
  83. <div class="ui divider"></div>
  84. <h4 class="ui header">
  85. Wallpaper Interval
  86. <div class="sub header">Set the interval between the wallpaper image cycles.</div>
  87. </h4>
  88. <select id="changeInterval" class="ui fluid dropdown" onchange="handleIntervalChange(this.value);">
  89. <option value="10">10 seconds</option>
  90. <option value="30">30 seconds</option>
  91. <option value="60">60 seconds</option>
  92. <option value="180">3 minutes</option>
  93. <option value="300">5 minutes</option>
  94. <option value="600">10 minutes</option>
  95. <option value="1800">30 minutes</option>
  96. <option value="3600">1 hour</option>
  97. </select>
  98. <div class="ui green segment" style="display:none" id="interfaceChangeConfirm">
  99. <h4 class="ui header">
  100. <i class="checkmark green icon"></i>
  101. <div class="content">
  102. Wallpaper Interval Updated
  103. <div class="sub header">This setting will only apply to this browser</div>
  104. </div>
  105. </h4>
  106. </div>
  107. </div>
  108. <br><br><br>
  109. </div>
  110. <div class="ui tab" data-tab="theme">
  111. <!-- Theme Color Related !-->
  112. <br>
  113. <div class="ui container">
  114. <h3 class="ui header">
  115. <i class="paint brush icon"></i>
  116. <div class="content">
  117. Theme Color
  118. <div class="sub header">Change the system theme color settings</div>
  119. </div>
  120. </h3>
  121. <div class="ui divider"></div>
  122. <p>Work In Progress</p>
  123. </div>
  124. </div>
  125. <div class="ui tab" data-tab="advance">
  126. <!-- Advance User Customization !-->
  127. <br>
  128. <div class="ui container">
  129. <h3 class="ui header">
  130. <i class="setting icon"></i>
  131. <div class="content">
  132. Advance Customization
  133. <div class="sub header">Manage your desktop preferences</div>
  134. </div>
  135. </h3>
  136. <div class="ui divider"></div>
  137. <h4 class="ui header">
  138. User Defined Wallpaper
  139. <div class="sub header">Advanced user customization function for desktop interface</div>
  140. </h4>
  141. <h3 id="userSelectedFolderPath">Disabled</h3>
  142. <p>If you have set a folder for loading desktop wallpapers, the image files from that folder will be used instead of the system build in wallpapers.</p>
  143. <button class="ui small right floated button" onclick="clearUserSelectedFolder();"><i class="remove icon"></i> Clear Selection</button>
  144. <button class="ui small black right floated button" onclick="selectUserFolder();"><i class="folder open icon"></i> Select Folder</button>
  145. <br><br>
  146. </div>
  147. </div>
  148. </div>
  149. <br><br>
  150. <script>
  151. var desktopThemeList = [];
  152. var isStartingUp = true;
  153. $(".dropdown").dropdown();
  154. $('.tabular.menu .item').tab();
  155. //Startup process
  156. initDefaultBackgroundChangeValue();
  157. initUserDefinedWallpaperFolder(function(themeName){
  158. initCurrentBackgroundPreview(themeName);
  159. });
  160. //Return the data stored in the theme settings
  161. //Will return either theme pack name or path for user defined folder
  162. function initUserDefinedWallpaperFolder(callback = undefined){
  163. $.get("../../system/desktop/theme?get=true", function(data) {
  164. if (data.includes(":/")){
  165. //This is a path
  166. $("#userSelectedFolderPath").text(data);
  167. $(".allowSelectDefaultThemes").addClass("disabled");
  168. }else{
  169. $("#userSelectedFolderPath").text("Disabled");
  170. }
  171. if (callback != undefined){
  172. callback(data);
  173. }
  174. });
  175. }
  176. function initDefaultBackgroundChangeValue(){
  177. if (localStorage.getItem("ao/desktop/backgroundInterval") == null){
  178. //No background interval set.
  179. $("#changeInterval").dropdown("set selected", "30");
  180. }else{
  181. //There is already a setting for background interval change. Use that instead
  182. var changeInterval = localStorage.getItem("ao/desktop/backgroundInterval");
  183. $("#changeInterval").dropdown("set selected", changeInterval);
  184. }
  185. }
  186. //Change the interval to the given
  187. function handleIntervalChange(newInterval){
  188. //Show change finsihed
  189. if (isStartingUp){
  190. //Ignore startup change
  191. return;
  192. }
  193. //Save interval to localStorage
  194. localStorage.setItem("ao/desktop/backgroundInterval", newInterval)
  195. $("#interfaceChangeConfirm").slideDown('fast').delay(3000).slideUp('fast');
  196. //Restart desktop background changer interval
  197. if (ao_module_virtualDesktop){
  198. console.log("Restarting desktop background changer interval")
  199. parent.clearInterval(parent.backgroundIntervalCounter);
  200. parent.initBackgroundSwitchingAnimation();
  201. }
  202. }
  203. function selectUserFolder(){
  204. ao_module_openFileSelector(folderSelected, undefined,"folder",false);
  205. }
  206. function folderSelected(filedata){
  207. for (var i=0; i < filedata.length; i++){
  208. var filename = filedata[i].filename;
  209. var filepath = filedata[i].filepath;
  210. //Save the overwrite folder path
  211. $("#userSelectedFolderPath").text(filepath);
  212. $.get("../../system/desktop/theme?set=" + filepath, function(data) {
  213. //Reload desktop background pack
  214. if (ao_module_virtualDesktop){
  215. parent.changeDesktopTheme(filepath);
  216. }
  217. //Disable change to system build in themes
  218. $(".allowSelectDefaultThemes").addClass("disabled");
  219. //Load the preview
  220. initCurrentBackgroundPreview();
  221. });
  222. }
  223. }
  224. function clearUserSelectedFolder(){
  225. //Clear user selected folder
  226. $.get("../../system/desktop/theme?set=default", function(data) {
  227. //Reload desktop background pack
  228. if (ao_module_virtualDesktop){
  229. parent.changeDesktopTheme("default");
  230. }
  231. //Re-enable the default theme seelct
  232. $(".allowSelectDefaultThemes").removeClass("disabled");
  233. $("#userSelectedFolderPath").text("Disabled");
  234. initUserDefinedWallpaperFolder();
  235. initCurrentBackgroundPreview();
  236. });
  237. }
  238. function initCurrentBackgroundPreview(){
  239. //Get the list of theme in the system
  240. $.get("../../system/desktop/theme", function(data) {
  241. desktopThemeList = data;
  242. //Generate the wallpaper list
  243. $("#wallpaperlist").html("");
  244. var deftaultData = "";
  245. desktopThemeList.forEach(themepack => {
  246. var encodedData = encodeURIComponent(JSON.stringify(themepack));
  247. var themeName = themepack.Theme.charAt(0).toUpperCase() + themepack.Theme.slice(1);
  248. $("#wallpaperlist").append(`<option value="${encodedData}">${themeName}</option>`);
  249. if (themepack.Theme == "default"){
  250. deftaultData = encodedData;
  251. }
  252. });
  253. //Get the one the user is currently using
  254. $.get("../../system/desktop/theme?get=true", function(data) {
  255. //Get the user theme settings
  256. $(".backgroundpreview").attr('src','../../img/desktop/bg/nobg.jpg');
  257. //Check if the theme is custom path
  258. if (data.includes(":/")){
  259. //Is path. Load path preview
  260. $.get("../../system/desktop/theme?load=" + data, function(imagelist){
  261. //Load background preview
  262. loadBackgroundPreviewForCustomFolder(imagelist);
  263. //End of startup process
  264. isStartingUp = false;
  265. });
  266. }else{
  267. //Check if the theme exists
  268. var themeExists = false;
  269. var targetThemeObject;
  270. desktopThemeList.forEach(theme => {
  271. if (theme.Theme == data){
  272. //Theme exists
  273. themeExists = true;
  274. targetThemeObject = theme;
  275. }
  276. });
  277. if (themeExists == false){
  278. //This theme not exists. Do not load preview
  279. $("#wallpaperlist").dropdown("set selected","Default");
  280. }else{
  281. loadBackgroundPreview(targetThemeObject);
  282. var themeName = data.charAt(0).toUpperCase() + data.slice(1)
  283. $("#wallpaperlist").dropdown("set selected",themeName);
  284. }
  285. //End of startup process
  286. isStartingUp = false;
  287. }
  288. });
  289. });
  290. }
  291. function loadBackgroundPreviewForCustomFolder(imageList){
  292. $("#backgroundPreviewList").html("");
  293. $("#mainBackground").attr("src","../../media/?file=" + imageList[0]);
  294. for (var i = 1; i < imageList.length; i++){
  295. $("#backgroundPreviewList").append(`<div class="four wide column">
  296. <img class="ui fluid image backgroundpreview" src="${"../../media/?file=" + imageList[i]}">
  297. </div>`);
  298. }
  299. }
  300. function loadBackgroundPreview(targetThemeObject){
  301. $("#backgroundPreviewList").html("");
  302. var imageList = targetThemeObject.Bglist;
  303. $("#mainBackground").attr("src","../../img/desktop/bg/" + targetThemeObject.Theme + "/" + imageList[0]);
  304. for (var i = 1; i < imageList.length; i++){
  305. $("#backgroundPreviewList").append(`<div class="four wide column">
  306. <img class="ui fluid image backgroundpreview" src="${"../../img/desktop/bg/" + targetThemeObject.Theme + "/" + imageList[i]}">
  307. </div>`);
  308. }
  309. }
  310. function handleBackgroundSelectionChange(value){
  311. var targetThemeObject = JSON.parse(decodeURIComponent(value));
  312. loadBackgroundPreview(targetThemeObject);
  313. }
  314. function applyWallpaper(){
  315. var targetWallpaper =JSON.parse(decodeURIComponent($("#wallpaperlist").val()));
  316. $.get("../../system/desktop/theme?set=" + targetWallpaper.Theme, function(data) {
  317. if (ao_module_virtualDesktop == true){
  318. parent.changeDesktopTheme(targetWallpaper.Theme);
  319. }
  320. if (data.includes("Error")) {
  321. console.log(data);
  322. return;
  323. }
  324. //Reload the preview
  325. initCurrentBackgroundPreview();
  326. //Show change finsihed
  327. $("#wallpaperChangeConfirm").slideDown('fast').delay(3000).slideUp('fast');
  328. });
  329. }
  330. </script>
  331. </body>
  332. </html>