mobile.system 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411
  1. <html>
  2. <head>
  3. <title>ArozOS Mobile</title>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <link rel="manifest" href="manifest.webmanifest">
  7. <link rel="stylesheet" href="script/semantic/semantic.css">
  8. <link rel="stylesheet" href="script/ao.css">
  9. <script type="text/javascript" src="script/jquery.min.js"></script>
  10. <script type="text/javascript" src="script/semantic/semantic.js"></script>
  11. <script type="text/javascript" src="script/ao_module.js"></script>
  12. <script type="text/javascript" src="./script/applocale.js"></script>
  13. <style>
  14. document, body{
  15. height: 100%;
  16. }
  17. .themeColor{
  18. background-color:#1c1c1c;
  19. }
  20. .taskBar{
  21. position:fixed;
  22. top:0px;
  23. left:0px;
  24. width:30px;
  25. height:100%;
  26. overflow: visible !important;
  27. z-index:999;
  28. }
  29. #mainFrame{
  30. width: calc(100% - 30px);
  31. position:fixed;
  32. top:0px;
  33. right:0px;
  34. overflow: hidden;
  35. }
  36. .toggleTaskBar{
  37. position:absolute;
  38. bottom:0px;
  39. right:0px;
  40. margin-right:-20px;
  41. width:30px;
  42. height:90px;
  43. border-radius: 0px 10px 10px 0px;
  44. }
  45. #listMenu{
  46. z-index:1000;
  47. position:fixed;
  48. top:0px;
  49. left:0px;
  50. width:100%;
  51. height:100%;
  52. padding:12px;
  53. background-color: #fcffff;
  54. box-shadow: 3px 3px 5px 0px rgba(207, 207, 207, 0.37);
  55. }
  56. #listMenu .searchBar {
  57. width: 100%;
  58. border-bottom: 2px solid #34b7eb;
  59. }
  60. #listMenu .listItemWrapper {
  61. overflow: hidden;
  62. }
  63. #listMenu .listItemWrapper .groups {
  64. background-color: #f5f5f5;
  65. width: 120px;
  66. height: calc(100% - 40px);
  67. display: inline-block;
  68. overflow-y: auto;
  69. padding-top: 8px;
  70. }
  71. #listMenu .listItemWrapper .groups .item {
  72. padding-left: 7px;
  73. padding-bottom: 6px;
  74. padding-top: 6px;
  75. cursor: pointer;
  76. }
  77. #listMenu .listItemWrapper .groups .item.selected {
  78. color: #34b7eb;
  79. }
  80. #listMenu .listItemWrapper .groups .item:hover {
  81. background-color: #dedede;
  82. }
  83. #listMenuItem{
  84. width: calc(100% - 130px) !important;
  85. float: right;
  86. overflow-y: auto;
  87. height: calc(100% - 40px) !important;
  88. }
  89. #listMenuItem img{
  90. width: 50px;
  91. }
  92. .module.item{
  93. padding:8px;
  94. }
  95. .hideListMenuButton{
  96. position: absolute;
  97. bottom:22px;
  98. left:32px;
  99. cursor:pointer;
  100. }
  101. .hideListMenuButton img{
  102. left:12px;
  103. width:50px;
  104. }
  105. .listMenuLauncher{
  106. position:absolute;
  107. bottom:12px;
  108. left:12px;
  109. }
  110. .listMenuLauncher .functionbtn{
  111. cursor:pointer;
  112. }
  113. .blurred{
  114. filter: blur(3px);
  115. }
  116. #backdrop {
  117. background-repeat: no-repeat;
  118. background-size: cover;
  119. background-position: center;
  120. background-image: url('img/desktop/bg/init.jpg');
  121. width: 100%;
  122. height: 100%;
  123. overflow-x: hidden;
  124. pointer-events: none;
  125. }
  126. #windowButtonWrapper{
  127. padding-top:6px;
  128. }
  129. .floatWindowButton{
  130. padding: 5px;
  131. }
  132. .floatWindowButton .minimizedIcon{
  133. width: 20px;
  134. height:20px;
  135. }
  136. .floatWindowButton .normalElements{
  137. padding:8px;
  138. border-bottom: 1px solid #4a4a4a;
  139. cursor:pointer;
  140. vertical-align:middle;
  141. position: relative;
  142. }
  143. .floatWindowButton .normalizedIcon{
  144. width:40;
  145. height:40px;
  146. margin-right:12px;
  147. }
  148. .normalElements .windowTitle{
  149. display:inline-block;
  150. width:200px !important;
  151. vertical-align:middle;
  152. white-space: nowrap;
  153. overflow: hidden;
  154. text-overflow: ellipsis;
  155. }
  156. .fwtab{
  157. position: absolute;
  158. top:0px;
  159. right: 0px;
  160. width: 100%;
  161. height: 100%;
  162. }
  163. #windowWrapper{
  164. height: 100%;
  165. width: 100%;
  166. position: absolute;
  167. top:0px;
  168. right:0px;
  169. }
  170. .floatWindowWrapper{
  171. width: 100%;
  172. height: 100%;
  173. }
  174. .floatWindow{
  175. width: 100%;
  176. height: 100%;
  177. position: absolute;
  178. }
  179. .fwtab iframe{
  180. border: 0px solid transparent;
  181. height: 100%;
  182. }
  183. .floatWindowButton .closebutton{
  184. position: absolute;
  185. font-size: 120%;
  186. color:white;
  187. right: 0em;
  188. top: 0px;
  189. margin-top: -8px;
  190. margin-left: -4px;
  191. padding: 3px;
  192. }
  193. .floatWindowButton .externalbutton{
  194. position: absolute;
  195. font-size: 120%;
  196. color:white;
  197. right: 1.6em;
  198. top: 0px;
  199. margin-top: -8px;
  200. margin-left: -4px;
  201. padding: 3px;
  202. }
  203. #conndrop{
  204. padding: 0.5em;
  205. position: fixed;
  206. top: 0px;
  207. right: 0px;
  208. z-index: 115;
  209. width: 100px;
  210. display: none;
  211. justify-content: flex-end;
  212. pointer-events: none;
  213. }
  214. .extendOnly{
  215. display:none;
  216. }
  217. /* Magic css to make the connection logo blink */
  218. @-moz-keyframes blink {
  219. 0% {
  220. opacity:1;
  221. }
  222. 50% {
  223. opacity:0;
  224. }
  225. 100% {
  226. opacity:1;
  227. }
  228. }
  229. @-webkit-keyframes blink {
  230. 0% {
  231. opacity:1;
  232. }
  233. 50% {
  234. opacity:0;
  235. }
  236. 100% {
  237. opacity:1;
  238. }
  239. }
  240. /* IE */
  241. @-ms-keyframes blink {
  242. 0% {
  243. opacity:1;
  244. }
  245. 50% {
  246. opacity:0;
  247. }
  248. 100% {
  249. opacity:1;
  250. }
  251. }
  252. /* Opera and prob css3 final iteration */
  253. @keyframes blink {
  254. 0% {
  255. opacity:1;
  256. }
  257. 50% {
  258. opacity:0;
  259. }
  260. 100% {
  261. opacity:1;
  262. }
  263. }
  264. .blink-image {
  265. -moz-animation: blink normal 2s infinite ease-in-out; /* Firefox */
  266. -webkit-animation: blink normal 2s infinite ease-in-out; /* Webkit */
  267. -ms-animation: blink normal 2s infinite ease-in-out; /* IE */
  268. animation: blink normal 2s infinite ease-in-out; /* Opera and prob css3 final iteration */
  269. }
  270. #sidebarToggleOverlay{
  271. width: 100%;
  272. height: 100%;
  273. z-index: 995;
  274. position: fixed;
  275. top:0px;
  276. left:0px;
  277. display:none;
  278. }
  279. #userprofile{
  280. z-index: 90;
  281. position: fixed;
  282. top: 0px;
  283. left: 3em;
  284. right: 3em;
  285. background-color: rgba(255,255,255,0.95);
  286. backdrop-filter: blur(4px);
  287. border-bottom-left-radius: 20px;
  288. border-bottom-right-radius: 20px;
  289. padding-left: 1.2em;
  290. padding-right: 1.2em;
  291. padding-top: 1.2em;
  292. display:none;
  293. box-shadow: 6px 8px 5px 2px rgba(0,0,0,0.2);
  294. -webkit-box-shadow: 6px 8px 5px 2px rgba(0,0,0,0.2);
  295. -moz-box-shadow: 6px 8px 5px 2px rgba(0,0,0,0.2);
  296. }
  297. .clock{
  298. position: fixed;
  299. left: 0px;
  300. width: 100%;
  301. top: 0px;
  302. padding-top: 0.3em;
  303. padding-bottom: 0.7em;
  304. color: white;
  305. text-align: center;
  306. pointer-events: none;
  307. background: rgb(255,255,255);
  308. background: linear-gradient(0deg, rgba(255,255,255,0) 2%, rgba(6,6,6,0.4479635060791801) 44%, rgba(29,29,29,1) 100%);
  309. }
  310. </style>
  311. </head>
  312. <body>
  313. <div class="taskBar themeColor" >
  314. <div class="toggleTaskBar themeColor" shown="false" onclick="toggleTaskBar(this);">
  315. <img class="ui image sidebararrow" style="margin-top:8px; margin-left: -10px;" src="img/mobile/keyboard_arrow_right-white-48dp.svg"></img>
  316. </div>
  317. <div class="listMenuLauncher">
  318. <img onclick="showListMenu();" class="functionbtn" src="img/mobile/apps-white-48dp.svg" style="width: 30px;"/>
  319. <img onclick="showProfileInfo();" class="functionbtn extendOnly" src="img/mobile/account_circle_white_48dp.svg" style="width: 30px;"/>
  320. <img onclick="openDesktopCustomization();" class="functionbtn extendOnly" src="img/mobile/palette_white_48dp.svg" style="width: 30px;"/>
  321. <img onclick="openDesktopAsFolder();" class="functionbtn extendOnly" src="img/mobile/folder_open_white_24dp.svg" style="width: 30px;"/>
  322. <img onclick="fullscreen();" class="functionbtn extendOnly" src="img/mobile/fullscreen_white_48dp.svg" style="width: 30px;"/>
  323. <img onclick="openSystemSettings();" class="functionbtn extendOnly" src="img/mobile/tune_white_24dp.svg" style="width: 30px;"/>
  324. <img onclick="showDesktop();" class="functionbtn extendOnly" src="img/mobile/layers_clear_white_48dp.svg" style="width: 30px;"/>
  325. </div>
  326. <div id="windowButtonWrapper">
  327. </div>
  328. </div>
  329. <div id="userprofile">
  330. <div class="ui minimal comments">
  331. <div class="ui comment">
  332. <div class="avatar" style="height: 2.5em">
  333. <img class="usericon" src="img/desktop/system_icon/user.svg">
  334. </div>
  335. <div class="content">
  336. <dic class="author" id="username">User</dic>
  337. <div class="text" id="usergroups">@user</div>
  338. </div>
  339. </div>
  340. </div>
  341. <button locale="quickAccess/logout" onclick="logout();" class="ui basic blue mini button" style="position: absolute; top: 1em; right: 1em;">Logout</button>
  342. <button onclick="toggleProfileInfo();" class="circular ui themecolor icon button" style="position: absolute; bottom: 0px; right: 0px; margin-bottom: -10px; margin-right: -10px; color: white;">
  343. <i class="remove icon"></i>
  344. </button>
  345. </div>
  346. <div id="listMenu" style="left:-100%;">
  347. <div class="searchBar" onkeydown="searchModule(event);">
  348. <div class="ui icon fluid input" style="border-radius: 0px !important;">
  349. <input id="searchBar" type="text" placeholder="Search">
  350. <i class="search icon"></i>
  351. </div>
  352. </div>
  353. <dib class="listItemWrapper">
  354. <div class="groups">
  355. <div locale="listmenu/catergory/searchResults" id="searchResults" class="item" style="display:none;">Search Results</div>
  356. <div locale="listmenu/catergory/all" class="item groupType selected" group="All">All</div>
  357. <div locale="listmenu/catergory/media" class="item groupType" group="Media">Media</div>
  358. <div locale="listmenu/catergory/office" class="item groupType" group="Office">Office</div>
  359. <div locale="listmenu/catergory/download" class="item groupType" group="Download">Download</div>
  360. <div locale="listmenu/catergory/files" class="item groupType" group="Files">Files</div>
  361. <div locale="listmenu/catergory/internet" class="item groupType" group="Internet">Internet</div>
  362. <div locale="listmenu/catergory/settings" class="item groupType" group="System Settings">System Settings</div>
  363. <div locale="listmenu/catergory/tools" class="item groupType" group="System Tools">System Tools</div>
  364. <div locale="listmenu/catergory/utils" class="item groupType" group="Utilities">Utilities</div>
  365. <div locale="listmenu/catergory/other" class="item groupType" group="Other">Other</div>
  366. <div class="hideListMenuButton" onclick="closeListMenu();">
  367. <img class="ui image" src="img/mobile/cancel-black-48dp.svg"></img>
  368. </div>
  369. </div>
  370. <div id="listMenuItem" class="items" align="left">
  371. </div>
  372. </div>
  373. </div>
  374. <div id="mainFrame">
  375. <div id="backdrop">
  376. </div>
  377. <div class="clock">
  378. ArozOS Desktop
  379. </div>
  380. <div id="windowWrapper">
  381. </div>
  382. <div id="conndrop">
  383. <img class="ui mini image blink-image" src="SystemAO/desktop/icons/connlost.svg">
  384. </div>
  385. </div>
  386. <div id="sidebarToggleOverlay"></div>
  387. <script>
  388. /*
  389. ArOZ Online Mobile Interfacae
  390. This script must maintain compatibility to the desktop.system interface
  391. regarding all cross iframe access functions.
  392. */
  393. var isDesktopMode = true; //Try to emulate Desktop mode
  394. var moduleInstalled = []; //List of installed modules on the system
  395. var desktopThemeList = []; //List of themes installed, same as desktop theme
  396. var listMenuShown = false;
  397. var hostInfo;
  398. //IME mockup
  399. window.ime = null;
  400. //Clock related
  401. var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  402. var daysNames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
  403. //initiation Functions
  404. initHostInfo();
  405. initModuleList();
  406. bindGroupTypeEvents();
  407. initBackdropImage();
  408. initUserDefinedThemeColor();
  409. bindBackgroundClickActions();
  410. initStartupSounds();
  411. initDesktopUserInfo();
  412. //Bind background click
  413. function bindBackgroundClickActions(){
  414. $("#mainFrame").on("touchstart click", function(evt){
  415. if ($(this).hasClass("blurred") && $(".taskBar").find(".toggleTaskBar").attr("shown") == "true"){
  416. //hide the taskbar
  417. hideTaskBar();
  418. }
  419. });
  420. $("#sidebarToggleOverlay").on("touchstart click", function(evt){
  421. if ($(".taskBar").find(".toggleTaskBar").attr("shown") == "true"){
  422. //hide the taskbar
  423. evt.preventDefault();
  424. hideTaskBar();
  425. }
  426. });
  427. }
  428. //Check and prepare localization
  429. if (applocale){
  430. //Applocale found. Do localization
  431. applocale.init("./SystemAO/locale/desktop.json", function(){
  432. applocale.translate();
  433. });
  434. }else{
  435. //Applocale not found. Is this a trim down version of ArozOS?
  436. var applocale = {
  437. getString: function(key, original){
  438. return original;
  439. }
  440. }
  441. }
  442. //Connection check
  443. setInterval(function() {
  444. $.ajax({
  445. url: 'system/auth/checkLogin',
  446. success: function(data) {
  447. if (data == true) {
  448. //Continue session
  449. } else {
  450. //Session timeout. Redirect to system index
  451. window.location.href = "index.html";
  452. }
  453. $("#conndrop").hide();
  454. $("#conndrop").css("display", "none");
  455. },
  456. error: function(evt) {
  457. //Server closed or freezed?
  458. $("#conndrop").show();
  459. $("#conndrop").css("display", "flex");
  460. },
  461. timeout: 15000
  462. });
  463. }, 15000);
  464. //Initiate the host information
  465. function initHostInfo(){
  466. $.get("system/desktop/host",function(data){
  467. hostInfo = data;
  468. document.title = hostInfo.Hostname;
  469. });
  470. }
  471. //Initialize background image
  472. function initBackdropImage(){
  473. $.get("system/desktop/theme", function(data) {
  474. //Return a list of theme stored on the system
  475. desktopThemeList = data;
  476. $.get("system/desktop/theme?get=true", function(data) {
  477. //Get the user theme settings
  478. changeDesktopTheme(data);
  479. });
  480. });
  481. }
  482. function initUserDefinedThemeColor(){
  483. $.ajax({
  484. url: "../../system/file_system/preference",
  485. data: {key: "themecolor"},
  486. success: function(data){
  487. if (data.error == undefined && data != ""){
  488. $(".themeColor").css("background-color", data);
  489. }
  490. }
  491. });
  492. }
  493. function changeDesktopTheme(themename){
  494. //Match the given theme to the themename
  495. if (themename.includes(":/") == false){
  496. //This is a path
  497. for (var i =0; i < desktopThemeList.length ; i++){
  498. if (desktopThemeList[i].Theme == themename){
  499. var targetImage = desktopThemeList[i].Bglist[0];
  500. $("#backdrop").css("background-image", `url(img/desktop/bg/${themename}/${targetImage})`)
  501. }
  502. }
  503. }else{
  504. //This is a path (user defined background folder)
  505. $.get("system/desktop/theme?load=" + themename, function(data){
  506. if (data.error !== undefined){
  507. //The folder is gone. Use default instead
  508. console.log(data.error);
  509. changeDesktopTheme("default");
  510. }else{
  511. $("#backdrop").css("background-image", `url(media/?file=${data[0]})`)
  512. }
  513. });
  514. }
  515. }
  516. function toggleFullScreen() {
  517. var doc = window.document;
  518. var docEl = doc.documentElement;
  519. var requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
  520. var cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
  521. if(!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) {
  522. requestFullScreen.call(docEl);
  523. }
  524. else {
  525. cancelFullScreen.call(doc);
  526. }
  527. }
  528. //Sidebar
  529. function toggleTaskBar(obj){
  530. if ($(obj).attr("shown") == "true"){
  531. hideTaskBar();
  532. }else{
  533. showTaskBar();
  534. }
  535. }
  536. function hideTaskBar(){
  537. //Hide the taskBar
  538. $(".taskBar").animate({
  539. width: "30px"
  540. },300, "swing");
  541. $(".taskBar").find('.sidebararrow').attr("src","img/mobile/keyboard_arrow_right-white-48dp.svg");
  542. $(".taskBar").find(".toggleTaskBar").attr("shown","false");
  543. $("#mainFrame").removeClass("blurred");
  544. //Minimize all fwbuttons
  545. $(".floatWindowButton").each(function(){
  546. $(this).find(".minimizedElements").show();
  547. $(this).find(".normalElements").hide();
  548. });
  549. $("#sidebarToggleOverlay").hide();
  550. $(".extendOnly").slideUp("fast");
  551. }
  552. function showTaskBar(){
  553. //Show the taskbar
  554. $(".taskBar").animate({
  555. width: "300px"
  556. }, 300, "swing", function(){
  557. //Switch all fwbuttons to normal size
  558. $(".floatWindowButton").each(function(){
  559. $(this).find(".minimizedElements").hide();
  560. $(this).find(".normalElements").show();
  561. });
  562. $(".extendOnly").slideDown("fast");
  563. });
  564. $(".taskBar").find('.sidebararrow').attr("src","img/mobile/keyboard_arrow_left-white-48dp.svg");
  565. $(".taskBar").find(".toggleTaskBar").attr("shown","true");
  566. $("#mainFrame").addClass("blurred");
  567. $("#sidebarToggleOverlay").show();
  568. }
  569. //List all modules
  570. function initModuleList(){
  571. $.ajax({
  572. url: "system/modules/list",
  573. success: function(data) {
  574. moduleInstalled = data;
  575. listModulesType("All");
  576. }
  577. });
  578. }
  579. //ListMenu group classification events
  580. function bindGroupTypeEvents(){
  581. $(".groupType").on("click",function(evt){
  582. //Clear all serach results
  583. $("#searchResults").slideUp('fast');
  584. listModulesType($(this).attr("group"));
  585. $(".groupType.selected").removeClass("selected");
  586. $(this).addClass("selected");
  587. /*
  588. var classificationObject = this;
  589. if ($(this).attr("group") == "All"){
  590. $('.item.module').show();
  591. } else if ($(this).attr("group") == "Other"){
  592. var excludeList = ["Media", "Office", "Download", "Files", "Internet", "System Settings", "System Tools", "Utilties"];
  593. $('.item.module').each(function(){
  594. if (excludeList.includes($(this).attr("group")) == false){
  595. $(this).show();
  596. }else{
  597. $(this).hide();
  598. }
  599. });
  600. }else{
  601. $('.item.module').each(function(){
  602. if ($(this).attr("group") == $(classificationObject).attr("group")){
  603. $(this).show();
  604. }else{
  605. $(this).hide();
  606. }
  607. });
  608. }
  609. */
  610. });
  611. }
  612. function searchModule(event) {
  613. if (event.which == 13) {
  614. var keyword = $("#searchBar").val().toLowerCase();
  615. var results = [];
  616. var lessAccurateResults = [];
  617. $(".groupType.selected").removeClass("selected");
  618. $("#searchResults").addClass("selected").slideDown('fast');
  619. //Load all search results
  620. for (var i = 0; i < moduleInstalled.length; i++) {
  621. var thisModule = moduleInstalled[i];
  622. var pathInfo = thisModule["StartDir"].split("/");
  623. for (var j = 0; j < pathInfo.length; j++) {
  624. pathInfo[j] = pathInfo[j].toLowerCase();
  625. }
  626. if (thisModule["Name"].toLowerCase().includes(keyword)) {
  627. results.push(thisModule);
  628. } else if (pathInfo.includes(keyword.toLowerCase()) || pathInfo.includes(keyword.split(" ").join("_").toLowerCase())) {
  629. lessAccurateResults.push(thisModule);
  630. }
  631. }
  632. results = results.concat(lessAccurateResults);
  633. //Append the results to list
  634. $("#listMenuItem").html("");
  635. for (var i = 0; i < results.length; i++) {
  636. generateListMenuItem(results[i]);
  637. }
  638. if (results.length == 0) {
  639. //Append a custom no results div to the content
  640. $("#listMenuItem").append(`<div class="item module"><span><img class="ui middle aligned tiny image" src="img/system/not found.png" style="padding-right: 12px;">No Results</span></div>`);
  641. }
  642. }
  643. }
  644. function listModulesType(groupType) {
  645. var listingItems = [];
  646. if (groupType == "All") {
  647. //List all of the items
  648. for (var i = 0; i < moduleInstalled.length; i++) {
  649. if (moduleInstalled[i]["StartDir"] != "") {
  650. listingItems.push(moduleInstalled[i]);
  651. }
  652. }
  653. } else if (groupType == "Other") {
  654. var excludeList = ["Media", "Office", "Download", "Files", "Internet", "System Settings", "System Tools", "Utilties"];
  655. //List the Other groups
  656. for (var i = 0; i < moduleInstalled.length; i++) {
  657. if (excludeList.includes(moduleInstalled[i]["Group"]) == false && moduleInstalled[i]["StartDir"] != "") {
  658. listingItems.push(moduleInstalled[i]);
  659. }
  660. }
  661. } else {
  662. //List the given group
  663. for (var i = 0; i < moduleInstalled.length; i++) {
  664. if (moduleInstalled[i]["Group"] == groupType && moduleInstalled[i]["StartDir"] != "") {
  665. listingItems.push(moduleInstalled[i]);
  666. }
  667. }
  668. }
  669. //List the item to the listmenu
  670. $("#listMenuItem").html("");
  671. for (var i = 0; i < listingItems.length; i++) {
  672. var thisModule = listingItems[i];
  673. generateListMenuItem(thisModule);
  674. }
  675. if (listingItems.length == 0) {
  676. $("#listMenuItem").html(`<div class="item module"><span><img class="ui middle aligned tiny image" src="img/system/not found.png" style="padding-right: 12px;">No WebApp found</span></div>`)
  677. }
  678. }
  679. function generateListMenuItem(thisModule) {
  680. var icon = thisModule["IconPath"];
  681. if (icon == "") {
  682. //Use default system icon
  683. icon = "img/system/service.png";
  684. }
  685. var name = thisModule["Name"];
  686. var startdir = thisModule["StartDir"];
  687. var group = thisModule["Group"];
  688. var fwsupport = "false";
  689. if (thisModule["SupportFW"]) {
  690. fwsupport = "true";
  691. }
  692. $("#listMenuItem").append(`<div class="item module" module="${name}" startdir="${startdir}" fw="${fwsupport}" group="${group}" onclick="openModuleFromMenu(this);">
  693. <span>
  694. <img class="ui middle aligned tiny image" src="${icon}" style="padding-right: 12px;"></img>
  695. ${name}
  696. </span>
  697. </div>`);
  698. }
  699. function closeListMenu(callback = undefined){
  700. $("#listMenu").animate({
  701. left: window.innerWidth * -1
  702. },300,"swing", function(){
  703. $(".taskBar").animate({
  704. width: "300px",
  705. },300,"swing", function(){
  706. if (typeof callback != "undefined"){
  707. callback();
  708. }else{
  709. $(".extendOnly").slideDown("fast");
  710. }
  711. });
  712. });
  713. listMenuShown = false;
  714. }
  715. //Bind swip events
  716. document.addEventListener('touchstart', handleTouchStart, false);
  717. document.addEventListener('touchmove', handleTouchMove, false);
  718. var xDown = null;
  719. var yDown = null;
  720. var swipeTarget = null;
  721. var targetType = "fw";
  722. function getTouches(evt) {
  723. return evt.touches || // browser API
  724. evt.originalEvent.touches; // jQuery
  725. }
  726. function handleTouchStart(evt) {
  727. const firstTouch = getTouches(evt)[0];
  728. if ($(evt.target).hasClass("taskBar")){
  729. swipeTarget = evt.target;
  730. targetType = "taskbar"
  731. }else if ($(evt.target).hasClass("toggleTaskBar")){
  732. }else{
  733. if (evt.path != undefined){
  734. swipeTarget = getFloatWindowObjectFromPath(evt.path);
  735. }
  736. }
  737. xDown = firstTouch.clientX;
  738. yDown = firstTouch.clientY;
  739. };
  740. function getFloatWindowObjectFromPath(path){
  741. var targetObject = undefined;
  742. targetType = undefined
  743. path.forEach(object => {
  744. if ($(object).hasClass("floatWindowButton")){
  745. targetObject = object
  746. targetType = "fw"
  747. }
  748. })
  749. return targetObject;
  750. }
  751. function handleTouchMove(evt) {
  752. if ( ! xDown || ! yDown ) {
  753. return;
  754. }
  755. var xUp = evt.touches[0].clientX;
  756. var yUp = evt.touches[0].clientY;
  757. var xDiff = xDown - xUp;
  758. var yDiff = yDown - yUp;
  759. if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
  760. if ( xDiff > 0 ) {
  761. /* left swipe */
  762. if (swipeTarget !== undefined && targetType == "fw"){
  763. closeFloatWindow($(swipeTarget).attr("windowId"));
  764. }else if (swipeTarget !== undefined && targetType == "taskbar"){
  765. hideTaskBar();
  766. }
  767. } else {
  768. /* right swipe */
  769. if (swipeTarget !== undefined && targetType == "fw"){
  770. //Allow left or right swipe to remove fw
  771. closeFloatWindow($(swipeTarget).attr("windowId"));
  772. }else if (swipeTarget !== undefined && targetType == "taskbar"){
  773. //Right swipe on taskbar
  774. if ($(swipeTarget).find(".toggleTaskBar").attr("shown") == "true"){
  775. //Already shown. Toggle list menu
  776. showListMenu();
  777. }else{
  778. showTaskBar();
  779. }
  780. }
  781. }
  782. } else {
  783. if ( yDiff > 0 ) {
  784. /* up swipe */
  785. } else {
  786. /* down swipe */
  787. }
  788. }
  789. /* reset values */
  790. xDown = null;
  791. yDown = null;
  792. swipeTarget = null;
  793. };
  794. function showListMenu(callback = undefined){
  795. if ($(".taskBar").find(".toggleTaskBar").attr("shown") == "false"){
  796. $(".taskBar").find(".toggleTaskBar").attr("shown", "true");
  797. $(".taskBar").find('.sidebararrow').attr("src","img/mobile/keyboard_arrow_left-white-48dp.svg");
  798. $("#mainFrame").addClass("blurred");
  799. }
  800. $(".taskBar").animate({
  801. width: window.innerWidth,
  802. },300, "swing", function(){
  803. //Switch all fwbuttons to normal size
  804. $(".floatWindowButton").each(function(){
  805. $(this).find(".minimizedElements").hide();
  806. $(this).find(".normalElements").show();
  807. });
  808. //Show list menu
  809. $("#listMenu").animate({
  810. left: 0
  811. },300,"swing", function(){
  812. if (typeof callback != "undefined"){
  813. callback();
  814. }
  815. });
  816. });
  817. listMenuShown = true;
  818. $("#sidebarToggleOverlay").show();
  819. }
  820. function openModule(moduleName) {
  821. $.get("system/modules/getLaunchPara?module=" + moduleName, function(data) {
  822. console.log(data);
  823. if (data.error !== undefined) {
  824. //Something went wrong.
  825. console.log("Unable to open module " + moduleName);
  826. if (data.error == "Not logged in."){
  827. //Session expired
  828. window.location.href = "login.system";
  829. }
  830. }else {
  831. //Launch the given module
  832. var url = data["StartDir"];
  833. var size = [undefined, undefined];
  834. var icon = "img/system/favicon.png";
  835. if (data["IconPath"] != "") {
  836. icon = data["IconPath"];
  837. }
  838. var title = data["Name"];
  839. //Check if the module support fw mode. If yes, launch with fwmode url. IF not, launch to index
  840. if (data["SupportFW"] == true) {
  841. if (data["LaunchFWDir"] != null) {
  842. url = data["LaunchFWDir"];
  843. }
  844. if (data["InitFWSize"] != null) {
  845. size = data["InitFWSize"];
  846. }
  847. }
  848. //Launch the given module
  849. newFloatWindow({
  850. url: url,
  851. width: size[0],
  852. height: size[1],
  853. appicon: icon,
  854. title: title
  855. });
  856. closeListMenu(function(){
  857. hideTaskBar();
  858. });
  859. }
  860. });
  861. }
  862. function openModuleFromMenu(object) {
  863. var moduleName = $(object).attr("module");
  864. openModule(moduleName);
  865. }
  866. //In mobile interface, there will be some option ignored by default
  867. function newFloatWindow(options){
  868. //Hide all other floatWindows
  869. $(".floatWindowWrapper").fadeOut("fast");
  870. //Construct the new window
  871. var windowID = Date.now();
  872. var parent = options.parent || "";
  873. var callback = options.callback || "";
  874. //Create a new iframe
  875. $("#windowWrapper").append(` <div class="floatWindowWrapper" windowId="${windowID}">
  876. <div class="floatWindow" windowId="${windowID}" parent="${parent}" callback="${callback}">
  877. <div class="fwtab">
  878. <iframe src="${options.url}" style="width: 100%; height: 100%;"></iframe>
  879. </div>
  880. </div>
  881. </div>`);
  882. //Create the button
  883. var title = options.title || "New FloatWindow";
  884. $("#windowButtonWrapper").append(`
  885. <div class="floatWindowButton" windowID="${windowID}" onclick="focusTab(this)">
  886. <div class="minimizedElements">
  887. <img class="minimizedIcon" src="${options.appicon}">
  888. </div>
  889. <div class="normalElements" style="display:none;">
  890. <img class="ui normalizedIcon middle aligned image" src="${options.appicon}">
  891. <span class="windowTitle" style="color:white;">${title}</span>
  892. <div class="closebutton" onclick="closefw(this);"><i class="remove icon"></i></div>
  893. <div class="externalbutton" onclick="openfwInNewTab(this);"><i class="external icon"></i></div>
  894. </div>
  895. </div>
  896. `);
  897. }
  898. ///Functions realted to window resize and auto scaling
  899. function updateWindowDimensions(){
  900. $("#backdrop").css({
  901. width: window.innerWidth,
  902. height: window.innerHeight
  903. });
  904. if (!listMenuShown){
  905. $("#listMenu").css("left", window.innerWidth * -1);
  906. }
  907. }
  908. updateWindowDimensions();
  909. $(window).on("resize", function(data){
  910. updateWindowDimensions();
  911. })
  912. //Float Window APIs
  913. function setFloatWindowTitle(id, title){
  914. $(".floatWindowButton").each(function(){
  915. if ($(this).attr("windowId") == id){
  916. $(this).find(".windowTitle").text(title);
  917. }
  918. })
  919. }
  920. function getFloatWindowByID(id){
  921. var targetObejct = undefined;
  922. $(".floatWindowWrapper").each(function(){
  923. if ($(this).attr("windowId") == id){
  924. targetObejct = $(this);
  925. }
  926. });
  927. return targetObejct;
  928. }
  929. function MoveFloatWindowToTop(targetfw){
  930. //Check if this windows is already topped
  931. if ($(targetfw).is(":visible")){
  932. //Already topped
  933. return;
  934. }
  935. $(".floatWindowWrapper").each(function(){
  936. $(this).fadeOut("fast");
  937. });
  938. console.log(targetfw);
  939. $(targetfw).parent().fadeIn("fast");
  940. }
  941. function focusTab(object){
  942. var windowID = $(object).attr("windowId");
  943. //Hide all other flowWindows
  944. $(".floatWindowWrapper").fadeOut("fast");
  945. //Show the target fw
  946. var fw = getFloatWindowByID(windowID);
  947. fw.fadeIn("fast", function(){
  948. hideTaskBar();
  949. });
  950. }
  951. function getFloatWindowByID(id){
  952. var targetObejct = undefined;
  953. $(".floatWindowWrapper").each(function(){
  954. if ($(this).attr("windowId") == id){
  955. targetObejct = $(this);
  956. }
  957. });
  958. return targetObejct;
  959. }
  960. function setFloatWindowResizePolicy(id, allowResize){
  961. //Disabled in mobile mode
  962. }
  963. function setFloatWindowSize(id, width, height){
  964. //Disabled in mobile mode
  965. }
  966. function closeFloatWindow(windowID){
  967. //Get the content iframe with that windowID
  968. var contentWindow = getFloatWindowByID(windowID);
  969. if (contentWindow == undefined){
  970. return;
  971. }
  972. contentWindow = contentWindow.find("iframe")[0].contentWindow;
  973. try {
  974. if (contentWindow.ao_module_close === undefined) {
  975. //This module do not use ao_module wrapper. Close it directly.
  976. closeFwProcess(windowID);
  977. } else {
  978. //Pass the closing events to the window itself
  979. contentWindow.ao_module_close();
  980. }
  981. } catch (ex) {
  982. //Problems of closing floatWindow. Force closing.
  983. closeFwProcess(windowID);
  984. }
  985. }
  986. function closefw(object){
  987. var windowID = $(object).parent().parent().attr("windowID");
  988. closeFloatWindow(windowID);
  989. }
  990. function openfwInNewTab(object){
  991. event.preventDefault();
  992. event.stopImmediatePropagation();
  993. var windowID = $(object).parent().parent().attr("windowID");
  994. var targetFloatWindow = null;
  995. $(".floatWindowWrapper").each(function(){
  996. if ($(this).attr("windowid") == windowID){
  997. targetFloatWindow = $(this);
  998. }
  999. });
  1000. if (targetFloatWindow == null){
  1001. return;
  1002. }
  1003. var iframe = $(targetFloatWindow).find("iframe");
  1004. var url = $(iframe)[0].contentWindow.location.href;
  1005. window.open(url);
  1006. }
  1007. //Get the window below this window id, can return null if there is no window
  1008. function getPreviousWindowObject(windowID){
  1009. var previousWindowID = null;
  1010. var result = null;
  1011. $(".floatWindowButton").each(function(){
  1012. if ($(this).attr("windowid") == windowID){
  1013. result = previousWindowID;
  1014. }else{
  1015. let thisWindowID = $(this).attr("windowid");
  1016. previousWindowID = thisWindowID;
  1017. }
  1018. });
  1019. return result;
  1020. }
  1021. function closeFwProcess(windowID){
  1022. //Get the previous window object
  1023. var previousWindowID = getPreviousWindowObject(windowID);
  1024. //Remove the window object
  1025. $(".floatWindowWrapper").each(function(){
  1026. if ($(this).attr("windowId") == windowID){
  1027. $(this).fadeOut("fast",function(){
  1028. $(this).remove();
  1029. });
  1030. }
  1031. });
  1032. //Remove the button object
  1033. $(".floatWindowButton").each(function(){
  1034. if ($(this).attr("windowId") == windowID){
  1035. $(this).fadeOut("fast",function(){
  1036. $(this).remove();
  1037. });
  1038. }
  1039. });
  1040. //Focus the window behind if exists
  1041. setTimeout(function(){
  1042. if (previousWindowID != null){
  1043. //Hide all other flowWindows
  1044. $(".floatWindowWrapper").fadeOut("fast");
  1045. //Show the target fw
  1046. var fw = getFloatWindowByID(previousWindowID);
  1047. console.log(fw);
  1048. fw.fadeIn("fast", function(){
  1049. });
  1050. }
  1051. }, 100);
  1052. }
  1053. function bindObjectToIMEEvents(object){
  1054. console.log("IME not supported in mobile desktop mode")
  1055. };
  1056. function openFileWithModule(moduleLaunchInfo, openFileList) {
  1057. var url = moduleLaunchInfo["StartDir"];
  1058. var size = [undefined, undefined];
  1059. var title = moduleLaunchInfo["Name"];
  1060. var icon = "img/system/favicon.png";
  1061. if (moduleLaunchInfo["IconPath"] != "") {
  1062. icon = moduleLaunchInfo["IconPath"];
  1063. }
  1064. //Use floatWindow if exists
  1065. if (moduleLaunchInfo["SupportFW"] == true && moduleLaunchInfo["LaunchFWDir"] != "") {
  1066. url = moduleLaunchInfo["LaunchFWDir"];
  1067. if (moduleLaunchInfo["InitFWSize"] !== null) {
  1068. size = moduleLaunchInfo["InitFWSize"]
  1069. }
  1070. }
  1071. //Use embedded mode if exists
  1072. if (moduleLaunchInfo["SupportEmb"] == true && moduleLaunchInfo["LaunchEmb"] != "") {
  1073. url = moduleLaunchInfo["LaunchEmb"];
  1074. if (moduleLaunchInfo["InitEmbSize"] !== null) {
  1075. size = moduleLaunchInfo["InitEmbSize"]
  1076. }
  1077. }
  1078. var openParamter = encodeURIComponent(JSON.stringify(openFileList));
  1079. //Add launch files info and launch floatWindow
  1080. newFloatWindow({
  1081. url: url + "#" + openParamter,
  1082. width: size[0],
  1083. height: size[1],
  1084. appicon: icon,
  1085. title: title
  1086. });
  1087. }
  1088. //Mobile interface do not support pin function yet
  1089. function PinFloatWindowToTopMostMode(object){
  1090. }
  1091. function UnpinFloatWindowFromTopMostMode(object){
  1092. }
  1093. /*
  1094. List Menu Specific function groups
  1095. */
  1096. function openDesktopAsFolder(){
  1097. newFloatWindow({
  1098. url: "SystemAO/file_system/file_explorer.html#" + encodeURIComponent("user:/Desktop/"),
  1099. appicon: "SystemAO/file_system/img/small_icon.png",
  1100. width:1080,
  1101. height:580,
  1102. title: "File Manager"
  1103. });
  1104. hideTaskBar();
  1105. }
  1106. function openDesktopCustomization(){
  1107. newFloatWindow({
  1108. url: "SystemAO/desktop/personalization.html",
  1109. appicon: "SystemAO/desktop/img/personalization.png",
  1110. width:640,
  1111. height:480,
  1112. title: "Personalization"
  1113. });
  1114. hideTaskBar();
  1115. }
  1116. function showDesktop(){
  1117. $(".floatWindowWrapper").fadeOut("fast");
  1118. hideTaskBar();
  1119. }
  1120. //Theme color placeholder functions
  1121. function setThemeColor(color){
  1122. $(".themeColor").css("background-color", color);
  1123. }
  1124. //Startup sound
  1125. function initStartupSounds(){
  1126. $.ajax({
  1127. url: "../../system/desktop/preference",
  1128. method: "GET",
  1129. data: {preference: "startup-audio"},
  1130. success: function(data){
  1131. if (data == undefined || data == ""){
  1132. return;
  1133. }
  1134. var currentGlobalVol = localStorage.getItem("global_volume");
  1135. if (currentGlobalVol != null && currentGlobalVol != undefined && currentGlobalVol != ""){
  1136. }else{
  1137. currentGlobalVol = 0;
  1138. }
  1139. var audio = new Audio("media?file=" + data);
  1140. audio.volume = currentGlobalVol;
  1141. audio.play();
  1142. }
  1143. });
  1144. }
  1145. function fullscreen() {
  1146. //Opening full screen will lead to hidden of all iframe for unknown reasons
  1147. var isInFullScreen = (document.fullscreenElement && document.fullscreenElement !== null) ||
  1148. (document.webkitFullscreenElement && document.webkitFullscreenElement !== null) ||
  1149. (document.mozFullScreenElement && document.mozFullScreenElement !== null) ||
  1150. (document.msFullscreenElement && document.msFullscreenElement !== null);
  1151. var elem = document.documentElement;
  1152. if (!isInFullScreen) {
  1153. if (elem.requestFullscreen) {
  1154. elem.requestFullscreen();
  1155. } else if (elem.mozRequestFullScreen) { /* Firefox */
  1156. elem.mozRequestFullScreen();
  1157. } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
  1158. elem.webkitRequestFullscreen();
  1159. } else if (elem.msRequestFullscreen) { /* IE/Edge */
  1160. elem.msRequestFullscreen();
  1161. }
  1162. } else {
  1163. if (document.exitFullscreen) {
  1164. document.exitFullscreen();
  1165. } else if (document.webkitExitFullscreen) {
  1166. document.webkitExitFullscreen();
  1167. } else if (document.mozCancelFullScreen) {
  1168. document.mozCancelFullScreen();
  1169. } else if (document.msExitFullscreen) {
  1170. document.msExitFullscreen();
  1171. }
  1172. }
  1173. hideTaskBar();
  1174. }
  1175. function initDesktopUserInfo(){
  1176. $.get("system/desktop/user", function(data){
  1177. if (data.error !== undefined){
  1178. alert(data.error);
  1179. }else{
  1180. userInfo = data;
  1181. //Update the user tag
  1182. $("#username").text(userInfo.Username);
  1183. $("#usergroups").text("@" + userInfo.UserGroups.join("/"));
  1184. $("#usergroups").attr("title",userInfo.UserGroups.join(" / "));
  1185. if (data.UserIcon !== ""){
  1186. $(".usericon").attr("src",data.UserIcon);
  1187. }
  1188. }
  1189. });
  1190. }
  1191. function showProfileInfo(){
  1192. hideTaskBar();
  1193. setTimeout(function(){
  1194. toggleProfileInfo();
  1195. }, 500);
  1196. }
  1197. function toggleProfileInfo(){
  1198. $("#userprofile").transition('drop');
  1199. }
  1200. function openSystemSettings(){
  1201. openModule("System Setting");
  1202. }
  1203. function logout() {
  1204. loggingOut = true;
  1205. if (confirm("Exiting Session. Confirm?")){
  1206. $.get("system/auth/logout", function() {
  1207. window.location.href = "/";
  1208. });
  1209. toggleProfileInfo();
  1210. }
  1211. }
  1212. //Keep the clock updated
  1213. setInterval(function(){
  1214. updateClockTime();
  1215. },5000);
  1216. updateClockTime();
  1217. function updateClockTime(){
  1218. var d = new Date();
  1219. var display = monthNames[d.getMonth()] + " " + d.getDate() + " " + zeropad(d.getHours(),2) + ":" + zeropad(d.getMinutes(),2);
  1220. if ($(".notification.object").length > 0){
  1221. display += `<span style="color: #f54242; margin-left: 8px; float: center;"><i class="notice circle icon"></i></span>`;
  1222. }
  1223. $(".clock").html(display);
  1224. var largedate = monthNames[d.getMonth()] + " " + d.getDate() + " " + d.getFullYear()
  1225. $("#largedate").text(largedate);
  1226. var dow = daysNames[d.getDay()];
  1227. $("#dayofweek").text(dow);
  1228. }
  1229. function zeropad(n, width, z) {
  1230. z = z || '0';
  1231. n = n + '';
  1232. return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
  1233. }
  1234. </script>
  1235. </body>
  1236. </html>