Difference between revisions of "Widget:Calendar"

From Hackerspace ACKspace
Jump to: navigation, search
(added notes)
(added title per date support)
Line 78: Line 78:
  
 
             this.hl = {};
 
             this.hl = {};
 +
            this.t = {};
 
             this._tblCalendar = document.createElement( "table" );
 
             this._tblCalendar = document.createElement( "table" );
 
             this._today = new Date( );
 
             this._today = new Date( );
Line 93: Line 94:
 
         Calendar.prototype._date = null;
 
         Calendar.prototype._date = null;
 
         Calendar.prototype.hl = null;
 
         Calendar.prototype.hl = null;
 +
        Calendar.prototype.t = null;
  
 
         Calendar.prototype._gen = function( )
 
         Calendar.prototype._gen = function( )
Line 138: Line 140:
 
                     if ( curDate.getTime() in this.hl )
 
                     if ( curDate.getTime() in this.hl )
 
                         td.className += " " + this.hl[ curDate.getTime() ];
 
                         td.className += " " + this.hl[ curDate.getTime() ];
 +
                    if ( curDate.getTime() in this.t )
 +
                        td.title = this.t[ curDate.getTime() ];
  
 
                     row.appendChild( td ).appendChild( document.createTextNode( curDate.getDate( ) ) );
 
                     row.appendChild( td ).appendChild( document.createTextNode( curDate.getDate( ) ) );
Line 162: Line 166:
 
     calendar.hl[ new Date( "<!--{$d|escape:'html'}-->" ).getTime() ] = "hl-<!--{$col|escape:'html'}-->";
 
     calendar.hl[ new Date( "<!--{$d|escape:'html'}-->" ).getTime() ] = "hl-<!--{$col|escape:'html'}-->";
 
<!--{/foreach}-->
 
<!--{/foreach}-->
 
+
<!--{foreach from=$t key=d item=text}-->
 +
    calendar.t[ new Date( "<!--{$d|escape:'html'}-->" ).getTime() ] = "hl-<!--{$text|escape:'html'}-->";
 +
<!--{/foreach}-->
 
     document.write( calendar );
 
     document.write( calendar );
 
}( ));
 
}( ));
 
</script>
 
</script>
 
</includeonly>
 
</includeonly>

Revision as of 15:24, 11 March 2016

This widget allows you to display a calendar

Created by Xopr

Using this widget

To insert this widget, use the following code:

{{#widget:Calendar
|date=february 26 2011
|hl.26 february 2011=blue
|hl.1 march 2011=red
}}

This will give the following result:

Note:

  • all parameters are optional. If date is omitted, the current month will be displayed
  • you can highlight dates by using the hl parameter, followed by a dot and the date you want to highlight. Available colors are: red, green, blue, yellow, cyan and purple

Copy to your site

To use this widget on your site, just install MediaWiki Widgets extension and copy full source code of this page to your wiki as Widget:Calendar article.