embedded.html 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <style>
  5. body{
  6. background-color: white;
  7. }
  8. </style>
  9. </head>
  10. <body>
  11. Initializing Environment...<br>
  12. <script src="../script/jquery.min.js"></script>
  13. <script src="../script/ao_module.js"></script>
  14. <script>
  15. //Try its best to hide this window
  16. ao_module_setWindowTitle("NotepadA Initializing...");
  17. var inputFiles = ao_module_loadInputFiles();
  18. if (inputFiles != null){
  19. console.log(inputFiles);
  20. let targetOpeningInstances = ao_module_getInstanceByPath("NotepadA/index.html")
  21. if (targetOpeningInstances == null){
  22. //Open the file in new NotepadA windows
  23. let encodedFileObject = encodeURIComponent(JSON.stringify(inputFiles));
  24. var url = "NotepadA/index.html#" + encodedFileObject;
  25. var title = "NotepadA";
  26. ao_module_newfw({
  27. url: url,
  28. width: 1080,
  29. height: 580,
  30. title: title,
  31. appicon: "NotepadA/img/small_icon.png",
  32. });
  33. setTimeout(function(){
  34. ao_module_close();
  35. }, 300);
  36. }else{
  37. //Make the running NotepadA instance to open those files
  38. inputFiles.forEach(function(file){
  39. console.log($(targetOpeningInstances).find("iframe")[0].contentWindow.newEditor(file.filepath));
  40. });
  41. setTimeout(function(){
  42. ao_module_close();
  43. }, 300);
  44. }
  45. }
  46. /*
  47. var instances = ao_module_getProcessID("NotepadA");
  48. var filepath = "<?php echo $filepath;?>";
  49. var filename = "<?php echo $filename;?>";
  50. remove(instances,ao_module_windowID);
  51. if (instances.includes("newWindow")){
  52. remove(instances,"newWindow");
  53. }
  54. if (instances.length == 0){
  55. //Open a new window for the file
  56. console.log("[NotepadA] Opening " + filepath + " in a new floatWindow");
  57. window.location.href = "index.php?filename=" + filename + "&filepath=" + filepath;
  58. }else if (instances.length > 0){
  59. //Open the new page in the first instances in list
  60. var targetWindow = instances[0];
  61. console.log("[NotepadA] Opening " + filepath + " in floatWindow " + targetWindow);
  62. parent.crossFrameFunctionCall(targetWindow,"newEditor('" + filepath + "');");
  63. ao_module_close();
  64. }
  65. function remove(array, element) {
  66. const index = array.indexOf(element);
  67. array.splice(index, 1);
  68. }
  69. */
  70. </script>
  71. </body>
  72. </html>