Difference between revisions of "Widget:SpaceAPI"

From Hackerspace ACKspace
Jump to: navigation, search
m (added BBQ sensor)
m (added debug mode, shortened list)
Line 73: Line 73:
 
         SpaceAPI.prototype._colorClosed    = "#f00";
 
         SpaceAPI.prototype._colorClosed    = "#f00";
 
         SpaceAPI.prototype._colorUnknown  = "#f70";
 
         SpaceAPI.prototype._colorUnknown  = "#f70";
 +
        SpaceAPI.prototype._debug    = null;
  
 
         SpaceAPI.prototype.start = function( )
 
         SpaceAPI.prototype.start = function( )
 
         {
 
         {
 
             // Use interval timer id as image id
 
             // Use interval timer id as image id
 +
this._debug = ( location.hash.split("#").slice(1).indexOf("debug") !== -1 );
 +
 
             this._intervalId = 0;
 
             this._intervalId = 0;
 
             if ( this._interval > 0 )
 
             if ( this._interval > 0 )
Line 212: Line 215:
 
                         attribution: '&copy; <a href="//openstreetmap.org/copyright">OpenStreetMap</a> contributors',
 
                         attribution: '&copy; <a href="//openstreetmap.org/copyright">OpenStreetMap</a> contributors',
 
                         minZoom: 2,
 
                         minZoom: 2,
                         maxZoom: 27,
+
                         maxZoom: 28,
 
                         maxNativeZoom: 19
 
                         maxNativeZoom: 19
 
                     }).addTo( this._leaflet.map );
 
                     }).addTo( this._leaflet.map );
 
 
                    L.tileLayer("/images/ACK_{x}_{y}_{z}.png", {
+
// Generic zoom (note that this will cause 404s
 +
L.tileLayer("/images/ACK_{x}_{y}_{z}.png", {
 
                         attribution: 'ACKspace',
 
                         attribution: 'ACKspace',
                         minZoom: 23,
+
                         minZoom: 24,
                         maxZoom: 27,
+
                         maxZoom: 28,
 
                         maxNativeZoom: 23
 
                         maxNativeZoom: 23
 
                     }).addTo( this._leaflet.map );
 
                     }).addTo( this._leaflet.map );
  
 +
// special zoom
 
                     var funcLayer = new L.TileLayer.Functional( function( view )
 
                     var funcLayer = new L.TileLayer.Functional( function( view )
 
                     {
 
                     {
switch ( view.zoom )
+
var bounds = {
 +
21 : { cl:  1083360, ch:  1083361, rl:  703073, rh:  703074 },
 +
22 : { cl:  2166720, ch:  2166723, rl:  1406146, rh:  1406148 },
 +
23 : { cl:  4333441, ch:  4333446, rl:  2812292, rh:  2812296 },
 +
24 : { cl:  8666890, ch:  8666890, rl:  5624590, rh:  5624590 },
 +
25 : { cl:  17333781, ch:  17333781, rl: 11249181, rh: 11249181 },
 +
26 : { cl:  34667562, ch:  34667562, rl: 22498362, rh: 22498362 },
 +
27 : { cl:  69335125, ch:  69335125, rl: 44996725, rh: 44996725 },
 +
28 : { cl: 138670250, ch: 138670251, rl: 89993450, rh: 89993451 }
 +
}
 +
if ( bounds[ view.zoom ] )
 
{
 
{
case 23:
+
if ( view.tile.column < bounds[ view.zoom ].cl || view.tile.column > bounds[ view.zoom ].ch )
if ( view.tile.column < 4333441 || view.tile.column > 4333446 )
+
return "/images/blank.png";
return "/images/blank.png";
+
if ( view.tile.row < bounds[ view.zoom ].rl || view.tile.row > bounds[ view.zoom ].rh )
if ( view.tile.row < 2812292 || view.tile.row > 2812296 )
+
return "/images/blank.png";
return "/images/blank.png";
 
break;
 
case 24:
 
if ( view.tile.column !== 8666890 && view.tile.column !== 5624590 )
 
return "/images/blank.png";
 
break;
 
case 25:
 
if ( view.tile.column !== 17333781 && view.tile.column !== 11249181 )
 
return "/images/blank.png";
 
break;
 
case 26:
 
if ( view.tile.column !== 34667562 && view.tile.column !== 22498362 )
 
return "/images/blank.png";
 
break;
 
case 27:
 
if ( view.tile.column !== 69335125 && view.tile.column !== 44996725 )
 
return "/images/blank.png";
 
break;
 
 
}
 
}
  
Line 261: Line 258:
 
                     {
 
                     {
 
                         attribution: 'ACKspace',
 
                         attribution: 'ACKspace',
                         minZoom: 23,
+
                         minZoom: 21,
                         maxZoom: 27/*,
+
                         maxZoom: 28
                        bounds: L.latLngBounds( [ L.latLng(50.892509702742856, 5.971158519387245), L.latLng(50.89240850727338, 5.971345268189907) ] )*/
 
 
                     } ).addTo( this._leaflet.map );
 
                     } ).addTo( this._leaflet.map );
 
 
Line 275: Line 271:
 
}, this );
 
}, this );
  
if ( false )
+
if ( this._debug )
 
{
 
{
 
this._leaflet.map.on( "click", function( _e )
 
this._leaflet.map.on( "click", function( _e )

Revision as of 10:18, 30 March 2017

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=/spaceAPI/
|width=260px
|height=20px
|padding=8px
|interval=20
|float=right
|features=
}}

This will give the following result:

Notes

  • url is mandatory, the rest is optional (leave out interval to make the data static).
    it also must be written without protocol since colon (:) is not allowed, and may be relative, for example: //ackspace.nl/spaceAPI/ or /spaceAPI/
  • 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.