Skip to content

Commit

Permalink
LENS Example Website
Browse files Browse the repository at this point in the history
  • Loading branch information
Admin-Host committed Dec 23, 2024
0 parents commit e5932aa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/.vs
/.vscode
.env
13 changes: 13 additions & 0 deletions assets/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const url = 'https://lens.admin-host.com'; // LENS server URL
const host = 'my-app'; // Registered app slug
const width = 600; // Popup window width
const height = 850; // Popup window height
document.querySelector('#domain').innerHTML += document.domain; // Display current domain on screen. This domain must be registered with LENS. Register 'localhost' for testing
function receiveMessage(event) {
if (event.origin === url) {
console.log(event.data); // Log response in console
document.querySelector('#response').innerHTML += JSON.stringify(event.data); // Display response on screen
};
};
window.addEventListener('message', receiveMessage, false);
const popupWindow = window.open(`${url}?host=${host}&return=${document.domain}`, 'popup', `width=${width},height=${height},left=${(screen.width / 2) - (width / 2)},top=${(screen.height / 2) - (height / 2)}`);
15 changes: 15 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>

<head>
<title>LENS App</title>
</head>

<body>
<h1>Hello World!</h1>
<p id="domain">Domain: </p>
<p id="response">Response: </p>
</body>
<script src="assets/script.js"></script>

</html>

0 comments on commit e5932aa

Please sign in to comment.