MyBB Community Forums

Full Version: Close div and show once in 24h
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Could anybody help me out here. I want to show a message that will have a close button which will hide the message when clicked, and the message will only show to the user that closed it once in 24 hours?
Well you can do such modifying this tutorial:
http://demonate.com/thread-1156.html

Further save the timestamp as well through cookie and place condition to display accordingly ...
Great, only one question is there a way not to use this link?

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
    document.write(unescape("%3Cscript src='http://demonate.com/jscripts/cdn/jquery-1.8.2.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<script type="text/javascript">jQuery.noConflict();</script>
<script type="text/javascript" src="http://demonate.net/CDN/Library/jquery.cookie.js"></script>
Which link?
Is there a way not to require external files?
You would have to rewrite the code to use MyBB's Cookie.get and Cookie.set instead of jQuery.cookie. Also set div's style.display = "none"; instead of using jQuery's hide() function and use default Javascript onClick method, for instance.
Thanks D666 could you come up with such a code? PLEASE Smile
(2014-02-03, 06:04 PM)Destroy666 Wrote: [ -> ]You would have to rewrite the code to use MyBB's Cookie.get and Cookie.set instead of jQuery.cookie. Also set div's style.display = "none"; instead of using jQuery's hide() function and use default Javascript onClick method, for instance.

Sorry, but whats wrong with jQuery while MyBB itself switching to that?

(2014-02-03, 05:48 PM)marcus123 Wrote: [ -> ]Is there a way not to require external files?

Yes. host jQuery library to your own site and hotlink from there ...
Nothing is wrong, except speed maybe (marcus123's site is about SEO and page loading speed is also part of it): http://vanilla-js.com

Also it is still switching, so not everyone uses jQuery and some people may not want to include another library + cookie functionality just for 1 script that can be easily written with basic JS + MyBB functions.

@marcus123, this should work:
<script type="text/javascript">
if(Cookie.get("sitenote") != "X")
{
    $$('.notebox')[0].style.display = 'block';
}

var dismiss = document.getElementById('dismissnote');

dismiss.addEventListener('click', function() {
    Cookie.set("sitenote", "X", 86400);
    $$('.notebox')[0].style.display = 'none';
}, false);
</script>
Add it after Prototype is loaded.
D666 this is an upstanding reply. You are back again to rank high on my list of top mybb supporters Smile

@effone baby thanks very much for you help but D666 answer is a bit more what I am looking for Wink

P.S. it's embarrassing but why message form is not showing it has to show first but remain hidden after clinked!
Pages: 1 2