Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Oct 2002
    Location
    Manchester, England
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts

    desperate script help please

    Any gurus please help

    I am trying to get a script to work the following paragraph out for our college.

    Welcome to the College timetable reminder. The current term is
    W2004 and the current time is 10:39 AM. This means that there are 31 minutes left until the next class starts at 11:10 AM. It also mean that the last class started 29 minutes ago.

    The bolded items must all be dynamically computed, accurate and be able to be written into an HTML document using JavaScript in particular using the Date object.

    The college works on a three term system. The terms are Autumn beginning September - Winter beginning January - Spring/Summer beginning May.

    The terms are usually designated by a letter code followed by the year. For example A2000 is Autumn 2000, W1998 was the Winter 1998 term and P2001 the Spring/Summer 2001 term.
    Also the college works an hourly schedule from 9:AM to 9:PM with classes starting at ten minutes past the hour every hour.

    Hoping that someone can please help me out with the script - I'm desperate

    All help much appreciated

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Is this a school assignment?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    632
    Thanks
    1
    Thanked 21 Times in 21 Posts
    <!DOCTYPE&nbsp;html&nbsp;PUBLIC&nbsp;"-//W3C//DTD&nbsp;XHTML&nbsp;1.0&nbsp;Transitional//EN"
    &nbsp;&nbsp;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html&nbsp;lang="en-US">
    &nbsp;&nbsp;<head>

    &nbsp;&nbsp;&nbsp;&nbsp;<title>College&nbsp;Schedule</title>
    &nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;<!--&nbsp;http://www.codingforums.com/showthre...=32894&nbsp;-->

    &nbsp;&nbsp;&nbsp;&nbsp;<meta&nbsp;http-equiv="Content-Type"&nbsp;content="text/html;&nbsp;charset=ISO-8859-1"&nbsp;/>
    &nbsp;&nbsp;&nbsp;&nbsp;<meta&nbsp;http-equiv="PICS-Label"&nbsp;content='(PICS-1.1&nbsp;"http://www.classify.org/safesurf/"&nbsp;l&nbsp;gen&nbsp;true&nbsp;for&nbsp;"http://spruce.flint.umich.edu/~jalarie/"&nbsp;r&nbsp;(SS~~000&nbsp;1))'&nbsp;/>
    &nbsp;&nbsp;&nbsp;&nbsp;<meta&nbsp;http-equiv="pics-label"&nbsp;content='(pics-1.1&nbsp;"http://www.icra.org/ratingsv02.html"&nbsp;comment&nbsp;"basic&nbsp;online&nbsp;form"&nbsp;l&nbsp;gen&nbsp;true&nbsp;for& nbsp;"http://spruce.flint.umich.edu/~jalarie/"&nbsp;r&nbsp;(nz&nbsp;1&nbsp;ns&nbsp;1&nbsp;vz&nbsp;1&nbsp;vs&nbsp;1&nbsp;lz&nbsp;1&nbsp;oz&nbsp;1& nbsp;cz&nbsp;1)&nbsp;"http://www.rsac.org/ratingsv01.html"&nbsp;l&nbsp;gen&nbsp;true&nbsp;for&nbsp;"http://spruce.flint.umich.edu/~jalarie/"&nbsp;r&nbsp;(n&nbsp;0&nbsp;s&nbsp;0&nbsp;v&nbsp;0&nbsp;l&nbsp;0))'&nbsp;/>
    &nbsp;&nbsp;&nbsp;&nbsp;<meta&nbsp;name="Author"&nbsp;content="James&nbsp;Alarie&nbsp;-&nbsp;jalarie@umich.edu"&nbsp;/>
    &nbsp;&nbsp;&nbsp;&nbsp;<link&nbsp;rev="made"&nbsp;href="mailto:jalarie@umich.edu"&nbsp;/>
    &nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;<meta&nbsp;http-equiv="Pragma"&nbsp;content="no-cache"&nbsp;/>
    &nbsp;&nbsp;&nbsp;&nbsp;<meta&nbsp;http-equiv="Cache-Control"&nbsp;content="no-cache"&nbsp;/>
    &nbsp;&nbsp;&nbsp;&nbsp;<meta&nbsp;http-equiv="expires"&nbsp;content="0"&nbsp;/>
    &nbsp;&nbsp;&nbsp;&nbsp;
    <!--
    &nbsp;&nbsp;&nbsp;&nbsp;Author:&nbsp;&nbsp;&nbsp;&nbsp;James&nbsp;Alarie
    &nbsp;&nbsp;&nbsp;&nbsp;Company:&nbsp;&nbsp;&nbsp;University&nbsp;of&nbsp;Michigan&nbsp;-&nbsp;Flint
    &nbsp;&nbsp;&nbsp;&nbsp;Address:&nbsp;&nbsp;&nbsp;Murchie&nbsp;Science&nbsp;Building&nbsp;-&nbsp;203E
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;303&nbsp;E &nbsp;Kearsley&nbsp;St
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Flint&nbsp ;&nbsp;MI&nbsp;&nbsp;48502
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;United&nbs p;States&nbsp;of&nbsp;America
    &nbsp;&nbsp;&nbsp;&nbsp;Telephone:&nbsp;+1-810-762-3394x21
    &nbsp;&nbsp;&nbsp;&nbsp;Fax:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;+1-810-762-3687
    &nbsp;&nbsp;&nbsp;&nbsp;Web&nbsp;Site:&nbsp;&nbsp;http://spruce.flint.umich.edu/~jalarie/
    &nbsp;&nbsp;&nbsp;&nbsp;E-Mail:&nbsp;&nbsp;&nbsp;&nbsp;jalarie@umich.edu
    &nbsp;&nbsp;&nbsp;&nbsp;Comments:&nbsp;&nbsp;Having&nbsp;said&nbsp;that,&nbsp;I've&nbsp;probably&nbs p;told&nbsp;you&nbsp;more&nbsp;than&nbsp;I&nbsp;know.
    -->

    &nbsp;&nbsp;</head>

    &nbsp;&nbsp;<body&nbsp;background="jaa_bgnd.jpg"&nbsp;bgcolor="#ffffee"&nbsp;text="black"
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;link="blue"&nbsp;vlink="#800088"&nbsp;alink="red">
    <!--&nbsp;Page&nbsp;Header&nbsp;-->
    &nbsp;&nbsp;&nbsp;&nbsp;<center><h1>College&nbsp;Schedule</h1></center>
    &nbsp;&nbsp;&nbsp;&nbsp;<hr&nbsp;/>

    <!--&nbsp;Content&nbsp;-->
    &nbsp;&nbsp;&nbsp;&nbsp;<script&nbsp;type="text/javascript">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<!--&nbsp;Hide&nbsp;this&nbsp;code&nbsp;from&nbsp;non-JavaScript&nbsp;browsers
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now=new&nbsp;Date();
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now_Y=Now.getYear();
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now_M=Now.getMonth()+1;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now_D=Now.getDate();
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now_H=Now.getHours();
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now_N=Now.getMinutes();
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now_S=Now.getSeconds();
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&n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;TermCode= 'A';&nbsp;}
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next=Now_H+1;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Left=60-Now_N+10;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Ago=Now_N-10;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out&nbsp;='Welcome&nbsp;to&nbsp;the&nbsp;College&nbs p;timetable&nbsp;reminder.&nbsp;&nbsp;The&nbsp;current&nbsp;term&nbsp;is&nbsp;';
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out+=TermCode+Now_Y;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out+='&nbsp;and&nbsp;the&nbsp;current&nbsp;time&nbsp ;is&nbsp;';
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out+=Now_H+':'+Now_N+'&nbsp;'+Now_A;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out+='.&nbsp;&nbsp;This&nbsp;means&nbsp;that&nbsp;th ere&nbsp;are&nbsp;';
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out+=Left;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out+='&nbsp;minutes&nbsp;left&nbsp;until&nbsp;the&nb sp;next&nbsp;class&nbsp;starts&nbsp;at&nbsp;';
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out+=Next+':10&nbsp;'+Now_A;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out+='.&nbsp;&nbsp;It&nbsp;also&nbsp;means&nbsp;that &nbsp;the&nbsp;last&nbsp;class&nbsp;started&nbsp;';
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out+=Ago;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Out+='&nbsp;minutes&nbsp;ago.';
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;document.write(Out);
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//&nbsp;End&nbsp;hiding&nbsp;-->
    &nbsp;&nbsp;&nbsp;&nbsp;</script>
    &nbsp;&nbsp;&nbsp;&nbsp;
    <!--&nbsp;Page&nbsp;Footer&nbsp;-->
    &nbsp;&nbsp;&nbsp;&nbsp;<br&nbsp;clear="all"&nbsp;/><hr&nbsp;/>
    &nbsp;&nbsp;&nbsp;&nbsp;Written&nbsp;on&nbsp;February&nbsp;10,&nbsp;2004,&nbsp;by:&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;<a&nbsp;href="mailto:jalarie@umich.edu">James&nbsp;Alarie</a>

    &nbsp;&nbsp;</body>

    </html>

  • #4
    Regular Coder
    Join Date
    Apr 2003
    Location
    Atlanta, GA
    Posts
    487
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've got a ticking solution (I thought it was a cool challenge), but I've got the same concerns as glenngv.

    I got a nice reusable function out of it, though. Check it out over in this other thread...

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just Remarks to jalarie script.

    1:It don't show the rigth amount of minutes to next lesson if the current time is between X:00-X:10 X being any hour, this result in it saying that there are 60+N minutes to next class, when infact there is only N minutes to next class,and the ago shows -N, when the correct is infact 60-N.
    Simple Soution:
    put this code
    Code:
    if(Ago<0)
    {
      Ago=60+Ago;
      Left=Left-60;
    }
    after this code in the script:
    Code:
    Next=Now_H+1;
    Left=60-Now_N+10;
    Ago=Now_N-10;
    2:It don't detect if it before or after 9 in the morning nite making it say that even after the classes end thats there one in the next hour.


    Remark to this idea in general

    1. school computer clocks are notoriously wrong making the script show wrong times, at least they are in my schools

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Flint, Michigan, USA
    Posts
    632
    Thanks
    1
    Thanked 21 Times in 21 Posts
    I, also, believe that this is a school assignment. If charter simply needs a boost to get started, it's there but he'll need to put forth some effort to understand it and make it his own. If he turns it in as-is as his own work, then he deserves whatever he gets.

    Garadon's observations are also valid. Charter should work these out on his own.

  • #7
    Registered User
    Join Date
    Oct 2002
    Location
    Manchester, England
    Posts
    118
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Sorry if i've confused anyone but I'm not a student, I'm a teacher.

    I'm just a newbie with JavaScript and I am trying to work out a timetable.

    Many thanks for your contributions.


  •  

    Posting Permissions

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