mirror of
https://github.com/leaningtech/cheerpj-meta.git
synced 2025-03-25 07:27:51 +01:00
modified index.html
This commit is contained in:
parent
7d63cfe2ff
commit
72b48e0d7f
@ -9,10 +9,13 @@
|
|||||||
|
|
||||||
<body>
|
<body>
|
||||||
<h1>CheerpJ Java Interoperability Tutorial</h1>
|
<h1>CheerpJ Java Interoperability Tutorial</h1>
|
||||||
<input type="text" id="inputText" placeholder="Type something here">
|
|
||||||
<button onclick="sendInputToJava()">Send to Java</button>
|
<!-- Wrap the input, button, and output in a div with an initial hidden style -->
|
||||||
<div id="javaOutput" style="margin-top:20px; font-weight: bold;">JavaScript received: </div>
|
<div id="inputDiv" style="display: none;">
|
||||||
</br>
|
<input type="text" id="inputText" placeholder="Type something here">
|
||||||
|
<button onclick="sendInputToJava()">Send to Java</button>
|
||||||
|
<div id="javaOutput" style="margin-top:20px; font-weight: bold;">JavaScript received: </div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
let exampleInstance;
|
let exampleInstance;
|
||||||
@ -27,6 +30,10 @@
|
|||||||
console.log(window.myApplication);
|
console.log(window.myApplication);
|
||||||
console.log(myApplication);
|
console.log(myApplication);
|
||||||
console.log("setting application");
|
console.log("setting application");
|
||||||
|
|
||||||
|
// Make the inputDiv visible after initialization
|
||||||
|
document.getElementById('inputDiv').style.display = 'block';
|
||||||
|
|
||||||
/* This makes the function 'never' return */
|
/* This makes the function 'never' return */
|
||||||
return new Promise(() => { });
|
return new Promise(() => { });
|
||||||
}
|
}
|
||||||
@ -35,19 +42,22 @@
|
|||||||
await cheerpjInit(
|
await cheerpjInit(
|
||||||
{
|
{
|
||||||
version: 8,
|
version: 8,
|
||||||
natives: {
|
natives: {
|
||||||
Java_com_example_Example_sendToHTML,
|
Java_com_example_Example_sendToHTML,
|
||||||
Java_com_example_Example_nativeSetApplication
|
Java_com_example_Example_nativeSetApplication
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
cheerpjCreateDisplay(400, 300);
|
cheerpjCreateDisplay(400, 300);
|
||||||
|
|
||||||
await cheerpjRunJar('/app/example.jar');
|
// here we use the path '/app/Interoperability/example.jar' for deployment on the cloud
|
||||||
|
// use the path '/app/example.jar' for local deployment
|
||||||
|
// await cheerpjRunJar('/app/example.jar');
|
||||||
|
await cheerpjRunJar('/app/Interoperability/example.jar');
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
||||||
async function sendInputToJava() {
|
async function sendInputToJava() {
|
||||||
|
|
||||||
// Get the input text from the HTML input box
|
// Get the input text from the HTML input box
|
||||||
const inputText = document.getElementById("inputText").value;
|
const inputText = document.getElementById("inputText").value;
|
||||||
console.log(inputText);
|
console.log(inputText);
|
||||||
@ -55,7 +65,6 @@
|
|||||||
// Call the Java method with the input text
|
// Call the Java method with the input text
|
||||||
const response = await window.myApplication.processInput(inputText);
|
const response = await window.myApplication.processInput(inputText);
|
||||||
window.alert(response);
|
window.alert(response);
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user