Skip to content

Webcomic Header

Family Deserts 28/33

Family Deserts 28/33 published on 24 Comments on Family Deserts 28/33

PSA: because the world is kind of a mess right now, and a lot of people are in worse financial straits than I am, I’ve paused Patreon charges for the month of April.

New patrons during that month will still be charged upfront, but if you’re an existing patron before April 1, your bill on that date will be skipped.


Larch: So if we start remembering the password, Hawthorn’s emergency-pickup plan won’t have to change at all.

Tansy: And Hyacinth is old enough not to need picking-up.

Hyacinth: I guess I should delete the weird message from Grandma unanswered, huh.

Tansy: Probably for the best, chickadee.

She doesn’t have your best interests in mind — nothing good will come out of talking to her.

Hyacinth: Mmhmm.

Unless . . .

Comment Header

24 Comments

I don’t know if this is an intentional thing or not, but when I try to use the Northern Lights or Rose Garden theme, going to a different strip sets it back to Blue Castle every time.

It’s not intentional, but I haven’t been able to find a way to fix it. (If anyone who’s more code-savvy has suggestions to make, I’ll give them a shot.)

One idea: all cookies are set for domain leifandthorn.com, EXCEPT the style cookie which is set for .leifandthorn.com (with leading dot) … on the other hand, probably is valid anyway because otherwise it wouldn’t show at all …

Better idea: it’s possible you have multiple functions set on body.onload. window.onload probably overrides body.onload, and you have window.onload used for google ads.

I would recommend to use addEventListener instead, or to be more specific:

var obj = document.getElementById(‘document’);
if (obj.addEventListener) {
obj.addEventListener(‘load’, set_style_from_cookie, false);
return true;
} else if (obj.attachEvent) {
return obj.attachEvent(‘onload’, set_style_from_cookie);
}

… because addEventListener will ADD the event handler instead of replacing the one currently there.

Sounds promising! Can you also be specific about where I’m supposed to paste this code, and how much of the existing code I should delete? (That’s about as far as my ability with Javascript goes.)

Must be below the get_cookie function, just below it (between the last } and the end of script tag) would be fine. Note that it needs to be function with those returns, so actually put there

(function() {
var obj = document.getElementById(‘document’);
if (obj.addEventListener) {
obj.addEventListener(‘load’, set_style_from_cookie, false);
return true;
} else if (obj.attachEvent) {
return obj.attachEvent(‘onload’, set_style_from_cookie);
})();

… oh, and be careful about the quotes. Should be real ASCII single quotes, not whatever fancy the comment system here replaces them with.

… forgot one closing } … second try:

(function() {
var obj = document.getElementById(‘document’);
if (obj.addEventListener) {
obj.addEventListener(‘load’, set_style_from_cookie, false);
return true;
} else if (obj.attachEvent) {
return obj.attachEvent(‘onload’, set_style_from_cookie);
}})();

Added!

No change yet, but I may be getting cached versions of pages — I’ll try again in a bit.

Hmmm … no, it really doesn’t work … I must admit I’m usually using jQuery so I don’t know all the quirks … let’s see … ok, seems I overcomplicated it needlessly. Body should be available as document.body, no need to search it by id.

So, next try, replace
var obj = document.getElementById(‘document’);
with
var obj = document.body;

It’s possible that the getElementById doesn’t work because the body is still open at that point.

Hmmm … no. Tried and the body is not there either. Ok. Let’s try something different and forget the body completely: let’s do just

var obj = window;

(Note that most pages on Stackoverflow recommends just using window.onload, not realizing there could be just one there … oh wait right there is obviously exact correct answer if you ask how to do two onloads :-))

Well, I tried that last one, and…it worked! It still starts out loading the default theme, but after a few seconds it flips to the one I set with the cookie.

If you have any idea how to make it check the user’s cookies before the CSS, that would be cool, but this is already a huge step up as-is.

Normal way how to do that would be on the server (in PHP) instead of in javascript. I suppose you don’t know how to do that either and that wordpress is making it harder … (the cookie is available as $_COOKIE[‘leifthornstyle’].

That said, you can try putting the script BELOW the alternate style links and instead of waiting for “load” event call the function to switch the styles immediately. Except I’m not sure if document.getElementsByTagName would work correctly without the document being fully loaded …

Heh, I don’t even have access to modify the PHP on the server, that’s all handled by the hosting company.

The script was below the alternate style links originally — I swapped them to see if that would change anything. Kinda feels like it’s half a second faster now…but that could always be other differences in page-load time, and either way it didn’t seem worth putting in a bunch of effort to analyze.

It actually may be faster when the styles are below the script. But the idea was to make the switch faster by having the styles first, then directly

set_style_from_cookie();

instead of the stuff with obj.addEventListener/obj.attachEvent … because that basically means “wait with switching the styles until the page is loaded”.

The problem may be that it won’t work at all because even with the styles above it it may need something else to finish loading.

Listen, I’m following the general idea here, and could probably figure out the specific code to implement it…if I had a free afternoon to spend just editing it different ways and testing whether it came out right, all with Javascript Syntax For Dummies open in another window! But I do not have that :/

So I’m happy to test this if you’re interested, but you’d still have to spell out for me exactly which lines to delete, and exactly what code to copy-and-paste in their place.

No, bad Hyacinth! Don’t let these toxic people in! Their own kids cut off contact because they’re awful. Don’t give them the benefit of the doubt because you don’t want to believe parents/grandparents can be awful, it’s naive and unhealthy to defend people you don’t even know to the people who DO know them.

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.