Skip to content
Snippets Groups Projects
Commit fdbfb00a authored by Julian Büning's avatar Julian Büning
Browse files

Wordpress plugin added

parent 2b211109
No related branches found
No related tags found
No related merge requests found
<?php
/**
* Plugin Name: Warpzone Status Widget
* Plugin URI: http://www.warpzone.ms
* Description: Widget, dass den aktuellen Warpzone-Status und die Temperaturen an
* Version: 0.1
* Author: Warpzone
* License: Public Domain / GPL (?)
*/
class WZ_Status extends WP_Widget {
public function __construct() {
parent::__construct(
'wz_status', // Base ID
__('Warpzone Status Widget', 'wz_status'), // Name
array( 'classname' => 'wz_status', 'description' => __( 'Zeigt den aktuellen Warpzone-Status und die Temperaturen an.', 'wz_status' ), ) // Args
);
if(is_active_widget(false, false, 'wz_status')) {
wp_register_script( 'wz-status', plugins_url( '/wz-status.js', __FILE__ ), array('jquery'), true );
wp_enqueue_script( 'wz-status' );
wp_register_style( 'wz-status', plugins_url( '/wz-status.css', __FILE__ ) );
wp_enqueue_style( 'wz-status' );
}
}
public function widget( $args, $instance ) {
echo <<<HTML
<ul>
<li><a class="zonenstatus" href="/api/static">Status: <span id="wankerTuerOffen" class="wankerClosed">Unbekannt</span></a></li>
<li><a class="zonenstatus" href="/api/static">Lounge: <span id="wankerTempLounge">--</span></a></li>
<li><a class="zonenstatus" href="/api/static">Werkstatt: <span id="wankerTempWerkstatt">--</span></a></li>
</ul>
HTML;
}
}
function wz_status_init() {
register_widget('WZ_Status');
}
add_action('widgets_init', 'wz_status_init');
#site-nav h3{
display: none;
}
#site-nav{
border: 0px;
}
.zonenstatus {
padding: 15px 10px;
display: block;
color: #050000;
font: 700 11px Sans-Serif;
}
function queryWankerStatus() {
jQuery.getJSON("/api/status", function(result) {
if(result.age < 600 && result != null) {
if(result.tuerOffen != null) {
if(result.tuerOffen == 1) {
jQuery("#wankerTuerOffen").html("<font color=\"00cc00\">Offen</font>");
} else {
jQuery("#wankerTuerOffen").html("<font color=\"cc0000\">Geschlossen</font>");
}
}
if(result.tempLounge != null && result.tempLounge) {
var tempLounge = (result.tempLounge / 10) + "&deg;C";
jQuery("#wankerTempLounge").html(tempLounge);
}
if(result.tempWerkstatt != null && result.tempWerkstatt) {
var tempWerkstatt = (result.tempWerkstatt / 10) + "&deg;C";
jQuery("#wankerTempWerkstatt").html(tempWerkstatt);
}
}
});
setInterval(queryWankerStatus, 30000);
}
jQuery(document).ready(function() {
queryWankerStatus();
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment