home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 25: Programming / pc_actual_25.iso / Javascript / InteractiveWebDesignJavascript / Scripting / js2 / labs / cookies / whats_new.js < prev   
Encoding:
JavaScript  |  2001-07-18  |  1.6 KB  |  45 lines

  1. /******** Create the News Worthy Event List *******
  2. **
  3. **  This script builds datastructures for all the 
  4. **  messages and the effective date of that message
  5. **
  6. **************************************************/
  7. var w_n_date = new Array()    //this is the what's new date field
  8. var w_n_msg = new Array()    //this is the what's new message
  9. var i = new Number(0)        //index should be same for date and message
  10. var news = new Number(0)    //counter of what's new hits
  11.  
  12. /** 
  13. *** To add an event, copy the line below and modify as appropriate
  14. *** 1) remove the '//' comment
  15. *** 2) add the date in yyyymmdd (number only) format
  16. *** 3) add an appropriate message
  17. **/
  18. //w_n_date[i] = 19990301; w_n_msg[i++]= 'your msg here'
  19.  
  20. // what's new events
  21. w_n_date[i] = 19990301; w_n_msg[i++]= 'This Site went live';
  22. w_n_date[i] = 19990315; w_n_msg[i++]= 'The colors were changed';
  23. w_n_date[i] = 19990406; w_n_msg[i++]= 'Registration for our sweepstakes began';
  24. w_n_date[i] = 19990503; w_n_msg[i++]= 'Winners were selected in the sweepstakes giveaway';
  25.  
  26. function whats_new(since_date)
  27. {
  28.     num_events = new Number(w_n_date.length)
  29.     last_visit = new Number(since_date)
  30.     if (last_visit == 99999999) msg = new String('<h3>Here\'s What\'s New at this Site</h3><ul>')
  31.     else msg = new String('<h3>Here\'s what\'s new since your last visit on ' + last_visit + '</h3><ul>')
  32.  
  33.     for (cnt = 0; cnt < num_events; cnt++)
  34.     {
  35.         //any new events since their last visit?
  36.         if (last_visit < Number(w_n_date[cnt]) || (last_visit == 99999999) )
  37.         {
  38.             msg += '<li>On ' + w_n_date[cnt] + ' ' + w_n_msg[cnt] + '</li>'
  39.             news++;
  40.         }
  41.     }
  42.     msg += '</ul>'
  43.     if (news == 0) msg = ''
  44.     return msg
  45. }