From fdbfb00afac13bc1ae19b96adba5407b5b363812 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20B=C3=BCning?= <jb@mint> Date: Sun, 15 Dec 2013 01:21:55 +0100 Subject: [PATCH] Wordpress plugin added --- widget/wordpress_plugin/wz-status/index.php | 46 +++++++++++++++++++ .../wordpress_plugin/wz-status/wz-status.css | 12 +++++ .../wordpress_plugin/wz-status/wz-status.js | 26 +++++++++++ 3 files changed, 84 insertions(+) create mode 100644 widget/wordpress_plugin/wz-status/index.php create mode 100644 widget/wordpress_plugin/wz-status/wz-status.css create mode 100644 widget/wordpress_plugin/wz-status/wz-status.js diff --git a/widget/wordpress_plugin/wz-status/index.php b/widget/wordpress_plugin/wz-status/index.php new file mode 100644 index 0000000..385fece --- /dev/null +++ b/widget/wordpress_plugin/wz-status/index.php @@ -0,0 +1,46 @@ +<?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'); diff --git a/widget/wordpress_plugin/wz-status/wz-status.css b/widget/wordpress_plugin/wz-status/wz-status.css new file mode 100644 index 0000000..7b98d31 --- /dev/null +++ b/widget/wordpress_plugin/wz-status/wz-status.css @@ -0,0 +1,12 @@ +#site-nav h3{ + display: none; +} +#site-nav{ + border: 0px; +} +.zonenstatus { + padding: 15px 10px; + display: block; + color: #050000; + font: 700 11px Sans-Serif; +} diff --git a/widget/wordpress_plugin/wz-status/wz-status.js b/widget/wordpress_plugin/wz-status/wz-status.js new file mode 100644 index 0000000..0ba4bc5 --- /dev/null +++ b/widget/wordpress_plugin/wz-status/wz-status.js @@ -0,0 +1,26 @@ +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) + "°C"; + jQuery("#wankerTempLounge").html(tempLounge); + } + if(result.tempWerkstatt != null && result.tempWerkstatt) { + var tempWerkstatt = (result.tempWerkstatt / 10) + "°C"; + jQuery("#wankerTempWerkstatt").html(tempWerkstatt); + } + } + }); + setInterval(queryWankerStatus, 30000); +} + +jQuery(document).ready(function() { + queryWankerStatus(); +}); -- GitLab