@@ -25,17 +25,19 @@ import * as abapMonaco from "@abaplint/monaco";
25
25
import Split from "split-grid" ;
26
26
import { abapfiles } from "./abap" ;
27
27
28
- const top = "zcl_excel_demo1.clas.abap" ;
29
28
const reg = new abaplint . Registry ( new abaplint . Config ( JSON . stringify ( config ) ) ) ;
30
29
for ( const filename in abapfiles ) {
31
- if ( filename === top ) {
30
+ if ( filename . indexOf ( "zcl_excel_demo" ) === 0 ) {
31
+ document . getElementById ( "demoDropdown" ) . innerHTML += `<option value="${ filename } ">${ filename } </option>\n` ;
32
32
continue ;
33
33
}
34
34
reg . addFile ( new abaplint . MemoryFile ( filename , abapfiles [ filename ] ) ) ;
35
35
}
36
36
abapMonaco . registerABAP ( reg ) ;
37
37
38
- const filename = "file:///" + top ;
38
+ let top = "zcl_excel_demo1.clas.abap" ;
39
+ const filename = "file:///zcl_demo.clas.abap" ;
40
+
39
41
const model1 = monaco . editor . createModel (
40
42
abapfiles [ top ] ,
41
43
"abap" ,
@@ -85,6 +87,21 @@ observer.observe(document.getElementById("horizon"), {
85
87
86
88
window . addEventListener ( "resize" , updateEditorLayouts ) ;
87
89
90
+ document . getElementById ( "revertButton" ) . addEventListener ( "click" , ( ) => {
91
+ reg . updateFile ( new abaplint . MemoryFile ( filename , abapfiles [ top ] ) ) ;
92
+ model1 . setValue ( abapfiles [ top ] ) ;
93
+ abapChanged ( ) ;
94
+ } ) ;
95
+
96
+ document . getElementById ( "demoDropdown" ) . addEventListener ( "change" , ( e ) => {
97
+ // @ts -ignore
98
+ top = document . getElementById ( "demoDropdown" ) . value ;
99
+
100
+ reg . updateFile ( new abaplint . MemoryFile ( filename , abapfiles [ top ] ) ) ;
101
+ model1 . setValue ( abapfiles [ top ] ) ;
102
+ abapChanged ( ) ;
103
+ } ) ;
104
+
88
105
// see https://github.com/SimulatedGREG/electron-vue/issues/777
89
106
// see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncFunction
90
107
const AsyncFunction = new Function ( `return Object.getPrototypeOf(async function(){}).constructor` ) ( ) ;
@@ -98,7 +115,8 @@ async function abapChanged() {
98
115
abapMonaco . updateMarkers ( reg , model1 ) ;
99
116
100
117
if ( contents === abapfiles [ top ] ) {
101
- document . getElementById ( "container2" ) . innerHTML = `<iframe src="https://view.officeapps.live.com/op/view.aspx?src=https://abap2xlsx.github.io/abap2xlsx-web/zcl_excel_demo1.xlsx" title="Excel"></iframe>` ;
118
+ const name = top . split ( "." ) [ 0 ] ;
119
+ document . getElementById ( "container2" ) . innerHTML = `<iframe src="https://view.officeapps.live.com/op/view.aspx?src=https://abap2xlsx.github.io/abap2xlsx-web/${ name } .xlsx" title="Excel"></iframe>` ;
102
120
103
121
setTimeout ( ( ) => monaco . editor . getEditors ( ) [ 0 ] . focus ( ) , 1000 ) ;
104
122
} else {
0 commit comments