Results 1 to 3 of 3

Thread: Multiple lessons subjects shown in weekly reminder

  1. #1
    Join Date
    Oct 2012
    Location
    England
    Posts
    98
    Thanks
    27
    Thanked 2 Times in 1 Post

    Default Multiple lessons subjects shown in weekly reminder

    Hi,

    this is a modified bit of code that I set up with help from the good folks on DD:

    HTML Code:
    <!DOCTYPE html>
    <html>
    <head>
    <title>Weekly Homework</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    
    <script type="text/javascript">
    Date.prototype.getWeek = function() {
     var onejan = new Date(this.getFullYear(),0,1);
     return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
     };
    (function(){
    	var suffixes = ['', 'st', 'nd', 'rd'];
    	function formatdate(d){
    		return d + (d > 3 && d < 21? 'th' : (suffixes[d % 10] || 'th'));
    	}
    	var msgs = [ //You need 52 of these:
    		
    	], months = [
    		'January', 'February', 'March', 'April', 'May', 'June',
    		'July', 'August', 'September', 'October', 'November', 'December'
    	], d = new Date(), weeknum = d.getWeek();
    	if(msgs[weeknum]){
    		msg = '<br>' + msgs[weeknum - 1];
    	}
    	while(d.getDay()){d.setDate(d.getDate() - 1);}
    	weekof = 'Sunday ' + months[d.getMonth()] + ' ' + formatdate(d.getDate()) + ', ' + d.getFullYear();
    	window.quoteoftheweek = weekimage;
    })();
    </script>
    
    
    
    <script type="text/javascript">
    Date.prototype.getWeek = function() {
     var onejan = new Date(this.getFullYear(),0,1);
     return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
     };
    (function(){
    	var suffixes = ['', 'st', 'nd', 'rd'];
    	function formatdate(d){
    		return d + (d > 3 && d < 21? 'th' : (suffixes[d % 10] || 'th'));
    	}
    	var msgs = [ //You need 52 of these:
    		'Message for Week 1 goes here.',
    		'Week 2 Message.',
    		'English', //you could have a blank one here or anywhere, this is week 3, it will have no message
    		'Maths',
    		'Science', //week 5
    		'Design',
    		'Week 7 Message.',
    		'Week 8 Message.',
    		'Week 9 Message.',
    		'Week 10 Message.', //week 10
    		'Week 11 Message.',
    		'Week 12 Message.',
    		'Week 13 Message.',
    		'Week 14 Message.',
    		'Week 15 Message.', //week 15
    		'Week 16 Message.',
    		'Week 17 Message.',
    		'Week 18 Message.',
    		'Week 19 Message.',
    		'Week 20 Message.', //week 20
    		'Week 21 Message.',
    		'Week 22 Message.',
    		'Week 23 Message.',
    		'Week 24 Message.',
    		'Week 25 Message.', //week 25
    		'Week 26 Message.',
    		'Week 27 Message.',
    		'Week 28 Message.',
    		'Week 29 Message.',
    		'Week 30 Message.', //week 30
    		'Week 31 Message.',
    		'Week 32 Message.',
    		'Week 33 Message.',
    		'Week 34 Message.',
    		'Whenever you find yourself on the side of the majority, it is time to pause and reflect.</br> <br>- <strong>Mark Twain</strong>', //week 35	
    		
    		'It takes a great deal of bravery to stand up to our enemies, but just as much to stand up to our friends. </br> <br>- <strong>J.K. Rowling</strong>', //week 36
    			
    		'Those who don't believe in magic will never find it.</br> <br>- <strong>Roald Dahl</strong>', //week 37
    		
    
    		
    	
    		
    		'One cannot be always laughing at a man without now and then stumbling on something witty.</br> <br>- <strong>Jane Austen</strong>', //week 38
    		
    		'Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.</br> <br>- <strong>Albert Einstein</strong>', //week 39
    		
    		'We ourselves feel that what we are doing is just a drop in the ocean. But the ocean would be less because of that missing drop.</br> <br>- <strong>Mother Teresa</strong>', //week 40
    			
    		'You are never too old to set another goal or to dream a new dream.</br> <br>- <strong>C.S. Lewis</strong>', //week 41
    			
    		'There is nothing I despise more than people trying to be something that they are not.</br> <br>- <strong>Charlize Theron</strong>', //week 42
    			
    		'Week 39 Message.',
    		'Week 40 Message.', //week 40
    		'Week 41 Message.',
    		'Week 42 Message.',
    		'Week 43 Message.',
    		'Week 44 Message.',
    		'Week 45 Message.', //week 45
    		'Week 46 Message.',
    		'Week 47 Message.',
    		'Week 48 Message.',
    		'Week 49 Message.',
    		'Week 50 Message.', //week 50
    		
    		
    		
    		'I will honor Christmas in my heart, and try to keep it all the year.</br> <br>- <strong>Charles Dickens</strong>', //week 51
    		
    	
    		
    		
    			'Christmas Eve was a night of song that wrapped itself about you like a shawl. But it warmed more than your body. It warmed your heart...filled it, too, with melody that would last forever.</br> <br>- <strong>Bess Streeter Aldrich</strong>', //week 52
    	], months = [
    		'January', 'February', 'March', 'April', 'May', 'June',
    		'July', 'August', 'September', 'October', 'November', 'December'
    	], d = new Date(), weeknum = d.getWeek(), weekof, msg = '';
    	if(msgs[weeknum]){
    		msg = '<br>' + msgs[weeknum - 1];
    	}
    	while(d.getDay()){d.setDate(d.getDate() - 1);}
    	weekof = 'Sunday ' + months[d.getMonth()] + ' ' + formatdate(d.getDate()) + ', ' + d.getFullYear();
    	window.subjectdescription = msg;
    })();
    </script>
    
    <script type="text/javascript">
    Date.prototype.getWeek = function() {
     var onejan = new Date(this.getFullYear(),0,1);
     return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
     };
    (function(){
    	var suffixes = ['', 'st', 'nd', 'rd'];
    	function formatdate(d){
    		return d + (d > 3 && d < 21? 'th' : (suffixes[d % 10] || 'th'));
    	}
    	var msgs = [ //You need 52 of these:
    		'Message for Week 1 goes here.',
    		'Week 2 Message.',
    		'Read a book', //you could have a blank one here or anywhere, this is week 3, it will have no message
    		'Do some sums',
    		'Draw a map', //week 5
    		'Design a toy',
    		'Week 7 Message.',
    		'Week 8 Message.',
    		'Week 9 Message.',
    		'Week 10 Message.', //week 10
    		'Week 11 Message.',
    		'Week 12 Message.',
    		'Week 13 Message.',
    		'Week 14 Message.',
    		'Week 15 Message.', //week 15
    		'Week 16 Message.',
    		'Week 17 Message.',
    		'Week 18 Message.',
    		'Week 19 Message.',
    		'Week 20 Message.', //week 20
    		'Week 21 Message.',
    		'Week 22 Message.',
    		'Week 23 Message.',
    		'Week 24 Message.',
    		'Week 25 Message.', //week 25
    		'Week 26 Message.',
    		'Week 27 Message.',
    		'Week 28 Message.',
    		'Week 29 Message.',
    		'Week 30 Message.', //week 30
    		'Week 31 Message.',
    		'Week 32 Message.',
    		'Week 33 Message.',
    		'Week 34 Message.',
    		'Whenever you find yourself on the side of the majority, it is time to pause and reflect.</br> <br>- <strong>Mark Twain</strong>', //week 35	
    		
    		'It takes a great deal of bravery to stand up to our enemies, but just as much to stand up to our friends. </br> <br>- <strong>J.K. Rowling</strong>', //week 36
    			
    		'Those who don't believe in magic will never find it.</br> <br>- <strong>Roald Dahl</strong>', //week 37
    		
    
    		
    	
    		
    		'One cannot be always laughing at a man without now and then stumbling on something witty.</br> <br>- <strong>Jane Austen</strong>', //week 38
    		
    		'Learn from yesterday, live for today, hope for tomorrow. The important thing is not to stop questioning.</br> <br>- <strong>Albert Einstein</strong>', //week 39
    		
    		'We ourselves feel that what we are doing is just a drop in the ocean. But the ocean would be less because of that missing drop.</br> <br>- <strong>Mother Teresa</strong>', //week 40
    			
    		'You are never too old to set another goal or to dream a new dream.</br> <br>- <strong>C.S. Lewis</strong>', //week 41
    			
    		'There is nothing I despise more than people trying to be something that they are not.</br> <br>- <strong>Charlize Theron</strong>', //week 42
    			
    		'Week 39 Message.',
    		'Week 40 Message.', //week 40
    		'Week 41 Message.',
    		'Week 42 Message.',
    		'Week 43 Message.',
    		'Week 44 Message.',
    		'Week 45 Message.', //week 45
    		'Week 46 Message.',
    		'Week 47 Message.',
    		'Week 48 Message.',
    		'Week 49 Message.',
    		'Week 50 Message.', //week 50
    		
    		
    		
    		'I will honor Christmas in my heart, and try to keep it all the year.</br> <br>- <strong>Charles Dickens</strong>', //week 51
    		
    	
    		
    		
    			'Christmas Eve was a night of song that wrapped itself about you like a shawl. But it warmed more than your body. It warmed your heart...filled it, too, with melody that would last forever.</br> <br>- <strong>Bess Streeter Aldrich</strong>', //week 52
    	], months = [
    		'January', 'February', 'March', 'April', 'May', 'June',
    		'July', 'August', 'September', 'October', 'November', 'December'
    	], d = new Date(), weeknum = d.getWeek(), weekof, msg = '';
    	if(msgs[weeknum]){
    		msg = '<br>' + msgs[weeknum - 1];
    	}
    	while(d.getDay()){d.setDate(d.getDate() - 1);}
    	weekof = 'Sunday ' + months[d.getMonth()] + ' ' + formatdate(d.getDate()) + ', ' + d.getFullYear();
    	window.taskdescription = msg;
    })();
    </script>
    
    
    
    </head>
    <body>
    
    
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td width="50%" align="left" valign="top">Subject</td>
        <td width="50%" align="left" valign="top">Task</td>
      </tr>
      <tr>
        <td align="left" valign="top"><div id="subjectdescription"> 
    <script type="text/javascript">
    document.write(subjectdescription);
    </script>
    </div></td>
        <td align="left" valign="top"><div id="taskdescription"> 
    <script type="text/javascript">
    document.write(taskdescription);
    </script>
    </div></td>
      </tr>
    </table>
    
    </body>
    </html>
    

    What I would like is that instead of it just showing 'English' this week, it shows a number of lesson subjects, say, 'English, Maths, Science etc.' and the related homework tasks set for the children for that week. The subject and tasks need to be on the webpage for 7 days and then refreshed after that.... aaaaaaaaaaagh!!! I've just realised that if I put some work on fro Friday, it will get rid of it by the following Sunday.... and therefore not allow the children to have a full seven days to see their homework assignments.... DOH!!!

  2. #2
    Join Date
    Oct 2012
    Location
    England
    Posts
    98
    Thanks
    27
    Thanked 2 Times in 1 Post

    Default

    HTML Code:
    <html>
    <head>
    <title>Home work assignments</title>
    
    </head>
    <body>
    
    	
    	
    	<script type="text/javascript">
    //the subject array data can be generated from server-side
    var arrsubject = [
      ['English', '1/15'],
      ['Maths', '1/15'],
      ['Science', '1/16'],
      ['Art', '1/17'],
      ['John Doe4', '5/18'],
      ['John Doe5', '5/18'],
      ['John Doe6', '5/20'], 
      ['Rosh Hashanah', '9/17']
      //...and so on (last entry must not have a trailing comma)
    ];
    
    function getsubjectsThisWeek(){
      var arrMonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
      var subject, idx;
      var subjectList = new Array();
      var today = new Date();
    
      for (var i=0;i<arrsubject.length;i++){
        var subject = new Date(arrsubject[i][1] + '/' + today.getFullYear());
        if (isNaN(subject)) continue;
    
        if ( issubjectInRange(subject, 7) ){
           idx = subjectList.length;
           subjectList[idx] = new Object();
           subjectList[idx].name = arrsubject[i][0];
           subjectList[idx].subject = subject;
           subjectList[idx].month = arrMonth[subject.getMonth()];      
        }
      }
      if (subjectList.length > 0){ //sort asc by birthdate
         subjectList.sort(
           function(a, b){
             if (a.subject < b.subject) return -1
             if (a.subject > b.subject) return 1;
             return 0;
           }
         );
      }
      return subjectList;
    }
    
    function issubjectInRange(subject, interval){
    //credit for this function goes to:
    //-Rob (@slingfive) Eberhardt, Slingshot Solutions
    //http://slingfive.com/pages/code/jsDate/jsDate.html
    
      var today = new Date(); 
      //have to override time so entire day will be valid
      today.setHours(0,0,0,0);
      //if the birthday has already occurred in the year, increment to the next year
      if (subject < today)
        subject.setFullYear(subject.getFullYear() + 1);
      
      // get ms between dates (UTC) and make into "difference" date
      var iDiffMS = subject.valueOf() - today.valueOf();
      //divide iDiffMS by 1000, Seconds, Minutes, Hours
      nDays = parseInt(iDiffMS / 1000 / 60 / 60 / 24);
      
      if(parseInt(nDays) <= parseInt(interval))
        return true;
      else
        return false;
    }
    
    function displaysubjectList(){
      var date = new Date().getDate();	
      var subjectList = getsubjectsThisWeek();
      var len = subjectList.length;
      var s = "";
      if (len>0){
         s += '';
        for (var i=0; i<len; i++){
           //be mindful of the string-line continuation character (\) at the end of the first line
    		s += '<p' + ((date == subjectList[i].subject.getDate())?' class="subjectToday"':'')+ '>\
    					<strong>' + subjectList[i].name + '</strong> ';       
        }
        s += '';
      }
      else{
        s += "";
      }
      document.write(s);
    }
    </script>
    
    	<script type="text/javascript">
    //the task array data can be generated from server-side
    var arrtask = [
      ['words', '1/15'],
      ['numbers', '1/15'],
      ['testubes', '1/16'],
      ['brushes', '1/17'],
      ['John Doe4', '5/18'],
      ['John Doe5', '5/18'],
      ['John Doe6', '5/20'], 
      ['Rosh Hashanah', '9/17']
      //...and so on (last entry must not have a trailing comma)
    ];
    
    function gettasksThisWeek(){
      var arrMonth = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
      var task, idx;
      var taskList = new Array();
      var today = new Date();
    
      for (var i=0;i<arrtask.length;i++){
        var task = new Date(arrtask[i][1] + '/' + today.getFullYear());
        if (isNaN(task)) continue;
    
        if ( istaskInRange(task, 7) ){
           idx = taskList.length;
           taskList[idx] = new Object();
           taskList[idx].name = arrtask[i][0];
           taskList[idx].task = task;
           taskList[idx].month = arrMonth[task.getMonth()];      
        }
      }
      if (taskList.length > 0){ //sort asc by birthdate
         taskList.sort(
           function(a, b){
             if (a.task < b.task) return -1
             if (a.task > b.task) return 1;
             return 0;
           }
         );
      }
      return taskList;
    }
    
    function istaskInRange(task, interval){
    //credit for this function goes to:
    //-Rob (@slingfive) Eberhardt, Slingshot Solutions
    //http://slingfive.com/pages/code/jsDate/jsDate.html
    
      var today = new Date(); 
      //have to override time so entire day will be valid
      today.setHours(0,0,0,0);
      //if the birthday has already occurred in the year, increment to the next year
      if (task < today)
        task.setFullYear(task.getFullYear() + 1);
      
      // get ms between dates (UTC) and make into "difference" date
      var iDiffMS = task.valueOf() - today.valueOf();
      //divide iDiffMS by 1000, Seconds, Minutes, Hours
      nDays = parseInt(iDiffMS / 1000 / 60 / 60 / 24);
      
      if(parseInt(nDays) <= parseInt(interval))
        return true;
      else
        return false;
    }
    
    function displaytaskList(){
      var date = new Date().getDate();	
      var taskList = gettasksThisWeek();
      var len = taskList.length;
      var s = "";
      if (len>0){
         s += '';
        for (var i=0; i<len; i++){
           //be mindful of the string-line continuation character (\) at the end of the first line
    		s += '<p' + ((date == taskList[i].task.getDate())?' class="taskToday"':'')+ '>\
    					<strong>' + taskList[i].name + '</strong> ';       
        }
        s += '';
      }
      else{
        s += "";
      }
      document.write(s);
    }
    </script>
    
    
    
    
    
    <table width="100%" border="1" cellspacing="0" cellpadding="0">
      <tr>
        <td width="50%">Subject</td>
        <td width="50%">Task</td>
      </tr>
      <tr>
        <td><script type="text/javascript">
    displaysubjectList();
    </script></td>
        <td><script type="text/javascript">
    displaytaskList();
    </script></td>
      </tr>
    </table>
    <p>&nbsp;</p>
    </body>
    </html>
    OK so this is 'plan B', this may seem the easier option, the only issue is that if I set up some homework for 15 January 2014, some 16 January 2014 it disappears... I really need Homework subjects and tasks on the page for a full seven days, so if I put something for 15 January, it doesn't go till 22 January, if that makes any sense?

    Many thanks,


    Jay Dog

  3. #3
    Join Date
    Oct 2012
    Location
    England
    Posts
    98
    Thanks
    27
    Thanked 2 Times in 1 Post

    Default

    OK, I think Plan B is the one I need to develop but the key issue is to be able to keep each homework assignment for a full seven days, if anyone can help that'd really be great.

    Jay Dog

Similar Threads

  1. Pop up event reminder.. Help.. Thanks
    By apj in forum JavaScript
    Replies: 2
    Last Post: 10-06-2009, 04:35 AM
  2. Event reminder
    By jackson in forum Looking for such a script or service
    Replies: 0
    Last Post: 02-13-2009, 12:33 AM
  3. Is there a "Weekly iframe content"-script?
    By Fizzgigg in forum Looking for such a script or service
    Replies: 5
    Last Post: 01-10-2008, 04:07 PM
  4. Automatic reminder help
    By makundib in forum PHP
    Replies: 1
    Last Post: 02-12-2007, 03:50 PM
  5. scrolling text box with time limits on subjects?
    By maji13 in forum JavaScript
    Replies: 4
    Last Post: 02-10-2006, 08:13 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •