Difference between revisions of "Widget:SpaceAPI"
m (whoops, symbol fail) |
m (replaced silly unit prefix logic) |
||
| Line 232: | Line 232: | ||
if ( this._beacon.icons[ this.data.sensors.beacon[0].name ] ) | if ( this._beacon.icons[ this.data.sensors.beacon[0].name ] ) | ||
this._beacon.icons[ this.data.sensors.beacon[0].name ].options.className = delta > 60 ? "disconnected" : ""; | this._beacon.icons[ this.data.sensors.beacon[0].name ].options.className = delta > 60 ? "disconnected" : ""; | ||
| − | + | if ( delta > 31556952 ) | |
| − | |||
| − | if ( delta | ||
{ | { | ||
| − | delta /= | + | delta /= 31556952; |
| − | postfix = " | + | postfix = "Y"; |
| + | } | ||
| + | else if ( delta > 2629746 ) | ||
| + | { | ||
| + | delta /= 2629746; | ||
| + | postfix = "M"; | ||
} | } | ||
| − | + | else if ( delta > 604800 ) | |
| − | |||
{ | { | ||
| − | delta /= | + | delta /= 604800; |
| − | postfix = " | + | postfix = "W"; |
} | } | ||
| − | + | else if ( delta > 86400 ) | |
| − | |||
{ | { | ||
| − | delta /= | + | delta /= 86400; |
postfix = "d"; | postfix = "d"; | ||
} | } | ||
| − | + | else if ( delta > 3600 ) | |
| − | |||
{ | { | ||
| − | delta /= | + | delta /= 3600; |
| − | postfix = " | + | postfix = "h"; |
} | } | ||
| − | + | else if ( delta > 60 ) | |
| − | |||
{ | { | ||
| − | delta = | + | delta /= 60; |
| − | postfix = " | + | postfix = "m"; |
} | } | ||
| − | + | else | |
| − | |||
{ | { | ||
| − | + | postfix = "s"; | |
| − | postfix = " | ||
} | } | ||
this._beacon.marker.bindPopup( "Hackers on a Bike<br/>Last update: " + Math.round( delta ) + postfix + " ago" ); | this._beacon.marker.bindPopup( "Hackers on a Bike<br/>Last update: " + Math.round( delta ) + postfix + " ago" ); | ||
Revision as of 08:58, 12 May 2016
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
}}
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.