Difference between revisions of "Widget:GraphInteractivity"

From Hackerspace ACKspace
Jump to: navigation, search
m (whoops, typo)
m (added interval)
Line 9: Line 9:
 
  <nowiki>{{#widget:</nowiki>{{PAGENAME}}<nowiki>}}</nowiki>
 
  <nowiki>{{#widget:</nowiki>{{PAGENAME}}<nowiki>}}</nowiki>
  
 +
(supported field for SpaceAPI is <code>interval</code>
 
This will add javascript logic that enables 'interactivity' to graphs.<br/>
 
This will add javascript logic that enables 'interactivity' to graphs.<br/>
  
Line 22: Line 23:
 
var g_coloredNodes;
 
var g_coloredNodes;
  
 +
var g_interval = <!--{$interval|validate:int|default:0}-->;
 
window.addEventListener( "load", function(){g_graphs = document.querySelectorAll( "svg > g.graph" );
 
window.addEventListener( "load", function(){g_graphs = document.querySelectorAll( "svg > g.graph" );
 
g_coloredNodes = [];//[ [ g_graphs[0].querySelector( "g#h4" ), "green" ] ];
 
g_coloredNodes = [];//[ [ g_graphs[0].querySelector( "g#h4" ), "green" ] ];
Line 37: Line 39:
 
} );
 
} );
  
setInterval( fetchState, 30000 );
+
        if ( g_interval )
fetchState( );
+
        {
 +
    setInterval( fetchState, g_interval );
 +
    fetchState( );
 +
        }
 
} );
 
} );
  

Revision as of 17:12, 4 February 2019

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:GraphInteractivity}}

(supported field for SpaceAPI is interval This will add javascript logic that enables 'interactivity' to graphs.

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