Announcement

Collapse
No announcement yet.

Automatic Holiday Banner

Collapse
X
Collapse
First Prev Next Last
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Automatic Holiday Banner

    This is a CSS/Script that displays Holiday banners based on current date.

    No having to change the banner manually.

    If no holiday is observed then a random non-holiday banner is selected

    I created this as I got annoyed with trying to remember.

    This one is set up for major Public US holidays.

    The States have Public, Federal, State, National and god help all, Hallmark holidays. Also, over 3,000 religions and their holidays. This isn't even to mention holidays of other nations. So don't expecting me to add them all.

    Use the Site Builder and create a new module using Static HTML.

    Add this code-
    Code:
    <style>
        .HolidayBanner {
       border-radius: 8px;
       border: 1px solid #ddd;
       border-radius: 4px;
       padding: 5px;
       max-width: 100%;
       height: auto;
       background-color: #000000;
       margin-left: auto;
       margin-right: auto;
       display: flex;
       align-items: center;
    }
    </style>
    <script type="text/javascript">
    
     var pic='';
     var mytime=new Date();
     var Today = mytime.getDate();
     var Month = mytime.getMonth()+1;
            if (Month==12 && Today >= 27) {pic="<img class='HolidayBanner' src='/Holiday/banners/Happy-New-Year-Banner.jpg' />";
     } else if (Month==1  && Today <= 3)  {pic="<img class='HolidayBanner' src='/Holiday/banners/Happy-New-Year-Banner.jpg' />";
     } else if (Month==1  && Today==18)   {pic="<img class='HolidayBanner' src='/Holiday/banners/martin-luther-king-jr.png' />";
     } else if (Month==2  && Today==2)    {pic="<img class='HolidayBanner' src='/Holiday/banners/GroundHogDay.jpg' />";
     } else if (Month==2  && Today==14)   {pic="<img class='HolidayBanner' src='/Holiday/banners/Happy-Valentines-Day.jpg' />";
     } else if (Month==3  && Today==17)   {pic="<img class='HolidayBanner' src='/Holiday/banners/StPD.jpg' />";
     } else if (Month==3  && Today >= 25 && Today <= 28){pic="<img class='HolidayBanner' src='/Holiday/banners/Easter.jpg' />";
     } else if (Month==7  && Today==4)    {pic="<img class='HolidayBanner' src='/Holiday/banners/Independence_Day.jpg' />";
     } else if (Month==10 && Today >= 30) {pic="<img class='HolidayBanner' src='/Holiday/banners/Halloween.jpg' />";
     } else if (Month==11 && Today <= 2)  {pic="<img class='HolidayBanner' src='/Holiday/banners/Halloween.jpg' />";
     } else if (Month==12 && Today >= 23 && Today <= 26){pic="<img class='HolidayBanner' src='/Holiday/banners/XMas.jpg' />";
     } else function random_imglink(){
    var myimages=new Array()
    
    myimages[1]="1.jpg"
    myimages[2]="2.jpg"
    myimages[3]="3.jpg"
    myimages[4]="4.jpg"
    myimages[5]="5.jpg"
    myimages[6]="6.jpg"
    myimages[7]="7.jpg"
    myimages[8]="8.jpg"
    myimages[9]="9.jpg"
    myimages[10]="10.jpg"
    myimages[11]="11.jpg"
    myimages[12]="12.jpg"
    myimages[13]="13.jpg"
    myimages[14]="14.jpg"
    myimages[15]="15.jpg"
    myimages[16]="16.jpg"
    myimages[17]="17.jpg"
    myimages[18]="18.jpg"
    myimages[19]="19.jpg"
    myimages[20]="20.jpg"
    myimages[21]="21.jpg"
    myimages[22]="22.jpg"
    myimages[23]="23.jpg"
    myimages[24]="24.jpg"
    myimages[25]="25.jpg"
    
    var ry=Math.floor(Math.random()*myimages.length)
    if (ry==0)
    ry=1
     pic="<img class='HolidayBanner' src='/Holiday/banners/blank.gif'>";
     document.write('<p>No observances today.</p><br /><img class="HolidayBanner" src="/Holiday/banners/'+myimages[ry]+'" />');
    }
    document.write(pic);
     random_imglink()
    </script>
    Download, extract and add Holiday folder to root/HTDOCS or base folder of forum.
    Reload site where you added new Holiday module and you should see something like this- Click image for larger version

Name:	Holiday.jpg
Views:	253
Size:	49.1 KB
ID:	1165


    GIF's, PNG, JPG, BMP... all standard web graphic formats can be used.

    Further, with some minor changes, SWF, AVI, MP4, OGG...

    and, by switching out images for CSS files, entire site themes.

    The PIC values and Document.Write need to be changed to accomplish, but easily done.

    By adding a little more code and <audio> tag one can do holiday banners with holiday music too.

    Or by adding STYLE sheets, audio and flash, one could do major holiday theme changes without touching forum code

    Very simple yet useful code to accomplish much with few alterations.

    Best part being all automated.

    The image banners can be downloaded from this third party host as it is 1.09 Mb and this forum only allows for a max. of 900 Kb
    http://s000.tinyupload.com/index.php...75465757087144
    Last edited by Felix2; 09-19-2016, 10:29 PM.

Users Viewing This Page

Collapse

There is 1 user viewing this forum topic.

  • Guest Guest

Latest Posts

Collapse

Working...
X
Searching...Please wait.
An unexpected error was returned: 'Your submission could not be processed because you have logged in since the previous page was loaded.

Please push the back button and reload the previous window.'
An unexpected error was returned: 'Your submission could not be processed because the token has expired.

Please push the back button and reload the previous window.'
An internal error has occurred and the module cannot be displayed.
There are no results that meet this criteria.
Search Result for "|||"