|
From: <ma...@us...> - 2010-11-28 22:02:52
|
Revision: 173
http://openautomation.svn.sourceforge.net/openautomation/?rev=173&view=rev
Author: mayerch
Date: 2010-11-28 22:02:46 +0000 (Sun, 28 Nov 2010)
Log Message:
-----------
Change camelCase to lowercase to conform to XML spec
Added Paths:
-----------
CometVisu/trunk/visu/plugins/colorchooser/
CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
Removed Paths:
-------------
CometVisu/trunk/visu/plugins/colorChooser/
CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
Deleted: CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/colorChooser/structure_plugin.js 2010-11-26 20:13:09 UTC (rev 165)
+++ CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2010-11-28 22:02:46 UTC (rev 173)
@@ -1,65 +0,0 @@
-/* structure_plugin.js (c) 2010 by Christian Mayer [CometVisu at ChristianMayer dot de]
- *
- * 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 is a custom function that extends the available widgets.
- * It's purpose is to change the design of the visu during runtime
- * to demonstrate all available
- */
-VisuDesign_Custom.prototype.addCreator("colorChooser", {
- create: function( page, path ) {
- var ret_val = $('<div class="widget" />');
- ret_val.addClass( 'colorChooser' );
- var label = '<div class="label">' + page.textContent + '</div>';
- var actor = '<div class="actor">';
- actor += '</div>';
- ret_val.append(label)
- .append($(actor)
- .data({
- 'mapping' : $(page).attr('mapping'),
- 'styling' : $(page).attr('styling'),
- 'type' : 'toggle'
- })
- .farbtastic( function(color){
- var r = parseInt(color.substring(1, 3), 16);
- var g = parseInt(color.substring(3, 5), 16);
- var b = parseInt(color.substring(5, 7), 16);
- var a_r = $(page).attr('address_r');
- var a_g = $(page).attr('address_g');
- var a_b = $(page).attr('address_b');
- var datatype = $(page).attr('datatype');
- visu.write( a_r, r, datatype );
- visu.write( a_g, g, datatype );
- visu.write( a_b, b, datatype );
- })) ;
- return ret_val;
- },
- attributes: {
- address_r: {type: "address", required: true},
- address_g: {type: "address", required: true},
- address_b: {type: "address", required: true},
- datatype: {type: "datatype", required: true},
- },
- content: {type: "string", required: true}
-});
-
-/**
- * Include the needed stuff
- */
-$( 'head' ).append( '<script type="text/javascript" src="plugins/colorChooser/farbtastic/farbtastic.js"></script>' );
-$( 'head' ).append( '<link rel="stylesheet" href="plugins/colorChooser/farbtastic/farbtastic.css" type="text/css" />' );
-
Copied: CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js (from rev 167, CometVisu/trunk/visu/plugins/colorChooser/structure_plugin.js)
===================================================================
--- CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js (rev 0)
+++ CometVisu/trunk/visu/plugins/colorchooser/structure_plugin.js 2010-11-28 22:02:46 UTC (rev 173)
@@ -0,0 +1,65 @@
+/* structure_plugin.js (c) 2010 by Christian Mayer [CometVisu at ChristianMayer dot de]
+ *
+ * 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 is a custom function that extends the available widgets.
+ * It's purpose is to change the design of the visu during runtime
+ * to demonstrate all available
+ */
+VisuDesign_Custom.prototype.addCreator("colorChooser", {
+ create: function( page, path ) {
+ var ret_val = $('<div class="widget" />');
+ ret_val.addClass( 'colorChooser' );
+ var label = '<div class="label">' + page.textContent + '</div>';
+ var actor = '<div class="actor">';
+ actor += '</div>';
+ ret_val.append(label)
+ .append($(actor)
+ .data({
+ 'mapping' : $(page).attr('mapping'),
+ 'styling' : $(page).attr('styling'),
+ 'type' : 'toggle'
+ })
+ .farbtastic( function(color){
+ var r = parseInt(color.substring(1, 3), 16) * 100 / 255;
+ var g = parseInt(color.substring(3, 5), 16) * 100 / 255;
+ var b = parseInt(color.substring(5, 7), 16) * 100 / 255;
+ var a_r = $(page).attr('address_r');
+ var a_g = $(page).attr('address_g');
+ var a_b = $(page).attr('address_b');
+ var datatype = $(page).attr('datatype');
+ visu.write( a_r, r, datatype );
+ visu.write( a_g, g, datatype );
+ visu.write( a_b, b, datatype );
+ })) ;
+ return ret_val;
+ },
+ attributes: {
+ address_r: {type: "address", required: true},
+ address_g: {type: "address", required: true},
+ address_b: {type: "address", required: true},
+ datatype: {type: "datatype", required: true},
+ },
+ content: {type: "string", required: true}
+});
+
+/**
+ * Include the needed stuff
+ */
+$( 'head' ).append( '<script type="text/javascript" src="plugins/colorChooser/farbtastic/farbtastic.js"></script>' );
+$( 'head' ).append( '<link rel="stylesheet" href="plugins/colorChooser/farbtastic/farbtastic.css" type="text/css" />' );
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-07-06 19:46:06
|
Revision: 383
http://openautomation.svn.sourceforge.net/openautomation/?rev=383&view=rev
Author: makki1
Date: 2011-07-06 19:45:58 +0000 (Wed, 06 Jul 2011)
Log Message:
-----------
Plugins RSS and Yahoo-weather - both still need some work on CSS to look fine, so no entry in visu_config_demo yet
Added Paths:
-----------
CometVisu/trunk/visu/plugins/rss/
CometVisu/trunk/visu/plugins/rss/structure_plugin.js
CometVisu/trunk/visu/plugins/rss/zrssfeed/
CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.vticker.js
CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.css
CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.js
CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.min.js
CometVisu/trunk/visu/plugins/zweather/
CometVisu/trunk/visu/plugins/zweather/structure_plugin.js
CometVisu/trunk/visu/plugins/zweather/zweatherfeed/
CometVisu/trunk/visu/plugins/zweather/zweatherfeed/jquery.zweatherfeed.css
CometVisu/trunk/visu/plugins/zweather/zweatherfeed/jquery.zweatherfeed.js
CometVisu/trunk/visu/plugins/zweather/zweatherfeed/jquery.zweatherfeed.min.js
Added: CometVisu/trunk/visu/plugins/rss/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/rss/structure_plugin.js (rev 0)
+++ CometVisu/trunk/visu/plugins/rss/structure_plugin.js 2011-07-06 19:45:58 UTC (rev 383)
@@ -0,0 +1,115 @@
+/* structure_plugin.js (c) 2011 by Michael Markstaller [de...@wi...]
+ *
+ * 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 jFeed to display RSS-Feeds into CometVisu.
+ */
+
+$("body").append("<script type=\"text/javascript\" src=\"plugins/rss/zrssfeed/jquery.zrssfeed.min.js\"></script>");
+
+VisuDesign_Custom.prototype.addCreator("rss", {
+ create: function( page, path ) {
+ var $p = $(page);
+
+ function uniqid() {
+ var newDate = new Date;
+ return newDate.getTime();
+ }
+
+ var id = "rss_" + uniqid();
+
+ var ret_val = $('<div class="widget" />');
+ ret_val.addClass( 'rss' );
+ var label = '<div class="label">' + page.textContent + '</div>';
+ var actor = $("<div class=\"actor\"><div class=\"rss_inline\" id=\"" + id + "\">loading...</div></div>");
+ var rss = $("#" + id, actor);
+
+ if ($p.attr("width")) {
+ rss.css("width", $p.attr("width"));
+ }
+ if ($p.attr("height")) {
+ rss.css("height", $p.attr("height"));
+ }
+
+ ret_val.append(label).append(actor);
+
+ rss.data("id", id);
+ rss.data("src", $p.attr("src"));
+ rss.data("label", page.textContent);
+ rss.data("refresh", $p.attr("refresh"));
+ rss.data("limit", $p.attr("limit")) || 10;
+ rss.data("header", $p.attr("header")) || true;
+ rss.data("date", $p.attr("date")) || true;
+ rss.data("content", $p.attr("content")) || true;
+ rss.data("snippet", $p.attr("snippet")) || true;
+ rss.data("showerror", $p.attr("showerror")) || true;
+ rss.data("ssl", $p.attr("ssl")) || false;
+ rss.data("linktarget", $p.attr("linktarget")) || "_new";
+
+ refreshRSS(rss, {});
+
+ return ret_val;
+ },
+ attributes: {
+ src: {type: "string", required: true},
+ width: {type: "string", required: false},
+ height: {type: "string", required: false},
+ refresh: {type: "numeric", required: false},
+ limit: {type: "numeric", required: false},
+ header: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ date: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ content: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ snippet: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ showerror: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ ssl: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ linktarget: {type: "list", required: false, list: {"_new": "_new", "_self": "_self"}}
+ },
+ content: {type: "string", required: true}
+});
+
+function refreshRSS(rss, data) {
+ var rss = $(rss);
+
+ var src = rss.data("src");
+ var label = rss.data("label");
+ var refresh = rss.data("refresh");
+ var limit = rss.data("limit");
+ //console.log("refresh rss:" + src); //DEBUG
+ //eval needed to convert string true/false to bool?
+ jQuery(function() {
+ $(rss).rssfeed(src, {
+ limit: rss.data("limit"),
+ header: eval(rss.data("header")),
+ date: eval(rss.data("date")),
+ date: eval(rss.data("date")),
+ content: rss.data("content"),
+ snippet: eval(rss.data("snippet")),
+ showerror: eval(rss.data("showerror")),
+ ssl: eval(rss.data("ssl")),
+ linktarget: rss.data("linktarget")
+ });
+
+ });
+ if (typeof (refresh) != "undefined" && refresh) {
+ // reload regularly
+ window.setTimeout(function(rss, data) {
+ refreshRSS(rss, data)
+ }, refresh * 1000, rss, data);
+ }
+
+ return false;
+}
Added: CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.vticker.js
===================================================================
--- CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.vticker.js (rev 0)
+++ CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.vticker.js 2011-07-06 19:45:58 UTC (rev 383)
@@ -0,0 +1,77 @@
+/*
+* Tadas Juozapaitis ( kas...@gm... )
+*
+* Modifed by Zazar:
+* 24.06.2011 - Corrected pausing issue with multiple instances
+*
+*/
+
+(function($){
+
+$.fn.vTicker = function(options) {
+ var defaults = {
+ speed: 700,
+ pause: 4000,
+ showItems: 3,
+ animation: '',
+ mousePause: true,
+ isPaused: false
+ };
+
+ var options = $.extend(defaults, options);
+
+ moveUp = function(obj2, height, paused){
+ if(paused) return;
+
+ var obj = obj2.children('ul');
+
+ first = obj.children('li:first').clone(true);
+
+ obj.animate({top: '-=' + height + 'px'}, options.speed, function() {
+ $(this).children('li:first').remove();
+ $(this).css('top', '0px');
+ });
+
+ if(options.animation == 'fade') {
+ obj.children('li:first').fadeOut(options.speed);
+ obj.children('li:last').hide().fadeIn(options.speed);
+ }
+
+ first.appendTo(obj);
+ };
+
+ return this.each(function() {
+ var obj = $(this);
+ var maxHeight = 0;
+ var itempause = options.isPaused;
+
+ obj.css({overflow: 'hidden', position: 'relative'})
+ .children('ul').css({position: 'absolute', margin: 0, padding: 0})
+ .children('li').css({margin: 0, padding: 0});
+
+ obj.children('ul').children('li').each(function(){
+
+ if($(this).height() > maxHeight) {
+ maxHeight = $(this).height();
+ }
+ });
+
+ obj.children('ul').children('li').each(function() {
+ $(this).height(maxHeight);
+ });
+
+ obj.height(maxHeight * options.showItems);
+
+ var interval = setInterval(function(){ moveUp(obj, maxHeight, itempause); }, options.pause);
+
+ if (options.mousePause)
+ {
+ obj.bind("mouseenter",function() {
+ itempause = true;
+ }).bind("mouseleave",function() {
+ itempause = false;
+ });
+ }
+ });
+};
+})(jQuery);
\ No newline at end of file
Added: CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.css
===================================================================
--- CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.css (rev 0)
+++ CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.css 2011-07-06 19:45:58 UTC (rev 383)
@@ -0,0 +1,52 @@
+@charset "UTF-8";
+/*
+ * Example of zRSSFeed Styling
+ *
+ * Version: 1.1.2
+ * (c) Copyright 2010-2011, Zazar Ltd
+ *
+ */
+
+body {
+ margin: 1em 3em;
+ font-family: Tahoma, Genevam, sans-serif;
+}
+
+.rssFeed {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 90%;
+ margin: 2em 3em;
+}
+.rssFeed a {
+ color: #444;
+ text-decoration: none;
+}
+.rssFeed a:hover {
+ color: #000;
+ text-decoration: underline;
+}
+
+.rssHeader { padding: 0.2em 0; }
+
+.rssBody { border: 1px solid #999; }
+.rssBody ul { list-style: none; }
+.rssBody ul, .rssRow, .rssRow h4, .rssRow p {
+ margin: 0;
+ padding: 0;
+}
+
+.rssRow { padding: 0.8em; }
+.rssRow h4 { font-size: 1.1em; }
+.rssRow div {
+ font-size: 90%;
+ color: #666;
+ margin: 0.2em 0 0.4em 0;
+}
+
+.odd { background-color: #e8e8fc; }
+.even { background-color: #d4d4e8; }
+
+.rssRow .rssMedia {
+ padding: 0.5em;
+ font-size: 1em;
+}
Added: CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.js
===================================================================
--- CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.js (rev 0)
+++ CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.js 2011-07-06 19:45:58 UTC (rev 383)
@@ -0,0 +1,187 @@
+/**
+ * Plugin: jquery.zRSSFeed
+ *
+ * Version: 1.1.2
+ * (c) Copyright 2010-2011, Zazar Ltd
+ *
+ * Description: jQuery plugin for display of RSS feeds via Google Feed API
+ * (Based on original plugin jGFeed by jQuery HowTo. Filesize function by Cary Dunn.)
+ *
+ * History:
+ * 1.1.2 - Added user callback function due to issue with ajaxStop after jQuery 1.4.2
+ * 1.1.1 - Correction to null xml entries and support for media with jQuery < 1.5
+ * 1.1.0 - Added support for media in enclosure tags
+ * 1.0.3 - Added feed link target
+ * 1.0.2 - Fixed issue with GET parameters (Seb Dangerfield) and SSL option
+ * 1.0.1 - Corrected issue with multiple instances
+ *
+ **/
+
+(function($){
+
+ $.fn.rssfeed = function(url, options, fn) {
+
+ // Set pluign defaults
+ var defaults = {
+ limit: 10,
+ header: true,
+ titletag: 'h4',
+ date: true,
+ content: true,
+ snippet: true,
+ showerror: true,
+ errormsg: '',
+ key: null,
+ ssl: false,
+ linktarget: '_self'
+ };
+ var options = $.extend(defaults, options);
+
+ // Functions
+ return this.each(function(i, e) {
+ var $e = $(e);
+ var s = '';
+
+ // Check for SSL protocol
+ if (options.ssl) s = 's';
+
+ // Add feed class to user div
+ if (!$e.hasClass('rssFeed')) $e.addClass('rssFeed');
+
+ // Check for valid url
+ if(url == null) return false;
+
+ // Create Google Feed API address
+ var api = "http"+ s +"://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q=" + encodeURIComponent(url);
+ if (options.limit != null) api += "&num=" + options.limit;
+ if (options.key != null) api += "&key=" + options.key;
+ api += "&output=json_xml"
+
+ // Send request
+ $.getJSON(api, function(data){
+
+ // Check for error
+ if (data.responseStatus == 200) {
+
+ // Process the feeds
+ _process(e, data.responseData, options);
+
+ // Optional user callback function
+ if ($.isFunction(fn)) fn.call(this,$e);
+
+ } else {
+
+ // Handle error if required
+ if (options.showerror)
+ if (options.errormsg != '') {
+ var msg = options.errormsg;
+ } else {
+ var msg = data.responseDetails;
+ };
+ $(e).html('<div class="rssError"><p>'+ msg +'</p></div>');
+ };
+ });
+ });
+ };
+
+ // Function to create HTML result
+ var _process = function(e, data, options) {
+
+ // Get JSON feed data
+ var feeds = data.feed;
+ if (!feeds) {
+ return false;
+ }
+ var html = '';
+ var row = 'odd';
+
+ // Get XML data for media (parseXML not used as requires 1.5+)
+ var xml = getXMLDocument(data.xmlString);
+ var xmlEntries = xml.getElementsByTagName('item');
+
+ // Add header if required
+ if (options.header)
+ html += '<div class="rssHeader">' +
+ '<a href="'+feeds.link+'" title="'+ feeds.description +'">'+ feeds.title +'</a>' +
+ '</div>';
+
+ // Add body
+ html += '<div class="rssBody">' +
+ '<ul>';
+
+ // Add feeds
+ for (var i=0; i<feeds.entries.length; i++) {
+
+ // Get individual feed
+ var entry = feeds.entries[i];
+
+ // Format published date
+ var entryDate = new Date(entry.publishedDate);
+ var pubDate = entryDate.toLocaleDateString() + ' ' + entryDate.toLocaleTimeString();
+
+ // Add feed row
+ html += '<li class="rssRow '+row+'">' +
+ '<'+ options.titletag +'><a href="'+ entry.link +'" title="View this feed at '+ feeds.title +'" target="'+ options.linktarget +'">'+ entry.title +'</a></'+ options.titletag +'>'
+ if (options.date) html += '<div>'+ pubDate +'</div>'
+ if (options.content) {
+
+ // Use feed snippet if available and optioned
+ if (options.snippet && entry.contentSnippet != '') {
+ var content = entry.contentSnippet;
+ } else {
+ var content = entry.content;
+ }
+
+ html += '<p>'+ content +'</p>'
+ }
+
+ // Add any media
+ if(xmlEntries.length > 0) {
+ var xmlMedia = xmlEntries[i].getElementsByTagName('enclosure');
+ if (xmlMedia.length > 0) {
+ html += '<div class="rssMedia"><div>Media files</div><ul>'
+ for (var m=0; m<xmlMedia.length; m++) {
+ var xmlUrl = xmlMedia[m].getAttribute("url");
+ var xmlType = xmlMedia[m].getAttribute("type");
+ var xmlSize = xmlMedia[m].getAttribute("length");
+ html += '<li><a href="'+ xmlUrl +'" title="Download this media">'+ xmlUrl.split('/').pop() +'</a> ('+ xmlType +', '+ formatFilesize(xmlSize) +')</li>';
+ }
+ html += '</ul></div>'
+ }
+ html += '</li>';
+ }
+
+ // Alternate row classes
+ if (row == 'odd') {
+ row = 'even';
+ } else {
+ row = 'odd';
+ }
+ }
+
+ html += '</ul>' +
+ '</div>'
+
+ $(e).html(html);
+ };
+
+ function formatFilesize(bytes) {
+ var s = ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB'];
+ var e = Math.floor(Math.log(bytes)/Math.log(1024));
+ return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+" "+s[e];
+ }
+
+ function getXMLDocument(string) {
+ var browser = navigator.appName;
+ var xml;
+ if (browser == 'Microsoft Internet Explorer') {
+ xml = new ActiveXObject('Microsoft.XMLDOM');
+ xml.async = 'false'
+ xml.loadXML(string);
+ } else {
+ xml = (new DOMParser()).parseFromString(string, 'text/xml');
+ }
+ return xml;
+ }
+
+})(jQuery);
Added: CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.min.js
===================================================================
--- CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.min.js (rev 0)
+++ CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.min.js 2011-07-06 19:45:58 UTC (rev 383)
@@ -0,0 +1,19 @@
+
+(function($){$.fn.rssfeed=function(url,options,fn){var defaults={limit:10,header:true,titletag:'h4',date:true,content:true,snippet:true,showerror:true,errormsg:'',key:null,ssl:false,linktarget:'_self'};var options=$.extend(defaults,options);return this.each(function(i,e){var $e=$(e);var s='';if(options.ssl)s='s';if(!$e.hasClass('rssFeed'))$e.addClass('rssFeed');if(url==null)return false;var api="http"+s+"://ajax.googleapis.com/ajax/services/feed/load?v=1.0&callback=?&q="+encodeURIComponent(url);if(options.limit!=null)api+="&num="+options.limit;if(options.key!=null)api+="&key="+options.key;api+="&output=json_xml"
+$.getJSON(api,function(data){if(data.responseStatus==200){_process(e,data.responseData,options);if($.isFunction(fn))fn.call(this,$e);}else{if(options.showerror)
+if(options.errormsg!=''){var msg=options.errormsg;}else{var msg=data.responseDetails;};$(e).html('<div class="rssError"><p>'+msg+'</p></div>');};});});};var _process=function(e,data,options){var feeds=data.feed;if(!feeds){return false;}
+var html='';var row='odd';var xml=getXMLDocument(data.xmlString);var xmlEntries=xml.getElementsByTagName('item');if(options.header)
+html+='<div class="rssHeader">'+'<a href="'+feeds.link+'" title="'+feeds.description+'">'+feeds.title+'</a>'+'</div>';html+='<div class="rssBody">'+'<ul>';for(var i=0;i<feeds.entries.length;i++){var entry=feeds.entries[i];var entryDate=new Date(entry.publishedDate);var pubDate=entryDate.toLocaleDateString()+' '+entryDate.toLocaleTimeString();html+='<li class="rssRow '+row+'">'+'<'+options.titletag+'><a href="'+entry.link+'" title="View this feed at '+feeds.title+'" target="'+options.linktarget+'">'+entry.title+'</a></'+options.titletag+'>'
+if(options.date)html+='<div>'+pubDate+'</div>'
+if(options.content){if(options.snippet&&entry.contentSnippet!=''){var content=entry.contentSnippet;}else{var content=entry.content;}
+html+='<p>'+content+'</p>'}
+if(xmlEntries.length>0){var xmlMedia=xmlEntries[i].getElementsByTagName('enclosure');if(xmlMedia.length>0){html+='<div class="rssMedia"><div>Media files</div><ul>'
+for(var m=0;m<xmlMedia.length;m++){var xmlUrl=xmlMedia[m].getAttribute("url");var xmlType=xmlMedia[m].getAttribute("type");var xmlSize=xmlMedia[m].getAttribute("length");html+='<li><a href="'+xmlUrl+'" title="Download this media">'+xmlUrl.split('/').pop()+'</a> ('+xmlType+', '+formatFilesize(xmlSize)+')</li>';}
+html+='</ul></div>'}
+html+='</li>';}
+if(row=='odd'){row='even';}else{row='odd';}}
+html+='</ul>'+'</div>'
+$(e).html(html);};function formatFilesize(bytes){var s=['bytes','kb','MB','GB','TB','PB'];var e=Math.floor(Math.log(bytes)/Math.log(1024));return(bytes/Math.pow(1024,Math.floor(e))).toFixed(2)+" "+s[e];}
+function getXMLDocument(string){var browser=navigator.appName;var xml;if(browser=='Microsoft Internet Explorer'){xml=new ActiveXObject('Microsoft.XMLDOM');xml.async='false'
+xml.loadXML(string);}else{xml=(new DOMParser()).parseFromString(string,'text/xml');}
+return xml;}})(jQuery);
\ No newline at end of file
Added: CometVisu/trunk/visu/plugins/zweather/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/zweather/structure_plugin.js (rev 0)
+++ CometVisu/trunk/visu/plugins/zweather/structure_plugin.js 2011-07-06 19:45:58 UTC (rev 383)
@@ -0,0 +1,89 @@
+/* structure_plugin.js (c) 2011 by Michael Markstaller [de...@wi...]
+ *
+ * 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 jFeed to display RSS-Feeds into CometVisu.
+ */
+
+// $( 'head' ).append( '<link rel="stylesheet" href="plugins/zweather/zweatherfeed/jquery.zweatherfeed.css" type="text/css" />' );
+$( 'head' ).append("<script type=\"text/javascript\" src=\"plugins/zweather/zweatherfeed/jquery.zweatherfeed.min.js\"></script>");
+
+VisuDesign_Custom.prototype.addCreator("zweather", {
+ create: function( page, path ) {
+ var $p = $(page);
+
+ function uniqid() {
+ var newDate = new Date;
+ return newDate.getTime();
+ }
+
+ var id = "zweather_" + uniqid();
+
+ var ret_val = $('<div class="widget" />');
+ ret_val.addClass( 'zweather' );
+ var label = '<div class="label">' + page.textContent + '</div>';
+ var actor = $("<div class=\"actor\"><div class=\"zweather_inline\" id=\"" + id + "\"></div></div>");
+ var zweather = $("#" + id, actor);
+
+ if ($p.attr("width")) {
+ zweather.css("width", $p.attr("width"));
+ }
+ if ($p.attr("height")) {
+ zweather.css("height", $p.attr("height"));
+ }
+
+ ret_val.append(label).append(actor);
+ console.log("loaded plugin zweather");
+
+ zweather.data("id", id);
+ zweather.data("label", page.textContent);
+ zweather.data("refresh", $p.attr("refresh"));
+ zweather.data("location", $p.attr("location"));
+ console.log(zweather.data("location"));
+ refreshZWeather(zweather, {});
+
+ return ret_val;
+ },
+ attributes: {
+ width: {type: "string", required: false},
+ height: {type: "string", required: false},
+ refresh: {type: "numeric", required: false},
+ location: {type: "string", required: true}
+ },
+ content: {type: "string", required: true}
+});
+
+function refreshZWeather(zweather, data) {
+ var zweather = $(zweather);
+
+ var label = zweather.data("label");
+ var refresh = zweather.data("refresh");
+ var location = zweather.data("location");
+ console.log("refresh zweather:" + location); //DEBUG
+ //eval needed to convert string true/false to bool?
+ jQuery(function() {
+ $(zweather).weatherfeed([location]);
+ });
+ if (typeof (refresh) != "undefined" && refresh) {
+ // reload regularly
+ window.setTimeout(function(zweather, data) {
+ refreshZWeather(zweather, data)
+ }, refresh * 1000, zweather, data);
+ }
+
+ return false;
+}
Added: CometVisu/trunk/visu/plugins/zweather/zweatherfeed/jquery.zweatherfeed.css
===================================================================
--- CometVisu/trunk/visu/plugins/zweather/zweatherfeed/jquery.zweatherfeed.css (rev 0)
+++ CometVisu/trunk/visu/plugins/zweather/zweatherfeed/jquery.zweatherfeed.css 2011-07-06 19:45:58 UTC (rev 383)
@@ -0,0 +1,44 @@
+@charset "UTF-8";
+/*
+ * Example of zWeatherFeed Styling
+ *
+ * Version: 1.0.2
+ * (c) Copyright 2010, Zazar Ltd
+ *
+ */
+
+.weatherFeed
+{
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 90%;
+ margin: 2em 3em;
+ width: 280px;
+}
+.weatherFeed a { color: #888; }
+.weatherFeed a:hover
+{
+ color: #000;
+ text-decoration: none;
+}
+.weatherItem
+{
+ padding: 0.8em;
+ text-align: right;
+}
+.weatherCity { text-transform: uppercase; }
+.weatherTemp
+{
+ font-size: 2.8em;
+ font-weight: bold;
+}
+.weatherDesc, .weatherCity { font-weight: bold; }
+.weatherDesc { margin-bottom: 0.4em; }
+.weatherRange, .weatherWind { font-size: 0.8em; }
+.weatherLink
+{
+ text-align: left;
+ font-size: 0.8em;
+}
+
+.odd { background-color: #e8e8fc; }
+.even { background-color: #d4d4e8; }
\ No newline at end of file
Added: CometVisu/trunk/visu/plugins/zweather/zweatherfeed/jquery.zweatherfeed.js
===================================================================
--- CometVisu/trunk/visu/plugins/zweather/zweatherfeed/jquery.zweatherfeed.js (rev 0)
+++ CometVisu/trunk/visu/plugins/zweather/zweatherfeed/jquery.zweatherfeed.js 2011-07-06 19:45:58 UTC (rev 383)
@@ -0,0 +1,141 @@
+/**
+ * Plugin: jquery.zWeatherFeed
+ *
+ * Version: 1.0.2
+ * (c) Copyright 2010, Zazar Ltd
+ *
+ * Description: jQuery plugin for display of Yahoo! Weather feeds
+ *
+ * History:
+ * 1.0.2 - Correction to options / link
+ * 1.0.1 - Added hourly caching to YQL to avoid rate limits
+ * Uses Weather Channel location ID and not Yahoo WOEID
+ * Displays day or night background images
+ *
+ **/
+
+(function($){
+
+ var row = 'odd';
+
+ $.fn.weatherfeed = function(locations, options) {
+
+ // Set pluign defaults
+ var defaults = {
+ unit: 'c',
+ image: true,
+ highlow: true,
+ wind: true,
+ link: true,
+ showerror: true
+ };
+ var options = $.extend(defaults, options);
+
+ // Functions
+ return this.each(function(i, e) {
+ var $e = $(e);
+
+ // Add feed class to user div
+ if (!$e.hasClass('weatherFeed')) $e.addClass('weatherFeed');
+
+ // Check and append locations
+ if (!$.isArray(locations)) return false;
+ var count = locations.length;
+ if (count > 10) count = 10;
+ var locationid = '';
+ for (var i=0; i<count; i++) {
+ if (locationid != '') locationid += ',';
+ locationid += "'"+ locations[i] + "'";
+ }
+
+ // Cache results for an hour to prevent overuse
+ now = new Date()
+
+ // Create Yahoo Weather feed API address
+ var query = "select * from weather.forecast where location in ("+ locationid +") and u='"+ options.unit +"'";
+ var api = 'http://query.yahooapis.com/v1/public/yql?q='+ encodeURIComponent(query) +'&rnd='+ now.getFullYear() + now.getMonth() + now.getDay() + now.getHours() +'&format=json&callback=?';
+
+ // Send request
+ //$.getJSON(api, function(data) {
+ $.ajax({
+ type: 'GET',
+ url: api,
+ dataType: 'json',
+ success: function(data) {
+
+ if (data.query) {
+
+ if (data.query.results.channel.length > 0 ) {
+
+ // Multiple locations
+ var result = data.query.results.channel.length;
+ for (var i=0; i<result; i++) {
+
+ // Create weather feed item
+ _callback(e, data.query.results.channel[i], options);
+ }
+ } else {
+
+ // Single location only
+ _callback(e, data.query.results.channel, options);
+ }
+ } else {
+ if (options.showerror) $e.html('<p>Weather information unavailable</p>');
+ }
+ },
+ error: function(data) {
+ if (options.showerror) $e.html('<p>Weather request failed</p>');
+ }
+ });
+
+ });
+ };
+
+ // Function to each feed item
+ var _callback = function(e, feed, options) {
+ var $e = $(e);
+
+ // Format feed items
+ var wd = feed.wind.direction;
+ if (wd>=348.75&&wd<=360){wd="N"};if(wd>=0&&wd<11.25){wd="N"};if(wd>=11.25&&wd<33.75){wd="NNE"};if(wd>=33.75&&wd<56.25){wd="NE"};if(wd>=56.25&&wd<78.75){wd="ENE"};if(wd>=78.75&&wd<101.25){wd="E"};if(wd>=101.25&&wd<123.75){wd="ESE"};if(wd>=123.75&&wd<146.25){wd="SE"};if(wd>=146.25&&wd<168.75){wd="SSE"};if(wd>=168.75&&wd<191.25){wd="S"};if(wd>=191.25 && wd<213.75){wd="SSW"};if(wd>=213.75&&wd<236.25){wd="SW"};if(wd>=236.25&&wd<258.75){wd="WSW"};if(wd>=258.75 && wd<281.25){wd="W"};if(wd>=281.25&&wd<303.75){wd="WNW"};if(wd>=303.75&&wd<326.25){wd="NW"};if(wd>=326.25&&wd<348.75){wd="NNW"};
+ var wf = feed.item.forecast[0];
+
+ // Determine day or night image
+ wpd = feed.item.pubDate;
+ n = wpd.indexOf(":");
+ tpb = _getTimeAsDate(wpd.substr(n-2,8));
+ tsr = _getTimeAsDate(feed.astronomy.sunrise);
+ tss = _getTimeAsDate(feed.astronomy.sunset);
+
+ if (tpb>tsr && tpb<tss) { daynight = 'd'; } else { daynight = 'n'; }
+
+ // Add item container
+ var html = '<div class="weatherItem '+ row +'"';
+ if (options.image) html += ' style="background-image: url(http://l.yimg.com/a/i/us/nws/weather/gr/'+ feed.item.condition.code + daynight +'.png); background-repeat: no-repeat;"';
+ html += '>';
+
+ // Add item data
+ html += '<div class="weatherCity">'+ feed.location.city +'</div>';
+ html += '<div class="weatherTemp">'+ feed.item.condition.temp +'°</div>';
+ html += '<div class="weatherDesc">'+ feed.item.condition.text +'</div>';
+ if (options.highlow) html += '<div class="weatherRange">High: '+ wf.high +'° Low: '+ wf.low +'°</div>';
+ if (options.wind) html += '<div class="weatherWind">Wind: '+ wd +' '+ feed.wind.speed + feed.units.speed +'</div>';
+ if (options.link) html += '<div class="weatherLink"><a href="'+ feed.item.link +'">Read full forecast</a></div>';
+
+ html += '</div>';
+
+ // Alternate row classes
+ if (row == 'odd') { row = 'even'; } else { row = 'odd'; }
+
+ $e.append(html);
+ };
+
+ // Get time string as date
+ var _getTimeAsDate = function(t) {
+
+ d = new Date();
+ r = new Date(d.toDateString() +' '+ t);
+
+ return r;
+ };
+})(jQuery);
Added: CometVisu/trunk/visu/plugins/zweather/zweatherfeed/jquery.zweatherfeed.min.js
===================================================================
--- CometVisu/trunk/visu/plugins/zweather/zweatherfeed/jquery.zweatherfeed.min.js (rev 0)
+++ CometVisu/trunk/visu/plugins/zweather/zweatherfeed/jquery.zweatherfeed.min.js 2011-07-06 19:45:58 UTC (rev 383)
@@ -0,0 +1,6 @@
+
+(function($){var row='odd';$.fn.weatherfeed=function(locations,options){var defaults={unit:'c',image:true,highlow:true,wind:true,link:true,showerror:true};var options=$.extend(defaults,options);return this.each(function(i,e){var $e=$(e);if(!$e.hasClass('weatherFeed'))$e.addClass('weatherFeed');if(!$.isArray(locations))return false;var count=locations.length;if(count>10)count=10;var locationid='';for(var i=0;i<count;i++){if(locationid!='')locationid+=',';locationid+="'"+locations[i]+"'";}
+now=new Date()
+var query="select * from weather.forecast where location in ("+locationid+") and u='"+options.unit+"'";var api='http://query.yahooapis.com/v1/public/yql?q='+encodeURIComponent(query)+'&rnd='+now.getFullYear()+now.getMonth()+now.getDay()+now.getHours()+'&format=json&callback=?';$.ajax({type:'GET',url:api,dataType:'json',success:function(data){if(data.query){if(data.query.results.channel.length>0){var result=data.query.results.channel.length;for(var i=0;i<result;i++){_callback(e,data.query.results.channel[i],options);}}else{_callback(e,data.query.results.channel,options);}}else{if(options.showerror)$e.html('<p>Weather information unavailable</p>');}},error:function(data){if(options.showerror)$e.html('<p>Weather request failed</p>');}});});};var _callback=function(e,feed,options){var $e=$(e);var wd=feed.wind.direction;if(wd>=348.75&&wd<=360){wd="N"};if(wd>=0&&wd<11.25){wd="N"};if(wd>=11.25&&wd<33.75){wd="NNE"};if(wd>=33.75&&wd<56.25){wd="NE"};if(wd>=56.25&&wd<78.75){wd="ENE...
[truncated message content] |
|
From: <ma...@us...> - 2011-07-13 18:15:18
|
Revision: 387
http://openautomation.svn.sourceforge.net/openautomation/?rev=387&view=rev
Author: makki1
Date: 2011-07-13 18:15:11 +0000 (Wed, 13 Jul 2011)
Log Message:
-----------
Add gweather (Google)-Plugin, withdraw zweather, Yahoo data is crap
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.css
Added Paths:
-----------
CometVisu/trunk/visu/plugins/gweather/
CometVisu/trunk/visu/plugins/gweather/gweather.css
CometVisu/trunk/visu/plugins/gweather/gweather.php
CometVisu/trunk/visu/plugins/gweather/structure_plugin.js
Removed Paths:
-------------
CometVisu/trunk/visu/plugins/zweather/
Added: CometVisu/trunk/visu/plugins/gweather/gweather.css
===================================================================
--- CometVisu/trunk/visu/plugins/gweather/gweather.css (rev 0)
+++ CometVisu/trunk/visu/plugins/gweather/gweather.css 2011-07-13 18:15:11 UTC (rev 387)
@@ -0,0 +1,44 @@
+.gweather {
+ overflow: auto;
+ padding: 10px;
+ margin: 10px;
+/* background: #ccc; */
+}
+
+.gweather div.day {
+ font-family: Verdana;
+ float: left;
+ border: 1px dashed #777;
+/* background: #bbf; */
+ width: 150px;
+ margin: 5px;
+ padding: 5px;
+}
+
+.gweather img {
+ float: left;
+/* height: 32px; */
+}
+
+.gweather div.name {
+ font-weight: bold;
+ height: 24px;
+ padding: 4px 4px 4px 4px;
+}
+
+.gweather .condition {
+ font-size: 12px;
+ padding: 0;
+ margin: 5px 0;
+ text-align: left;
+ height: 58px;
+ overflow: hidden;
+}
+
+.gweather .temp {
+ padding: 0;
+ margin: 0;
+ text-align: center;
+}
+
+
Added: CometVisu/trunk/visu/plugins/gweather/gweather.php
===================================================================
--- CometVisu/trunk/visu/plugins/gweather/gweather.php (rev 0)
+++ CometVisu/trunk/visu/plugins/gweather/gweather.php 2011-07-13 18:15:11 UTC (rev 387)
@@ -0,0 +1,8 @@
+<?php
+header("content-type: text/xml");
+$city = $_GET['city'];
+$lang = $_GET['lang'];
+
+$xmlData = utf8_encode(file_get_contents("http://www.google.com/ig/api?hl=$lang&weather=$city"));
+echo $xmlData;
+?>
\ No newline at end of file
Added: CometVisu/trunk/visu/plugins/gweather/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/gweather/structure_plugin.js (rev 0)
+++ CometVisu/trunk/visu/plugins/gweather/structure_plugin.js 2011-07-13 18:15:11 UTC (rev 387)
@@ -0,0 +1,142 @@
+/* structure_plugin.js (c) 2011 by Michael Markstaller [de...@wi...]
+ *
+ * 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 google weather into CometVisu.
+ */
+
+$( 'head' ).append( '<link rel="stylesheet" href="plugins/gweather/gweather.css" type="text/css" />' );
+
+VisuDesign_Custom.prototype.addCreator("gweather", {
+ create: function( page, path ) {
+ var $p = $(page);
+
+ function uniqid() {
+ var newDate = new Date;
+ return newDate.getTime();
+ }
+
+ var id = "gweather_" + uniqid();
+
+ var ret_val = $('<div class="widget" />');
+ ret_val.addClass( 'gweather' );
+ var label = '<div class="label">' + page.textContent + '</div>';
+ var actor = $("<div class=\"actor\"><div class=\"gweather\" id=\"" + id + "\">loading</div></div>");
+ var gweather = $("#" + id, actor);
+
+ if ($p.attr("width")) {
+ gweather.css("width", $p.attr("width"));
+ }
+ if ($p.attr("height")) {
+ gweather.css("height", $p.attr("height"));
+ }
+
+ ret_val.append(label).append(actor);
+ console.log("loaded plugin gweather");
+
+ gweather.data("id", id);
+ gweather.data("label", page.textContent);
+ gweather.data("refresh", $p.attr("refresh"));
+ gweather.data("city", $p.attr("city"));
+ gweather.data("lang", $p.attr("lang"));
+ gweather.data("image_url", $p.attr("image_url"));
+ gweather.data("current", $p.attr("current"));
+ gweather.data("forecast", $p.attr("forecast"));
+ refreshGweather(gweather, {});
+
+ return ret_val;
+ },
+ attributes: {
+ width: {type: "string", required: false},
+ height: {type: "string", required: false},
+ refresh: {type: "numeric", required: false},
+ city: {type: "string", required: true},
+ lang: {type: "string", required: false},
+ image_url: {type: "string", required: false},
+ current: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ forecast: {type: "list", required: false, list: {'true': "yes", 'false': "no"}}
+ },
+ content: {type: "string", required: true}
+});
+
+function refreshGweather(gweather, data) {
+ var gweather = $(gweather);
+
+ var label = gweather.data("label");
+ var refresh = gweather.data("refresh");
+ var city = gweather.data("city");
+ var lang = gweather.data("lang") || "de";
+ var current = gweather.data("current") || true;
+ var forecast = gweather.data("forecast") || true;
+ var image_url = gweather.data("image_url") || "http://www.google.com";
+ var childData = function(selector, arg)
+ {
+ return selector.find(arg).attr('data');
+ }
+
+ function addForecastDiv( day, condition, temp, icon ){
+ daydiv = $("<div class='day'></div>");
+ daydiv.append( "<img src=\""+image_url+icon+"\" />");
+ daydiv.append( "<div class='name'>" + day + "</div>" );
+ daydiv.append( "<p class='condition'>" + condition + "</p>" );
+ daydiv.append( "<p class='temp'>" + temp + "</p>");
+ $(gweather).append(daydiv);
+ }
+
+ $.ajax({
+ type: "GET",
+ datatype: "xml",
+ data: "city="+encodeURI(city)+"&lang="+lang,
+ url: "plugins/gweather/gweather.php",
+ success: function(data){
+ $(gweather).text('');
+ if(eval(current)){
+ addForecastDiv(
+ //$(data).find('forecast_information').find('current_date_time').attr('data'),
+ '',
+ $(data).find('current_conditions').find('condition').attr('data') + '<br/>' +
+ $(data).find('current_conditions').find('humidity').attr('data') + '<br/>' +
+ $(data).find('current_conditions').find('wind_condition').attr('data'),
+ $(data).find('current_conditions').find('temp_c').attr('data') + '°C',
+ $(data).find('current_conditions').find('icon').attr('data')
+ );
+ }
+
+ if(eval(forecast)){
+ $(data).find('forecast_conditions').each(function(){
+ addForecastDiv(
+ $(this).find('day_of_week').attr('data'),
+ $(this).find('condition').attr('data'),
+ $(this).find('low').attr('data') + '°C' + ' - ' +
+ $(this).find('high').attr('data') + '°C',
+ $(this).find('icon').attr('data')
+ );
+ });
+ }
+ }
+ });
+
+ //refresh regularly
+ if (typeof (refresh) != "undefined" && refresh) {
+ // reload regularly
+ window.setTimeout(function(gweather, data) {
+ refreshGweather(gweather, data)
+ }, refresh * 1000, gweather, data);
+ }
+ console.log("gweather end");
+ return false;
+}
Modified: CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.css
===================================================================
--- CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.css 2011-07-12 21:57:38 UTC (rev 386)
+++ CometVisu/trunk/visu/plugins/rss/zrssfeed/jquery.zrssfeed.css 2011-07-13 18:15:11 UTC (rev 387)
@@ -1,52 +1,55 @@
-@charset "UTF-8";
-/*
- * Example of zRSSFeed Styling
- *
- * Version: 1.1.2
- * (c) Copyright 2010-2011, Zazar Ltd
- *
- */
-
-body {
- margin: 1em 3em;
- font-family: Tahoma, Genevam, sans-serif;
-}
-
-.rssFeed {
- font-family: Arial, Helvetica, sans-serif;
- font-size: 90%;
- margin: 2em 3em;
-}
-.rssFeed a {
- color: #444;
- text-decoration: none;
-}
-.rssFeed a:hover {
- color: #000;
- text-decoration: underline;
-}
-
-.rssHeader { padding: 0.2em 0; }
-
-.rssBody { border: 1px solid #999; }
-.rssBody ul { list-style: none; }
-.rssBody ul, .rssRow, .rssRow h4, .rssRow p {
- margin: 0;
- padding: 0;
-}
-
-.rssRow { padding: 0.8em; }
-.rssRow h4 { font-size: 1.1em; }
-.rssRow div {
- font-size: 90%;
- color: #666;
- margin: 0.2em 0 0.4em 0;
-}
-
-.odd { background-color: #e8e8fc; }
-.even { background-color: #d4d4e8; }
-
-.rssRow .rssMedia {
- padding: 0.5em;
- font-size: 1em;
-}
+@charset "UTF-8";
+/*
+ * Example of zRSSFeed Styling
+ *
+ * Version: 1.1.2
+ * (c) Copyright 2010-2011, Zazar Ltd
+ *
+ */
+
+/*
+body {
+ margin: 1em 3em;
+ font-family: Tahoma, Genevam, sans-serif;
+}
+*/
+
+.rssFeed {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 90%;
+ margin: 2em 3em;
+}
+.rssFeed a {
+ color: #444;
+ text-decoration: none;
+}
+.rssFeed a:hover {
+ color: #000;
+ text-decoration: underline;
+}
+
+.rssHeader { padding: 0.2em 0; }
+
+.rssBody { border: 1px solid #999; }
+.rssBody ul { list-style: none; }
+.rssBody ul, .rssRow, .rssRow h4, .rssRow p {
+ margin: 0;
+ padding: 0;
+}
+
+.rssRow { padding: 0.8em; }
+.rssRow h4 { font-size: 1.1em; }
+.rssRow div {
+ font-size: 90%;
+ color: #666;
+ margin: 0.2em 0 0.4em 0;
+}
+
+.odd { background-color: #e8e8fc; }
+.even { background-color: #d4d4e8; }
+
+.rssRow .rssMedia {
+ padding: 0.5em;
+ font-size: 1em;
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ma...@us...> - 2011-10-21 20:50:36
|
Revision: 462
http://openautomation.svn.sourceforge.net/openautomation/?rev=462&view=rev
Author: makki1
Date: 2011-10-21 20:50:30 +0000 (Fri, 21 Oct 2011)
Log Message:
-----------
CometVisu: jqclock - a clock widget with statusbar-support
Added Paths:
-----------
CometVisu/trunk/visu/plugins/jqclock/
CometVisu/trunk/visu/plugins/jqclock/jqclock.css
CometVisu/trunk/visu/plugins/jqclock/jqclock.min.js
CometVisu/trunk/visu/plugins/jqclock/structure_plugin.js
Added: CometVisu/trunk/visu/plugins/jqclock/jqclock.css
===================================================================
--- CometVisu/trunk/visu/plugins/jqclock/jqclock.css (rev 0)
+++ CometVisu/trunk/visu/plugins/jqclock/jqclock.css 2011-10-21 20:50:30 UTC (rev 462)
@@ -0,0 +1,36 @@
+.jqclock {
+ float:right;
+ white-space: nowrap;
+/*
+ text-align:center;
+ background: LightYellow;
+ border: 1px Black solid;
+ padding: 10px;
+ margin:20px;
+*/
+}
+.clockdate {
+ white-space: nowrap;
+/*
+ color: DarkRed;
+ margin-bottom: 10px;
+ font-size: 18px;
+ display: block;
+*/
+}
+.clocktime {
+ white-space: nowrap;
+/*
+ border: 2px
+ inset White;
+ background: Black;
+ padding: 5px;
+ font-size: 14px;
+ font-family: "Courier";
+ color: LightGreen;
+ display: block;
+*/
+ margin: 10px;
+}
+
+
Added: CometVisu/trunk/visu/plugins/jqclock/jqclock.min.js
===================================================================
--- CometVisu/trunk/visu/plugins/jqclock/jqclock.min.js (rev 0)
+++ CometVisu/trunk/visu/plugins/jqclock/jqclock.min.js 2011-10-21 20:50:30 UTC (rev 462)
@@ -0,0 +1 @@
+(function($){$.clock={version:"2.0.1",locale:{}};t=[];$.fn.clock=function(d){var c={it:{weekdays:["Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"],months:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]},en:{weekdays:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],months:["January","February","March","April","May","June","July","August","September","October","November","December"]},es:{weekdays:["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"],months:["Enero","Febrero","Marzo","Abril","May","junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"]},de:{weekdays:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],months:["Januar","Februar","März","April","könnte","Juni","Juli","August","September","Oktober","November","Dezember"]},fr:{weekdays:["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"],months:["Janvier","Février","Mars","Avril","May","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"]},ru:{weekdays:["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"],months:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"]}};return this.each(function(){$.extend(c,$.clock.locale);d=d||{};d.timestamp=d.timestamp||"z";y=new Date().getTime();d.sysdiff=0;if(d.timestamp!="z"){d.sysdiff=d.timestamp-y}d.langSet=d.langSet||"en";d.format=d.format||((d.langSet!="en")?"24":"12");d.calendar=d.calendar||"true";if(!$(this).hasClass("jqclock")){$(this).addClass("jqclock")}var e=function(g){if(g<10){g="0"+g}return g},f=function(j,n){var r=$(j).attr("id");if(n=="destroy"){clearTimeout(t[r])}else{m=new Date(new Date().getTime()+n.sysdiff);var p=m.getHours(),l=m.getMinutes(),v=m.getSeconds(),u=m.getDay(),i=m.getDate(),k=m.getMonth(),q=m.getFullYear(),o="",z="",w=n.langSet;if(n.format=="12"){o=" AM";if(p>11){o=" PM"}if(p>12){p=p-12}if(p==0){p=12}}p=e(p);l=e(l);v=e(v);if(n.calendar!="false"){z=((w=="en")?"<span class='clockdate'>"+c[w].weekdays[u]+", "+c[w].months[k]+" "+i+", "+q+"</span>":"<span class='clockdate'>"+c[w].weekdays[u]+", "+i+" "+c[w].months[k]+" "+q+"</span>")}$(j).html(z+"<span class='clocktime'>"+p+":"+l+":"+v+o+"</span>");t[r]=setTimeout(function(){f($(j),n)},1000)}};f($(this),d)})};return this})(jQuery);
Added: CometVisu/trunk/visu/plugins/jqclock/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/jqclock/structure_plugin.js (rev 0)
+++ CometVisu/trunk/visu/plugins/jqclock/structure_plugin.js 2011-10-21 20:50:30 UTC (rev 462)
@@ -0,0 +1,67 @@
+/* structure_plugin.js (c) 2011 by Michael Markstaller [de...@wi...]
+ *
+ * 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 date/clock into CometVisu.
+ */
+
+$('head').append('<script type=\"text/javascript\" src=\"plugins/jqclock/jqclock.min.js\" charset=\"UTF-8\"></script>');
+$('head').append('<link rel="stylesheet" href="plugins/jqclock/jqclock.css" type="text/css" />');
+
+VisuDesign_Custom.prototype.addCreator("jqclock", {
+ create: function( page, path ) {
+ var $p = $(page);
+ function uniqid() {
+ var newDate = new Date;
+ return newDate.getTime();
+ }
+ var id = "jqclock_" + uniqid();
+
+ var ret_val = $('<div class="widget" />');
+ ret_val.addClass( 'jqclock' );
+ var label = '<div class="label">' + page.textContent + '</div>';
+ var actor = $("<div class=\"actor\"><div class=\"jqclock_inline\" id=\"" + id + "\"></div></div>");
+ var jqclock = $("#"+id,actor);
+
+ if ($p.attr("width")) {
+ jqclock.css("width", $p.attr("width"));
+ }
+ if ($p.attr("height")) {
+ jqclock.css("height", $p.attr("height"));
+ }
+
+ //start the clock in statusbar - if any
+ $("div#jqclock_status").clock({"langSet":$("div#jqclock_status").attr('lang'),"calendar":$("div#jqclock_status").attr('date')});
+
+ window.setTimeout(function() {
+ //start myself after 1 sec? a quirk?
+ $("#"+id).clock({"langSet":$p.attr("lang"), "calendar":$p.attr("date")});
+ }, 1000);
+
+ ret_val.append(label).append(actor);
+ return ret_val;
+ },
+ attributes: {
+ width: {type: "string", required: false},
+ height: {type: "string", required: false},
+ //refresh: {type: "numeric", required: false},
+ lang: {type: "list", required: true, list: {'de':'Deutsch','en':'English','es':'Espanol','fr':'Francais','it':'Italiano','ru':'Ruski'}},
+ date: {type: "list", required: false, list: {'true': "yes", 'false': "no"}}
+ },
+ content: {type: "string", required: false}
+});
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <j-...@us...> - 2011-12-12 19:12:39
|
Revision: 572
http://openautomation.svn.sourceforge.net/openautomation/?rev=572&view=rev
Author: j-n-k
Date: 2011-12-12 19:12:30 +0000 (Mon, 12 Dec 2011)
Log Message:
-----------
Inital commit plugin: jsonviewer
Added Paths:
-----------
CometVisu/trunk/visu/plugins/jsonviewer/
CometVisu/trunk/visu/plugins/jsonviewer/structure_plugin.js
Added: CometVisu/trunk/visu/plugins/jsonviewer/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/jsonviewer/structure_plugin.js (rev 0)
+++ CometVisu/trunk/visu/plugins/jsonviewer/structure_plugin.js 2011-12-12 19:12:30 UTC (rev 572)
@@ -0,0 +1,83 @@
+/* structure_plugin.js (c) 2011 by Jan N. Klug
+ *
+ * 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 views json-feeds
+ */
+
+ VisuDesign_Custom.prototype.addCreator('jsonviewer', {
+ maturity: Maturity.development,
+ create: function( page, path ) {
+ var $p = $(page);
+ var ret_val = $('<div class="widget text" />');
+ var style = '';
+
+ if( style != '' ) style = 'style="' + style + '"';
+ var json = $('<div class="value">-</div>');
+ var refresh = $p.attr('refresh') || 30; // default 30s
+
+ json.data("src", $p.attr('src'));
+ json.data("refresh", refresh);
+ json.data("view", $p.attr('view')); // default alles
+ json.data("idx", 0);
+
+ var data = jQuery.extend({}, json.data());
+ ret_val.append(json);
+
+
+
+ refreshjson(json, data);
+ return ret_val;
+ },
+ attributes: {
+ src: { type: 'string', required: true },
+ refresh: { type: 'numeric', required: false }
+ },
+ elements: {
+ },
+ content: false
+});
+
+function refreshjson(e,data) {
+ var element = $(e);
+ var tmp = $.getJSON(data.src, function(json) {
+ var content = '';
+ var feed = json.responseData.feed;
+ var feedlength = feed.entries.length;
+ var viewnum = data.view;
+ if (viewnum > feedlength) { // max is number of entries
+ viewnum = feedlength;
+ }
+ for (var i=0; i<viewnum; i++) {
+ var showidx = i + data.idx;
+ if (showidx >= feedlength) {
+ showidx = showidx - feedlength;
+ }
+ content += ""+feed.entries[showidx].content + "<br>";
+ };
+ element.html(content);
+ if (data.idx >= feedlength) {
+ data.idx=0;
+ } else {
+ data.idx = data.idx+1;
+ }
+ });
+ var tmp2=0;
+ window.setTimeout(function(element, data) {
+ refreshjson(element, data)
+ }, data.refresh * 1000, element, data);
+};
\ No newline at end of file
Property changes on: CometVisu/trunk/visu/plugins/jsonviewer/structure_plugin.js
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <j-...@us...> - 2012-01-18 17:57:18
|
Revision: 660
http://openautomation.svn.sourceforge.net/openautomation/?rev=660&view=rev
Author: j-n-k
Date: 2012-01-18 17:57:12 +0000 (Wed, 18 Jan 2012)
Log Message:
-----------
As discussed in the forum: split rss / rsslog. Use rss-plugin for external
(web) RSS feeds, use rsslog for local feeds (e.g. by rsslog.php)
Modified Paths:
--------------
CometVisu/trunk/visu/plugins/rss/structure_plugin.js
Added Paths:
-----------
CometVisu/trunk/visu/plugins/rsslog/
CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js
Modified: CometVisu/trunk/visu/plugins/rss/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/rss/structure_plugin.js 2012-01-15 21:53:11 UTC (rev 659)
+++ CometVisu/trunk/visu/plugins/rss/structure_plugin.js 2012-01-18 17:57:12 UTC (rev 660)
@@ -42,7 +42,7 @@
var ret_val = $('<div class="widget clearfix" />');
ret_val.addClass( 'rss' );
var label = '<div class="label">' + page.textContent + '</div>';
- var actor = $("<div class=\"actor\"><div class=\"rss_inline\" id=\"" + id + "\"><div class='ul'></div></div></div>");
+ var actor = $("<div class=\"actor\"><div class=\"rss_inline\" id=\"" + id + "\"></div>");
var rss = $("#" + id, actor);
if ($p.attr("width")) {
@@ -68,9 +68,7 @@
rss.data("linktarget", $p.attr("linktarget")) || "_new";
rss.data("link", $p.attr("link")) || true;
rss.data("title", $p.attr("title")) || true;
- rss.data("mode", $p.attr("mode") || "last");
- rss.data("itemoffset", 0);
-
+
refreshRSS(rss, {});
return ret_val;
@@ -90,7 +88,6 @@
linktarget: {type: "list", required: false, list: {"_new": "_new", "_self": "_self"}},
link: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
title: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
- mode: {type: "list", required: false, list: {'first': 'first', 'last': 'last', 'rollover':'rollover' }}
},
content: {type: "string", required: true}
});
@@ -103,8 +100,7 @@
var refresh = rss.data("refresh");
var limit = rss.data("limit");
//FIXME: eval really needed?? to convert string true/false to bool?
- if (src.match(/^http/)) {
- //use zrssfeed
+
jQuery(function() {
$(rss).rssfeed(src, {
limit: rss.data("limit"),
@@ -117,25 +113,7 @@
linktarget: rss.data("linktarget"),
});
});
- } else {
- jQuery(function() {
- $(rss).rssfeedlocal({
- src: src,
- limit: rss.data("limit"),
- header: eval(rss.data("header")),
- date: eval(rss.data("date")),
- content: rss.data("content"),
- snippet: eval(rss.data("snippet")),
- showerror: eval(rss.data("showerror")),
- ssl: eval(rss.data("ssl")),
- linktarget: rss.data("linktarget"),
- link: eval(rss.data("link")),
- title: eval(rss.data("title")),
- mode: rss.data("mode"),
- });
- });
- }
- if (typeof (refresh) != "undefined" && refresh) {
+ if (typeof (refresh) != "undefined" && refresh) {
// reload regularly
window.setTimeout(function(rss, data) {
refreshRSS(rss, data)
@@ -144,122 +122,3 @@
//rss.data("itemoffset") = itemoffset;
return false;
}
-
-(function($){
- jQuery.fn.extend({
- rssfeedlocal: function(options) {
-
- var defaults = {
- src: '',
- header: false,
- html: '{title}{date}{text}',
- wrapper: 'li',
- dataType: 'xml',
- limit: 10,
- linktarget: 'new',
- date: true,
- link: true,
- title: true
- }
- var options = jQuery.extend(defaults, options);
-
- return this.each(function() {
- var o = options;
- var c = jQuery(this);
-
- if (o.src == '') {
- console.log('rssfeedlocal: no src URL');
- return; // avoid the request
- }
-
- jQuery.ajax({
- url: o.src,
- type: 'GET',
- dataType: o.dataType,
- error: function (xhr, status, e) {
- console.log('C: #%s, Error: %s, Feed: %s', $(c).attr('id'), e, o.src);
- },
- success: function(feed){
- jQuery(c).html('');
-
-/* FIXME: Header gets added on each refresh, unsupported in rssfeedlocal for now..
- if (options.header)
- jQuery(c).parent().parent().prepend( '<p><div class="rssHeader">' +
- '<a href="' + jQuery(feed).find('link:first').text()
- +'" title="'+ jQuery(feed).find('description:first').text()
- +'" target="' + o.linktarget + '">'
- + jQuery(feed).find('title:first').text()
- +'</a>' + '</div></p>');
-*/
- // get height of one entry, calc max num of display items in widget
- var dummyDiv = $('<' + o.wrapper + ' class="rssRow odd" id="dummydiv">').append('l1<br />l2').appendTo($(c));
- var itemheight = dummyDiv.height();
- dummyDiv.remove();
- var displayheight = $(c).height();
- var displayrows = Math.floor(displayheight/itemheight);
-
- var items = $(feed).find('item');
- var itemnum = items.length;
- var itemoffset = 0; // correct if mode='first' or itemnum<=displayrows
-
-
- if (itemnum>displayrows) { // no need to check mode if items are less than rows
- if (o.mode=='last') {
- itemoffset=itemnum-displayrows;
- }
- if (o.mode=='rollover') {
- itemoffset = $(c).data("itemoffset") || 0;
- if (itemoffset==itemnum) {
- itemoffset = 0;
- }
- $(c).data("itemoffset", itemoffset+1);
- }
- }
-
- var row = 'odd';
-
- for (var i=itemoffset; i<itemoffset+displayrows; i++) {
- var idx = i;
- if (i>=itemnum) {
- idx = idx - itemnum;
- }
-
- var item = items[idx];
-
- var itemHtml;
- if (o.link)
- itemHtml = o.html.replace(/{title}/, '<a href="'
- + jQuery(item).find('guid').text()
- + '" target="' + o.linktarget + '">'
- + jQuery(item).find('title').text() + '</a><br />');
- else if (o.title)
- itemHtml = o.html.replace(/{title}/,
- jQuery(item).find('title').text() + '<br />');
- else
- itemHtml = o.html.replace(/{title}/, '');
-
- itemHtml = itemHtml.replace(/{text}/, jQuery(item).find('description').text());
- var entryDate = new Date($(item).find('pubDate').text());
- if (o.date && entryDate)
- itemHtml = itemHtml.replace(/{date}/, entryDate.toLocaleDateString() + ' ' + entryDate.toLocaleTimeString() + ' ');
- else
- itemHtml = itemHtml.replace(/{date}/, '');
-
- jQuery(c).append(jQuery('<' + o.wrapper + ' class="rssRow ' + row + '">').append(itemHtml));
-
- // Alternate row classes
- if (row == 'odd') {
- row = 'even';
- } else {
- row = 'odd';
- }
- };
- $('li').wrapAll("<ul>");
- }
- });
- });
- return this;
- }
- });
-})(jQuery);
-
Added: CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js (rev 0)
+++ CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js 2012-01-18 17:57:12 UTC (rev 660)
@@ -0,0 +1,261 @@
+/* structure_plugin.js (c) 2011 by Michael Markstaller [de...@wi...]
+ *
+ * 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 zrssfeed to display RSS-Feeds via Google-API
+ * *and* a parser for local feeds using jQuery 1.5+ into CometVisu.
+ * rssfeedlocal is derived from simplerss and zrssfeed
+ * rssfeedlocal is mainly meant to be used with rsslog.php and plugins
+ * Examples
+ * <rss src="/visu/plugins/rss/rsslog.php" refresh="300" link="false" title="false"></rss>
+ * <rss src="http://www.tagesschau.de/xml/rss2" refresh="300">Test API</rss>
+ * <rss src="/visu/plugins/rss/tagesschau-rss2.xml" refresh="300" header="true" date="true"></rss>
+ */
+
+VisuDesign_Custom.prototype.addCreator("rsslog", {
+ create: function( page, path ) {
+ var $p = $(page);
+
+ function uniqid() {
+ var newDate = new Date;
+ return newDate.getTime();
+ }
+
+ var id = "rss_" + uniqid();
+
+ var ret_val = $('<div class="widget clearfix" style="height:205px"/>');
+ ret_val.addClass( 'rsslog' );
+ var label = '<div class="label" style="clear:both;">' + page.textContent + '</div>';
+ var actor = $('<div class="actor" style="clear:left;"><div class="rsslog_inline" id="' + id + '"></div></div>');
+ var rss = $("#" + id, actor);
+
+ if ($p.attr("width")) {
+ rss.css("width", $p.attr("width"));
+ }
+ if ($p.attr("height")) {
+ rss.css("height", $p.attr("height"));
+ }
+
+ ret_val.append(label).append(actor);
+
+ rss.data("id", id);
+ rss.data("src", $p.attr("src"));
+ rss.data("label", page.textContent);
+ rss.data("refresh", $p.attr("refresh"));
+ rss.data("limit", $p.attr("limit")) || 10;
+ rss.data("header", $p.attr("header")) || true;
+ rss.data("date", $p.attr("date")) || true;
+ rss.data("content", $p.attr("content")) || true;
+ rss.data("snippet", $p.attr("snippet")) || true;
+ rss.data("showerror", $p.attr("showerror")) || true;
+ rss.data("ssl", $p.attr("ssl")) || false;
+ rss.data("linktarget", $p.attr("linktarget")) || "_new";
+ rss.data("link", $p.attr("link")) || true;
+ rss.data("title", $p.attr("title")) || true;
+ rss.data("mode", $p.attr("mode") || "last");
+ rss.data("itemoffset", 0);
+ rss.data("timeformat", $p.attr("timeformat"));
+
+ refreshRSSlog(rss, {});
+
+ return ret_val;
+ },
+ attributes: {
+ src: {type: "string", required: true},
+ width: {type: "string", required: false},
+ height: {type: "string", required: false},
+ refresh: {type: "numeric", required: false},
+ limit: {type: "numeric", required: false},
+ header: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ date: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ content: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ snippet: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ showerror: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ ssl: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ linktarget: {type: "list", required: false, list: {"_new": "_new", "_self": "_self"}},
+ link: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ title: {type: "list", required: false, list: {'true': "yes", 'false': "no"}},
+ mode: {type: "list", required: false, list: {'first': 'first', 'last': 'last', 'rollover':'rollover' }}
+ },
+ content: {type: "string", required: true}
+});
+
+function refreshRSSlog(rss, data) {
+ var rss = $(rss);
+
+ var src = rss.data("src");
+ var label = rss.data("label");
+ var refresh = rss.data("refresh");
+ var limit = rss.data("limit");
+ //FIXME: eval really needed?? to convert string true/false to bool?
+
+ jQuery(function() {
+ $(rss).rssfeedlocal({
+ src: src,
+ limit: rss.data("limit"),
+ header: eval(rss.data("header")),
+ date: eval(rss.data("date")),
+ content: rss.data("content"),
+ snippet: eval(rss.data("snippet")),
+ showerror: eval(rss.data("showerror")),
+ ssl: eval(rss.data("ssl")),
+ linktarget: rss.data("linktarget"),
+ link: eval(rss.data("link")),
+ title: eval(rss.data("title")),
+ mode: rss.data("mode"),
+ timeformat: rss.data("timeformat"),
+ });
+ });
+
+ if (typeof (refresh) != "undefined" && refresh) {
+ // reload regularly
+ window.setTimeout(function(rss, data) {
+ refreshRSSlog(rss, data)
+ }, refresh * 1000, rss, data);
+ }
+ //rss.data("itemoffset") = itemoffset;
+ return false;
+}
+
+(function($){
+ jQuery.fn.extend({
+ rssfeedlocal: function(options) {
+
+ var defaults = {
+ src: '',
+ header: false,
+ html: '{date}: {text}',
+ wrapper: 'li',
+ dataType: 'xml',
+ limit: 10,
+ linktarget: 'new',
+ date: true,
+ link: true,
+ title: true
+ }
+ var options = jQuery.extend(defaults, options);
+
+ return this.each(function() {
+ var o = options;
+ var c = jQuery(this);
+
+ if (o.src == '') {
+ console.log('rssfeedlocal: no src URL');
+ return; // avoid the request
+ }
+
+ jQuery.ajax({
+ url: o.src,
+ type: 'GET',
+ dataType: o.dataType,
+ error: function (xhr, status, e) {
+ console.log('C: #%s, Error: %s, Feed: %s', $(c).attr('id'), e, o.src);
+ },
+ success: function(feed){
+ jQuery(c).html('');
+
+/* FIXME: Header gets added on each refresh, unsupported in rssfeedlocal for now..
+ if (options.header)
+ jQuery(c).parent().parent().prepend( '<p><div class="rssHeader">' +
+ '<a href="' + jQuery(feed).find('link:first').text()
+ +'" title="'+ jQuery(feed).find('description:first').text()
+ +'" target="' + o.linktarget + '">'
+ + jQuery(feed).find('title:first').text()
+ +'</a>' + '</div></p>');
+*/
+ // get height of one entry, calc max num of display items in widget
+ var dummyDiv = $('<' + o.wrapper + ' class="rssRow odd" id="dummydiv">').append('<li />').appendTo($(c));
+ var itemheight = dummyDiv.height();
+ dummyDiv.remove();
+ var widget=$(c).parent().parent(); // get the parent widget
+ var displayheight = widget.height()-$('.label', widget).height(); // max. height of actor is widget-label(if exists)
+ var displayrows = Math.floor(displayheight/itemheight);
+
+ var items = $(feed).find('item');
+ var itemnum = items.length;
+ var itemoffset = 0; // correct if mode='first' or itemnum<=displayrows
+
+
+ if (itemnum>displayrows) { // no need to check mode if items are less than rows
+ if (o.mode=='last') {
+ itemoffset=itemnum-displayrows;
+ }
+ if (o.mode=='rollover') {
+ itemoffset = $(c).data("itemoffset") || 0;
+ if (itemoffset==itemnum) {
+ itemoffset = 0;
+ }
+ $(c).data("itemoffset", itemoffset+1);
+ }
+ }
+
+ var row = 'odd';
+ var last = itemoffset+displayrows;
+ if (last>itemnum) {
+ last=itemnum;
+ }
+ for (var i=itemoffset; i<last; i++) {
+ var idx = i;
+ if (i>=itemnum) {
+ idx = idx - itemnum;
+ }
+
+ var item = items[idx];
+
+ var itemHtml=o.html;
+ /*if (o.link)
+ itemHtml = o.html.replace(/{title}/, '<a href="'
+ + jQuery(item).find('guid').text()
+ + '" target="' + o.linktarget + '">'
+ + jQuery(item).find('title').text() + '</a><br />');
+ else if (o.title)
+ itemHtml = o.html.replace(/{title}/,
+ jQuery(item).find('title').text() + '<br />');
+ else
+ itemHtml = o.html.replace(/{title}/, ''); */
+
+ itemHtml = itemHtml.replace(/{text}/, jQuery(item).find('description').text());
+ var entryDate = new Date($(item).find('pubDate').text());
+ if (o.date && entryDate) {
+ if (o.timeformat) {
+ itemHtml = itemHtml.replace(/{date}/, entryDate.toLocaleFormat(o.timeformat) + ' ');
+ } else {
+ itemHtml = itemHtml.replace(/{date}/, entryDate.toLocaleDateString() + ' ' + entryDate.toLocaleTimeString() + ' ');
+ }
+ } else {
+ itemHtml = itemHtml.replace(/{date}/, '');
+ }
+
+ jQuery(c).append(jQuery('<' + o.wrapper + ' class="rssRow ' + row + '">').append(itemHtml));
+
+ // Alternate row classes
+ if (row == 'odd') {
+ row = 'even';
+ } else {
+ row = 'odd';
+ }
+ };
+
+ $('li', c).wrapAll("<ul>");
+ }
+ });
+ });
+ return this;
+ }
+ });
+})(jQuery);
+
Property changes on: CometVisu/trunk/visu/plugins/rsslog/structure_plugin.js
___________________________________________________________________
Added: svn:executable
+ *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <chr...@us...> - 2012-08-18 08:49:28
|
Revision: 976
http://openautomation.svn.sourceforge.net/openautomation/?rev=976&view=rev
Author: christian523
Date: 2012-08-18 08:49:22 +0000 (Sat, 18 Aug 2012)
Log Message:
-----------
New plugin for displaying a blind-status with a svg-file.
Added Paths:
-----------
CometVisu/trunk/visu/plugins/svg/
CometVisu/trunk/visu/plugins/svg/rollo.svg
CometVisu/trunk/visu/plugins/svg/structure_plugin.js
Added: CometVisu/trunk/visu/plugins/svg/rollo.svg
===================================================================
--- CometVisu/trunk/visu/plugins/svg/rollo.svg (rev 0)
+++ CometVisu/trunk/visu/plugins/svg/rollo.svg 2012-08-18 08:49:22 UTC (rev 976)
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:xlink="http://www.w3.org/1999/xlink"
+ version="1.1"
+ width="48"
+ height="48"
+ id="svg2">
+ <metadata
+ id="metadata7">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g stroke="#FFFFFF" >
+ <line id="line1" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line2" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line3" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line4" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line5" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line6" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line7" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line8" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line9" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line10" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line11" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line12" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line13" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line14" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line15" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line16" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line17" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line18" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line19" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <line id="line20" x1="2" x2="46" y1="9" y2="9" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" fill="none"/>
+ <path id="windowframe" d="m3,5 l42,0 l0,38 l-42,0 l0,-38" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" stroke="#FEFEFE" fill="none" />
+ <rect id="toprect" x="1" y="5" width="46" height="4" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" stroke="#FEFEFE" fill="#FEFEFE" />
+ <line id="middleline" x1="24" x2="24" y1="5" y2="43" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" stroke="#FEFEFE" fill="none"/>
+ <line id="grip" x1="22" x2="26" y1="25" y2="25" stroke-linecap="round" stroke-linejoin="round" stroke-width="3" stroke="#FEFEFE" fill="none"/>
+ </g>
+</svg>
Added: CometVisu/trunk/visu/plugins/svg/structure_plugin.js
===================================================================
--- CometVisu/trunk/visu/plugins/svg/structure_plugin.js (rev 0)
+++ CometVisu/trunk/visu/plugins/svg/structure_plugin.js 2012-08-18 08:49:22 UTC (rev 976)
@@ -0,0 +1,88 @@
+/* structure_plugin.js (c) 2010 by Christian Mayer [CometVisu at ChristianMayer dot de]
+ *
+ * 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 is a custom function that extends the available widgets.
+ * It's purpose is to change the design of the visu during runtime
+ * to demonstrate all available
+ */
+VisuDesign_Custom.prototype.addCreator('svg', {
+ create: function( element, path, flavour, type ) {
+ var $e = $(element);
+ var layout = $e.children('layout')[0];
+ var style = layout ? 'style="' + extractLayout( layout, type ) + '"' : '';
+ var ret_val = $('<div class="widget clearfix image" ' + style + '/>');
+ ret_val.setWidgetLayout($e);
+ ret_val.append( extractLabel( $e.find('label')[0] ) );
+
+ var address = {};
+ $e.find('address').each( function(){
+ var src = this.textContent;
+ var transform = this.getAttribute('transform');
+ var color = this.getAttribute('variant' );
+ var readonly = this.getAttribute('readonly' );
+ ga_list.push( src );
+ address[ '_' + src ] = [ transform, color, readonly=='true' ];
+ });
+
+ var actor = '<div class="actor"></div>';
+
+ var $actor = $(actor);
+ $actor.svg({loadURL:'plugins/svg/rollo.svg'});
+
+
+ var refresh = $e.attr('refresh') ? $e.attr('refresh')*1000 : 0;
+ $actor.data( {
+ 'address': address,
+ 'refresh': refresh
+ } ).each(setupRefreshAction); // abuse "each" to call in context...
+ for( var addr in address ) {
+ $actor.bind( addr, this.update );
+ }
+ ret_val.append( $actor );
+ return ret_val;
+ },
+ update: function(e,d) {
+ var element = $(this);
+ var h = defaultUpdate( e, d, element );
+ var linewidth=3;
+ var space = 1;
+ var total = linewidth + space;
+ var line_qty = 48 / total;
+ for(var i = 0; i<=Math.floor(h/line_qty);i++) {
+ element.find('#line'+(i+1)).attr('y1',9+total*(i)+((h%line_qty)/line_qty)*total);
+ element.find('#line'+(i+1)).attr('y2',9+total*(i)+((h%line_qty)/line_qty)*total);
+ }
+ for(var i = Math.floor(h/line_qty)+1; i<=line_qty;i++) {
+ element.find('#line'+(i+1)).attr('y1',9);
+ element.find('#line'+(i+1)).attr('y2',9);
+ }
+ },
+ attributes: {
+ format: { type: 'format' , required: false },
+ mapping: { type: 'mapping', required: false },
+ styling: { type: 'styling', required: false },
+ colspan: { type: 'numeric', required: false },
+ rowspan: { type: 'numeric', required: false }
+ },
+ elements: {
+ label: { type: 'string' , required: true , multi: false },
+ address: { type: 'address', required: true , multi: true },
+ layout: { type: 'layout' , required: false, multi: false }
+ },
+ content: false
+});
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|