Automatically Refresh A SharePoint 2010 Calendar View

For some reason (at least to my knowledge) SharePoint 2010 does not provide a function to automatically refresh a SharePoint calendar view’s items at a given interval. The lack of this feature means a full page refresh is required any time a user wishes to check for any updates. While this might be suitable for infrequently updated calendars, for calendars that get frequently updated this is not desirable.

Fortunately, SharePoint does include a JavaScript library that provides methods for updating calendar views asynchronously. The particular library of interest is:

SP.UI.ApplicationPages.CalendarInstanceRepository

This repository contains a pointer to all of the calendar instances on the current page. If there is only one instance on the page, or you’re only interested in the first instance, there is a helper method firstInstance() to retrieve that calendar. Otherwise, you can find the collection of calendars as properties on the $o_0 property. You can turn this into a list using the following code:

Using The Calendar Repositories

Now that we have access to the calendar(s) we need to use them. One way of doing this is to create a hidden content editor web part that uses the following script to call refreshItems() every 10 seconds. First, create a new file RefreshCalendar.html and publish it somewhere on your SharePoint site.

Next, add a content editor web part to the same page as the calendar view you wish to update automatically; setting the content link to the location of the RefreshCalendar.html page, and setting the Chrome Type to none to remove any headers, borders, e.t.c. (i.e. make the content editor web part invisible to the user).

Automatically Refresh a Sharepoint Calendar View Content Editor

Now, when a user goes to the calendar view, the items are automatically updated every 10 seconds. Because the call is asynchronous the user will not be impacted when an update occurs, even if they are adding, or editing, a calendar item.

ScrewTurn Syntax Highlighter

Overview

This is a lightweight Syntax Highlighter plugin for ScrewTurn Wiki. The plugin uses the Lonwas Highlighter, by Thomas Johansen and Christian Nordbakk, which currently supports 23 languages by default and is extensible through the use of an XML file.

Note: The Syntax Highlighter is only being used as a lightweight highlighter. This means that it does not support some of the more advanced features, such as line numbering or keyword hyperlinks.

Usage

To highlight code simply surround the desired code with <code language> and </code>, where “language” denotes the language of the code E.G. C#.

Example: <code c#>public static void TestMethod() { return; }</code>

The <code> tags are parsed during phase1 (prior to the wiki parsing). During this time — apart from the syntax highlighting — the <code> tag is replaced with <pre class=“code language”>, where language denotes the language entered. This allows you to alter the display of the code, both for all code blocks and specific languages, through the use of CSS.

A few rules are applied to the language name when it is outputted as the class name of the pre tag.

  • The language name is converted to all lower cases.
  • White spaces are stripped.
  • # is converted to “sharp”.
  • . is converted to “dot”.
  • + is converted to “plus”.

For example, this means <code c#> will produce <pre class=“code csharp”>.

Note: <nowiki> tags are placed around the code so that any wiki syntax in the code will not be parsed by the wiki engine.

Supported languages: ASPX, C, C++, C#, COBOL, Eiffel, Fortran, Haskell, HTML, Java, JavaScript, Mercury, MSIL, Pascal, Perl, PHP, Python, Ruby, SQL, Visual Basic, VBScript, VB.NETXML.

Installation

  1. Download Syntax Highlighter.
  2. Extract the uploads.zip folder into your root wiki directory.
    • Definitions.xml should go into your root directory.
    • Lonwas.Highlight.dll should go into your bin directory.
  3. Log into your Wiki’s administration panel.
  4. Click on the Providers tab.
  5. Under Add new Providers click on browse and select TimBellette.ScrewTurnSyntaxHighlighter.dll and click upload.
    • If your Definitions.xml file is not in the default location or has been renamed, it will show up as disabled.
      1. Click Syntax Highlighter in your providers’ list and click Configure.
      2. Enter the URL of the uploaded Definitions.xml file (E.G. http://yoursite.com/wiki/Definitions.xml) and click save.
      3. Click Enable to enable the Syntax Highlighter.
  6. You’re Done.

History

  • [Version 1.2, released 2007-06-16]
    • Added default configuration setting.
  • [Version 1.1, released 2007-06-16]
    • Fixed wiki rendering bug.
    • Fixed CSS class names bug.
  • [Version 1.0, released 2007-06-15]
    • First released.

Licensing

Copyright ©2007 Tim Bellette. All rights reserved.