personalization.html 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  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. <script type="text/javascript" src="../../script/applocale.js"></script>
  12. <style>
  13. .hidden{
  14. display:none;
  15. }
  16. .backgroundpreview{
  17. border: 1px solid #898989;
  18. }
  19. .colorpallete{
  20. border: 1px solid transparent;
  21. cursor: pointer;
  22. }
  23. .colorpallete:hover{
  24. border: 1px solid white;
  25. }
  26. </style>
  27. </head>
  28. <body>
  29. <div class="ui tabular menu" style="position:fixed; top:0px; left:0px; width: 100%;">
  30. <div class="active item" data-tab="wallpaper" locale="menu/wallpaper">Wallpaper</div>
  31. <div class="item" data-tab="sound" locale="menu/sound">Sound</div>
  32. <div class="item" data-tab="theme" locale="menu/theme">Theme</div>
  33. <div class="item" data-tab="advance" locale="menu/advance">Advance</div>
  34. </div>
  35. <div style="position:fixed; top: 42px; left:0px; width: 100%; height: calc(100% - 42px); overflow-y:auto;">
  36. <div class="ui active tab" data-tab="wallpaper">
  37. <!-- Wallpaper Functions -->
  38. <br>
  39. <div class="ui container">
  40. <h3 class="ui header">
  41. <i class="image outline icon"></i>
  42. <div class="content">
  43. <span locale="wallpaper/title">Wallpapers</span>
  44. <div locale="wallpaper/desc" class="sub header">Manage your desktop preferences</div>
  45. </div>
  46. </h3>
  47. <div class="ui divider"></div>
  48. <div class="ui grid">
  49. <div class="ten wide column">
  50. <img id="mainBackground" class="ui fluid image backgroundpreview" src="">
  51. </div>
  52. <div class="six wide column">
  53. </div>
  54. </div>
  55. <div class="ui divider"></div>
  56. <div id="backgroundPreviewList" class="ui grid">
  57. <div class="four wide column">
  58. <img class="ui fluid image backgroundpreview" src="">
  59. </div>
  60. <div class="four wide column">
  61. <img class="ui fluid image backgroundpreview" src="">
  62. </div>
  63. <div class="four wide column">
  64. <img class="ui fluid image backgroundpreview" src="">
  65. </div>
  66. <div class="four wide column">
  67. <img class="ui fluid image backgroundpreview" src="">
  68. </div>
  69. </div>
  70. <div class="ui divider"></div>
  71. <h4 class="ui header">
  72. <span locale="wallpaper/title">Background Wallpaper</span>
  73. <div locale="wallpaper/desc" class="sub header">Set your desktop background wallpaper theme.</div>
  74. </h4>
  75. <select id="wallpaperlist" class="ui fluid dropdown allowSelectDefaultThemes" onchange="handleBackgroundSelectionChange(this.value);">
  76. <option value="" locale="wallpaper/option/title">Wallpaper Packs</option>
  77. </select>
  78. <small locale="wallpaper/option/desc">This option will be disabled by default if you have set your "User Defined Wallpaper" in Advance tab.</small>
  79. <br> <br>
  80. <button class="ui small green right floated button allowSelectDefaultThemes" onclick="applyWallpaper();" locale="wallpaper/option/apply"><i class="checkmark icon"></i> Apply Wallpaper</button>
  81. <br><br><br>
  82. <div class="ui green segment" style="display:none" id="wallpaperChangeConfirm">
  83. <h4 class="ui header">
  84. <i class="checkmark green icon"></i>
  85. <div class="content">
  86. <span locale="wallpaper/option/updated">Wallpaper Updated</span>
  87. <div class="sub header" locale="wallpaper/option/updateddesc">You should be seeing your desktop wallpaper change in a moment.</div>
  88. </div>
  89. </h4>
  90. </div>
  91. <!-- Wallpaper change interval-->
  92. <div class="ui divider"></div>
  93. <h4 class="ui header">
  94. <span locale="wallpaper/option/interval">Wallpaper Interval</span>
  95. <div class="sub header" locale="wallpaper/option/intervaldesc">Set the interval between the wallpaper image cycles.</div>
  96. </h4>
  97. <select id="changeInterval" class="ui fluid dropdown" onchange="handleIntervalChange(this.value);">
  98. <option value="10" locale="wallpaper/interval/10s">10 seconds</option>
  99. <option value="30" locale="wallpaper/interval/30s">30 seconds</option>
  100. <option value="60" locale="wallpaper/interval/60s">60 seconds</option>
  101. <option value="180" locale="wallpaper/interval/3min">3 minutes</option>
  102. <option value="300" locale="wallpaper/interval/5min">5 minutes</option>
  103. <option value="600" locale="wallpaper/interval/10min">10 minutes</option>
  104. <option value="1800" locale="wallpaper/interval/30min">30 minutes</option>
  105. <option value="3600" locale="wallpaper/interval/1h">1 hour</option>
  106. </select>
  107. <div class="ui green segment" style="display:none" id="interfaceChangeConfirm">
  108. <h4 class="ui header">
  109. <i class="checkmark green icon"></i>
  110. <div class="content">
  111. <span locale="wallpaper/interval/succ">Wallpaper Interval Updated</span>
  112. <div class="sub header" locale="wallpaper/interval/succdesc">This setting will only apply to this browser</div>
  113. </div>
  114. </h4>
  115. </div>
  116. </div>
  117. <br><br><br>
  118. </div>
  119. <div class="ui tab" data-tab="sound">
  120. <br>
  121. <div class="ui container">
  122. <h3 class="ui header">
  123. <i class="music icon"></i>
  124. <div class="content">
  125. <span locale="sound/title">System Sound</span>
  126. <div class="sub header" locale="sound/desc">Customize system sound effect</div>
  127. </div>
  128. </h3>
  129. <div class="ui divider"></div>
  130. <h4 class="ui header">
  131. <span locale="sound/custom/title">Custom Startup Sound</span>
  132. <div class="sub header" locale="sound/custom/desc">User defined startup sound to play when login to the web desktop</div>
  133. </h4>
  134. <h3 id="userSelectedStartupSound" locale="sound/custom/disable">Disabled</h3>
  135. <button class="ui small right floated button" onclick="clearStartupAudioSelection()"><i class="remove icon"></i> <span locale="sound/custom/clear">Clear Selection</span></button>
  136. <button class="ui small black right floated button" onclick="selectStartupAudio();"><i class="folder open icon"></i> <span locale="sound/custom/select">Select File</span></button>
  137. <br><br>
  138. <div class="ui divider"></div>
  139. </div>
  140. </div>
  141. <div class="ui tab" data-tab="theme">
  142. <!-- Theme Color Related !-->
  143. <br>
  144. <div class="ui container">
  145. <h3 class="ui header">
  146. <i class="paint brush icon"></i>
  147. <div class="content">
  148. <span locale="themecolor/title">Theme Color</span>
  149. <div class="sub header" locale="themecolor/desc">Change the system theme color settings</div>
  150. </div>
  151. </h3>
  152. <div class="ui divider"></div>
  153. <div class="ui container">
  154. <div id="colorgrid">
  155. Loading...
  156. </div>
  157. </div>
  158. <br>
  159. <div class="ui divider"></div>
  160. <button class="ui small basic black button" onclick="restoreDefaultThemeColor();" locale="themecolor/color/Default">Restore Default</button>
  161. <br><br><br>
  162. </div>
  163. </div>
  164. <div class="ui tab" data-tab="advance">
  165. <!-- Advance User Customization !-->
  166. <br>
  167. <div class="ui container">
  168. <h3 class="ui header">
  169. <i class="setting icon"></i>
  170. <div class="content">
  171. <span locale="advance/title">Advance Customization</span>
  172. <div class="sub header" locale="advance/desc">Manage your desktop preferences</div>
  173. </div>
  174. </h3>
  175. <div class="ui divider"></div>
  176. <h4 class="ui header">
  177. <span locale="advance/wallpaper/title">User Defined Wallpaper</span>
  178. <div class="sub header" locale="advance/wallpaper/desc">Advanced user customization function for desktop interface</div>
  179. </h4>
  180. <h3 id="userSelectedFolderPath" locale="advance/wallpaper/disabled">Disabled</h3>
  181. <p locale="advance/wallpaper/reminder">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>
  182. <button class="ui small right floated button" onclick="clearUserSelectedFolder();"><i class="remove icon"></i><span locale="advance/wallpaper/clear">Clear Selection</span></button>
  183. <button class="ui small black right floated button" onclick="selectUserFolder();"><i class="folder open icon"></i> <span locale="advance/wallpaper/select">Select Folder</span></button>
  184. <br><br>
  185. </div>
  186. </div>
  187. </div>
  188. <br><br>
  189. <script>
  190. var desktopThemeList = [];
  191. var isStartingUp = true;
  192. var cancelColorRestore = false; //If the user clicked on the target color pallete, do not restore the desktop to its original color before selection
  193. $(".dropdown").dropdown();
  194. $('.tabular.menu .item').tab();
  195. try{
  196. applocale.init("../locale/personalization.json", function(){
  197. applocale.translate();
  198. init();
  199. });
  200. }catch(ex){
  201. //fail to load localization file. Use default
  202. init()
  203. }
  204. function init(){
  205. //Startup process
  206. initDefaultBackgroundChangeValue();
  207. initUserDefinedWallpaperFolder(function(themeName){
  208. initCurrentBackgroundPreview(themeName);
  209. });
  210. generateColorGrids();
  211. getStartupAudio();
  212. }
  213. //Return the data stored in the theme settings
  214. //Will return either theme pack name or path for user defined folder
  215. function initUserDefinedWallpaperFolder(callback = undefined){
  216. $.get("../../system/desktop/theme?get=true", function(data) {
  217. if (data.includes(":/")){
  218. //This is a path
  219. $("#userSelectedFolderPath").text(data);
  220. $(".allowSelectDefaultThemes").addClass("disabled");
  221. }else{
  222. $("#userSelectedFolderPath").text(applocale.getString("advance/wallpaper/disabled", "Disabled"));
  223. }
  224. if (callback != undefined){
  225. callback(data);
  226. }
  227. });
  228. }
  229. function initDefaultBackgroundChangeValue(){
  230. if (localStorage.getItem("ao/desktop/backgroundInterval") == null){
  231. //No background interval set.
  232. $("#changeInterval").dropdown("set selected", "30");
  233. }else{
  234. //There is already a setting for background interval change. Use that instead
  235. var changeInterval = localStorage.getItem("ao/desktop/backgroundInterval");
  236. $("#changeInterval").dropdown("set selected", changeInterval);
  237. }
  238. }
  239. //Startup sound
  240. function selectStartupAudio(){
  241. ao_module_openFileSelector(setStartupAudio, undefined,"file",{
  242. filter: ["mp3", "aac", "ogg", "wav"]
  243. });
  244. }
  245. function setStartupAudio(filedata){
  246. var filename = filedata[0].filename;
  247. var filepath = filedata[0].filepath;
  248. $("#userSelectedStartupSound").text(filepath);
  249. $.ajax({
  250. url: "../../system/desktop/preference",
  251. method: "GET",
  252. data: {preference: "startup-audio", value: filepath},
  253. success: function(data){
  254. console.log(data);
  255. }
  256. });
  257. }
  258. function getStartupAudio(callback=undefined){
  259. $.ajax({
  260. url: "../../system/desktop/preference",
  261. method: "GET",
  262. data: {preference: "startup-audio"},
  263. success: function(data){
  264. if (data != undefined && data != ""){
  265. $("#userSelectedStartupSound").text(data);
  266. }
  267. if (callback != undefined){
  268. callback(data);
  269. }else{
  270. console.log(data);
  271. }
  272. }
  273. });
  274. }
  275. function clearStartupAudioSelection(){
  276. $.ajax({
  277. url: "../../system/desktop/preference",
  278. method: "GET",
  279. data: {preference: "startup-audio", remove: "true"},
  280. success: function(data){
  281. $("#userSelectedStartupSound").text(applocale.getString("sound/disabled", "Disabled"));
  282. }
  283. });
  284. }
  285. //Change the interval to the given
  286. function handleIntervalChange(newInterval){
  287. //Show change finsihed
  288. if (isStartingUp){
  289. //Ignore startup change
  290. return;
  291. }
  292. //Save interval to localStorage
  293. localStorage.setItem("ao/desktop/backgroundInterval", newInterval)
  294. $("#interfaceChangeConfirm").slideDown('fast').delay(3000).slideUp('fast');
  295. //Restart desktop background changer interval
  296. if (ao_module_virtualDesktop){
  297. console.log("Restarting desktop background changer interval")
  298. if (parent.backgroundIntervalCounter){
  299. parent.clearInterval(parent.backgroundIntervalCounter);
  300. }
  301. parent.initBackgroundSwitchingAnimation();
  302. }
  303. }
  304. function selectUserFolder(){
  305. ao_module_openFileSelector(folderSelected, undefined,"folder",false);
  306. }
  307. function folderSelected(filedata){
  308. for (var i=0; i < filedata.length; i++){
  309. var filename = filedata[i].filename;
  310. var filepath = filedata[i].filepath;
  311. //Save the overwrite folder path
  312. $("#userSelectedFolderPath").text(filepath);
  313. $.get("../../system/desktop/theme?set=" + filepath, function(data) {
  314. //Reload desktop background pack
  315. if (ao_module_virtualDesktop){
  316. parent.changeDesktopTheme(filepath);
  317. }
  318. //Disable change to system build in themes
  319. $(".allowSelectDefaultThemes").addClass("disabled");
  320. //Load the preview
  321. initCurrentBackgroundPreview();
  322. });
  323. }
  324. }
  325. function clearUserSelectedFolder(){
  326. //Clear user selected folder
  327. $.get("../../system/desktop/theme?set=default", function(data) {
  328. //Reload desktop background pack
  329. if (ao_module_virtualDesktop){
  330. parent.changeDesktopTheme("default");
  331. }
  332. //Re-enable the default theme seelct
  333. $(".allowSelectDefaultThemes").removeClass("disabled");
  334. $("#userSelectedFolderPath").text(applocale.getString("advance/wallpaper/select", "Disabled"));
  335. initUserDefinedWallpaperFolder();
  336. initCurrentBackgroundPreview();
  337. });
  338. }
  339. function initCurrentBackgroundPreview(){
  340. //Get the list of theme in the system
  341. $.get("../../system/desktop/theme", function(data) {
  342. desktopThemeList = data;
  343. //Generate the wallpaper list
  344. $("#wallpaperlist").html("");
  345. var deftaultData = "";
  346. desktopThemeList.forEach(themepack => {
  347. var encodedData = encodeURIComponent(JSON.stringify(themepack));
  348. var themeName = themepack.Theme.charAt(0).toUpperCase() + themepack.Theme.slice(1);
  349. $("#wallpaperlist").append(`<option value="${encodedData}">${themeName}</option>`);
  350. if (themepack.Theme == "default"){
  351. deftaultData = encodedData;
  352. }
  353. });
  354. //Get the one the user is currently using
  355. $.get("../../system/desktop/theme?get=true", function(data) {
  356. //Get the user theme settings
  357. $(".backgroundpreview").attr('src','../../img/desktop/bg/nobg.jpg');
  358. //Check if the theme is custom path
  359. if (data.includes(":/")){
  360. //Is path. Load path preview
  361. $.get("../../system/desktop/theme?load=" + data, function(imagelist){
  362. //Load background preview
  363. loadBackgroundPreviewForCustomFolder(imagelist);
  364. //End of startup process
  365. isStartingUp = false;
  366. });
  367. }else{
  368. //Check if the theme exists
  369. var themeExists = false;
  370. var targetThemeObject;
  371. desktopThemeList.forEach(theme => {
  372. if (theme.Theme == data){
  373. //Theme exists
  374. themeExists = true;
  375. targetThemeObject = theme;
  376. }
  377. });
  378. if (themeExists == false){
  379. //This theme not exists. Do not load preview
  380. $("#wallpaperlist").dropdown("set selected","Default");
  381. }else{
  382. loadBackgroundPreview(targetThemeObject);
  383. var themeName = data.charAt(0).toUpperCase() + data.slice(1)
  384. $("#wallpaperlist").dropdown("set selected",themeName);
  385. }
  386. //End of startup process
  387. isStartingUp = false;
  388. }
  389. });
  390. });
  391. }
  392. function loadBackgroundPreviewForCustomFolder(imageList){
  393. $("#backgroundPreviewList").html("");
  394. $("#mainBackground").attr("src","../../media/?file=" + imageList[0]);
  395. for (var i = 1; i < imageList.length; i++){
  396. $("#backgroundPreviewList").append(`<div class="four wide column">
  397. <img class="ui fluid image backgroundpreview" src="${"../../media/?file=" + imageList[i]}">
  398. </div>`);
  399. }
  400. }
  401. function loadBackgroundPreview(targetThemeObject){
  402. $("#backgroundPreviewList").html("");
  403. var imageList = targetThemeObject.Bglist;
  404. $("#mainBackground").attr("src","../../img/desktop/bg/" + targetThemeObject.Theme + "/" + imageList[0]);
  405. for (var i = 1; i < imageList.length; i++){
  406. $("#backgroundPreviewList").append(`<div class="four wide column">
  407. <img class="ui fluid image backgroundpreview" src="${"../../img/desktop/bg/" + targetThemeObject.Theme + "/" + imageList[i]}">
  408. </div>`);
  409. }
  410. }
  411. function handleBackgroundSelectionChange(value){
  412. var targetThemeObject = JSON.parse(decodeURIComponent(value));
  413. loadBackgroundPreview(targetThemeObject);
  414. }
  415. function generateColorGrids(){
  416. $("#colorgrid").html("");
  417. $.getJSON("./colors.json", function(data){
  418. for (let key in data) {
  419. let colorcodes = data[key];
  420. let thisSection = '';
  421. let thisColorKey = key.charAt(0).toUpperCase() + key.slice(1);
  422. thisSection += (`<div class="ui grid">`);
  423. thisSection += (`<div class="five wide column">
  424. ${applocale.getString("themecolor/color/" + thisColorKey, thisColorKey)}
  425. </div>`);
  426. for (let colorIndex in colorcodes) {
  427. if (colorIndex < 300){
  428. //Skip all the light colors
  429. continue;
  430. }
  431. let colorHexCoxde = colorcodes[colorIndex];
  432. thisSection += (`<div class="one wide column colorpallete" hex="${colorHexCoxde}" material="${colorIndex}" style="background-color: ${colorHexCoxde}; text-align: center;"><br></div>`);
  433. }
  434. thisSection += "</div>"
  435. $("#colorgrid").append(thisSection);
  436. }
  437. //Bind events to change the color for preview
  438. let previousColorCode = {};
  439. $(".colorpallete").on({
  440. mouseover: function() {
  441. event.preventDefault();
  442. $(this).animate({opacity: 0.25}, 100);
  443. //Save the current color
  444. var thisColorCode = $(this).attr("hex");
  445. previousColorCode["floatWindow"] = $(parent.window.content.document).find(".floatWindow .controls").css("background-color");
  446. previousColorCode["statusbar"] = $(parent.window.content.document).find("#statusbar").css("background-color");
  447. previousColorCode["navimenu"] = $(parent.window.content.document).find("#navimenu").css("background-color");
  448. //Set the preview color
  449. if (ao_module_virtualDesktop){
  450. $(parent.window.content.document).find(".floatWindow .controls").css("background-color",hexToRgbA(thisColorCode, 0.85));
  451. $(parent.window.content.document).find("#statusbar").css("background-color",thisColorCode );
  452. $(parent.window.content.document).find("#navimenu").css("background-color",hexToRgbA(thisColorCode, 0.5));
  453. }
  454. },
  455. mouseout: function() {
  456. event.preventDefault();
  457. $(this).animate({opacity: 1}, 100);
  458. $(".themeColorSolid").css("background-color", "");
  459. //Restore the original color
  460. if (ao_module_virtualDesktop && !cancelColorRestore){
  461. $(parent.window.content.document).find(".floatWindow .controls").css("background-color",previousColorCode["floatWindow"]);
  462. $(parent.window.content.document).find("#statusbar").css("background-color",previousColorCode["statusbar"]);
  463. $(parent.window.content.document).find("#navimenu").css("background-color",previousColorCode["navimenu"]);
  464. }else if (cancelColorRestore){
  465. cancelColorRestore = false;
  466. }
  467. }
  468. });
  469. //Setting the current theme
  470. $(".colorpallete").on("click", function(){
  471. var colorCode = $(this).attr("hex");
  472. writePreference("themecolor",colorCode, function(data){
  473. if (data.error != undefined){
  474. alert(data.error);
  475. }
  476. //Tick the current using color
  477. tickTheCurrentSelectedThemeColor();
  478. //Update the desktop theme color
  479. if (ao_module_virtualDesktop){
  480. cancelColorRestore=true;
  481. parent.setThemeColor(colorCode);
  482. }
  483. });
  484. });
  485. tickTheCurrentSelectedThemeColor();
  486. });
  487. }
  488. function restoreDefaultThemeColor(){
  489. $.ajax({
  490. url: "../../system/file_system/preference",
  491. data: {key: "themecolor", remove: true},
  492. success: function(data){
  493. if (data.error !== undefined){
  494. console.log(data.error);
  495. }else{
  496. if (ao_module_virtualDesktop){
  497. //Just emulate the restored effect first,
  498. //The theme color will restore after refresh
  499. parent.setThemeColor("#262626");
  500. }
  501. }
  502. }
  503. });
  504. }
  505. function tickTheCurrentSelectedThemeColor(){
  506. //Tick the one that is currently using
  507. readPreference("themecolor", function(data){
  508. if (data.error == undefined){
  509. //See if there is a colorpallete match the hex string
  510. $(".colorpallete").each(function(){
  511. if ($(this).attr("hex") == data){
  512. //This is the pallete to tick
  513. $(this).html(`<i style="color:white; margin-left: -4px;" class="checkmark icon"></i>`);
  514. }else{
  515. $(this).html(`<br>`);
  516. }
  517. })
  518. }
  519. })
  520. }
  521. function readPreference(key, callback=undefined){
  522. $.ajax({
  523. url: "../../system/file_system/preference",
  524. data: {key: key},
  525. success: function(data){
  526. if (callback != undefined){
  527. callback(data);
  528. }
  529. }
  530. });
  531. }
  532. function writePreference(key, value, callback=undefined){
  533. $.ajax({
  534. url: "../../system/file_system/preference",
  535. data: {key: key, value: value},
  536. success: function(data){
  537. if (callback != undefined){
  538. callback(data);
  539. }
  540. }
  541. })
  542. }
  543. function hexToRgbA(hex, transparent=1){
  544. var c;
  545. if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){
  546. c= hex.substring(1).split('');
  547. if(c.length== 3){
  548. c= [c[0], c[0], c[1], c[1], c[2], c[2]];
  549. }
  550. c= '0x'+c.join('');
  551. return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+',' + transparent + ')';
  552. }
  553. throw new Error('Bad Hex');
  554. }
  555. function applyWallpaper(){
  556. var targetWallpaper =JSON.parse(decodeURIComponent($("#wallpaperlist").val()));
  557. $.get("../../system/desktop/theme?set=" + targetWallpaper.Theme, function(data) {
  558. if (ao_module_virtualDesktop == true){
  559. parent.changeDesktopTheme(targetWallpaper.Theme);
  560. }
  561. if (data.includes("Error")) {
  562. console.log(data);
  563. return;
  564. }
  565. //Reload the preview
  566. initCurrentBackgroundPreview();
  567. //Show change finsihed
  568. $("#wallpaperChangeConfirm").slideDown('fast').delay(3000).slideUp('fast');
  569. });
  570. }
  571. </script>
  572. </body>
  573. </html>