Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE REQUEST] Auto switch pages specified in minutes, looping between all the pages for a period of time #92

Closed
HummusB0x opened this issue May 20, 2024 · 1 comment

Comments

@HummusB0x
Copy link

HummusB0x commented May 20, 2024

Hello,

First of all, thank you very much for the share of this tool!

To use your project as dashboard, could we have an option that would automatically switch between pages after a given period defined by the user?

This configuration could be proposed through an option within the page page itself or even globally.

For example, let's configure the case you have 4 pages: page1, page2, page3 and page4.

  • When reaching the home page ( page1), I would like to to stay on this page 2 minutes.
  • Then page2 for 1:30 minutes
  • Then page3 for 4 minutes
  • Then page4 for 1 hour
  • Then it goes back to page1 for 2 minutes, etc.

When the auto switch enabled, the default time between page switch could be 1 minute for example.

This would be an awesome feature!

@svilenmarkov
Copy link
Member

Hey,

It kind of sounds like you're trying to use Glance for a kiosk. While I don't intend on adding such automatic page switching functionality, you could easily achieve the same with a bit of HTML and JS:

<body>

<style>
    * {
        padding: 0;
        margin: 0;
        width: 100%;
        height: 100%;
        overflow: hidden;
    }
</style>

<iframe id="iframe" src="" frameborder="0"></iframe>

<script>
    const baseUrl = "http://localhost:8080";

    const pages = [
        {
            path: "page1",
            // 90 seconds
            duration: 90 * 1000
        },
        {
            path: "page2",
            // 4 minutes
            duration: 4 * 60 * 1000
        },
        {
            path: "page3",
            // 1 hour
            duration: 60 * 60 * 1000
        },
    ];

    const iframe = document.getElementById('iframe');
    var currentPage = 0;

    const update = () => {
        const page = pages[currentPage];
        currentPage = (currentPage + 1) % pages.length;
        iframe.src = `${baseUrl}/${page.path}`;
        setTimeout(update, page.duration);
    }

    update();
</script>

</body>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants