config.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <!-- Meta headers for mobile devices-->
  5. <meta name="apple-mobile-web-app-capable" content="yes" />
  6. <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"/>
  7. <meta charset="UTF-8">
  8. <link rel="icon" href="favicon.png">
  9. <!-- CSS and JavaScript, access to scripe folder is not blocked for non logged in users-->
  10. <link rel="stylesheet" href="../../../script/semantic/semantic.min.css">
  11. <script src="../../../script/jquery.min.js"></script>
  12. <!-- <script src="../../../script/ao_module.js"></script> -->
  13. <script src="../../../script/semantic/semantic.min.js"></script>
  14. <title>Personal Homepage</title>
  15. <style>
  16. body{
  17. background-color:white;
  18. }
  19. </style>
  20. </head>
  21. <body>
  22. <br>
  23. <div class="ui container">
  24. <div class="ui basic segment">
  25. <h3 class="ui header">
  26. <i class="home icon"></i>
  27. <div class="content">
  28. Personal Home Page
  29. <div class="sub header">Create your own home page on ArozOS</div>
  30. </div>
  31. </h3>
  32. </div>
  33. <div class="ui divider"></div>
  34. <div class="ui message">
  35. <div class="header">
  36. What is Personal Home Page?
  37. </div>
  38. <ul class="list">
  39. <li>You can host a static website using ArozOS</li>
  40. <li>All website source are accessiable by your File Manager located inside your user file system</li>
  41. <li>Everyone can access your home page using <a id="homepageLink" target="_blank"><span class="protocol">http:</span>//<span class="hostname"></span><span class="port"></span>/www/<span class="username">{your_username}</span>/</a></li>
  42. </ul>
  43. </div>
  44. <div class="ui container">
  45. <h4>Toggle Personal Home Page</h4>
  46. <div class="ui toggle checkbox">
  47. <input type="checkbox" id="enablehp" onchange="updateHomepageStatus(this.checked);">
  48. <label>Enable personal home page</label>
  49. </div>
  50. <div id="updateSuceed" style="display:none;" class="ui green inverted segment"><i class="checkmark icon"></i> Home Page Status Updated</div>
  51. <br>
  52. <h4>Select web root folder location</h4>
  53. <div class="ui action fluid input">
  54. <input id="webroot" type="text" placeholder="Select Location" readonly="true">
  55. <button class="ui black button" onclick="selectWebRootLocation();"><i class="folder open icon"></i> Open</button>
  56. </div>
  57. <div class="ui yellow message"><i class="warning icon"></i> All files located inside the web root will be accessiable by everyone on the internet.</div>
  58. <div id="webrootSetSuceed" style="display:none;" class="ui green inverted segment"><i class="checkmark icon"></i> Web Root Location Updated</div>
  59. <br>
  60. <small>*All changes will be saved automatically upon updates.</small>
  61. </div>
  62. <br><br>
  63. </div>
  64. <script>
  65. var ignoreChange = true;
  66. //Update the user information
  67. $.get("../../../system/desktop/user", function(data){
  68. if (data.error == undefined){
  69. $(".username").text(data.Username);
  70. $("#homepageLink").attr('href', $("#homepageLink").text());
  71. }
  72. });
  73. //Update tutorial information
  74. $(".hostname").text(window.location.hostname);
  75. $(".port").text(":" + window.location.port);
  76. if (window.location.port == ""){
  77. $(".port").text("");
  78. }
  79. $(".protocol").text(window.location.protocol);
  80. initHomePageInfo();
  81. function initHomePageInfo(){
  82. $.get("../../../system/network/www/toggle", function(data){
  83. if (data.error == undefined){
  84. $("#enablehp")[0].checked = data;
  85. ignoreChange = false;
  86. }
  87. });
  88. $.get("../../../system/network/www/webRoot", function(data){
  89. if (data.error !== undefined){
  90. //Not defined.
  91. }else{
  92. //Defined. Set it to the input field
  93. $("#webroot").val(data);
  94. }
  95. });
  96. }
  97. function updateHomepageStatus(enableHomePage = false){
  98. if (ignoreChange){
  99. return;
  100. }
  101. $.ajax({
  102. url: "../../../system/network/www/toggle",
  103. data: {set: enableHomePage},
  104. success: function(data){
  105. if (data.error !== undefined){
  106. alert(data.error);
  107. }else{
  108. $("#updateSuceed").slideDown("fast").delay(3000).slideUp("fast");
  109. }
  110. }
  111. });
  112. }
  113. function selectWebRootLocation(){
  114. ao_module_openFileSelector(webrootSelected, "user:/", "folder",false);
  115. }
  116. function webrootSelected(filedata){
  117. for (var i=0; i < filedata.length; i++){
  118. var filename = filedata[i].filename;
  119. var filepath = filedata[i].filepath;
  120. $("#webroot").val(filepath);
  121. }
  122. //Update the server database
  123. $.ajax({
  124. url: "../../../system/network/www/webRoot",
  125. data: {set: $("#webroot").val()},
  126. success: function(data){
  127. if (data.error !== undefined){
  128. alert(data.error);
  129. }else{
  130. $("#webrootSetSuceed").slideDown("fast").delay(3000).slideUp("fast");
  131. }
  132. }
  133. });
  134. }
  135. </script>
  136. </body>
  137. </html>