mivalsten / ddb-dm-screen

MIT License
30 stars 10 forks source link

Auto-Updater? #29

Open FerrocCaldrson opened 4 years ago

FerrocCaldrson commented 4 years ago

Hey, so been chatting with you on the other guy's GitHub, and honestly I'm liking your original version better. No errors in information displayed at all. As per our discussion, an chance of adding an auto-updater, so that one does not need to continually refresh the page every few minutes?

Also the loading times are a little long, but this is sorta secondary. Just figured if you have time and it is something you can tweak, might as well mention it.

mivalsten commented 4 years ago

So, the way that it works is as follows: For each active character it opens hidden iframe and loads the character in the background, then it pulls data from the sheet. That way it is always correct as it takes values calculated by DDB team. The downside is, it is a bit slow and can be laggy if you have a lot of characters in campaign. I'm looking into a way to do some kind of auto-updater, but my knowledge of js is kindda basic. First version of the code I wrote, one awesome dude comes in and refactors the hell out of it - out of 200 lines of code he left two that were mine. :D

FerrocCaldrson commented 4 years ago

That's totally fair- and honestly I value the accuracy over the speed as I said earlier. Much prefer being able to get reliable information consistently rather than having to remember the exact number. Might as well just memorize the values then, and that would make the whole thing redundant!

Definitely, appreciate the time and effort you have put in, and while I hope the auto-updater does come soon I can be patient!

mivalsten commented 4 years ago

Fyi, working on it. I got it working to the point when I can update data without reloading whole page, now I need to add some GUI and automate data renewal.

FerrocCaldrson commented 4 years ago

That is awesome!

mivalsten commented 4 years ago

@FerrocCaldrson First version is live on dev branch, please check on https://github.com/mivalsten/ddb-dm-screen/raw/auto-updater/ddb-dm-screen.user.js

For now there is not way of easy controlling autoupdating, it's always on and updates roughly every 30 seconds or so. If you want to change it, set new update value on line 397. Adding UI should be easy now, but will probably take a few more days as I do not have a lot of spare time when I can still think clearly. :)

Let me know if you like it.

mivalsten commented 4 years ago

Aaand the GUI is in, looks bad though.

image

I know nothing about styling, so it will probably keep looking like crap until someone comes and fixes it. :) Please test and let me know if it is to your liking.

FerrocCaldrson commented 4 years ago

I mean I personally don't mind the look at all. And it works great! I've tested it out with a couple of characters in my campaign and it does do the job. I noticed the updater has the option of going less than 30, but I assume (and testing it out I think I'm pretty sure) the fastest it can update is 30. Nothing wrong with that at all, but if someone does end up going in and "fixing" it to look all pretty, may wanna have them cap the lowest option at thirty. But honestly great job, this will make game nights a lot easier! Thanks so much!

mivalsten commented 4 years ago

but I assume (and testing it out I think I'm pretty sure) the fastest it can update is 30.

Actually no, it's just the way it works right now that might give this impression.

After the function that retrieves data and draws it on screen a setTimeout function is called which waits for the provided time before executing it's contents. Due to that, if you change time between updates, it will be active from the next iteration forward. (also, if you set the value to to high a number, it will be probably faster to reload than to wait that high amount of seconds)

Glad you like it! :)

mivalsten commented 4 years ago

@FerrocCaldrson, could I ask you to test newest version? It's the same link as above. I added config persistency, so now update period you set once should work even after restarts/refreshes.

FerrocCaldrson commented 4 years ago

Just tested it, timer configuration persists even after closing and opening the page in a new tab. Very cool addition, thanks!

mivalsten commented 4 years ago

@FerrocCaldrson, there has been a major update bone by @TeaWithLucas, I think you want to update to their version. https://github.com/TeaWithLucas/DNDBeyond-DM-Screen

FerrocCaldrson commented 4 years ago

Thanks for the heads up!