Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Feb 8th, 2012  |  syntax: ColdFusion  |  size: 4.12 KB  |  hits: 113  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <cfapplication name="gCal">
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3.         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html>
  5.         <head>
  6.                 <title>Cal</title>
  7.         <link rel="stylesheet" href="css/master.css" type="text/css" media="screen" charset="utf-8" />
  8.                 <script src="js/jquery-1.3.min.js" type="text/javascript"> </script>
  9.                 <script src="js/coda.js" type="text/javascript"> </script>
  10.         </head>
  11.    
  12.     <cfif not structKeyExists(application, "gCal") or structKeyExists(url, "reinit")>
  13.         <cfset application.gCal = createObject("component", "GoogleCalendar").init("info@example.de","mypass",+1)>
  14. </cfif>
  15.  
  16. <!--- Default should be current month --->
  17. <cfparam name="form.date" default="#createdate(year(now()),month(now()),1)#">
  18.  
  19.    <!--- stuff for calculating the padding --->
  20.    <cfset start=form.date>
  21.    <cfset end=DaysInMonth(start)>
  22.    <cfset firstDay=dayofweek(start)-2>
  23.        
  24.    <!---- retrieve all available events --->    
  25.   <cfset events = application.gCal.getEvents(calid="mycalID",maxevents=100,orderby="starttime",sortdir="d")>
  26.  
  27. <cfoutput>     
  28. <body>
  29.                 <h1>Events</h1>
  30.      
  31.     <form action="" enctype="multipart/form-data" method="post">
  32.         <select name="date">
  33.         <!--- Selections for a full year --->
  34.         <cfloop from="1" to="12" index="m">
  35.         <option value="#createdate(year(now()),m,1)#">#dateformat(createdate(year(now()),m,1),"dd-mm-yyyy")#</option>
  36.         </cfloop>
  37.       </select>
  38.         <input type="submit" />
  39.                 </form>
  40.  
  41.                 <table cellspacing="0">
  42.                         <thead>
  43.                                 <tr>
  44.                                         <th>Mo</th><th>Di</th><th>Mi</th>
  45.                                         <th>Do</th><th>Fr</th><th>Sa</th>
  46.                                         <th>So</th>
  47.                                 </tr>
  48.                         </thead>
  49.                         <tbody>
  50.             <tr>
  51.         <!--- Counter for cells --->
  52.             <cfset x=1>
  53.            
  54.             <!--- Padding if 1. of month isn't a monday ---->
  55.                         <cfif firstDay gt 0>
  56.             <td class="padding" colspan="#firstDay#"></td>
  57.             <!--- padding cells must be added to counter --->
  58.                         <cfset x=x+firstDay>
  59.                         </cfif>
  60.            
  61.            <!--- Loop every day in current month --->
  62.             <cfloop from="1" to="#end#" index="i">
  63.  
  64. <!--- is there an event today? ---->
  65.                     <cfquery dbtype="query" name="today">
  66.                     SELECT * FROM events WHERE starttime BETWEEN #createdatetime(year(start),month(start),i,0,0,0)# AND #createdatetime(year(start),month(start),i,23,59,59)# OR endtime BETWEEN #createdatetime(year(start),month(start),i,0,0,0)# AND #createdatetime(year(start),month(start),i,23,59,59)#
  67.                     </cfquery>
  68.                                      
  69.                      <!--- hilite today or event ---->          
  70.                     <td<cfif day(now()) eq i and not today.recordcount> class="today"</cfif> <cfif today.recordcount>class="date_has_event"</cfif>>#i#
  71.                     <!---- insert event --->
  72.                                         <cfif today.recordcount>
  73.                     <div class="events">
  74.                                                         <ul>
  75.                             <cfloop query="today">
  76.                                                                 <li>
  77.                                                                         <span class="title">#title#</span>
  78.                                                                         <span class="desc">
  79.                                     Von: #dateformat(starttime,"dd.mm.yyyy")# #timeformat(starttime,"HH:mm")# Uhr <br />
  80.                                     Bis: #dateformat(endtime,"dd.mm.yyyy")# #timeformat(endtime,"HH:mm")# Uhr <br />
  81.                                    
  82.                                     #where#<br />
  83.                                                                         #content#</span>
  84.                                                                 </li>
  85.                                                                 </cfloop>
  86.                                                         </ul>
  87.                                                 </div>
  88.                     </cfif>
  89.                     </td>
  90.              
  91.           <!--- start a new row every 7th cell ---->
  92.                 <cfif x MOD 7 eq 0></tr><tr></cfif>
  93.                  
  94.       <cfset x++>
  95.          
  96.                 </cfloop>
  97.                 <!--- 5 rows with 7 cells each = 35 --->
  98.                 <cfif 35-(x-1) gt 0>
  99.                 <!--- add padding to the end if needed --->
  100.                 <td class="padding" colspan="#35-(x-1)#"></td>
  101.                 </cfif>
  102.              </tbody>
  103.                         <tfoot>
  104.                                 <th>Mo</th><th>Di</th><th>Mi</th>
  105.                                         <th>Do</th><th>Fr</th><th>Sa</th>
  106.                                         <th>So</th>
  107.                         </tfoot>
  108.                 </table>
  109.         </body></cfoutput>
  110. </html>