JavaScript -> Auto-updating Image - Printable Version +- The VG Resource (https://www.vg-resource.com) +-- Forum: Archive (https://www.vg-resource.com/forum-65.html) +--- Forum: July 2014 Archive (https://www.vg-resource.com/forum-139.html) +---- Forum: Other Stuff (https://www.vg-resource.com/forum-6.html) +----- Forum: Questions, Info, and Tutorials (https://www.vg-resource.com/forum-89.html) +----- Thread: JavaScript -> Auto-updating Image (/thread-24096.html) |
RE: JavaScript -> Auto-updating Image - Phaze - 11-09-2013 Code: $url = "http://thedilbertstore.com/images/periodic_content/dilbert/dt".date("ymd")."dhct.jpg"; One liner for the URL, lol. Compare it to the GIF version: Code: $url = "http://www.dilbert.com/dyn/str_strip/"; // base URL Will make the image generation/caching code tonight if I can stop faffing about. RE: JavaScript -> Auto-updating Image - puggsoy - 11-09-2013 Looking good! PHP seems pretty handy, I'll have to check it out when I can. RE: JavaScript -> Auto-updating Image - Phaze - 11-09-2013 (11-09-2013, 07:56 PM)puggsoy Wrote: Looking good! PHP seems like a pretty nice language, I'll have to check it out when I can. PHP has its... quirks. This image describes PHP best if it were a tool: OH MAN, I FINALLY FINISHED SOMETHING PROGRAMMING RELATED! It's not exactly a big job, but I feel pretty great now Source code is here: See the script in action here RE: JavaScript -> Auto-updating Image - puggsoy - 11-09-2013 I LOVE YOU. Thank you thank you thank you, you're awesome I also noticed that you specified the timestamp to be the American one. Thanks for that, otherwise I'd get my Dilbert earlier than everyone else that'd just be weird Question though, how do I pass a parameter for the larger JPG version? Nice job man, hopefully other Dilbert nerds will see this and can enjoy the awesomeness of a daily image of this great comic. RE: JavaScript -> Auto-updating Image - Phaze - 11-09-2013 (11-09-2013, 10:49 PM)puggsoy Wrote: I also noticed that you specified the timestamp to be the American one. Thanks for that, otherwise I'd get my Dilbert earlier than everyone else that'd just be weird Question though, how do I pass a parameter for the larger JPG version?Well the problem is that it tries to get a comic that doesn't exist if I don't set it to that! http://phazepages.net/code/dilbert/dilbert.php?format=jpg (or use "jpeg") I consider the JPG version ugly though, it has a lot of artifacts (not to mention it's somehow bigger in filesize than the GIF despite it). Sure easier to retrieve the URL though :v RE: JavaScript -> Auto-updating Image - puggsoy - 11-09-2013 Really? When I used the JavaScript code it got tomorrow's one (since I'm GMT+12). Maybe that's only with the JPG though. Also yeah, the GIF is more desirable than the JPG. Some people might find the latter useful if they want it a bit bigger, but as you said it has artefacts. What's more it's 800 pixels wide and would be resized in my sig by the forum, which wouldn't look too good. Luckily the GIF is only 680 pixels, so thanks a lot for going to the trouble to get that as well. RE: JavaScript -> Auto-updating Image - Phaze - 11-09-2013 (11-09-2013, 11:09 PM)puggsoy Wrote: Really? When I used the JavaScript code it got tomorrow's one (since I'm GMT+12). Maybe that's only with the JPG though.vOv It's just as well that I screwed up and was working on getting the GIF version's URL, huh :v RE: JavaScript -> Auto-updating Image - puggsoy - 11-10-2013 Looks like we got a glitch. It's getting the strip of the 4th, which is missing the last 2 speech bubbles. The JPG version gives me a page full of warnings. By my estimation this happened about 26 minutes ago, when it just passed midnight in New York. The Dilbert site itself is still on the comic of the 9th, so it appears that it changes according to a different time zone, maybe on the American west coast time. RE: JavaScript -> Auto-updating Image - Phaze - 11-10-2013 (11-10-2013, 12:27 AM)puggsoy Wrote: Looks like we got a glitch. It's getting the strip of the 4th, which is missing the last 2 speech bubbles. The JPG version gives me a page full of warnings. Dammit! Changed to Los Angeles, hopefully that will prevent that happening. RE: JavaScript -> Auto-updating Image - puggsoy - 11-10-2013 Awesome, thanks! Tiny fidget, Los Angeles is a bit behind. It probably won't break, but it would be nice to have it switch at the exact same time. I checked and apparently Dilbert updates according to CST. EDIT: OK, so it broke with the new hour. I don't get it. RE: JavaScript -> Auto-updating Image - Phaze - 11-10-2013 I am... confused. I'll try testing it later to pinpoint the exact problem. Edit: Well I found the problem for the gif comics. Sunday comics have "sunday" in the filename and a unique ID for some stupid reason. JPGs were a simple fix in comparison, I forgot the "s" : "d" part. For GIFs I need to compute another ID difference. Ok, I think it should actually work uninterrupted, now. Code: // Thank you for arbitrarily using a different index and filename for Sunday. God fucking dammit. Now I feel like Dilbert. *master of shitty hacks* RE: JavaScript -> Auto-updating Image - puggsoy - 11-10-2013 You're a saint, my man. Thanks a huuuuuuge bunch! I would assume that the reason Sunday comics differ is because they are somewhat larger in height. I can't think of a reason why a completely different ID would be necessary, but I guess that's just easier for whatever system the Dilbert site uses. Perhaps there's some sort of feature for grabbing all Sunday comics or something. RE: JavaScript -> Auto-updating Image - Phaze - 11-10-2013 (11-10-2013, 02:59 PM)puggsoy Wrote: You're a saint, my man. Thanks a huuuuuuge bunch! i'm phaze (no problem). Maybe! But hopefully that's the last gotcha that I need to deal with for Dilbert comics :v RE: JavaScript -> Auto-updating Image - PatientZero - 11-10-2013 Not a bad bit of code there, part of me wants to think there must be a more elegant solution to the sunday exception, but if it works it works. I have to admit that the bug with it loading everything but the text on the last panel gave me a good chuckle, my brain was short-circuiting over "images don't work like that" logic. RE: JavaScript -> Auto-updating Image - Phaze - 11-10-2013 (11-10-2013, 06:30 PM)PatientZero Wrote: Not a bad bit of code there, part of me wants to think there must be a more elegant solution to the sunday exception, but if it works it works. I wish there was a more elegant solution that was obvious, it would've made programming it easier Easier solution on the Dilbert site itself would've been to have a "daily.gif/jpg" that got updated when the CMS he's using had a new comic added to it, but shrug. Yeah, I think the Dilbert site sends some generic image when that happens. |