The objective of this JavaScript was to add an additional call out on our main webpage when we are streaming our worship services. This small amount of code inserts the TV and statement "Live video streaming available from each of our worship services" above our calendar on that page.
These instructions are specific to the FinalWeb service; however, the only FinalWeb specific instructions are related to the image upload and how to insert the JavaScript on a page. You can easily adjust those instructions to your circumstance for your server. As long as you can insert the enclose JavaScript on your page you can use these instructions. To the right is an example of the block that inserts on the welcome page. The image and the text does not appear the remainder of the week.
You first will need to upload the clip art that the code uses, this will be uploaded to the file manager for your site. You will not upload it to the page directly. This image then is also available on any page in your site that you want to use this code.
Hint: you should create a sandbox page to play in when you are learning JavaScript. You can easily blow up the page and perhaps not even be able to access the administration tools that FinalWeb provides.
Find the location that you wish to insert this on your page. In the case of our homepage the calendar is in a column that cannot have sections added to them. Adding a section just for this JavaScript is better, but it really depends on the provided template your church may be using.
Access your content block and get into the text editing mode. Don't use the double click method, use the configure section or edit column function.
Click on the Source button in the upper right hand corner.
Find in the HTML code the place that you want to insert your icon and message. The exact point in the code is where this script is going to insert your text.
Copy and paste from the code block below to the editor where you want to insert your block.
Make changes to the code to include the URL you noted in the setup of the clip art above. Change the message also if you wish your own phrase. Change the getHours and getDay to match what you want to match in your logic.
Click Save Changes to save your website and test. You may need to use artificial day of weeks and time.
The provided is between 7AM and 12PM Sunday and 6PM to 9PM on Wednesday. getDay starts at 0 for Sunday and goes through 6 for Saturday. Since this runs on your computer browser side, not server side, then the timezone and date of the local computer is already considered. Replace the XXXXXXXXXXXXXXX in the block below with the URL you created in the clip art section above.
<!-- -- insert live streaming details here on Sunday & Wednesday service times ---->
<SCRIPT type="text/javascript">
today=new Date()
if (((today.getHours() >= 7 && today.getHours() < 12) && (today.getDay() == 0)) ||
((today.getHours() >= 18 && today.getHours() < 21) && (today.getDay() == 3)))
{
document.write('<DIV style="text-align: center;"><IMG SRC="XXXXXXXXXXXXXXX"><P></DIV><DIV style="text-align: center;"><A HREF="/stream">Live video streaming</A> available from each of our worship services.</DIV>');
}