|
From: <ha...@us...> - 2012-10-11 10:57:32
|
Revision: 1046
http://openautomation.svn.sourceforge.net/openautomation/?rev=1046&view=rev
Author: hausl
Date: 2012-10-11 10:57:25 +0000 (Thu, 11 Oct 2012)
Log Message:
-----------
New plugin strftime added for formatted date and time texts
Modified Paths:
--------------
CometVisu/trunk/ChangeLog
CometVisu/trunk/visu/visu_config.xsd
Added Paths:
-----------
CometVisu/trunk/visu/plugins/strftime/
CometVisu/trunk/visu/plugins/strftime/strftime.css
CometVisu/trunk/visu/plugins/strftime/structure_plugin.js
Modified: CometVisu/trunk/ChangeLog
===================================================================
--- CometVisu/trunk/ChangeLog 2012-10-10 19:43:37 UTC (rev 1045)
+++ CometVisu/trunk/ChangeLog 2012-10-11 10:57:25 UTC (rev 1046)
@@ -1,6 +1,7 @@
HEAD
====
+- New plugin: strftime
- New plugin: clock
- New plugin: rsslog
- New plugin: upnpcontroller
Added: CometVisu/trunk/visu/plugins/strftime/strftime.css
===================================================================
--- CometVisu/trunk/visu/plugins/strftime/strftime.css (rev 0)
+++ CometVisu/trunk/visu/plugins/strftime/strftime.css 2012-10-11 10:57:25 UTC (rev 1046)
@@ -0,0 +1,3 @@
+.strftime {
+ white-space: nowrap;
+}
Property changes on: CometVisu/trunk/visu/plugins/strftime/strftime.css
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: CometVisu/trunk/visu/plugins/strftime/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/strftime/structure_plugin.js (rev 0)
+++ CometVisu/trunk/visu/plugins/strftime/structure_plugin.js 2012-10-11 10:57:25 UTC (rev 1046)
@@ -0,0 +1,88 @@
+/* structure_plugin.js (c) 2012 by Michael Hausl [mi...@ha...]
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 3 of the License, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ */
+
+/**
+ * This plugins integrates formated date and clock strings into CometVisu based
+ * on strftime.
+ *
+ * Thanks to Michael Markstaller for implementing the jqclock as reference.
+ */
+
+$('head').append('<link rel="stylesheet" href="plugins/strftime/strftime.css" type="text/css" />');
+
+VisuDesign_Custom.prototype.addCreator("strftime", {
+ create : function(page, path) {
+ var $p = $(page);
+ function uniqid() {
+ var newDate = new Date;
+ return newDate.getTime();
+ }
+ var id = "strftime_" + uniqid();
+
+ var ret_val = $('<div class="widget clearfix text strftime"/>');
+ ret_val.setWidgetLayout($p);
+
+ var actor = $('<div id="' + id + '"></div>');
+ ret_val.append(actor);
+
+ var locale = $p.attr('lang');
+ var format = '%c';
+ if ($p.attr('format')) {
+ format = $p.attr('format');
+ }
+
+ // extend locales by German and French
+ Date.ext.locales['de'] = {
+ a: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
+ A: ['Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'],
+ b: ['Jan', 'Feb', 'Mär', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez'],
+ B: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
+ c: '%a %d %b %Y %T %Z',
+ p: ['', ''],
+ P: ['', ''],
+ x: '%d.%m.%Y',
+ X: '%T'
+ };
+ Date.ext.locales['fr'] = {
+ a: ['dim', 'lun', 'mar', 'mer', 'jeu', 'ven', 'sam'],
+ A: ['dimanche', 'lundi', 'mardi', 'mercredi', 'jeudi', 'vendredi', 'samedi'],
+ b: ['jan', 'fév', 'mar', 'avr', 'mai', 'jun', 'jui', 'aoû', 'sep', 'oct', 'nov', 'déc'],
+ B: ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre'],
+ c: '%a %d %b %Y %T %Z',
+ p: ['', ''],
+ P: ['', ''],
+ x: '%d.%m.%Y',
+ X: '%T'
+ };
+
+ f = function() {
+ var d = new Date();
+ d.locale = locale;
+ var iso = d.strftime(format);
+ $("#" + id).html(iso);
+ window.setTimeout(f, 1000);
+ };
+ f();
+
+ return ret_val;
+ },
+ attributes : {
+ lang : {type : "list" , required : false, list : {en : "en", de : "de", fr : "fr"}},
+ format : {type : "string", required : false},
+ },
+ content : false
+});
Property changes on: CometVisu/trunk/visu/plugins/strftime/structure_plugin.js
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: CometVisu/trunk/visu/visu_config.xsd
===================================================================
--- CometVisu/trunk/visu/visu_config.xsd 2012-10-10 19:43:37 UTC (rev 1045)
+++ CometVisu/trunk/visu/visu_config.xsd 2012-10-11 10:57:25 UTC (rev 1046)
@@ -220,6 +220,7 @@
<xsd:element name="rss" type="rss" />
<xsd:element name="rsslog" type="rsslog" />
<xsd:element name="jqclock" type="jqclock" />
+ <xsd:element name="strftime" type="strftime" />
<xsd:element name="upnpcontroller" type="upnpcontroller" />
<xsd:element name="page" type="page" />
<xsd:element name="layout" type="layout" />
@@ -276,6 +277,7 @@
<xsd:element name="rss" type="rss" />
<xsd:element name="rsslog" type="rsslog" />
<xsd:element name="jqclock" type="jqclock" />
+ <xsd:element name="strftime" type="strftime" />
<xsd:element name="upnpcontroller" type="upnpcontroller" />
<xsd:element name="page" type="page" />
<xsd:element name="group" type="group" />
@@ -317,6 +319,7 @@
<xsd:element name="gweather" type="gweather" />
<xsd:element name="rss" type="rss" />
<xsd:element name="jqclock" type="jqclock" />
+ <xsd:element name="strftime" type="strftime" />
<xsd:element name="upnpcontroller" type="upnpcontroller" />
<xsd:element name="page" type="page" />
</xsd:choice>
@@ -674,6 +677,19 @@
<xsd:attribute name="date" type="xsd:string" use="optional" />
</xsd:complexType>
+ <xsd:complexType name="strftime">
+ <xsd:attribute name="lang" use="optional">
+ <xsd:simpleType>
+ <xsd:restriction base="xsd:string">
+ <xsd:enumeration value="en" />
+ <xsd:enumeration value="de" />
+ <xsd:enumeration value="fr" />
+ </xsd:restriction>
+ </xsd:simpleType>
+ </xsd:attribute>
+ <xsd:attribute name="format" type="xsd:string" use="optional" />
+ </xsd:complexType>
+
<xsd:complexType name="upnpcontroller">
<xsd:attribute name="label" type="xsd:string" use="required" />
<xsd:attribute name="player_ip_addr" type="xsd:string" use="required" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|