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

[BUG] date.getHour inside html embed widget not working #1238

Closed
CrazyWolf13 opened this issue Jun 23, 2023 · 5 comments
Closed

[BUG] date.getHour inside html embed widget not working #1238

CrazyWolf13 opened this issue Jun 23, 2023 · 5 comments
Assignees
Labels
🐛 Bug [ISSUE] Ticket describing something that isn't working

Comments

@CrazyWolf13
Copy link
Collaborator

CrazyWolf13 commented Jun 23, 2023

Environment

Self-Hosted (Docker)

System

RaspberryPi OS 32Bit

Version

2.1.1 (latest from docker)

Describe the problem

using this code below creates a wonderful time widget if opened via browser, but dashy does not display any digits, my guess that the date.getHour ... don't work.

         * {
            margin: 0;
            padding: 0;
            font-family: 'Poppins', sans-serif;
         }


         html, body {
            display: grid;
            height: 100%;
            place-items: center;
         }

         .wrapper {
            height: 100px;
            width: 360px;
            position: relative;
            cursor: default;
         }

         .wrapper .display,
         .wrapper span {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
         }

         .wrapper .display {
            z-index: 999;
            height: 85px;
            width: 345px;
            background: #1b1b1b77;
            border-radius: 6px;
            text-align: center;
         }

         .display #time {
            line-height: 85px;
            color: #fff;
            font-size: 50px;
            font-weight: 600;
         }
      </style>
   </head>
   <body>
      <div class="wrapper">
         <div class="display">
            <div id="time"></div>
         </div>
      </div>
      <script>
         setInterval(() => {
            const time = document.querySelector(".display #time");
            let date = new Date();
            let hours = date.getHours();
            let minutes = date.getMinutes();
            let seconds = date.getSeconds();
            if(seconds < 10){
             seconds = "0" + seconds;
           }
           if(minutes < 10){
             minutes = "0" + minutes;
           }
           if(hours < 10){
             hours = "0" + hours;
           }
            time.textContent = hours + ":" + minutes + ":" + seconds;
         });
      </script>
   </body>```

### Additional info

_No response_

### Please tick the boxes

- [X] You have explained the issue clearly, and included all relevant info
- [X] You are using a [supported](https://github.com/Lissy93/dashy/blob/master/.github/SECURITY.md#supported-versions) version of Dashy
- [X] You've checked that this [issue hasn't already been raised](https://github.com/Lissy93/dashy/issues?q=is%3Aissue)
- [X] You've checked the [docs](https://github.com/Lissy93/dashy/tree/master/docs#readme) and [troubleshooting](https://github.com/Lissy93/dashy/blob/master/docs/troubleshooting.md#troubleshooting) guide ![important](https://img.shields.io/badge/Important!-F6094E)
- [X] You agree to the [code of conduct](https://github.com/Lissy93/dashy/blob/master/.github/CODE_OF_CONDUCT.md#contributor-covenant-code-of-conduct)
@CrazyWolf13 CrazyWolf13 added the 🐛 Bug [ISSUE] Ticket describing something that isn't working label Jun 23, 2023
@liss-bot
Copy link
Collaborator

This issue has gone 3 months without an update. To keep the ticket open, please indicate that it is still relevant in a comment below. Otherwise it will be closed in 5 working days.

@liss-bot liss-bot added the ⚰️ Stale [ISSUE] [PR] No activity for over 1 month label Sep 22, 2023
@liss-bot
Copy link
Collaborator

This issue was automatically closed because it has been stalled for over 6 weeks with no activity.

@liss-bot liss-bot removed the ⚰️ Stale [ISSUE] [PR] No activity for over 1 month label Sep 27, 2023
@CrazyWolf13
Copy link
Collaborator Author

No this is still a problem....

@Lissy93
Copy link
Owner

Lissy93 commented Dec 31, 2023

Heya @CrazyWolf13

I think this is a JS issue with the code you've got.

I got it working with the below snippet.

But since the code in your ticket got cut-off, I had to (try to) re-create it: https://jsfiddle.net/lissy93/djrcvyw8/


sections:
- name: CrazyWolf13 Timer Section
  widgets:
  - type: iframe
    options:
      url: https://t1m3.netlify.app

Edit t1m3

Let me know if that helps :)

@CrazyWolf13
Copy link
Collaborator Author

Heya @CrazyWolf13

I think this is a JS issue with the code you've got.

I got it working with the below snippet.

But since the code in your ticket got cut-off, I had to (try to) re-create it: https://jsfiddle.net/lissy93/djrcvyw8/

```yaml sections: - name: CrazyWolf13 Timer Section widgets: - type: iframe options: url: https://t1m3.netlify.app ```

Edit t1m3

Let me know if that helps :)

Huge thanks for this !

I think the problem was that I used html embed instead of an iframe. Because with your js code the html embed is also not working.

Got it working, huge thanks! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug [ISSUE] Ticket describing something that isn't working
Projects
Status: Done
Development

No branches or pull requests

3 participants