By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,797 Members | 1,262 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,797 IT Pros & Developers. It's quick & easy.

Using Javascript/DHTML in Sharepoint

P: 21
I have a html file with javascript and am loading information into it with a xml file stored within sharepoint. I am having problems getting the dates to appear correctly, specifically, start date and due dates.
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  3. <title>Timeline-WorkPrint</title>
  4. <html>
  5.   <head>
  6.     <script src="https://sharepoint.global.lmco.com/sites/BSAGroup/BSATestSite/Shared%20Documents/Timeline%20Documents/timeline/api/timeline-api.js" type="text/javascript"></script>
  7.     <script  src="date.js" type="text/javascript"></script>
  8.     <script>
  9. var tl;
  10. var eventSource = new Timeline.DefaultEventSource();
  11.  
  12. function openXMLfile(file)
  13. {
  14.     if (document.implementation && document.implementation.createDocument)
  15.     {
  16.         xmlDoc = document.implementation.createDocument("", "", null);
  17.     }
  18.     else if (window.ActiveXObject)
  19.     {
  20.         xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  21.         xmlDoc.async="false";
  22.      }
  23.     else
  24.     {
  25.         alert('Your browser can\'t handle this script');
  26.         return;
  27.     }
  28.     xmlDoc.load(file);
  29.     return(xmlDoc);
  30. }
  31.  
  32. function takeEventOut(url)
  33. {
  34.     xmlDoc = openXMLfile(url);
  35.     var rows = xmlDoc.getElementsByTagName('z:row');
  36.  
  37.     for (j=0;j<rows.length;j++)
  38.     {
  39.         //document.write(rows.item(j).getAttribute('ows_DueDate'));
  40.         // taking the event info from the xml
  41.         var dateEvent = Date.parseExact(rows.item(j).getAttribute('ows_DueDate'), "yyyy-dd-mm hh:mm:ss");
  42.  
  43.         var title = rows.item(j).getAttribute('ows_LinkTitle');
  44.         var status = rows.item(j).getAttribute('ows_Status');
  45.  
  46.         /*id,
  47.         start, end, latestStart, earliestEnd, instant, 
  48.         text, description, image, link,
  49.         icon, color, textColor */
  50.         var color;
  51.         switch (status)
  52.         {
  53.             case "In Progress":
  54.                 color = "yellow";
  55.                 break
  56.             case "Not Started":
  57.                 color = "red";
  58.                 break
  59.                 case "Completed":
  60.                 color = "green";
  61.                 break
  62.             default:
  63.                 color = "black";
  64.                 break
  65.         }
  66.         var evt = new Timeline.DefaultEventSource.Event( 
  67.                  dateEvent , //start
  68.                  new Date(dateEvent).addDays(+2), //end
  69.                  dateEvent ,//dateEvent.addMonths(1), //latestStart
  70.                  new Date(dateEvent).addDays(+2) ,//dateEvent.addWeeks(1), //earliestEnd
  71.                  true, //instant
  72.                  title, //text
  73.                 status, 0,0 ,0 ,color  //description
  74.                   );
  75.         // adding it to the source
  76.         //document.write(evt.getStart.toString);
  77.          eventSource.add(evt);
  78.  
  79.     }    
  80.  
  81.  
  82. }
  83.  
  84. function onLoad()
  85. {
  86.         takeEventOut("https://sharepoint.global.lmco.com/sites/BSAGroup/BSATestSite/_vti_bin/owssvr.dll?XMLDATA=1&List={C9DA434F-216F-4C7C-9D5E-A5AC72DBA45B}&View={8315210C-1A47-47B4-8BE3-B6271BC97E8B}&RowLimit=0&RootFolder"); 
Jul 9 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
I have a html file with javascript and am loading information into it with a xml file stored within sharepoint. I am having problems getting the dates to appear correctly, specifically, start date and due dates.
What problems? Do you get errors? It seems as if you've added methods to the Date object. It might help if you post the code in date.js
Jul 10 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.