defaultOpener.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <html>
  2. <head>
  3. <title>Module List</title>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
  6. <link rel="stylesheet" href="../../script/semantic/semantic.min.css">
  7. <script type="text/javascript" src="../../script/jquery.min.js"></script>
  8. <script type="text/javascript" src="../../script/semantic/semantic.min.js"></script>
  9. <!-- <script type="text/javascript" src="../../script/ao_module.js"></script> -->
  10. </head>
  11. <body>
  12. <div class="ui container">
  13. <div class="ui basic segment">
  14. <div class="ui header">
  15. <i class="external icon"></i>
  16. <div class="content">
  17. Default Opening Module
  18. <div class="sub header">Manage your default modules to open files with given extensions</div>
  19. </div>
  20. </div>
  21. </div>
  22. <div id="msgbox" class="ui icon positive message" style="display:none;">
  23. <i class="checkmark icon"></i>
  24. <div class="content">
  25. <div class="header">
  26. Default Opening Module Updated
  27. </div>
  28. <p>Try to open your file again and see if it is working</p>
  29. </div>
  30. </div>
  31. <table class="ui celled table">
  32. <thead>
  33. <tr><th>File Extension</th>
  34. <th>Current Default </th>
  35. <th>Modify Default (Save on Change)</th>
  36. </tr></thead>
  37. <tbody id="defaultOpenerList">
  38. </tbody>
  39. </table>
  40. </div>
  41. <script>
  42. loadDefaultOpener();
  43. function loadDefaultOpener(){
  44. $("#defaultOpenerList").html("");
  45. $.ajax({
  46. url: "../../system/modules/getDefault?opr=list",
  47. success: function(data){
  48. if (data.error !== undefined){
  49. console.log(data.error);
  50. return;
  51. }
  52. for (var i =0; i < data.length; i++){
  53. var ext = data[i][0];
  54. var module = encodeURIComponent(data[i][1]);
  55. var displayModuleName = data[i][1];
  56. $("#defaultOpenerList").append(`<tr>
  57. <td>${ext}</td>
  58. <td>${displayModuleName}</td>
  59. <td><select class="ui search selection dropdown" ext="${ext}" module="${module}" onchange="updateDefaultOpener(this);">
  60. <option value="default">${displayModuleName}</option>
  61. </select>
  62. </td>
  63. </tr>`);
  64. }
  65. //Load modules into search dropdowns
  66. $.get("../../system/modules/list",function(moudleList){
  67. for (var i=0; i < moudleList.length; i++){
  68. var thisModule = moudleList[i];
  69. $(".search.dropdown").each(function(){
  70. var thisExt = $(this).attr("ext");
  71. var thisDefaultModule = decodeURIComponent($(this).attr("module"));
  72. if (thisModule.SupportedExt !== null && thisModule.SupportedExt.includes(thisExt)){
  73. //Accept this file type
  74. }
  75. if (thisDefaultModule !== thisModule.Name){
  76. $(this).append(`<option value="${thisModule.Name}">${thisModule.Name}</option>`);
  77. }
  78. });
  79. }
  80. $('.ui.dropdown').dropdown();
  81. });
  82. }
  83. });
  84. }
  85. function updateDefaultOpener(object){
  86. if ($(object).val() !== "default"){
  87. var ext = $(object).attr('ext');
  88. //Refresh the list
  89. $.ajax({
  90. url: "../../system/modules/getDefault?opr=set&ext=" + ext + "&module=" + $(object).val(),
  91. success: function(data){
  92. setTimeout(loadDefaultOpener,500);
  93. }
  94. });
  95. $("#msgbox").stop().finish().slideDown('fast').delay(5000).slideUp('fast');
  96. }
  97. }
  98. </script>
  99. </body>
  100. </html>