inherit
92560
0
Jan 27, 2023 16:09:21 GMT -8
Befera
Don't beg for things. Do it yourself, or else you won't get anything.
98
November 2006
befera
|
Post by Befera on Mar 10, 2013 22:31:36 GMT -8
Hello. Working on this site here. There are a few people on that site who don't like the Live Prieview code, so I'm trying to give the members an option when they post to disable it. In this thread, they solve my problem and do it well, but when I put the code in I noticed this piece which I thought was awesome: b.onblur = function EU_Cookie(){if(/\bdisablelivepreview=/.test(document.cookie) || confirm("Do you wish to save the current live preview setting to a cookie so it can be remembered for the next time?"))document.cookie = "disablelivepreview=" + (/off/.test(document.getElementById('togglepreview').href)?"0":"1") + ";expires=" + (new Date(new Date(+new Date).setFullYear(2017)).toGMTString()) + ";"}insert code here Specifically the "Do you wish to save the current live preview setting" part. I would really like it if members could save it so that Live Preview is disabled until they want to re-enable it, but this code isn't doing that currently. I put the code in and tested it and no message comes up that asks to save the cookies, and I'm not sure why. I assume the code may just need to be modified a bit or another small part needs to be added, but I don't have the coding knowledge to figure out what, so here I am. Any help is greatly appreciated! Thanks! -Bef
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,022
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 10, 2013 23:25:50 GMT -8
The code only asks the first time in order to comply with the EU cookie law, then it doesn't ask again unless the cookie (named "disablelivepreview") is deleted or permission was not granted by the user. It would be pretty annoying if it asked each and every time, so all subsequent saving is done silently since permission was granted that first time. Unless there was an unintended change made to the code during the conversion to V5 I don't see where it would not still work (on a V4 forum that is)
If you have a guest viewable link demonstrating the code not working then I'll take a look
|
|
inherit
92560
0
Jan 27, 2023 16:09:21 GMT -8
Befera
Don't beg for things. Do it yourself, or else you won't get anything.
98
November 2006
befera
|
Post by Befera on Mar 11, 2013 8:54:12 GMT -8
This is a guest friendly board. I have the code enabled and you may test it there. The problem is that it doesn't even ask the first time. It does not ask at all. Thanks - - - here are some screenshots (though they don't really show anything, but i guess that's the point) ^ this is what happens when i first go to make a post. live preview is there already, and... ^ ...i click the toggle button to remove it. ^ then i create the post. it does not prompt me at all during the process to save my settings, and live preview is still enabled when i try to make another post or thread. hopefully that demonstrates the problem a bit better.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,022
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 11, 2013 13:55:45 GMT -8
Thanks for the link. May I ask what browser you are using? The code worked as intended for me It asked the first time I used the feature and remembered the last chosen state after being refreshed multiple times. It also no longer asked no matter how many times I toggled back and forth even after closing the browser and reopening. I had to manually delete the cookie to get it to ask again. I notice you edited the confirmation message but I see no ill effects from it on this end.
|
|
inherit
92560
0
Jan 27, 2023 16:09:21 GMT -8
Befera
Don't beg for things. Do it yourself, or else you won't get anything.
98
November 2006
befera
|
Post by Befera on Mar 12, 2013 13:08:31 GMT -8
I'm glad the code worked for you, at least. If anything, maybe it'll at least work for some people who have the browser or browsers that support it. I'm using Google Chrome.
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,022
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 12, 2013 15:02:19 GMT -8
Well that is indeed strange because I just tried it in Chrome and got the same results you did. Since it worked in Chrome when I wrote it this means Chrome has once again "flipped the script". It appears to not be firing the onblur event even though this is a link (ergo can have focus and therefore also can have blur).
It does however work in Chrome if I add a tab index to the link so find this like line and add the red
b.id = "togglepreview"; b.tabIndex = 1000;
Informational Update: It appears recent versions of Chrome treat links that use the javascript: protocol in its href as non-focusable links which is why tabindex is now needed to make it focusable. A value of 0 seems to be the new convention but need data on how widespread this convention has been adopted by browser manufacturers and which older browser would still balk at this.
|
|
inherit
92560
0
Jan 27, 2023 16:09:21 GMT -8
Befera
Don't beg for things. Do it yourself, or else you won't get anything.
98
November 2006
befera
|
Post by Befera on Mar 13, 2013 14:05:36 GMT -8
It worked perfectly! Thank you so much!
|
|
inherit
Official Code Helper
65613
0
1
Oct 22, 2024 1:56:19 GMT -8
Chris
"'Oops' is the sound we make when we improve"
9,022
December 2005
horace
RedBassett's Mini-Profile
|
Post by Chris on Mar 13, 2013 18:30:22 GMT -8
You bet! "Viva la V4..."
|
|