mobile.system 69 KB

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