mobile.system 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541
  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. #shortcuts{
  311. position: absolute;
  312. bottom: 0px;
  313. right: 0px;
  314. width: calc(100% - 20px);
  315. padding: 1em;
  316. }
  317. #shortcuts .clickable{
  318. cursor: pointer;
  319. border-radius: 10px;
  320. }
  321. .disabled{
  322. pointer-events: none;
  323. }
  324. </style>
  325. </head>
  326. <body>
  327. <div class="taskBar themeColor" >
  328. <div class="toggleTaskBar themeColor" shown="false" onclick="toggleTaskBar(this);">
  329. <img class="ui image sidebararrow" style="margin-top:8px; margin-left: -10px;" src="img/mobile/keyboard_arrow_right-white-48dp.svg"></img>
  330. </div>
  331. <div class="listMenuLauncher">
  332. <img onclick="showListMenu();" class="functionbtn" src="img/mobile/apps-white-48dp.svg" style="width: 30px;"/>
  333. <img onclick="showProfileInfo();" class="functionbtn extendOnly" src="img/mobile/account_circle_white_48dp.svg" style="width: 30px;"/>
  334. <img onclick="openDesktopCustomization();" class="functionbtn extendOnly" src="img/mobile/palette_white_48dp.svg" style="width: 30px;"/>
  335. <img onclick="openDesktopAsFolder();" class="functionbtn extendOnly" src="img/mobile/folder_open_white_24dp.svg" style="width: 30px;"/>
  336. <img onclick="fullscreen();" class="functionbtn extendOnly" src="img/mobile/fullscreen_white_48dp.svg" style="width: 30px;"/>
  337. <img onclick="openSystemSettings();" class="functionbtn extendOnly" src="img/mobile/tune_white_24dp.svg" style="width: 30px;"/>
  338. <img onclick="showDesktop();" class="functionbtn extendOnly" src="img/mobile/layers_clear_white_48dp.svg" style="width: 30px;"/>
  339. </div>
  340. <div id="windowButtonWrapper">
  341. </div>
  342. </div>
  343. <div id="userprofile">
  344. <div class="ui minimal comments">
  345. <div class="ui comment">
  346. <div class="avatar" style="height: 2.5em">
  347. <img class="usericon" src="img/desktop/system_icon/user.svg">
  348. </div>
  349. <div class="content">
  350. <dic class="author" id="username">User</dic>
  351. <div class="text" id="usergroups">@user</div>
  352. </div>
  353. </div>
  354. </div>
  355. <button locale="quickAccess/logout" onclick="logout();" class="ui basic blue mini button" style="position: absolute; top: 1em; right: 1em;">Logout</button>
  356. <button onclick="toggleProfileInfo();" class="circular ui themecolor icon button" style="position: absolute; bottom: 0px; right: 0px; margin-bottom: -10px; margin-right: -10px; color: white;">
  357. <i class="remove icon"></i>
  358. </button>
  359. </div>
  360. <div id="listMenu" style="left:-100%;">
  361. <div class="searchBar" onkeydown="searchModule(event);">
  362. <div class="ui icon fluid input" style="border-radius: 0px !important;">
  363. <input id="searchBar" type="text" placeholder="Search">
  364. <i class="search icon"></i>
  365. </div>
  366. </div>
  367. <dib class="listItemWrapper">
  368. <div class="groups">
  369. <div locale="listmenu/catergory/searchResults" id="searchResults" class="item" style="display:none;">Search Results</div>
  370. <div locale="listmenu/catergory/all" class="item groupType selected" group="All">All</div>
  371. <div locale="listmenu/catergory/media" class="item groupType" group="Media">Media</div>
  372. <div locale="listmenu/catergory/office" class="item groupType" group="Office">Office</div>
  373. <div locale="listmenu/catergory/download" class="item groupType" group="Download">Download</div>
  374. <div locale="listmenu/catergory/files" class="item groupType" group="Files">Files</div>
  375. <div locale="listmenu/catergory/internet" class="item groupType" group="Internet">Internet</div>
  376. <div locale="listmenu/catergory/settings" class="item groupType" group="System Settings">System Settings</div>
  377. <div locale="listmenu/catergory/tools" class="item groupType" group="System Tools">System Tools</div>
  378. <div locale="listmenu/catergory/utils" class="item groupType" group="Utilities">Utilities</div>
  379. <div locale="listmenu/catergory/other" class="item groupType" group="Other">Other</div>
  380. <div class="hideListMenuButton" onclick="closeListMenu();">
  381. <img class="ui image" src="img/mobile/cancel-black-48dp.svg"></img>
  382. </div>
  383. </div>
  384. <div id="listMenuItem" class="items" align="left">
  385. </div>
  386. </div>
  387. </div>
  388. <div id="mainFrame">
  389. <div id="backdrop">
  390. </div>
  391. <div class="clock">
  392. ArozOS Desktop
  393. </div>
  394. <div id="windowWrapper">
  395. </div>
  396. <div id="shortcuts">
  397. <!-- System Shortcuts -->
  398. <div class="ui divider"></div>
  399. <div class="ui four column grid">
  400. <div class="column">
  401. <img id="shortcut1" module="" onclick="launchThisModule(this);" class="ui medium clickable image" src="">
  402. </div>
  403. <div class="column">
  404. <img id="shortcut2" module="" onclick="launchThisModule(this);" class="ui medium clickable image" src="">
  405. </div>
  406. <div class="column">
  407. <img id="shortcut3" module="" onclick="launchThisModule(this);" class="ui medium clickable image" src="">
  408. </div>
  409. <div class="column">
  410. <img id="shortcut4" module="" onclick="launchThisModule(this);" class="ui medium clickable image" src="">
  411. </div>
  412. </div>
  413. </div>
  414. <div id="conndrop">
  415. <img class="ui mini image blink-image" src="SystemAO/desktop/icons/connlost.svg">
  416. </div>
  417. </div>
  418. <div id="sidebarToggleOverlay"></div>
  419. <script>
  420. /*
  421. ArOZ Online Mobile Interfacae
  422. This script must maintain compatibility to the desktop.system interface
  423. regarding all cross iframe access functions.
  424. */
  425. var isDesktopMode = true; //Try to emulate Desktop mode
  426. var moduleInstalled = []; //List of installed modules on the system
  427. var desktopThemeList = []; //List of themes installed, same as desktop theme
  428. var listMenuShown = false;
  429. var hostInfo;
  430. //IME mockup
  431. window.ime = null;
  432. //Clock related
  433. var monthNames = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
  434. var daysNames = ['Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'];
  435. //initiation Functions
  436. initHostInfo();
  437. initModuleList();
  438. bindGroupTypeEvents();
  439. initBackdropImage();
  440. initUserDefinedThemeColor();
  441. bindBackgroundClickActions();
  442. initStartupSounds();
  443. initDesktopUserInfo();
  444. initShortcuts();
  445. //Bind background click
  446. function bindBackgroundClickActions(){
  447. $("#mainFrame").on("touchstart click", function(evt){
  448. if ($(this).hasClass("blurred") && $(".taskBar").find(".toggleTaskBar").attr("shown") == "true"){
  449. //hide the taskbar
  450. hideTaskBar();
  451. }
  452. });
  453. $("#sidebarToggleOverlay").on("touchstart click", function(evt){
  454. if ($(".taskBar").find(".toggleTaskBar").attr("shown") == "true"){
  455. //hide the taskbar
  456. evt.preventDefault();
  457. hideTaskBar();
  458. }
  459. });
  460. }
  461. //Check and prepare localization
  462. if (applocale){
  463. //Applocale found. Do localization
  464. applocale.init("./SystemAO/locale/desktop.json", function(){
  465. applocale.translate();
  466. });
  467. }else{
  468. //Applocale not found. Is this a trim down version of ArozOS?
  469. var applocale = {
  470. getString: function(key, original){
  471. return original;
  472. }
  473. }
  474. }
  475. //Connection check
  476. setInterval(function() {
  477. $.ajax({
  478. url: 'system/auth/checkLogin',
  479. success: function(data) {
  480. if (data == true) {
  481. //Continue session
  482. } else {
  483. //Session timeout. Redirect to system index
  484. window.location.href = "index.html";
  485. }
  486. $("#conndrop").hide();
  487. $("#conndrop").css("display", "none");
  488. },
  489. error: function(evt) {
  490. //Server closed or freezed?
  491. $("#conndrop").show();
  492. $("#conndrop").css("display", "flex");
  493. },
  494. timeout: 15000
  495. });
  496. }, 15000);
  497. //Initiate the host information
  498. function initHostInfo(){
  499. $.get("system/desktop/host",function(data){
  500. hostInfo = data;
  501. document.title = hostInfo.Hostname;
  502. });
  503. }
  504. //Initialize background image
  505. function initBackdropImage(){
  506. $.get("system/desktop/theme", function(data) {
  507. //Return a list of theme stored on the system
  508. desktopThemeList = data;
  509. $.get("system/desktop/theme?get=true", function(data) {
  510. //Get the user theme settings
  511. changeDesktopTheme(data);
  512. });
  513. });
  514. }
  515. function initUserDefinedThemeColor(){
  516. $.ajax({
  517. url: "../../system/file_system/preference",
  518. data: {key: "themecolor"},
  519. success: function(data){
  520. if (data.error == undefined && data != ""){
  521. $(".themeColor").css("background-color", data);
  522. }
  523. }
  524. });
  525. }
  526. function changeDesktopTheme(themename){
  527. //Match the given theme to the themename
  528. if (themename.includes(":/") == false){
  529. //This is a path
  530. for (var i =0; i < desktopThemeList.length ; i++){
  531. if (desktopThemeList[i].Theme == themename){
  532. var targetImage = desktopThemeList[i].Bglist[0];
  533. $("#backdrop").css("background-image", `url(img/desktop/bg/${themename}/${targetImage})`)
  534. }
  535. }
  536. }else{
  537. //This is a path (user defined background folder)
  538. $.get("system/desktop/theme?load=" + themename, function(data){
  539. if (data.error !== undefined){
  540. //The folder is gone. Use default instead
  541. console.log(data.error);
  542. changeDesktopTheme("default");
  543. }else{
  544. $("#backdrop").css("background-image", `url(media/?file=${data[0]})`)
  545. }
  546. });
  547. }
  548. }
  549. function toggleFullScreen() {
  550. var doc = window.document;
  551. var docEl = doc.documentElement;
  552. var requestFullScreen = docEl.requestFullscreen || docEl.mozRequestFullScreen || docEl.webkitRequestFullScreen || docEl.msRequestFullscreen;
  553. var cancelFullScreen = doc.exitFullscreen || doc.mozCancelFullScreen || doc.webkitExitFullscreen || doc.msExitFullscreen;
  554. if(!doc.fullscreenElement && !doc.mozFullScreenElement && !doc.webkitFullscreenElement && !doc.msFullscreenElement) {
  555. requestFullScreen.call(docEl);
  556. }
  557. else {
  558. cancelFullScreen.call(doc);
  559. }
  560. }
  561. //Sidebar
  562. function toggleTaskBar(obj){
  563. if ($(obj).attr("shown") == "true"){
  564. hideTaskBar();
  565. }else{
  566. showTaskBar();
  567. }
  568. }
  569. function hideTaskBar(){
  570. //Hide the taskBar
  571. $(".taskBar").animate({
  572. width: "30px"
  573. },300, "swing");
  574. $(".taskBar").find('.sidebararrow').attr("src","img/mobile/keyboard_arrow_right-white-48dp.svg");
  575. $(".taskBar").find(".toggleTaskBar").attr("shown","false");
  576. $("#mainFrame").removeClass("blurred");
  577. //Minimize all fwbuttons
  578. $(".floatWindowButton").each(function(){
  579. $(this).find(".minimizedElements").show();
  580. $(this).find(".normalElements").hide();
  581. });
  582. $("#sidebarToggleOverlay").hide();
  583. $(".extendOnly").slideUp("fast");
  584. //Check the number of floatWindow
  585. if ($(".floatWindowWrapper").length == 0){
  586. //Reaching desktop layer
  587. showShortcuts();
  588. }else{
  589. //Check if all float windows are hidden
  590. var allHidden = $(".floatWindowWrapper").is(":hidden");
  591. if (!allHidden){
  592. hideShortcuts();
  593. }
  594. }
  595. }
  596. function showTaskBar(){
  597. //Show the taskbar
  598. $(".taskBar").animate({
  599. width: "300px"
  600. }, 300, "swing", function(){
  601. //Switch all fwbuttons to normal size
  602. $(".floatWindowButton").each(function(){
  603. $(this).find(".minimizedElements").hide();
  604. $(this).find(".normalElements").show();
  605. });
  606. $(".extendOnly").slideDown("fast");
  607. });
  608. $(".taskBar").find('.sidebararrow').attr("src","img/mobile/keyboard_arrow_left-white-48dp.svg");
  609. $(".taskBar").find(".toggleTaskBar").attr("shown","true");
  610. $("#mainFrame").addClass("blurred");
  611. $("#sidebarToggleOverlay").show();
  612. }
  613. //List all modules
  614. function initModuleList(){
  615. $.ajax({
  616. url: "system/modules/list",
  617. success: function(data) {
  618. moduleInstalled = data;
  619. listModulesType("All");
  620. }
  621. });
  622. }
  623. //ListMenu group classification events
  624. function bindGroupTypeEvents(){
  625. $(".groupType").on("click",function(evt){
  626. //Clear all serach results
  627. $("#searchResults").slideUp('fast');
  628. listModulesType($(this).attr("group"));
  629. $(".groupType.selected").removeClass("selected");
  630. $(this).addClass("selected");
  631. /*
  632. var classificationObject = this;
  633. if ($(this).attr("group") == "All"){
  634. $('.item.module').show();
  635. } else if ($(this).attr("group") == "Other"){
  636. var excludeList = ["Media", "Office", "Download", "Files", "Internet", "System Settings", "System Tools", "Utilties"];
  637. $('.item.module').each(function(){
  638. if (excludeList.includes($(this).attr("group")) == false){
  639. $(this).show();
  640. }else{
  641. $(this).hide();
  642. }
  643. });
  644. }else{
  645. $('.item.module').each(function(){
  646. if ($(this).attr("group") == $(classificationObject).attr("group")){
  647. $(this).show();
  648. }else{
  649. $(this).hide();
  650. }
  651. });
  652. }
  653. */
  654. });
  655. }
  656. function searchModule(event) {
  657. if (event.which == 13) {
  658. var keyword = $("#searchBar").val().toLowerCase();
  659. var results = [];
  660. var lessAccurateResults = [];
  661. $(".groupType.selected").removeClass("selected");
  662. $("#searchResults").addClass("selected").slideDown('fast');
  663. //Load all search results
  664. for (var i = 0; i < moduleInstalled.length; i++) {
  665. var thisModule = moduleInstalled[i];
  666. var pathInfo = thisModule["StartDir"].split("/");
  667. for (var j = 0; j < pathInfo.length; j++) {
  668. pathInfo[j] = pathInfo[j].toLowerCase();
  669. }
  670. if (thisModule["Name"].toLowerCase().includes(keyword)) {
  671. results.push(thisModule);
  672. } else if (pathInfo.includes(keyword.toLowerCase()) || pathInfo.includes(keyword.split(" ").join("_").toLowerCase())) {
  673. lessAccurateResults.push(thisModule);
  674. }
  675. }
  676. results = results.concat(lessAccurateResults);
  677. //Append the results to list
  678. $("#listMenuItem").html("");
  679. for (var i = 0; i < results.length; i++) {
  680. generateListMenuItem(results[i]);
  681. }
  682. if (results.length == 0) {
  683. //Append a custom no results div to the content
  684. $("#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>`);
  685. }
  686. }
  687. }
  688. function listModulesType(groupType) {
  689. var listingItems = [];
  690. if (groupType == "All") {
  691. //List all of the items
  692. for (var i = 0; i < moduleInstalled.length; i++) {
  693. if (moduleInstalled[i]["StartDir"] != "") {
  694. listingItems.push(moduleInstalled[i]);
  695. }
  696. }
  697. } else if (groupType == "Other") {
  698. var excludeList = ["Media", "Office", "Download", "Files", "Internet", "System Settings", "System Tools", "Utilties"];
  699. //List the Other groups
  700. for (var i = 0; i < moduleInstalled.length; i++) {
  701. if (excludeList.includes(moduleInstalled[i]["Group"]) == false && moduleInstalled[i]["StartDir"] != "") {
  702. listingItems.push(moduleInstalled[i]);
  703. }
  704. }
  705. } else {
  706. //List the given group
  707. for (var i = 0; i < moduleInstalled.length; i++) {
  708. if (moduleInstalled[i]["Group"] == groupType && moduleInstalled[i]["StartDir"] != "") {
  709. listingItems.push(moduleInstalled[i]);
  710. }
  711. }
  712. }
  713. //List the item to the listmenu
  714. $("#listMenuItem").html("");
  715. for (var i = 0; i < listingItems.length; i++) {
  716. var thisModule = listingItems[i];
  717. generateListMenuItem(thisModule);
  718. }
  719. if (listingItems.length == 0) {
  720. $("#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>`)
  721. }
  722. }
  723. function generateListMenuItem(thisModule) {
  724. var icon = thisModule["IconPath"];
  725. if (icon == "") {
  726. //Use default system icon
  727. icon = "img/system/service.png";
  728. }
  729. var name = thisModule["Name"];
  730. var startdir = thisModule["StartDir"];
  731. var group = thisModule["Group"];
  732. var fwsupport = "false";
  733. if (thisModule["SupportFW"]) {
  734. fwsupport = "true";
  735. }
  736. $("#listMenuItem").append(`<div class="item module" module="${name}" startdir="${startdir}" fw="${fwsupport}" group="${group}" onclick="openModuleFromMenu(this);">
  737. <span>
  738. <img class="ui middle aligned tiny image" src="${icon}" style="padding-right: 12px;"></img>
  739. ${name}
  740. </span>
  741. </div>`);
  742. }
  743. function closeListMenu(callback = undefined){
  744. if (listMenuShown == false){
  745. //Already closed
  746. if (typeof callback != "undefined"){
  747. callback();
  748. }
  749. return;
  750. }
  751. $("#listMenu").animate({
  752. left: window.innerWidth * -1
  753. },300,"swing", function(){
  754. $(".taskBar").animate({
  755. width: "300px",
  756. },300,"swing", function(){
  757. if (typeof callback != "undefined"){
  758. callback();
  759. }else{
  760. $(".extendOnly").slideDown("fast");
  761. }
  762. });
  763. });
  764. listMenuShown = false;
  765. }
  766. //Bind swip events
  767. document.addEventListener('touchstart', handleTouchStart, false);
  768. document.addEventListener('touchmove', handleTouchMove, false);
  769. var xDown = null;
  770. var yDown = null;
  771. var swipeTarget = null;
  772. var targetType = "fw";
  773. function getTouches(evt) {
  774. return evt.touches || // browser API
  775. evt.originalEvent.touches; // jQuery
  776. }
  777. function handleTouchStart(evt) {
  778. const firstTouch = getTouches(evt)[0];
  779. if ($(evt.target).hasClass("taskBar")){
  780. swipeTarget = evt.target;
  781. targetType = "taskbar"
  782. }else if ($(evt.target).hasClass("toggleTaskBar")){
  783. }else{
  784. if (evt.path != undefined){
  785. swipeTarget = getFloatWindowObjectFromPath(evt.path);
  786. }
  787. }
  788. xDown = firstTouch.clientX;
  789. yDown = firstTouch.clientY;
  790. };
  791. function getFloatWindowObjectFromPath(path){
  792. var targetObject = undefined;
  793. targetType = undefined
  794. path.forEach(object => {
  795. if ($(object).hasClass("floatWindowButton")){
  796. targetObject = object
  797. targetType = "fw"
  798. }
  799. })
  800. return targetObject;
  801. }
  802. function handleTouchMove(evt) {
  803. if ( ! xDown || ! yDown ) {
  804. return;
  805. }
  806. var xUp = evt.touches[0].clientX;
  807. var yUp = evt.touches[0].clientY;
  808. var xDiff = xDown - xUp;
  809. var yDiff = yDown - yUp;
  810. if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/
  811. if ( xDiff > 0 ) {
  812. /* left swipe */
  813. if (swipeTarget !== undefined && targetType == "fw"){
  814. closeFloatWindow($(swipeTarget).attr("windowId"));
  815. }else if (swipeTarget !== undefined && targetType == "taskbar"){
  816. hideTaskBar();
  817. }
  818. } else {
  819. /* right swipe */
  820. if (swipeTarget !== undefined && targetType == "fw"){
  821. //Allow left or right swipe to remove fw
  822. closeFloatWindow($(swipeTarget).attr("windowId"));
  823. }else if (swipeTarget !== undefined && targetType == "taskbar"){
  824. //Right swipe on taskbar
  825. if ($(swipeTarget).find(".toggleTaskBar").attr("shown") == "true"){
  826. //Already shown. Toggle list menu
  827. showListMenu();
  828. }else{
  829. showTaskBar();
  830. }
  831. }
  832. }
  833. } else {
  834. if ( yDiff > 0 ) {
  835. /* up swipe */
  836. } else {
  837. /* down swipe */
  838. }
  839. }
  840. /* reset values */
  841. xDown = null;
  842. yDown = null;
  843. swipeTarget = null;
  844. };
  845. function showListMenu(callback = undefined){
  846. if ($(".taskBar").find(".toggleTaskBar").attr("shown") == "false"){
  847. $(".taskBar").find(".toggleTaskBar").attr("shown", "true");
  848. $(".taskBar").find('.sidebararrow').attr("src","img/mobile/keyboard_arrow_left-white-48dp.svg");
  849. $("#mainFrame").addClass("blurred");
  850. }
  851. $(".taskBar").animate({
  852. width: window.innerWidth,
  853. },300, "swing", function(){
  854. //Switch all fwbuttons to normal size
  855. $(".floatWindowButton").each(function(){
  856. $(this).find(".minimizedElements").hide();
  857. $(this).find(".normalElements").show();
  858. });
  859. //Show list menu
  860. $("#listMenu").animate({
  861. left: 0
  862. },300,"swing", function(){
  863. if (typeof callback != "undefined"){
  864. callback();
  865. }
  866. });
  867. });
  868. listMenuShown = true;
  869. $("#sidebarToggleOverlay").show();
  870. }
  871. function openModule(moduleName) {
  872. $.get("system/modules/getLaunchPara?module=" + moduleName, function(data) {
  873. console.log(data);
  874. if (data.error !== undefined) {
  875. //Something went wrong.
  876. console.log("Unable to open module " + moduleName);
  877. if (data.error == "Not logged in."){
  878. //Session expired
  879. window.location.href = "login.system";
  880. }
  881. }else {
  882. //Launch the given module
  883. var url = data["StartDir"];
  884. var size = [undefined, undefined];
  885. var icon = "img/system/favicon.png";
  886. if (data["IconPath"] != "") {
  887. icon = data["IconPath"];
  888. }
  889. var title = data["Name"];
  890. //Check if the module support fw mode. If yes, launch with fwmode url. IF not, launch to index
  891. if (data["SupportFW"] == true) {
  892. if (data["LaunchFWDir"] != null) {
  893. url = data["LaunchFWDir"];
  894. }
  895. if (data["InitFWSize"] != null) {
  896. size = data["InitFWSize"];
  897. }
  898. }
  899. //Launch the given module
  900. newFloatWindow({
  901. url: url,
  902. width: size[0],
  903. height: size[1],
  904. appicon: icon,
  905. title: title
  906. });
  907. closeListMenu(function(){
  908. hideTaskBar();
  909. });
  910. }
  911. });
  912. }
  913. function openModuleFromMenu(object) {
  914. var moduleName = $(object).attr("module");
  915. openModule(moduleName);
  916. }
  917. //In mobile interface, there will be some option ignored by default
  918. function newFloatWindow(options){
  919. //Hide all other floatWindows
  920. $(".floatWindowWrapper").fadeOut("fast");
  921. //Hide shortcuts
  922. hideShortcuts();
  923. //Construct the new window
  924. var windowID = Date.now();
  925. var parent = options.parent || "";
  926. var callback = options.callback || "";
  927. //Create a new iframe
  928. $("#windowWrapper").append(` <div class="floatWindowWrapper" windowId="${windowID}">
  929. <div class="floatWindow" windowId="${windowID}" parent="${parent}" callback="${callback}">
  930. <div class="fwtab">
  931. <iframe src="${options.url}" style="width: 100%; height: 100%;"></iframe>
  932. </div>
  933. </div>
  934. </div>`);
  935. //Create the button
  936. var title = options.title || "New FloatWindow";
  937. $("#windowButtonWrapper").append(`
  938. <div class="floatWindowButton" windowID="${windowID}" onclick="focusTab(this)">
  939. <div class="minimizedElements">
  940. <img class="minimizedIcon" src="${options.appicon}">
  941. </div>
  942. <div class="normalElements" style="display:none;">
  943. <img class="ui normalizedIcon middle aligned image" src="${options.appicon}">
  944. <span class="windowTitle" style="color:white;">${title}</span>
  945. <div class="closebutton" onclick="closefw(this);"><i class="remove icon"></i></div>
  946. <div class="externalbutton" onclick="openfwInNewTab(this);"><i class="external icon"></i></div>
  947. </div>
  948. </div>
  949. `);
  950. }
  951. ///Functions realted to window resize and auto scaling
  952. function updateWindowDimensions(){
  953. $("#backdrop").css({
  954. width: window.innerWidth,
  955. height: window.innerHeight
  956. });
  957. if (!listMenuShown){
  958. $("#listMenu").css("left", window.innerWidth * -1);
  959. }
  960. }
  961. updateWindowDimensions();
  962. $(window).on("resize", function(data){
  963. updateWindowDimensions();
  964. })
  965. //Float Window APIs
  966. function setFloatWindowTitle(id, title){
  967. $(".floatWindowButton").each(function(){
  968. if ($(this).attr("windowId") == id){
  969. $(this).find(".windowTitle").text(title);
  970. }
  971. })
  972. }
  973. function getFloatWindowByID(id){
  974. var targetObejct = undefined;
  975. $(".floatWindowWrapper").each(function(){
  976. if ($(this).attr("windowId") == id){
  977. targetObejct = $(this);
  978. }
  979. });
  980. return targetObejct;
  981. }
  982. function MoveFloatWindowToTop(targetfw){
  983. //Check if this windows is already topped
  984. if ($(targetfw).is(":visible")){
  985. //Already topped
  986. return;
  987. }
  988. $(".floatWindowWrapper").each(function(){
  989. $(this).fadeOut("fast");
  990. });
  991. console.log(targetfw);
  992. $(targetfw).parent().fadeIn("fast");
  993. }
  994. function focusTab(object){
  995. var windowID = $(object).attr("windowId");
  996. //Hide all other flowWindows
  997. $(".floatWindowWrapper").fadeOut("fast");
  998. //Show the target fw
  999. var fw = getFloatWindowByID(windowID);
  1000. hideShortcuts();
  1001. fw.fadeIn("fast", function(){
  1002. hideTaskBar();
  1003. });
  1004. }
  1005. function getFloatWindowByID(id){
  1006. var targetObejct = undefined;
  1007. $(".floatWindowWrapper").each(function(){
  1008. if ($(this).attr("windowId") == id){
  1009. targetObejct = $(this);
  1010. }
  1011. });
  1012. return targetObejct;
  1013. }
  1014. function setFloatWindowResizePolicy(id, allowResize){
  1015. //Disabled in mobile mode
  1016. }
  1017. function setFloatWindowSize(id, width, height){
  1018. //Disabled in mobile mode
  1019. }
  1020. function closeFloatWindow(windowID){
  1021. //Get the content iframe with that windowID
  1022. var contentWindow = getFloatWindowByID(windowID);
  1023. if (contentWindow == undefined){
  1024. return;
  1025. }
  1026. contentWindow = contentWindow.find("iframe")[0].contentWindow;
  1027. try {
  1028. if (contentWindow.ao_module_close === undefined) {
  1029. //This module do not use ao_module wrapper. Close it directly.
  1030. closeFwProcess(windowID);
  1031. } else {
  1032. //Pass the closing events to the window itself
  1033. contentWindow.ao_module_close();
  1034. }
  1035. } catch (ex) {
  1036. //Problems of closing floatWindow. Force closing.
  1037. closeFwProcess(windowID);
  1038. }
  1039. }
  1040. function closefw(object){
  1041. var windowID = $(object).parent().parent().attr("windowID");
  1042. closeFloatWindow(windowID);
  1043. }
  1044. function openfwInNewTab(object){
  1045. event.preventDefault();
  1046. event.stopImmediatePropagation();
  1047. var windowID = $(object).parent().parent().attr("windowID");
  1048. var targetFloatWindow = null;
  1049. $(".floatWindowWrapper").each(function(){
  1050. if ($(this).attr("windowid") == windowID){
  1051. targetFloatWindow = $(this);
  1052. }
  1053. });
  1054. if (targetFloatWindow == null){
  1055. return;
  1056. }
  1057. var iframe = $(targetFloatWindow).find("iframe");
  1058. var url = $(iframe)[0].contentWindow.location.href;
  1059. window.open(url);
  1060. }
  1061. //Get the window below this window id, can return null if there is no window
  1062. function getPreviousWindowObject(windowID){
  1063. var previousWindowID = null;
  1064. var result = null;
  1065. $(".floatWindowButton").each(function(){
  1066. if ($(this).attr("windowid") == windowID){
  1067. result = previousWindowID;
  1068. }else{
  1069. let thisWindowID = $(this).attr("windowid");
  1070. previousWindowID = thisWindowID;
  1071. }
  1072. });
  1073. return result;
  1074. }
  1075. function closeFwProcess(windowID){
  1076. //Get the previous window object
  1077. var previousWindowID = getPreviousWindowObject(windowID);
  1078. //Remove the window object
  1079. $(".floatWindowWrapper").each(function(){
  1080. if ($(this).attr("windowId") == windowID){
  1081. $(this).fadeOut("fast",function(){
  1082. $(this).remove();
  1083. });
  1084. }
  1085. });
  1086. //Remove the button object
  1087. $(".floatWindowButton").each(function(){
  1088. if ($(this).attr("windowId") == windowID){
  1089. $(this).fadeOut("fast",function(){
  1090. $(this).remove();
  1091. });
  1092. }
  1093. });
  1094. //Focus the window behind if exists
  1095. setTimeout(function(){
  1096. if (previousWindowID != null){
  1097. //Hide all other flowWindows
  1098. $(".floatWindowWrapper").fadeOut("fast");
  1099. //Show the target fw
  1100. var fw = getFloatWindowByID(previousWindowID);
  1101. console.log(fw);
  1102. fw.fadeIn("fast", function(){
  1103. });
  1104. }
  1105. }, 100);
  1106. }
  1107. function bindObjectToIMEEvents(object){
  1108. console.log("IME not supported in mobile desktop mode")
  1109. };
  1110. function openFileWithModule(moduleLaunchInfo, openFileList) {
  1111. var url = moduleLaunchInfo["StartDir"];
  1112. var size = [undefined, undefined];
  1113. var title = moduleLaunchInfo["Name"];
  1114. var icon = "img/system/favicon.png";
  1115. if (moduleLaunchInfo["IconPath"] != "") {
  1116. icon = moduleLaunchInfo["IconPath"];
  1117. }
  1118. //Use floatWindow if exists
  1119. if (moduleLaunchInfo["SupportFW"] == true && moduleLaunchInfo["LaunchFWDir"] != "") {
  1120. url = moduleLaunchInfo["LaunchFWDir"];
  1121. if (moduleLaunchInfo["InitFWSize"] !== null) {
  1122. size = moduleLaunchInfo["InitFWSize"]
  1123. }
  1124. }
  1125. //Use embedded mode if exists
  1126. if (moduleLaunchInfo["SupportEmb"] == true && moduleLaunchInfo["LaunchEmb"] != "") {
  1127. url = moduleLaunchInfo["LaunchEmb"];
  1128. if (moduleLaunchInfo["InitEmbSize"] !== null) {
  1129. size = moduleLaunchInfo["InitEmbSize"]
  1130. }
  1131. }
  1132. var openParamter = encodeURIComponent(JSON.stringify(openFileList));
  1133. //Add launch files info and launch floatWindow
  1134. newFloatWindow({
  1135. url: url + "#" + openParamter,
  1136. width: size[0],
  1137. height: size[1],
  1138. appicon: icon,
  1139. title: title
  1140. });
  1141. }
  1142. //Mobile interface do not support pin function yet
  1143. function PinFloatWindowToTopMostMode(object){
  1144. }
  1145. function UnpinFloatWindowFromTopMostMode(object){
  1146. }
  1147. /*
  1148. List Menu Specific function groups
  1149. */
  1150. function openDesktopAsFolder(){
  1151. newFloatWindow({
  1152. url: "SystemAO/file_system/file_explorer.html#" + encodeURIComponent("user:/Desktop/"),
  1153. appicon: "SystemAO/file_system/img/small_icon.png",
  1154. width:1080,
  1155. height:580,
  1156. title: "File Manager"
  1157. });
  1158. hideTaskBar();
  1159. }
  1160. function openDesktopCustomization(){
  1161. newFloatWindow({
  1162. url: "SystemAO/desktop/personalization.html",
  1163. appicon: "SystemAO/desktop/img/personalization.png",
  1164. width:640,
  1165. height:480,
  1166. title: "Personalization"
  1167. });
  1168. hideTaskBar();
  1169. }
  1170. function showDesktop(){
  1171. $(".floatWindowWrapper").fadeOut("fast");
  1172. hideTaskBar();
  1173. showShortcuts();
  1174. }
  1175. //Theme color placeholder functions
  1176. function setThemeColor(color){
  1177. $(".themeColor").css("background-color", color);
  1178. }
  1179. //Startup sound
  1180. function initStartupSounds(){
  1181. $.ajax({
  1182. url: "../../system/desktop/preference",
  1183. method: "POST",
  1184. data: {preference: "startup-audio"},
  1185. success: function(data){
  1186. if (data == undefined || data == ""){
  1187. return;
  1188. }
  1189. var currentGlobalVol = localStorage.getItem("global_volume");
  1190. if (currentGlobalVol != null && currentGlobalVol != undefined && currentGlobalVol != ""){
  1191. }else{
  1192. currentGlobalVol = 0;
  1193. }
  1194. var audio = new Audio("media?file=" + data);
  1195. audio.volume = currentGlobalVol;
  1196. audio.play();
  1197. }
  1198. });
  1199. }
  1200. function fullscreen() {
  1201. //Opening full screen will lead to hidden of all iframe for unknown reasons
  1202. var isInFullScreen = (document.fullscreenElement && document.fullscreenElement !== null) ||
  1203. (document.webkitFullscreenElement && document.webkitFullscreenElement !== null) ||
  1204. (document.mozFullScreenElement && document.mozFullScreenElement !== null) ||
  1205. (document.msFullscreenElement && document.msFullscreenElement !== null);
  1206. var elem = document.documentElement;
  1207. if (!isInFullScreen) {
  1208. if (elem.requestFullscreen) {
  1209. elem.requestFullscreen();
  1210. } else if (elem.mozRequestFullScreen) { /* Firefox */
  1211. elem.mozRequestFullScreen();
  1212. } else if (elem.webkitRequestFullscreen) { /* Chrome, Safari and Opera */
  1213. elem.webkitRequestFullscreen();
  1214. } else if (elem.msRequestFullscreen) { /* IE/Edge */
  1215. elem.msRequestFullscreen();
  1216. }
  1217. } else {
  1218. if (document.exitFullscreen) {
  1219. document.exitFullscreen();
  1220. } else if (document.webkitExitFullscreen) {
  1221. document.webkitExitFullscreen();
  1222. } else if (document.mozCancelFullScreen) {
  1223. document.mozCancelFullScreen();
  1224. } else if (document.msExitFullscreen) {
  1225. document.msExitFullscreen();
  1226. }
  1227. }
  1228. hideTaskBar();
  1229. }
  1230. function initDesktopUserInfo(){
  1231. $.get("system/desktop/user", function(data){
  1232. if (data.error !== undefined){
  1233. alert(data.error);
  1234. }else{
  1235. userInfo = data;
  1236. //Update the user tag
  1237. $("#username").text(userInfo.Username);
  1238. $("#usergroups").text("@" + userInfo.UserGroups.join("/"));
  1239. $("#usergroups").attr("title",userInfo.UserGroups.join(" / "));
  1240. if (data.UserIcon !== ""){
  1241. $(".usericon").attr("src",data.UserIcon);
  1242. }
  1243. }
  1244. });
  1245. }
  1246. function showProfileInfo(){
  1247. hideTaskBar();
  1248. setTimeout(function(){
  1249. toggleProfileInfo();
  1250. }, 500);
  1251. }
  1252. function initShortcuts(){
  1253. initShortcut(1, $("#shortcut1"));
  1254. initShortcut(2, $("#shortcut2"));
  1255. initShortcut(3, $("#shortcut3"));
  1256. initShortcut(4, $("#shortcut4"));
  1257. }
  1258. function initShortcut(id, displayTarget){
  1259. getStorage("ao/mobile/shorcut/" + id, function(data){
  1260. if (data != ""){
  1261. $.get("system/modules/getLaunchPara?module=" + data, function(para){
  1262. displayTarget.attr("src", para.IconPath);
  1263. if (para.StartDir == ""){
  1264. displayTarget.addClass("disabled");
  1265. }else{
  1266. displayTarget.attr("module", encodeURIComponent(JSON.stringify(para.Name)));
  1267. }
  1268. });
  1269. }else{
  1270. //No data for this shortcut
  1271. displayTarget.attr("src", "img/desktop/system_icon/bad_shortcut.png");
  1272. displayTarget.addClass("disabled");
  1273. }
  1274. });
  1275. }
  1276. function showShortcuts(){
  1277. $("#shortcuts").slideDown("fast");
  1278. }
  1279. function hideShortcuts(){
  1280. $("#shortcuts").slideUp("fast");
  1281. }
  1282. function launchThisModule(object){
  1283. var moduleName = JSON.parse(decodeURIComponent($(object).attr("module")));
  1284. if (moduleName != ""){
  1285. openModule(moduleName);
  1286. }
  1287. }
  1288. function toggleProfileInfo(){
  1289. $("#userprofile").transition('drop');
  1290. }
  1291. function openSystemSettings(){
  1292. openModule("System Setting");
  1293. }
  1294. function logout() {
  1295. loggingOut = true;
  1296. if (confirm("Exiting Session. Confirm?")){
  1297. $.get("system/auth/logout", function() {
  1298. window.location.href = "/";
  1299. });
  1300. toggleProfileInfo();
  1301. }
  1302. }
  1303. function setStorage(key, value, callback = undefined) {
  1304. $.ajax({
  1305. url: "system/desktop/preference",
  1306. data: {preference: key, value: value},
  1307. method: "POST",
  1308. success: function(data) {
  1309. if (data.error !== undefined) {
  1310. console.log(data.error);
  1311. } else {
  1312. if (callback !== undefined) {
  1313. callback();
  1314. }
  1315. }
  1316. }
  1317. });
  1318. }
  1319. function getStorage(key, callback) {
  1320. $.ajax({
  1321. url: "system/desktop/preference",
  1322. data: {preference: key},
  1323. method: "POST",
  1324. success: callback
  1325. });
  1326. }
  1327. //Keep the clock updated
  1328. setInterval(function(){
  1329. updateClockTime();
  1330. },5000);
  1331. updateClockTime();
  1332. function updateClockTime(){
  1333. var d = new Date();
  1334. var display = monthNames[d.getMonth()] + " " + d.getDate() + " " + zeropad(d.getHours(),2) + ":" + zeropad(d.getMinutes(),2);
  1335. if ($(".notification.object").length > 0){
  1336. display += `<span style="color: #f54242; margin-left: 8px; float: center;"><i class="notice circle icon"></i></span>`;
  1337. }
  1338. $(".clock").html(display);
  1339. var largedate = monthNames[d.getMonth()] + " " + d.getDate() + " " + d.getFullYear()
  1340. $("#largedate").text(largedate);
  1341. var dow = daysNames[d.getDay()];
  1342. $("#dayofweek").text(dow);
  1343. }
  1344. function zeropad(n, width, z) {
  1345. z = z || '0';
  1346. n = n + '';
  1347. return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
  1348. }
  1349. </script>
  1350. </body>
  1351. </html>