Difference between revisions of "Widget:SpaceAPI"

From Hackerspace ACKspace
Jump to: navigation, search
(fixed documentation)
(fixed some variable references, added title (in preparation of lastchange timestamp))
Line 109: Line 109:
 
         };
 
         };
  
         SpaceState.prototype._updateSpaceState = function( _message, _color )
+
         SpaceState.prototype._updateSpaceState = function( _message, _color, _title )
 
         {
 
         {
 
             this._node.innerText = _message;
 
             this._node.innerText = _message;
 
             this._node.style.backgroundColor = _color;
 
             this._node.style.backgroundColor = _color;
 +
            if ( _title )
 +
                this._node.title = _title;
 +
            else
 +
                this._node.title = "";
 
         };
 
         };
  
Line 120: Line 124:
 
             var open = null;
 
             var open = null;
 
             var message = null;
 
             var message = null;
 +
            var title = null;
  
 
             try
 
             try
Line 126: Line 131:
 
                 open = spaceState.state.open;
 
                 open = spaceState.state.open;
 
                 message = spaceState.state.message;
 
                 message = spaceState.state.message;
 +
                //spaceState.state.lastchange
 +
                console && console.log( spaceState.state.lastchange, new Date( spaceState.state.lastchange ) )
 +
                title = spaceState.state.lastchange;
 
             }
 
             }
 
             catch( _e )
 
             catch( _e )
Line 132: Line 140:
 
             }
 
             }
  
             if ( spaceState.state.open )
+
             if ( open )
                 this._updateSpaceState( spaceState.state.message || this._msgOpen, this._colorOpen );
+
                 this._updateSpaceState( message || this._msgOpen, this._colorOpen, title );
             else if ( spaceState.state.open === false )
+
             else if ( open === false )
                 this._updateSpaceState( spaceState.state.message || this._msgClosed, this._colorClosed );
+
                 this._updateSpaceState( message || this._msgClosed, this._colorClosed, title );
 
             else
 
             else
                 this._updateSpaceState( spaceState.state.message || this._msgUnknown, this._colorUnknown );
+
                 this._updateSpaceState( message || this._msgUnknown, this._colorUnknown, title );
 
         };
 
         };
  

Revision as of 16:14, 25 August 2015

This widget allows you to display the Space API data (provided as JSON)

Created by Xopr

Using this widget

To insert this widget, use the following code:

{{#widget:SpaceAPI
|url=https://ackspace.nl/spaceAPI/
|width=260px
|height=20px
|padding=8px
|interval=20
}}

This will give the following result:

Note that url is mandatory, the rest is optional (leave out interval to make the data static). Also, you must provide a unit for the sizes (i.e. px, %, etc.)

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:SpaceAPI article.