authreq.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Authentication Required</title>
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
  7. <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
  8. <script type="text/javascript" src="../../script/jquery.min.js"></script>
  9. <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
  10. <script type="text/javascript" src="../../script/ao_module.js"></script>
  11. <style>
  12. .topSlate{
  13. background-image: url("img/auth_slate.png");
  14. background-repeat: no-repeat;
  15. background-repeat: no-repeat !important;
  16. background-size: 100% auto;
  17. background-attachment: fixed !important;
  18. background-color: #1a1a1a;
  19. height: 70px;
  20. margin-bottom: 4px;
  21. }
  22. .whitefont{
  23. color: white !important;
  24. }
  25. </style>
  26. </head>
  27. <body>
  28. <div class="topSlate">
  29. <div class="ui container">
  30. <h3 class="ui header" style="padding-top: 12px;">
  31. <div class="content whitefont">
  32. <span id="title">Authentication Required</span>
  33. <div id="desc" class="sub header whitefont">in order to proceed this operation</div>
  34. </div>
  35. </h3>
  36. </div>
  37. </div>
  38. <div class="ui container">
  39. <div class="ui left icon small fluid input" style="margin-top: 12px;">
  40. <input id="username" type="text" placeholder="Username">
  41. <i class="user icon"></i>
  42. </div>
  43. <div class="ui left icon fluid input" style="margin-top: 12px;">
  44. <input id="password" type="password" placeholder="Password">
  45. <i class="key icon"></i>
  46. </div>
  47. <br>
  48. <div align="right">
  49. <button class="ui blue button" onclick="confirm()">Confirm</button>
  50. <button class="ui button" onclick="cancel()">Cancel</button>
  51. </div>
  52. </div>
  53. <script>
  54. ao_module_setFixedWindowSize();
  55. ao_module_setWindowSize(420, 260);
  56. var actionObject = {};
  57. var method = "GET";
  58. if (window.location.hash.length > 1){
  59. var object = JSON.parse(decodeURIComponent(window.location.hash.substr(1)));
  60. console.log(object);
  61. if (typeof(object.title) != "undefined"){
  62. $("#title").html(object.title);
  63. }
  64. if (typeof(object.desc) != "undefined"){
  65. $("#desc").html(object.desc);
  66. }
  67. if (typeof(object.thisuser) != "undefined" && object.thisuser == true){
  68. //Load user info from server side
  69. $.get("../../system/desktop/user", function(data){
  70. $("#username").val(data.Username);
  71. $("#username").attr("readonly","true");
  72. $("#username").parent().addClass("disabled");
  73. });
  74. }
  75. if (typeof(object.method) != "undefined" && object.method != ""){
  76. method = object.method;
  77. }
  78. actionObject = object;
  79. }else{
  80. //Invalid usage
  81. }
  82. function confirm(){
  83. $("password").parent().removeClass("error");
  84. var payload = actionObject.data;
  85. //Append custom payload to the original payload
  86. payload.username = $("#username").val();
  87. payload.password = $("#password").val();
  88. //Request endpoint
  89. $.ajax({
  90. url: "../../" + actionObject.api,
  91. data: payload,
  92. method: method,
  93. success: function(data){
  94. if (data.error != undefined){
  95. $("#password").parent().addClass("error");
  96. if ($("#username").parent().hasClass("disabled") == false){
  97. $("#username").parent().addClass("error");
  98. }
  99. }else{
  100. if (ao_module_hasParentCallback()){
  101. ao_module_parentCallback(data);
  102. }
  103. ao_module_close();
  104. }
  105. }
  106. })
  107. }
  108. function cancel(){
  109. if (ao_module_hasParentCallback()){
  110. ao_module_parentCallback(false);
  111. }
  112. ao_module_close();
  113. }
  114. </script>
  115. </body>
  116. </html>