embedded.html 2.1 KB

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